Package org.onebusaway.geospatial.grid

Examples of org.onebusaway.geospatial.grid.GridFactory


    double walkingVelocity = minTravelTimeToStops.getWalkingVelocity() / 1000;

    CoordinateBounds b = SphericalGeometryLibrary.bounds(location, 800);
    double latStep = b.getMaxLat() - b.getMinLat();
    double lonStep = b.getMaxLon() - b.getMinLon();
    GridFactory gridFactory = new GridFactory(latStep, lonStep);
    TimedGridFactory timedGridFactory = new TimedGridFactory(latStep / 4,
        lonStep / 4, walkingVelocity);

    long maxTripLength = c.getMaxTripDuration() * 1000;

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

      double stopLat = minTravelTimeToStops.getStopLat(i);
      double stopLon = minTravelTimeToStops.getStopLon(i);

      long duration = minTravelTimeToStops.getTravelTime(i);

      double remainingWalkingDistance = (maxTripLength - duration)
          * walkingVelocity;
      remainingWalkingDistance = Math.min(remainingWalkingDistance,
          maxWalkDistance);

      CoordinateBounds bounds = SphericalGeometryLibrary.bounds(stopLat,
          stopLon, remainingWalkingDistance);
      gridFactory.addBounds(bounds);

      long remainingWalkingTime = (long) (remainingWalkingDistance / walkingVelocity);
      if (remainingWalkingTime > 0)
        timedGridFactory.addPoint(stopLat, stopLon, duration,
            remainingWalkingTime);
    }

    MinTransitTimeResult result = new MinTransitTimeResult();
    result.setComplete(true);
    result.setMinTravelTimeToStops(minTravelTimeToStops);
    if (timeSegmentSize < 1)
      timeSegmentSize = 5;

    Map<Integer, List<EncodedPolygonBean>> polygonsByTime = timedGridFactory.getPolygonsByTime(timeSegmentSize);
    for (Map.Entry<Integer, List<EncodedPolygonBean>> entry : polygonsByTime.entrySet()) {
      int t = entry.getKey();
      for (EncodedPolygonBean bean : entry.getValue()) {
        result.getTimePolygons().add(bean);
        result.getTimes().add(t * timeSegmentSize);
      }
    }

    result.setSearchGrid(gridFactory.getGrid());
    return result;
  }
View Full Code Here

TOP

Related Classes of org.onebusaway.geospatial.grid.GridFactory

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.