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();
}
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();
}
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);
}
}
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;
}
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;
}
Aggregations