Search in sources :

Example 11 with EncodedPolylineBean

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);
}
Also used : RouteInRegionResult(org.onebusaway.enterprise.webapp.actions.api.model.RouteInRegionResult) StopGroupingBean(org.onebusaway.transit_data.model.StopGroupingBean) StopGroupBean(org.onebusaway.transit_data.model.StopGroupBean) ArrayList(java.util.ArrayList) StopsForRouteBean(org.onebusaway.transit_data.model.StopsForRouteBean) NameBean(org.onebusaway.transit_data.model.NameBean) EncodedPolylineBean(org.onebusaway.geospatial.model.EncodedPolylineBean)

Example 12 with EncodedPolylineBean

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));
}
Also used : EncodedPolylineBean(org.onebusaway.geospatial.model.EncodedPolylineBean) BeanFactoryV2(org.onebusaway.api.model.transit.BeanFactoryV2)

Example 13 with EncodedPolylineBean

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());
}
Also used : EncodedPolylineBean(org.onebusaway.geospatial.model.EncodedPolylineBean) Test(org.junit.Test)

Example 14 with EncodedPolylineBean

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);
}
Also used : CoordinatePoint(org.onebusaway.geospatial.model.CoordinatePoint) ArrayList(java.util.ArrayList) EncodedPolylineBean(org.onebusaway.geospatial.model.EncodedPolylineBean) Test(org.junit.Test)

Example 15 with EncodedPolylineBean

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;
}
Also used : AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) BlockTripEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry) StopGroupBean(org.onebusaway.transit_data.model.StopGroupBean) ArrayList(java.util.ArrayList) StopsForRouteBean(org.onebusaway.transit_data.model.StopsForRouteBean) StopSequence(org.onebusaway.transit_data_federation.model.StopSequence) FrequencyBlockTripIndex(org.onebusaway.transit_data_federation.services.blocks.FrequencyBlockTripIndex) StopGroupingBean(org.onebusaway.transit_data.model.StopGroupingBean) StopEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopEntry) NameBean(org.onebusaway.transit_data.model.NameBean) EncodedPolylineBean(org.onebusaway.geospatial.model.EncodedPolylineBean) BlockTripIndex(org.onebusaway.transit_data_federation.services.blocks.BlockTripIndex) FrequencyBlockTripIndex(org.onebusaway.transit_data_federation.services.blocks.FrequencyBlockTripIndex) AbstractBlockTripIndex(org.onebusaway.transit_data_federation.services.blocks.AbstractBlockTripIndex) StopSequenceCollection(org.onebusaway.transit_data_federation.model.StopSequenceCollection)

Aggregations

EncodedPolylineBean (org.onebusaway.geospatial.model.EncodedPolylineBean)15 ArrayList (java.util.ArrayList)9 StopGroupBean (org.onebusaway.transit_data.model.StopGroupBean)7 StopGroupingBean (org.onebusaway.transit_data.model.StopGroupingBean)7 StopsForRouteBean (org.onebusaway.transit_data.model.StopsForRouteBean)7 NameBean (org.onebusaway.transit_data.model.NameBean)6 Test (org.junit.Test)5 CoordinatePoint (org.onebusaway.geospatial.model.CoordinatePoint)5 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)4 StopBean (org.onebusaway.transit_data.model.StopBean)3 HashSet (java.util.HashSet)2 RouteDirection (org.onebusaway.enterprise.webapp.actions.api.model.RouteDirection)2 RouteBean (org.onebusaway.transit_data.model.RouteBean)2 BlockTripIndex (org.onebusaway.transit_data_federation.services.blocks.BlockTripIndex)2 HashMap (java.util.HashMap)1 RouteDirection (org.onebusaway.api.actions.siri.model.RouteDirection)1 RouteResult (org.onebusaway.api.actions.siri.model.RouteResult)1 StopOnRoute (org.onebusaway.api.actions.siri.model.StopOnRoute)1 StopRouteDirection (org.onebusaway.api.actions.siri.model.StopRouteDirection)1 BeanFactoryV2 (org.onebusaway.api.model.transit.BeanFactoryV2)1