use of org.onebusaway.geospatial.model.CoordinatePoint in project onebusaway-application-modules by camsys.
the class ShapeGeospatialIndexTask method addGridCellForShapePoint.
private void addGridCellForShapePoint(Map<CoordinatePoint, Set<AgencyAndId>> shapeIdsByGridCellCorner, double lat, double lon, double latStep, double lonStep, AgencyAndId shapeId) {
CoordinatePoint gridCellCorner = getGridCellCornerForPoint(lat, lon, latStep, lonStep);
shapeIdsByGridCellCorner.get(gridCellCorner).add(shapeId);
}
use of org.onebusaway.geospatial.model.CoordinatePoint 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.model.CoordinatePoint in project onebusaway-application-modules by camsys.
the class MonitoredResult method addLatLon.
public void addLatLon(double latitude, double longitude) {
CoordinatePoint cp = new CoordinatePoint(latitude, longitude);
_allCoordinates.add(cp);
}
use of org.onebusaway.geospatial.model.CoordinatePoint in project onebusaway-application-modules by camsys.
the class ShapePointsLibrary method getProjectedShapePoints.
public List<XYPoint> getProjectedShapePoints(ShapePoints shapePoints, UTMProjection projection) {
List<XYPoint> projectedShapePoints = new ArrayList<XYPoint>();
double[] lats = shapePoints.getLats();
double[] lons = shapePoints.getLons();
int n = lats.length;
for (int i = 0; i < n; i++) projectedShapePoints.add(projection.forward(new CoordinatePoint(lats[i], lons[i])));
return projectedShapePoints;
}
use of org.onebusaway.geospatial.model.CoordinatePoint in project onebusaway-application-modules by camsys.
the class ShapePointsFactory method create.
public ShapePoints create() {
ShapePoints shapePoints = new ShapePoints();
shapePoints.setShapeId(_shapeId);
double[] lats = new double[_points.size()];
double[] lons = new double[_points.size()];
double[] distances = new double[_points.size()];
for (int i = 0; i < _points.size(); i++) {
CoordinatePoint p = _points.get(i);
lats[i] = p.getLat();
lons[i] = p.getLon();
}
shapePoints.setLats(lats);
shapePoints.setLons(lons);
shapePoints.setDistTraveled(distances);
shapePoints.ensureDistTraveled();
return shapePoints;
}
Aggregations