Search in sources :

Example 16 with ShapePoints

use of org.onebusaway.transit_data_federation.model.ShapePoints in project onebusaway-application-modules by camsys.

the class ShapePointServiceImpl method getShapePointsForShapeIds.

@Cacheable
@Override
public ShapePoints getShapePointsForShapeIds(List<AgencyAndId> shapeIds) {
    ShapePointsFactory factory = new ShapePointsFactory();
    for (AgencyAndId shapeId : shapeIds) {
        ShapePoints shapePoints = getShapePointsForShapeId(shapeId);
        factory.addPoints(shapePoints);
    }
    return factory.create();
}
Also used : ShapePoints(org.onebusaway.transit_data_federation.model.ShapePoints) ShapePointsFactory(org.onebusaway.transit_data_federation.model.ShapePointsFactory) AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) Cacheable(org.onebusaway.container.cache.Cacheable)

Example 17 with ShapePoints

use of org.onebusaway.transit_data_federation.model.ShapePoints in project onebusaway-application-modules by camsys.

the class GenerateNarrativesTask method getAllOrientationsForStop.

private Collection<PointAndOrientation> getAllOrientationsForStop(NarrativeProviderImpl provider, StopEntry stop) {
    List<BlockStopTimeIndex> stopTimeIndices = _blockIndexService.getStopTimeIndicesForStop(stop);
    List<PointAndOrientation> pos = new ArrayList<PointAndOrientation>();
    Map<ShapeIdAndDistance, PointAndOrientation> orientationsByKey = new HashMap<ShapeIdAndDistance, PointAndOrientation>();
    for (BlockStopTimeIndex stopTimeIndex : stopTimeIndices) {
        for (BlockStopTimeEntry blockStopTime : stopTimeIndex.getStopTimes()) {
            StopTimeEntry stopTime = blockStopTime.getStopTime();
            TripEntry trip = stopTime.getTrip();
            AgencyAndId shapeId = trip.getShapeId();
            if (shapeId == null)
                continue;
            ShapePoints shapePoints = provider.getShapePointsForId(shapeId);
            if (shapePoints == null)
                continue;
            int shapePointIndex = stopTime.getShapePointIndex();
            if (shapePointIndex == -1)
                continue;
            ShapeIdAndDistance key = new ShapeIdAndDistance(shapeId, stopTime.getShapeDistTraveled());
            PointAndOrientation orientation = orientationsByKey.get(key);
            if (orientation == null) {
                int indexFrom = Math.max(0, shapePointIndex - 5);
                int indexTo = Math.min(shapePoints.getSize(), shapePointIndex + 5);
                ShapePointIndex shapePointIndexMethod = new DistanceTraveledShapePointIndex(stopTime.getShapeDistTraveled(), indexFrom, indexTo);
                orientation = shapePointIndexMethod.getPointAndOrientation(shapePoints);
                if (orientation == null)
                    continue;
                orientationsByKey.put(key, orientation);
            }
            pos.add(orientation);
        }
    }
    return orientationsByKey.values();
}
Also used : AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) HashMap(java.util.HashMap) DistanceTraveledShapePointIndex(org.onebusaway.transit_data_federation.impl.shapes.DistanceTraveledShapePointIndex) DoubleArrayList(cern.colt.list.DoubleArrayList) ArrayList(java.util.ArrayList) PointAndOrientation(org.onebusaway.transit_data_federation.impl.shapes.PointAndOrientation) TripEntry(org.onebusaway.transit_data_federation.services.transit_graph.TripEntry) ShapePointIndex(org.onebusaway.transit_data_federation.impl.shapes.ShapePointIndex) DistanceTraveledShapePointIndex(org.onebusaway.transit_data_federation.impl.shapes.DistanceTraveledShapePointIndex) ProjectedPoint(org.onebusaway.transit_data_federation.model.ProjectedPoint) ShapePoints(org.onebusaway.transit_data_federation.model.ShapePoints) BlockStopTimeIndex(org.onebusaway.transit_data_federation.services.blocks.BlockStopTimeIndex) StopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopTimeEntry) BlockStopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry) BlockStopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry)

Example 18 with ShapePoints

use of org.onebusaway.transit_data_federation.model.ShapePoints in project onebusaway-application-modules by camsys.

the class GenerateNarrativesTask method generateShapePointNarratives.

public void generateShapePointNarratives(NarrativeProviderImpl provider) {
    List<AgencyAndId> shapeIds = _gtfsDao.getAllShapeIds();
    int shapeSize = shapeIds.size();
    _log.info("shapes to process=" + shapeSize);
    int logInterval = LoggingIntervalUtil.getAppropriateLoggingInterval(shapeSize) * 10;
    int index = 0;
    for (AgencyAndId shapeId : shapeIds) {
        if (index % logInterval == 0)
            _log.info("shapes=" + index);
        index++;
        ShapePoints shapePoints = _shapePointsHelper.getShapePointsForShapeId(shapeId);
        provider.setShapePointsForId(shapeId, shapePoints);
    }
}
Also used : ShapePoints(org.onebusaway.transit_data_federation.model.ShapePoints) AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) ProjectedPoint(org.onebusaway.transit_data_federation.model.ProjectedPoint)

Example 19 with ShapePoints

use of org.onebusaway.transit_data_federation.model.ShapePoints in project onebusaway-application-modules by camsys.

the class ShapePointHelper method getShapePointsForShapeId.

public ShapePoints getShapePointsForShapeId(AgencyAndId shapeId) {
    ShapePoints shapePoints = _cache.get(shapeId);
    if (shapePoints == null) {
        shapePoints = getShapePointsForShapeIdNonCached(shapeId);
        _cache.put(shapeId, shapePoints);
    }
    return shapePoints;
}
Also used : ShapePoints(org.onebusaway.transit_data_federation.model.ShapePoints)

Example 20 with ShapePoints

use of org.onebusaway.transit_data_federation.model.ShapePoints in project onebusaway-application-modules by camsys.

the class UnitTestingSupport method shapePoints.

public static ShapePoints shapePoints(String id, double[] lats, double[] lons, double[] distTraveled) {
    ShapePoints shapePoints = new ShapePoints();
    shapePoints.setShapeId(aid(id));
    shapePoints.setLats(lats);
    shapePoints.setLons(lons);
    shapePoints.setDistTraveled(distTraveled);
    return shapePoints;
}
Also used : ShapePoints(org.onebusaway.transit_data_federation.model.ShapePoints)

Aggregations

ShapePoints (org.onebusaway.transit_data_federation.model.ShapePoints)26 Test (org.junit.Test)13 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)12 StopTimeEntryImpl (org.onebusaway.transit_data_federation.impl.transit_graph.StopTimeEntryImpl)10 ShapePointsFactory (org.onebusaway.transit_data_federation.model.ShapePointsFactory)9 TripEntryImpl (org.onebusaway.transit_data_federation.impl.transit_graph.TripEntryImpl)8 Stop (org.onebusaway.gtfs.model.Stop)6 Agency (org.onebusaway.gtfs.model.Agency)5 StopTime (org.onebusaway.gtfs.model.StopTime)5 Route (org.onebusaway.gtfs.model.Route)4 Trip (org.onebusaway.gtfs.model.Trip)4 DistanceAlongShapeLibrary (org.onebusaway.transit_data_federation.bundle.tasks.transit_graph.DistanceAlongShapeLibrary)4 PointAndIndex (org.onebusaway.transit_data_federation.impl.shapes.PointAndIndex)4 TransitGraphImpl (org.onebusaway.transit_data_federation.impl.transit_graph.TransitGraphImpl)4 StopEntry (org.onebusaway.transit_data_federation.services.transit_graph.StopEntry)4 TripEntry (org.onebusaway.transit_data_federation.services.transit_graph.TripEntry)4 ArrayList (java.util.ArrayList)3 Cacheable (org.onebusaway.container.cache.Cacheable)3 CoordinatePoint (org.onebusaway.geospatial.model.CoordinatePoint)3 StopTimeEntriesFactory (org.onebusaway.transit_data_federation.bundle.tasks.transit_graph.StopTimeEntriesFactory)3