use of org.onebusaway.geospatial.model.CoordinatePoint in project onebusaway-application-modules by camsys.
the class VehiclePositionsForAgencyAction method fillFeedMessage.
@Override
protected void fillFeedMessage(FeedMessage.Builder feed, String agencyId, long timestamp) {
ListBean<VehicleStatusBean> vehicles = _service.getAllVehiclesForAgency(agencyId, timestamp);
for (VehicleStatusBean vehicle : vehicles.getList()) {
FeedEntity.Builder entity = feed.addEntityBuilder();
entity.setId(Integer.toString(feed.getEntityCount()));
VehiclePosition.Builder vehiclePosition = entity.getVehicleBuilder();
TripStatusBean tripStatus = vehicle.getTripStatus();
if (tripStatus != null) {
TripBean activeTrip = tripStatus.getActiveTrip();
RouteBean route = activeTrip.getRoute();
TripDescriptor.Builder tripDesc = vehiclePosition.getTripBuilder();
tripDesc.setTripId(normalizeId(activeTrip.getId()));
tripDesc.setRouteId(normalizeId(route.getId()));
}
VehicleDescriptor.Builder vehicleDesc = vehiclePosition.getVehicleBuilder();
vehicleDesc.setId(normalizeId(vehicle.getVehicleId()));
CoordinatePoint location = vehicle.getLocation();
if (location != null) {
Position.Builder position = vehiclePosition.getPositionBuilder();
position.setLatitude((float) location.getLat());
position.setLongitude((float) location.getLon());
}
vehiclePosition.setTimestamp(vehicle.getLastUpdateTime() / 1000);
}
}
use of org.onebusaway.geospatial.model.CoordinatePoint in project onebusaway-application-modules by camsys.
the class FederatedByCoordinatePointsMethodInvocationHandlerImpl method invoke.
public Object invoke(FederatedServiceCollection collection, Method method, Object[] args) throws ServiceAreaServiceException, IllegalArgumentException, IllegalAccessException, InvocationTargetException {
List<CoordinatePoint> points = new ArrayList<CoordinatePoint>();
for (int i = 0; i < _argumentIndices.length; i++) {
Object value = args[_argumentIndices[i]];
PropertyPathExpression expression = _expressions[i];
if (expression != null)
value = expression.invoke(value);
CoordinatePoint point = (CoordinatePoint) value;
points.add(point);
}
FederatedService service = collection.getServiceForLocations(points);
return method.invoke(service, args);
}
use of org.onebusaway.geospatial.model.CoordinatePoint in project onebusaway-application-modules by camsys.
the class GtfsController method getStops.
@RequestMapping(value = "/stops/{agencyId}/{id}")
@ResponseBody
public List<CoordinatePoint> getStops(@PathVariable String agencyId, @PathVariable String id) {
AgencyAndId routeId = new AgencyAndId(agencyId, id);
RouteEntry route = _transitGraphDao.getRouteForId(routeId);
TripEntry trip = routeToTrip(route);
List<StopTimeEntry> stopTimes = trip.getStopTimes();
List<CoordinatePoint> points = new ArrayList<CoordinatePoint>();
for (StopTimeEntry entry : stopTimes) {
StopEntry stop = entry.getStop();
points.add(stop.getStopLocation());
}
return points;
}
use of org.onebusaway.geospatial.model.CoordinatePoint in project onebusaway-application-modules by camsys.
the class PolylineEncoderTest method test2.
@Test
public void test2() {
List<CoordinatePoint> points = new ArrayList<CoordinatePoint>();
points.add(new CoordinatePoint(47.67839087880088, -122.27878118907307));
points.add(new CoordinatePoint(47.67845871865856, -122.27342376951559));
points.add(new CoordinatePoint(47.682076843204875, -122.2735240417865));
String expected = "}d_bHlqiiVKo`@sUR";
EncodedPolylineBean actual = PolylineEncoder.createEncodings(points, 0);
Assert.assertEquals(expected, actual.getPoints());
List<CoordinatePoint> decodedPoints = PolylineEncoder.decode(actual);
GeospatialTestSupport.assertEqualsPointLists(points, decodedPoints, 1e-5);
}
use of org.onebusaway.geospatial.model.CoordinatePoint in project onebusaway-application-modules by camsys.
the class SphericalGeometryLibraryTest method testProjectPointToSegmentApproximate.
@Test
public void testProjectPointToSegmentApproximate() {
CoordinatePoint p = new CoordinatePoint(40.737284, -73.955430);
CoordinatePoint seg1 = new CoordinatePoint(40.737997, -73.955472);
CoordinatePoint seg2 = new CoordinatePoint(40.734575, -73.954979);
CoordinatePoint r = SphericalGeometryLibrary.projectPointToSegmentAppropximate(p, seg1, seg2);
assertEquals(40.73729256997116, r.getLat(), 0.0);
assertEquals(-73.95537051431788, r.getLon(), 0.0);
}
Aggregations