Package org.onebusaway.transit_data_federation.model

Examples of org.onebusaway.transit_data_federation.model.ShapePoints


      TripEntry tripA = trips.get(index);
      TripEntry tripB = trips.get(index + 1);

      double d = 0;

      ShapePoints shapeFrom = _shapePointHelper.getShapePointsForShapeId(tripA.getShapeId());
      ShapePoints shapeTo = _shapePointHelper.getShapePointsForShapeId(tripB.getShapeId());

      if (shapeFrom != null && shapeTo != null && !shapeFrom.isEmpty()
          && !shapeTo.isEmpty()) {
        int n = shapeFrom.getSize();
        double lat1 = shapeFrom.getLatForIndex(n - 1);
        double lon1 = shapeFrom.getLonForIndex(n - 1);
        double lat2 = shapeTo.getLatForIndex(0);
        double lon2 = shapeTo.getLonForIndex(0);
        d = SphericalGeometryLibrary.distance(lat1, lon1, lat2, lon2);
      }

      tripGapDistances[index] = d;
    }
View Full Code Here


    ShapePointsFactory factory = new ShapePointsFactory();
    factory.addPoint(47.652300128129454, -122.30622018270873);
    factory.addPoint(47.653181844549394, -122.30523312979125);
    factory.addPoint(47.654265901710744, -122.30511511259459);
    ShapePoints shapeA = factory.create();

    factory = new ShapePointsFactory();
    factory.addPoint(47.661275594717026, -122.31189573698424);
    factory.addPoint(47.661347854692465, -122.3240622370758);
    factory.addPoint(47.661368177792546, -122.32508885257624);
    factory.addPoint(47.66496659665593, -122.32501375072383);
    ShapePoints shapeB = factory.create();

    Mockito.when(shapePointHelper.getShapePointsForShapeId(shapeIdA)).thenReturn(
        shapeA);
    Mockito.when(shapePointHelper.getShapePointsForShapeId(shapeIdB)).thenReturn(
        shapeB);
View Full Code Here

    ShapePoint p3 = point(47.654265901710744, -122.30511511259459);
    List<ShapePoint> points = Arrays.asList(p1, p2, p3);

    Mockito.when(gtfsDao.getShapePointsForShapeId(shapeId)).thenReturn(points);

    ShapePoints shapePoints = helper.getShapePointsForShapeId(shapeId);

    assertEquals(3, shapePoints.getSize());
    for (int i = 0; i < 3; i++) {
      assertEquals(points.get(i).getLat(), shapePoints.getLatForIndex(i), 1e-7);
      assertEquals(points.get(i).getLon(), shapePoints.getLonForIndex(i), 1e-7);
    }

    assertEquals(0.0, shapePoints.getDistTraveledForIndex(0), 0.01);
    assertEquals(122.79, shapePoints.getDistTraveledForIndex(1), 0.01);
    assertEquals(243.66, shapePoints.getDistTraveledForIndex(2), 0.01);

    helper.getShapePointsForShapeId(shapeId);

    // The second call should be cached
    Mockito.verify(gtfsDao, Mockito.times(1)).getShapePointsForShapeId(shapeId);
View Full Code Here

  }

  @Test
  public void testGenerateShapePointNarratives() {
    AgencyAndId shapeId = aid("shapeId");
    ShapePoints points = new ShapePoints();
    Mockito.when(_shapePointHelper.getShapePointsForShapeId(shapeId)).thenReturn(
        points);

    Mockito.when(_gtfsDao.getAllShapeIds()).thenReturn(Arrays.asList(shapeId));
View Full Code Here

    AgencyAndId shapeId = aid("shapeA");
    ShapePointsFactory factory = new ShapePointsFactory();
    factory.addPoint(47.661225, -122.3009201);
    factory.addPoint(47.664375, -122.3008986);
    ShapePoints shapePoints = factory.create();

    _provider.setShapePointsForId(shapeId, shapePoints);

    TripEntryImpl trip = trip("trip");
    trip.setShapeId(shapeId);
View Full Code Here

     */
    AgencyAndId shapeIdA = aid("shapeA");
    ShapePointsFactory factoryA = new ShapePointsFactory();
    factoryA.addPoint(47.661225, -122.3009201);
    factoryA.addPoint(47.664375, -122.3008986);
    ShapePoints shapePointsA = factoryA.create();
    _provider.setShapePointsForId(shapeIdA, shapePointsA);

    AgencyAndId shapeIdB = aid("shapeB");
    ShapePointsFactory factoryB = new ShapePointsFactory();
    factoryB.addPoint(47.664375, -122.3008986);
    factoryB.addPoint(47.661225, -122.3009201);
    ShapePoints shapePointsB = factoryB.create();
    _provider.setShapePointsForId(shapeIdB, shapePointsB);

    TripEntryImpl tripA = trip("tripA");
    tripA.setShapeId(shapeIdA);

View Full Code Here

    return shapePoints(id, lats, lons, distances);
  }

  public static ShapePoints shapePoints(String id, double[] lats,
      double[] lons, double[] distTraveled) {
    ShapePoints shapePoints = new ShapePoints();
    shapePoints.setShapeId(aid(id));
    shapePoints.setLats(lats);
    shapePoints.setLons(lons);
    shapePoints.setDistTraveled(distTraveled);
    return shapePoints;
  }
View Full Code Here

    _transitGraphDao = transitGraphDao;
  }

  @Cacheable
  public EncodedPolylineBean getPolylineForShapeId(AgencyAndId id) {
    ShapePoints shapePoints = _shapePointService.getShapePointsForShapeId(id);
    if (shapePoints == null)
      return null;
    return PolylineEncoder.createEncodings(shapePoints.getLats(),
        shapePoints.getLons(), -1);
  }
View Full Code Here

    List<CoordinatePoint> currentLine = new ArrayList<CoordinatePoint>();
    Set<Edge> edges = new HashSet<Edge>();

    for (AgencyAndId shapeId : shapeIds) {

      ShapePoints shapePoints = _shapePointService.getShapePointsForShapeId(shapeId);

      if (shapePoints == null) {
        _log.warn("no shape points for shapeId=" + shapeId);
        continue;
      }

      double[] lats = shapePoints.getLats();
      double[] lons = shapePoints.getLons();

      CoordinatePoint prev = null;

      for (int i = 0; i < shapePoints.getSize(); i++) {

        CoordinatePoint loc = new CoordinatePoint(lats[i], lons[i]);
        if (prev != null && !prev.equals(loc)) {
          Edge edge = new Edge(prev, loc);
          if (!edges.add(edge)) {
View Full Code Here

    AgencyAndId shapeId = trip.getShapeId();

    if (shapeId == null)
      return null;

    ShapePoints shapePoints = _shapePointService.getShapePointsForShapeId(shapeId);

    BlockStopTimeEntry fromStop = null;
    BlockStopTimeEntry toStop = null;

    if (builder.getFromStop() != null)
      fromStop = builder.getFromStop().getBlockStopTime();

    if (builder.getToStop() != null)
      toStop = builder.getToStop().getBlockStopTime();

    CoordinatePoint nextPoint = null;

    BlockTripEntry nextBlockTrip = builder.getNextTrip();
    if (nextBlockTrip != null) {
      TripEntry nextTrip = nextBlockTrip.getTrip();
      AgencyAndId nextShapeId = nextTrip.getShapeId();
      if (nextShapeId != null) {
        ShapePoints nextShapePoints = _shapePointService.getShapePointsForShapeId(nextShapeId);
        nextPoint = nextShapePoints.getPointForIndex(0);
      }
    }

    if (fromStop == null && toStop == null) {
      return ShapeSupport.getFullPath(shapePoints, nextPoint);
View Full Code Here

TOP

Related Classes of org.onebusaway.transit_data_federation.model.ShapePoints

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.