Unverified Commit 091f9fa0 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

Add locationSearch support

parent f6f56f81
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -150,6 +150,15 @@ if ( $opt{station} ) {
}
elsif ( $opt{geoSearch} ) {
	for my $result ( $status->results ) {
		if ( defined $result->eva ) {
			printf( "%8d  %s\n", $result->eva, $result->name );
		}
	}
}
elsif ( $opt{locationSearch} ) {
	for my $result ( $status->results ) {
		if ( defined $result->eva ) {
			printf( "%8d  %s\n", $result->eva, $result->name );
		}
	}
}
+8 −4
Original line number Diff line number Diff line
@@ -57,6 +57,10 @@ sub new {
		$req
		  = "https://www.bahn.de/web/api/reiseloesung/orte/nearby?lat=${lat}&long=${lon}&radius=9999&maxNo=100";
	}
	elsif ( my $query = $conf{locationSearch} ) {
		$req
		  = "https://www.bahn.de/web/api/reiseloesung/orte?suchbegriff=${query}&typ=ALL&limit=10";
	}

	# journey : https://www.bahn.de/web/api/reiseloesung/fahrt?journeyId=2%7C%23VN%231%23ST%231733779122%23PI%230%23ZI%23324190%23TA%230%23DA%23141224%231S%238000001%231T%231822%23LS%238000080%23LT%232050%23PU%2380%23RT%231%23CA%23DPN%23ZE%2326431%23ZB%23RE+26431%23PC%233%23FR%238000001%23FT%231822%23TO%238000080%23TT%232050%23&poly=true
	else {
@@ -100,8 +104,8 @@ sub new {
	if ( $conf{station} ) {
		$self->parse_stationboard;
	}
	elsif ( $conf{geoSearch} ) {
		$self->parse_geosearch;
	elsif ( $conf{geoSearch} or $conf{locationSearch} ) {
		$self->parse_search;
	}

	return $self;
@@ -129,7 +133,7 @@ sub new_p {
			if ( $conf{station} ) {
				$self->parse_stationboard;
			}
			elsif ( $conf{geoSearch} ) {
			elsif ( $conf{geoSearch} or $conf{locationSearch} ) {
				$self->parse_search;
			}
			else {
@@ -237,7 +241,7 @@ sub get_with_cache_p {
	return $promise;
}

sub parse_geosearch {
sub parse_search {
	my ($self) = @_;

	$self->{results} = [];