use of org.onebusaway.geospatial.model.EncodedPolylineBean in project onebusaway-application-modules by camsys.
the class SearchResultFactoryImpl method getRouteResultForRegion.
@Override
public SearchResult getRouteResultForRegion(RouteBean routeBean) {
List<String> polylines = new ArrayList<String>();
StopsForRouteBean stopsForRoute = _transitDataService.getStopsForRoute(routeBean.getId());
List<StopGroupingBean> stopGroupings = stopsForRoute.getStopGroupings();
for (StopGroupingBean stopGroupingBean : stopGroupings) {
for (StopGroupBean stopGroupBean : stopGroupingBean.getStopGroups()) {
NameBean name = stopGroupBean.getName();
String type = name.getType();
if (!type.equals("destination"))
continue;
for (EncodedPolylineBean polyline : stopGroupBean.getPolylines()) {
polylines.add(polyline.getPoints());
}
}
}
return new RouteInRegionResult(routeBean, polylines);
}
use of org.onebusaway.geospatial.model.EncodedPolylineBean in project onebusaway-application-modules by camsys.
the class ShapeAction method show.
public DefaultHttpHeaders show() {
if (hasErrors())
return setValidationErrorsResponse();
EncodedPolylineBean shape = _service.getShapeForId(_id);
if (shape == null)
return setResourceNotFoundResponse();
BeanFactoryV2 factory = getBeanFactoryV2();
return setOkResponse(factory.getResponse(shape));
}
use of org.onebusaway.geospatial.model.EncodedPolylineBean in project onebusaway-application-modules by camsys.
the class PolylineEncoderTest method test3.
@Test
public void test3() {
double[] lat = { 47.67839087880088, 47.67845871865856, 47.682076843204875 };
double[] lon = { -122.27878118907307, -122.27342376951559, -122.2735240417865 };
String expected = "}d_bHlqiiVKo`@sUR";
EncodedPolylineBean actual = PolylineEncoder.createEncodings(lat, lon, 0);
Assert.assertEquals(expected, actual.getPoints());
}
use of org.onebusaway.geospatial.model.EncodedPolylineBean in project onebusaway-application-modules by camsys.
the class PolylineEncoderTest method test2.
@Test
public void test2() {
List<CoordinatePoint> points = new ArrayList<CoordinatePoint>();
points.add(new CoordinatePoint(47.67839087880088, -122.27878118907307));
points.add(new CoordinatePoint(47.67845871865856, -122.27342376951559));
points.add(new CoordinatePoint(47.682076843204875, -122.2735240417865));
String expected = "}d_bHlqiiVKo`@sUR";
EncodedPolylineBean actual = PolylineEncoder.createEncodings(points, 0);
Assert.assertEquals(expected, actual.getPoints());
List<CoordinatePoint> decodedPoints = PolylineEncoder.decode(actual);
GeospatialTestSupport.assertEqualsPointLists(points, decodedPoints, 1e-5);
}
use of org.onebusaway.geospatial.model.EncodedPolylineBean in project onebusaway-application-modules by camsys.
the class RouteBeanServiceImpl method getStopsForRouteCollectionAndNarrative.
private StopsForRouteBean getStopsForRouteCollectionAndNarrative(RouteCollectionEntry routeCollection, RouteCollectionNarrative narrative) {
StopsForRouteBean result = new StopsForRouteBean();
AgencyAndId routeCollectionId = routeCollection.getId();
result.setRoute(getRouteBeanForRouteCollection(routeCollectionId, narrative));
result.setStops(getStopBeansForRoute(routeCollectionId));
result.setPolylines(getEncodedPolylinesForRoute(routeCollection));
StopGroupingBean directionGrouping = new StopGroupingBean();
directionGrouping.setType(TransitDataConstants.STOP_GROUPING_TYPE_DIRECTION);
List<StopGroupBean> directionGroups = new ArrayList<StopGroupBean>();
directionGrouping.setStopGroups(directionGroups);
directionGrouping.setOrdered(true);
result.addGrouping(directionGrouping);
List<BlockTripIndex> blockIndices = _blockIndexService.getBlockTripIndicesForRouteCollectionId(routeCollectionId);
List<FrequencyBlockTripIndex> frequencyBlockIndices = _blockIndexService.getFrequencyBlockTripIndicesForRouteCollectionId(routeCollectionId);
List<BlockTripEntry> blockTrips = new ArrayList<BlockTripEntry>();
getBlockTripsForIndicesMatchingRouteCollection(blockIndices, routeCollectionId, blockTrips);
getBlockTripsForIndicesMatchingRouteCollection(frequencyBlockIndices, routeCollectionId, blockTrips);
List<StopSequence> sequences = _stopSequencesService.getStopSequencesForTrips(blockTrips);
List<StopSequenceCollection> blocks = _stopSequenceBlocksService.getStopSequencesAsCollections(sequences);
for (StopSequenceCollection block : blocks) {
NameBean name = new NameBean(NameBeanTypes.DESTINATION, block.getDescription());
List<StopEntry> stops = getStopsInOrder(block);
List<String> groupStopIds = new ArrayList<String>();
for (StopEntry stop : stops) groupStopIds.add(ApplicationBeanLibrary.getId(stop.getId()));
Set<AgencyAndId> shapeIds = getShapeIdsForStopSequenceBlock(block);
List<EncodedPolylineBean> polylines = _shapeBeanService.getMergedPolylinesForShapeIds(shapeIds);
StopGroupBean group = new StopGroupBean();
group.setId(block.getPublicId());
group.setName(name);
group.setStopIds(groupStopIds);
group.setPolylines(polylines);
directionGroups.add(group);
}
sortResult(result);
return result;
}
Aggregations