use of org.onebusaway.geospatial.services.UTMProjection in project onebusaway-application-modules by camsys.
the class ShapePointsLibraryTest method test04.
@Test
public void test04() {
ShapePointsFactory factory = new ShapePointsFactory();
factory.addPoint(47.66851509562011, -122.29019398384474);
factory.addPoint(47.66486634286269, -122.29014033966445);
factory.addPoint(47.66486634286269, -122.29560131721877);
ShapePoints shapePoints = factory.create();
UTMProjection projection = UTMLibrary.getProjectionForPoint(shapePoints.getLatForIndex(0), shapePoints.getLonForIndex(0));
ShapePointsLibrary spl = new ShapePointsLibrary();
List<XYPoint> projectedShapePoints = spl.getProjectedShapePoints(shapePoints, projection);
XYPoint stopPoint = projection.forward(new CoordinatePoint(47.664922340500475, -122.29066873484038));
double[] distanceAlongShape = { 0.0, 405.7, 814.0 };
List<PointAndIndex> assignments = spl.computePotentialAssignments(projectedShapePoints, distanceAlongShape, stopPoint, 0, 3);
assertEquals(2, assignments.size());
PointAndIndex assignment = assignments.get(0);
assertEquals(398.9, assignment.distanceAlongShape, 0.1);
assertEquals(39.6, assignment.distanceFromTarget, 0.1);
assignment = assignments.get(1);
assertEquals(445.4, assignment.distanceAlongShape, 0.1);
assertEquals(6.2, assignment.distanceFromTarget, 0.1);
}
use of org.onebusaway.geospatial.services.UTMProjection in project onebusaway-application-modules by camsys.
the class DistanceAlongShapeLibrary method getDistancesAlongShape.
public PointAndIndex[] getDistancesAlongShape(ShapePoints shapePoints, List<StopTimeEntryImpl> stopTimes) throws DistanceAlongShapeException {
PointAndIndex[] stopTimePoints = new PointAndIndex[stopTimes.size()];
UTMProjection projection = UTMLibrary.getProjectionForPoint(shapePoints.getLats()[0], shapePoints.getLons()[0]);
List<XYPoint> projectedShapePoints = _shapePointsLibrary.getProjectedShapePoints(shapePoints, projection);
double[] shapePointsDistTraveled = shapePoints.getDistTraveled();
List<List<PointAndIndex>> possibleAssignments = computePotentialAssignments(projection, projectedShapePoints, shapePointsDistTraveled, stopTimes);
pruneUnnecessaryAssignments(possibleAssignments);
assignmentSanityCheck(shapePoints, stopTimes, possibleAssignments);
double maxDistanceTraveled = shapePointsDistTraveled[shapePointsDistTraveled.length - 1];
List<PointAndIndex> bestAssignment = computeBestAssignment(shapePoints, stopTimes, possibleAssignments, projection, projectedShapePoints);
double last = Double.NEGATIVE_INFINITY;
for (int i = 0; i < stopTimePoints.length; i++) {
PointAndIndex pindex = bestAssignment.get(i);
if (pindex.distanceAlongShape > maxDistanceTraveled) {
int index = projectedShapePoints.size() - 1;
XYPoint point = projectedShapePoints.get(index);
StopEntryImpl stop = stopTimes.get(i).getStop();
XYPoint stopPoint = projection.forward(stop.getStopLocation());
double d = stopPoint.getDistance(point);
pindex = new PointAndIndex(point, index, d, maxDistanceTraveled);
}
if (last > pindex.distanceAlongShape) {
constructError(shapePoints, stopTimes, possibleAssignments, projection);
}
last = pindex.distanceAlongShape;
stopTimePoints[i] = pindex;
}
return stopTimePoints;
}
use of org.onebusaway.geospatial.services.UTMProjection in project onebusaway-application-modules by camsys.
the class GtfsComputePolylineBoundaryForStopsMain method handleOutputAsOSMPolygon.
private void handleOutputAsOSMPolygon(PrintWriter out, StopToPolygonEntityHandler handler) throws IOException {
Geometry geometry = handler.getGeometry();
UTMProjection proj = handler.getProjection();
out.println("polygon");
AtomicInteger index = new AtomicInteger();
printGeometry(out, geometry, proj, index, false);
out.println("END");
}
use of org.onebusaway.geospatial.services.UTMProjection in project onebusaway-application-modules by camsys.
the class ProjectedShapePointServiceImpl method getProjectedShapePoints.
@Cacheable
@Override
public T2<List<XYPoint>, double[]> getProjectedShapePoints(List<AgencyAndId> shapeIds, int utmZoneId) {
ShapePoints shapePoints = _shapePointService.getShapePointsForShapeIds(shapeIds);
if (shapePoints == null || shapePoints.isEmpty())
return null;
UTMProjection projection = new UTMProjection(utmZoneId);
List<XYPoint> projected = _shapePointsLibrary.getProjectedShapePoints(shapePoints, projection);
return Tuples.tuple(projected, shapePoints.getDistTraveled());
}
use of org.onebusaway.geospatial.services.UTMProjection in project onebusaway-application-modules by camsys.
the class ProjectedPointFactory method forward.
public static ProjectedPoint forward(CoordinatePoint latlon, int zone) {
UTMProjection projection = new UTMProjection(zone);
XYPoint point = projection.forward(latlon);
return new ProjectedPoint(latlon.getLat(), latlon.getLon(), point.getX(), point.getY(), zone);
}
Aggregations