Search in sources :

Example 1 with SampleFactory

use of org.opentripplanner.analyst.request.SampleFactory in project OpenTripPlanner by opentripplanner.

the class AddTripPattern method materialize.

/**
 * Create temporary stops associated with the given graph. Note that a given AddTripPattern can be associated only with a single graph.
 */
public void materialize(Graph graph) {
    SampleFactory sfac = graph.getSampleFactory();
    temporaryStops = new TemporaryStop[stops.cardinality()];
    int stop = 0;
    for (int i = stops.nextSetBit(0); i >= 0; i = stops.nextSetBit(i + 1)) {
        temporaryStops[stop++] = new TemporaryStop(geometry.getCoordinateN(i), sfac);
    }
}
Also used : SampleFactory(org.opentripplanner.analyst.request.SampleFactory)

Example 2 with SampleFactory

use of org.opentripplanner.analyst.request.SampleFactory in project OpenTripPlanner by opentripplanner.

the class StreetVertexIndexServiceImpl method getSampleVertexAt.

@Override
public Vertex getSampleVertexAt(Coordinate coordinate, boolean dest) {
    SampleFactory sfac = graph.getSampleFactory();
    Sample s = sfac.getSample(coordinate.x, coordinate.y);
    if (s == null)
        return null;
    // create temp vertex
    SampleVertex v = new SampleVertex(graph, coordinate);
    // create edges
    if (dest) {
        if (s.v0 != null)
            new SampleEdge(s.v0, v, s.d0);
        if (s.v1 != null)
            new SampleEdge(s.v1, v, s.d1);
    } else {
        if (s.v0 != null)
            new SampleEdge(v, s.v0, s.d0);
        if (s.v1 != null)
            new SampleEdge(v, s.v1, s.d1);
    }
    return v;
}
Also used : SampleFactory(org.opentripplanner.analyst.request.SampleFactory) Sample(org.opentripplanner.analyst.core.Sample) SampleVertex(org.opentripplanner.routing.vertextype.SampleVertex)

Example 3 with SampleFactory

use of org.opentripplanner.analyst.request.SampleFactory in project OpenTripPlanner by opentripplanner.

the class SampleStopLinker method link.

/**
 * Link all transit stops. If makeTransfers is true, create direct transfer
 * edges between stops linked to the same pair of vertices. This is important
 * e.g. for transit centers where there are many stops on the same street segment;
 * we don't want to force the user to walk to the end of the street and back.
 *
 * If you're not generating transfers via the street network there is no need to make
 * transfers at this stage. But if you're not generating transfers via the street network,
 * why are you using this module at all?
 */
public void link(boolean makeTransfers) {
    if (makeTransfers)
        links = HashMultimap.create();
    SampleFactory sf = graph.getSampleFactory();
    for (TransitStop tstop : Iterables.filter(graph.getVertices(), TransitStop.class)) {
        Sample s = sf.getSample(tstop.getLon(), tstop.getLat());
        // TODO: stop unlinked annotation
        if (s == null)
            continue;
        new IntersectionTransitLink(tstop, (OsmVertex) s.v0, s.d0);
        new IntersectionTransitLink((OsmVertex) s.v0, tstop, s.d0);
        new IntersectionTransitLink(tstop, (OsmVertex) s.v1, s.d1);
        new IntersectionTransitLink((OsmVertex) s.v1, tstop, s.d1);
        if (makeTransfers) {
            // save the sample so we can make direct transfers between stops
            VertexPair vp = new VertexPair(s.v0, s.v1);
            links.put(vp, tstop);
        }
    }
    if (makeTransfers) {
        // make direct transfers between stops
        for (Collection<TransitStop> tss : links.asMap().values()) {
            for (TransitStop ts0 : tss) {
                for (TransitStop ts1 : tss) {
                    // make a geometry
                    GeometryFactory gf = GeometryUtils.getGeometryFactory();
                    LineString geom = gf.createLineString(new Coordinate[] { ts0.getCoordinate(), ts1.getCoordinate() });
                    double dist = SphericalDistanceLibrary.distance(ts0.getLat(), ts0.getLon(), ts1.getLat(), ts1.getLon());
                    // building unidirectional edge, we'll hit this again in the opposite direction
                    new SimpleTransfer(ts1, ts1, dist, geom);
                }
            }
        }
    }
}
Also used : GeometryFactory(com.vividsolutions.jts.geom.GeometryFactory) TransitStop(org.opentripplanner.routing.vertextype.TransitStop) IntersectionTransitLink(org.opentripplanner.routing.edgetype.IntersectionTransitLink) SampleFactory(org.opentripplanner.analyst.request.SampleFactory) LineString(com.vividsolutions.jts.geom.LineString) Sample(org.opentripplanner.analyst.core.Sample) SimpleTransfer(org.opentripplanner.routing.edgetype.SimpleTransfer)

Aggregations

SampleFactory (org.opentripplanner.analyst.request.SampleFactory)3 Sample (org.opentripplanner.analyst.core.Sample)2 GeometryFactory (com.vividsolutions.jts.geom.GeometryFactory)1 LineString (com.vividsolutions.jts.geom.LineString)1 IntersectionTransitLink (org.opentripplanner.routing.edgetype.IntersectionTransitLink)1 SimpleTransfer (org.opentripplanner.routing.edgetype.SimpleTransfer)1 SampleVertex (org.opentripplanner.routing.vertextype.SampleVertex)1 TransitStop (org.opentripplanner.routing.vertextype.TransitStop)1