use of org.onebusaway.gtfs.model.Location in project onebusaway-gtfs-modules by OneBusAway.
the class LocationsGeoJSONReader method read.
public Collection<Location> read() throws IOException {
FeatureCollection featureCollection = new ObjectMapper().readValue(reader, FeatureCollection.class);
Collection<Location> locations = new ArrayList<>(featureCollection.getFeatures().size());
for (Feature feature : featureCollection.getFeatures()) {
Location location = new Location();
location.setId(new AgencyAndId(this.defaultAgencyId, feature.getId()));
location.setGeometry(feature.getGeometry());
location.setName((String) feature.getProperties().get("stop_name"));
location.setDescription((String) feature.getProperties().get("stop_description"));
location.setUrl((String) feature.getProperties().get("stop_url"));
location.setZoneId((String) feature.getProperties().get("zone_id"));
locations.add(location);
}
return locations;
}
use of org.onebusaway.gtfs.model.Location in project onebusaway-gtfs-modules by OneBusAway.
the class LocationsGeoJSONReaderTest method read.
@Test
public void read() throws IOException {
Collection<Location> locations = new LocationsGeoJSONReader(new InputStreamReader(new FileInputStream(GtfsTestData.getLocationsGeojson())), "").read();
assertEquals(locations.size(), 1);
Location location = locations.iterator().next();
assertEquals("si_Wendenschlossstrasse", location.getId().getId());
assertEquals("Wendenschlossstrasse", location.getName());
assertEquals("A nice description", location.getDescription());
assertTrue(location.getGeometry() instanceof Polygon);
assertEquals(new Polygon(new LngLatAlt(13.576526641845703, 52.44413508398945), new LngLatAlt(13.575839996337889, 52.429169943434495), new LngLatAlt(13.590774536132812, 52.4105872618342), new LngLatAlt(13.60879898071289, 52.43225757383383), new LngLatAlt(13.576526641845703, 52.44413508398945)), location.getGeometry());
assertEquals("fare-zone-A", location.getZoneId());
assertEquals("http://example.com", location.getUrl());
}
Aggregations