Search in sources :

Example 11 with CoordinatePoint

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

Example 12 with CoordinatePoint

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);
}
Also used : ShapePoints(org.onebusaway.transit_data_federation.model.ShapePoints) XYPoint(org.onebusaway.geospatial.model.XYPoint) CoordinatePoint(org.onebusaway.geospatial.model.CoordinatePoint) ShapePointsFactory(org.onebusaway.transit_data_federation.model.ShapePointsFactory) UTMProjection(org.onebusaway.geospatial.services.UTMProjection) Test(org.junit.Test)

Example 13 with CoordinatePoint

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

Example 14 with CoordinatePoint

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

Example 15 with CoordinatePoint

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

Aggregations

CoordinatePoint (org.onebusaway.geospatial.model.CoordinatePoint)57 ArrayList (java.util.ArrayList)22 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)12 Test (org.junit.Test)10 XYPoint (org.onebusaway.geospatial.model.XYPoint)10 ScheduledBlockLocation (org.onebusaway.transit_data_federation.services.blocks.ScheduledBlockLocation)9 CoordinateBounds (org.onebusaway.geospatial.model.CoordinateBounds)7 BlockInstance (org.onebusaway.transit_data_federation.services.blocks.BlockInstance)7 StopEntry (org.onebusaway.transit_data_federation.services.transit_graph.StopEntry)7 BlockLocation (org.onebusaway.transit_data_federation.services.realtime.BlockLocation)6 BlockConfigurationEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockConfigurationEntry)6 StopTimeEntry (org.onebusaway.transit_data_federation.services.transit_graph.StopTimeEntry)5 EncodedPolylineBean (org.onebusaway.geospatial.model.EncodedPolylineBean)4 VehicleLocationRecordBean (org.onebusaway.transit_data.model.realtime.VehicleLocationRecordBean)4 TripEntry (org.onebusaway.transit_data_federation.services.transit_graph.TripEntry)4 VehiclePosition (com.google.transit.realtime.GtfsRealtime.VehiclePosition)3 List (java.util.List)3 Min (org.onebusaway.collections.Min)3 VehicleLocationRecord (org.onebusaway.realtime.api.VehicleLocationRecord)3 Record (org.onebusaway.transit_data.model.realtime.CurrentVehicleEstimateQueryBean.Record)3