Navitia: Find products for nearby stations

This commit is contained in:
Torsten Grote 2016-05-22 22:49:02 -03:00 committed by Andreas Schildbach
parent d6d3371de2
commit 4566bf3cfb
2 changed files with 18 additions and 2 deletions

View file

@ -257,7 +257,18 @@ public abstract class AbstractNavitiaProvider extends AbstractNetworkProvider
if (admin.length() > 0)
place = Strings.emptyToNull(admin.getJSONObject(0).optString("name"));
}
return new Location(type, id, point, place, name);
Set<Product> products = null;
if (location.has("stop_area") && location.getJSONObject("stop_area").has("physical_modes"))
{
products = EnumSet.noneOf(Product.class);
JSONArray physicalModes = location.getJSONObject("stop_area").getJSONArray("physical_modes");
for (int i = 0; i < physicalModes.length(); i++) {
JSONObject mode = physicalModes.getJSONObject(i);
Product product = parseLineProductFromMode(mode.getString("id"));
if (product != null) products.add(product);
}
}
return new Location(type, id, point, place, name, products);
}
catch (final JSONException jsonExc)
{
@ -853,7 +864,7 @@ public abstract class AbstractNavitiaProvider extends AbstractNetworkProvider
queryUri.append("&distance=").append(maxDistance);
if (maxLocations > 0)
queryUri.append("&count=").append(maxLocations);
queryUri.append("&depth=0");
queryUri.append("&depth=3");
final CharSequence page = httpClient.get(queryUri.toString());
try

View file

@ -70,6 +70,11 @@ public final class Location implements Serializable
this(type, id, lat, lon, place, name, null);
}
public Location(final LocationType type, final String id, final Point coord, final String place, final String name, final Set<Product> products)
{
this(type, id, coord != null ? coord.lat : 0, coord != null ? coord.lon : 0, place, name, products);
}
public Location(final LocationType type, final String id, final Point coord, final String place, final String name)
{
this(type, id, coord != null ? coord.lat : 0, coord != null ? coord.lon : 0, place, name);