mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-07 22:48:49 +00:00
Navitia: Fix location type handling in queryNearbyLocations.
This commit is contained in:
parent
026b1fb111
commit
82e367a08b
2 changed files with 22 additions and 5 deletions
|
@ -765,14 +765,14 @@ public abstract class AbstractNavitiaProvider extends AbstractNetworkProvider
|
||||||
{
|
{
|
||||||
final ResultHeader resultHeader = new ResultHeader(network, SERVER_PRODUCT, SERVER_VERSION, 0, null);
|
final ResultHeader resultHeader = new ResultHeader(network, SERVER_PRODUCT, SERVER_VERSION, 0, null);
|
||||||
|
|
||||||
// Check that Location object has coordinates.
|
|
||||||
if (!location.isIdentified())
|
|
||||||
throw new IllegalArgumentException();
|
|
||||||
|
|
||||||
// Build query uri depending of location type.
|
// Build query uri depending of location type.
|
||||||
final String queryUriType;
|
final String queryUriType;
|
||||||
if (location.type == LocationType.ADDRESS)
|
if (location.type == LocationType.ADDRESS || location.type == LocationType.ANY)
|
||||||
{
|
{
|
||||||
|
if (!location.hasLocation())
|
||||||
|
{
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
final double lon = location.lon / 1E6;
|
final double lon = location.lon / 1E6;
|
||||||
final double lat = location.lat / 1E6;
|
final double lat = location.lat / 1E6;
|
||||||
|
|
||||||
|
@ -780,10 +780,18 @@ public abstract class AbstractNavitiaProvider extends AbstractNetworkProvider
|
||||||
}
|
}
|
||||||
else if (location.type == LocationType.STATION)
|
else if (location.type == LocationType.STATION)
|
||||||
{
|
{
|
||||||
|
if (!location.isIdentified())
|
||||||
|
{
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
queryUriType = "stop_point/" + location.id + "/";
|
queryUriType = "stop_point/" + location.id + "/";
|
||||||
}
|
}
|
||||||
else if (location.type == LocationType.POI)
|
else if (location.type == LocationType.POI)
|
||||||
{
|
{
|
||||||
|
if (!location.isIdentified())
|
||||||
|
{
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
queryUriType = "poi/" + location.id + "/";
|
queryUriType = "poi/" + location.id + "/";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -89,6 +89,15 @@ public class ParisProviderLiveTest extends AbstractProviderLiveTest
|
||||||
print(result);
|
print(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void nearbyStationsAny() throws Exception
|
||||||
|
{
|
||||||
|
final NearbyLocationsResult result = queryNearbyLocations(EnumSet.of(LocationType.STATION),
|
||||||
|
new Location(LocationType.ANY, 48877523, 2378353), 700, 10);
|
||||||
|
assertEquals(NearbyLocationsResult.Status.OK, result.status);
|
||||||
|
print(result);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void nearbyStationsInvalidStation() throws Exception
|
public void nearbyStationsInvalidStation() throws Exception
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue