Search in sources :

Example 11 with WTWD

use of org.opentripplanner.analyst.request.SampleGridRenderer.WTWD in project OpenTripPlanner by opentripplanner.

the class TNPropagatedTimesStore method makeSampleGridForVertices.

// FIXME the following function requires a reference to the LinkedPointSet or the TransportNetwork. It should be elsewhere (PointSetTimeRange?)
/**
 * Create a SampleGrid from only the times stored in this PropagatedTimesStore.
 * This assumes that the target indexes in this router/propagatedTimesStore are vertex indexes, not pointset indexes.
 * This is not really ideal since it includes only intersection nodes, and no points along the road segments.
 * FIXME this may be why we're getting hole-punching failures.
 * TODO: rewrite the isoline code to use only primitive collections and operate on a scalar field.
 */
public SparseMatrixZSampleGrid<WTWD> makeSampleGridForVertices(int[] times, final double gridSizeMeters) {
    SparseMatrixZSampleGrid<WTWD> grid;
    long t0 = System.currentTimeMillis();
    // Off-road max distance MUST be APPROX EQUALS to the grid precision
    // TODO: Loosen this restriction (by adding more closing sample).
    // Change the 0.8 magic factor here with caution. Should be roughly grid size.
    final double offroadWalkDistance = 0.8 * gridSizeMeters;
    // in m/sec
    final double offroadWalkSpeed = 1.00;
    // FIXME new Coordinate(transitLayer.centerLon, transitLayer.centerLat);
    Coordinate coordinateOrigin = null;
    final double cosLat = FastMath.cos(toRadians(coordinateOrigin.y));
    double dY = Math.toDegrees(gridSizeMeters / SphericalDistanceLibrary.RADIUS_OF_EARTH_IN_M);
    double dX = dY / cosLat;
    grid = new SparseMatrixZSampleGrid<WTWD>(16, times.length, dX, dY, coordinateOrigin);
    AccumulativeGridSampler.AccumulativeMetric<WTWD> metric = new WTWDAccumulativeMetric(cosLat, offroadWalkDistance, offroadWalkSpeed, gridSizeMeters);
    AccumulativeGridSampler<WTWD> sampler = new AccumulativeGridSampler<>(grid, metric);
    // Iterate over every vertex, adding it to the ZSampleGrid if it was reached.
    // FIXME streetLayer.vertexStore.getCursor();
    Vertex vertex = null;
    for (int v = 0; v < times.length; v++) {
        int time = times[v];
        if (time == Integer.MAX_VALUE) {
            // MAX_VALUE is the "unreached" value
            continue;
        }
        WTWD z = new WTWD();
        z.w = 1.0;
        z.d = 0.0;
        z.wTime = time;
        // unused
        z.wBoardings = 0;
        // unused
        z.wWalkDist = 0;
    // vertex.seek(v); FIXME need street layer to get vertex cursor
    // // FIXME we should propagate along street geometries here
    // if (vertex != null) {
    // sampler.addSamplingPoint(vertex.getCoordinate(), z, offroadWalkSpeed);
    // }
    }
    sampler.close();
    long t1 = System.currentTimeMillis();
    LOG.info("Made scalar SampleGrid from TimeSurface in {} msec.", (int) (t1 - t0));
    return grid;
}
Also used : WTWDAccumulativeMetric(org.opentripplanner.analyst.request.SampleGridRenderer.WTWDAccumulativeMetric) Vertex(org.opentripplanner.routing.graph.Vertex) WTWD(org.opentripplanner.analyst.request.SampleGridRenderer.WTWD) Coordinate(com.vividsolutions.jts.geom.Coordinate) AccumulativeGridSampler(org.opentripplanner.common.geometry.AccumulativeGridSampler)

Aggregations

WTWD (org.opentripplanner.analyst.request.SampleGridRenderer.WTWD)11 Coordinate (com.vividsolutions.jts.geom.Coordinate)5 ArrayList (java.util.ArrayList)5 IsochroneData (org.opentripplanner.analyst.core.IsochroneData)5 DelaunayIsolineBuilder (org.opentripplanner.common.geometry.DelaunayIsolineBuilder)5 AccumulativeGridSampler (org.opentripplanner.common.geometry.AccumulativeGridSampler)4 Vertex (org.opentripplanner.routing.graph.Vertex)3 TIntArrayList (gnu.trove.list.array.TIntArrayList)2 ResultSet (org.opentripplanner.analyst.ResultSet)2 WTWDAccumulativeMetric (org.opentripplanner.analyst.request.SampleGridRenderer.WTWDAccumulativeMetric)2 ImageInfo (ar.com.hjg.pngj.ImageInfo)1 ImageLineInt (ar.com.hjg.pngj.ImageLineInt)1 PngWriter (ar.com.hjg.pngj.PngWriter)1 PngChunkTEXT (ar.com.hjg.pngj.chunks.PngChunkTEXT)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 Date (java.util.Date)1 CacheControl (javax.ws.rs.core.CacheControl)1 SampleGridRenderer (org.opentripplanner.analyst.request.SampleGridRenderer)1 SampleGridRequest (org.opentripplanner.analyst.request.SampleGridRequest)1 ZMetric (org.opentripplanner.common.geometry.IsolineBuilder.ZMetric)1