Package org.onebusaway.geospatial.model

Examples of org.onebusaway.geospatial.model.CoordinatePoint


        MonitoredCall monitoredCall = new MonitoredCall();
        MonitoredStopVisit.MonitoredVehicleJourney.MonitoredCall = monitoredCall;
        monitoredCall.Extensions = new DistanceExtensions();
        monitoredCall.StopPointRef = SiriUtils.getIdWithoutAgency(stopId);

        CoordinatePoint position = status.getLocation();
        if (position != null) {
          MonitoredStopVisit.MonitoredVehicleJourney.VehicleLocation = new VehicleLocation();
          MonitoredStopVisit.MonitoredVehicleJourney.VehicleLocation.Latitude = status.getLocation().getLat();
          MonitoredStopVisit.MonitoredVehicleJourney.VehicleLocation.Longitude = status.getLocation().getLon();
          double distance = status.getDistanceAlongTrip();
View Full Code Here


        + shapeIdsByGridCellCorner.size());

    Map<CoordinateBounds, List<AgencyAndId>> shapeIdsByGridCell = new HashMap<CoordinateBounds, List<AgencyAndId>>();

    for (Map.Entry<CoordinatePoint, Set<AgencyAndId>> entry : shapeIdsByGridCellCorner.entrySet()) {
      CoordinatePoint p = entry.getKey();
      CoordinateBounds bounds = new CoordinateBounds(p.getLat(), p.getLon(),
          p.getLat() + latStep, p.getLon() + lonStep);

      List<AgencyAndId> shapeIds = new ArrayList<AgencyAndId>(entry.getValue());
      shapeIdsByGridCell.put(bounds, shapeIds);
    }
View Full Code Here

  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);
  }
View Full Code Here

  private CoordinatePoint getGridCellCornerForPoint(double lat, double lon,
      double latStep, double lonStep) {

    double latCorner = Math.floor(lat / latStep) * latStep;
    double lonCorner = Math.floor(lon / lonStep) * lonStep;
    return new CoordinatePoint(latCorner, lonCorner);
  }
View Full Code Here

    List<CoordinatePoint> points = PolylineEncoder.decode(polygon.getOuterRing());
    points = shiftPoints(points);

    assertEquals(8, points.size());

    assertEqualsPoints(new CoordinatePoint(5.0, 4.0), points.get(0), DELTA);
    assertEqualsPoints(new CoordinatePoint(5.1, 4.0), points.get(1), DELTA);
    assertEqualsPoints(new CoordinatePoint(5.2, 4.0), points.get(2), DELTA);
    assertEqualsPoints(new CoordinatePoint(5.2, 4.1), points.get(3), DELTA);
    assertEqualsPoints(new CoordinatePoint(5.2, 4.2), points.get(4), DELTA);
    assertEqualsPoints(new CoordinatePoint(5.1, 4.2), points.get(5), DELTA);
    assertEqualsPoints(new CoordinatePoint(5.0, 4.2), points.get(6), DELTA);
    assertEqualsPoints(new CoordinatePoint(5.0, 4.1), points.get(7), DELTA);

    factory.addBounds(new CoordinateBounds(5.15, 4.05, 5.26, 4.19));

    grid = factory.getGrid();

    assertEquals(6, grid.size());

    Collections.sort(grid, BOUNDS_COMPARATOR);

    checkBounds(grid.get(0), new CoordinateBounds(5.0, 4.0, 5.1, 4.1), DELTA);
    checkBounds(grid.get(1), new CoordinateBounds(5.0, 4.1, 5.1, 4.2), DELTA);
    checkBounds(grid.get(2), new CoordinateBounds(5.1, 4.0, 5.2, 4.1), DELTA);
    checkBounds(grid.get(3), new CoordinateBounds(5.1, 4.1, 5.2, 4.2), DELTA);
    checkBounds(grid.get(4), new CoordinateBounds(5.2, 4.0, 5.3, 4.1), DELTA);
    checkBounds(grid.get(5), new CoordinateBounds(5.2, 4.1, 5.3, 4.2), DELTA);

    boundary = factory.getBoundary();
    assertEquals(1, boundary.size());

    polygon = boundary.get(0);
    assertTrue(polygon.getInnerRings().isEmpty());

    points = PolylineEncoder.decode(polygon.getOuterRing());
    points = shiftPoints(points);

    assertEquals(10, points.size());

    assertEqualsPoints(new CoordinatePoint(5.0, 4.0), points.get(0), DELTA);
    assertEqualsPoints(new CoordinatePoint(5.1, 4.0), points.get(1), DELTA);
    assertEqualsPoints(new CoordinatePoint(5.2, 4.0), points.get(2), DELTA);
    assertEqualsPoints(new CoordinatePoint(5.3, 4.0), points.get(3), DELTA);
    assertEqualsPoints(new CoordinatePoint(5.3, 4.1), points.get(4), DELTA);
    assertEqualsPoints(new CoordinatePoint(5.3, 4.2), points.get(5), DELTA);
    assertEqualsPoints(new CoordinatePoint(5.2, 4.2), points.get(6), DELTA);
    assertEqualsPoints(new CoordinatePoint(5.1, 4.2), points.get(7), DELTA);
    assertEqualsPoints(new CoordinatePoint(5.0, 4.2), points.get(8), DELTA);
    assertEqualsPoints(new CoordinatePoint(5.0, 4.1), points.get(9), DELTA);
  }
View Full Code Here

    List<CoordinatePoint> points = PolylineEncoder.decode(polygon.getOuterRing());
    points = shiftPoints(points);

    assertEquals(8, points.size());

    assertEqualsPoints(new CoordinatePoint(1.0, 2.0), points.get(0), DELTA);
    assertEqualsPoints(new CoordinatePoint(2.0, 2.0), points.get(1), DELTA);
    assertEqualsPoints(new CoordinatePoint(3.0, 2.0), points.get(2), DELTA);
    assertEqualsPoints(new CoordinatePoint(3.0, 3.0), points.get(3), DELTA);
    assertEqualsPoints(new CoordinatePoint(3.0, 4.0), points.get(4), DELTA);
    assertEqualsPoints(new CoordinatePoint(2.0, 4.0), points.get(5), DELTA);
    assertEqualsPoints(new CoordinatePoint(1.0, 4.0), points.get(6), DELTA);
    assertEqualsPoints(new CoordinatePoint(1.0, 3.0), points.get(7), DELTA);

    factory.addBounds(new CoordinateBounds(5.5, 4.5, 5.6, 4.6));

    grid = factory.getGrid();

    assertEquals(5, grid.size());

    Collections.sort(grid, BOUNDS_COMPARATOR);

    checkBounds(grid.get(0), new CoordinateBounds(1.0, 2.0, 2.0, 3.0), DELTA);
    checkBounds(grid.get(1), new CoordinateBounds(1.0, 3.0, 2.0, 4.0), DELTA);
    checkBounds(grid.get(2), new CoordinateBounds(2.0, 2.0, 3.0, 3.0), DELTA);
    checkBounds(grid.get(3), new CoordinateBounds(2.0, 3.0, 3.0, 4.0), DELTA);
    checkBounds(grid.get(4), new CoordinateBounds(5.0, 4.0, 6.0, 5.0), DELTA);

    boundary = factory.getBoundary();

    assertEquals(2, boundary.size());

    Collections.sort(boundary, POLYGON_COMPARATOR);
   
    polygon = boundary.get(0);
    assertTrue(polygon.getInnerRings().isEmpty());

    points = PolylineEncoder.decode(polygon.getOuterRing());
    points = shiftPoints(points);

    assertEquals(8, points.size());

    assertEqualsPoints(new CoordinatePoint(1.0, 2.0), points.get(0), DELTA);
    assertEqualsPoints(new CoordinatePoint(2.0, 2.0), points.get(1), DELTA);
    assertEqualsPoints(new CoordinatePoint(3.0, 2.0), points.get(2), DELTA);
    assertEqualsPoints(new CoordinatePoint(3.0, 3.0), points.get(3), DELTA);
    assertEqualsPoints(new CoordinatePoint(3.0, 4.0), points.get(4), DELTA);
    assertEqualsPoints(new CoordinatePoint(2.0, 4.0), points.get(5), DELTA);
    assertEqualsPoints(new CoordinatePoint(1.0, 4.0), points.get(6), DELTA);
    assertEqualsPoints(new CoordinatePoint(1.0, 3.0), points.get(7), DELTA);

    polygon = boundary.get(1);
    assertTrue(polygon.getInnerRings().isEmpty());

    points = PolylineEncoder.decode(polygon.getOuterRing());
    points = shiftPoints(points);

    assertEquals(4, points.size());

    assertEqualsPoints(new CoordinatePoint(5.0, 4.0), points.get(0), DELTA);
    assertEqualsPoints(new CoordinatePoint(6.0, 4.0), points.get(1), DELTA);
    assertEqualsPoints(new CoordinatePoint(6.0, 5.0), points.get(2), DELTA);
    assertEqualsPoints(new CoordinatePoint(5.0, 5.0), points.get(3), DELTA);
  }
View Full Code Here

    if (points.size() < 2)
      return points;

    int minIndex = 0;
    CoordinatePoint minPoint = null;

    for (int index = 0; index < points.size(); index++) {
      CoordinatePoint p = points.get(index);
      if (minPoint == null || POINTS_COMPARATOR.compare(p, minPoint) < 0) {
        minIndex = index;
        minPoint = p;
      }
    }
View Full Code Here

      BlockLocation location = _blockLocationService.getLocationForVehicleAndTime(
          vid, tt);

      if (location != null) {

        CoordinatePoint p = applyNoiseToLocation(location.getLocation(), noise);

        Record r = new Record();
        r.setLocation(location.getLocation());
        r.setTimestamp(tt.getTargetTime());
        r.setLocation(p);
View Full Code Here

    CoordinateBounds b = SphericalGeometryLibrary.bounds(location, noise);
    double latSpan = b.getMaxLat() - b.getMinLat();
    double lonSpan = b.getMaxLon() - b.getMinLon();
    double lat = b.getMinLat() + Math.random() * latSpan;
    double lon = b.getMinLon() + Math.random() * lonSpan;
    return new CoordinatePoint(lat, lon);
  }
View Full Code Here

      ScheduledBlockLocation location = _scheduledBlockLocationService.getScheduledBlockLocationFromScheduledTime(
          blockInstance.getBlock(), scheduleTime);

      if (location != null) {

        CoordinatePoint p = applyNoiseToLocation(location.getLocation(), noise);

        Record r = new Record();
        r.setLocation(location.getLocation());
        r.setTimestamp(time - i * 1000);
        r.setLocation(p);
View Full Code Here

TOP

Related Classes of org.onebusaway.geospatial.model.CoordinatePoint

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.