Examples of PackedCoordinateSequence


Examples of com.vividsolutions.jts.geom.impl.PackedCoordinateSequence

    /**
     * @see org.geotools.geometry.coordinatesequence.CSBuilder#setOrdinate(com.vividsolutions.jts.geom.CoordinateSequence, double, int, int)
     */
    public void setOrdinate(CoordinateSequence sequence, double value, int ordinateIndex, int coordinateIndex) {
      PackedCoordinateSequence pcs = (PackedCoordinateSequence) sequence;
      pcs.setOrdinate(coordinateIndex, ordinateIndex, value);
    }
View Full Code Here

Examples of com.vividsolutions.jts.geom.impl.PackedCoordinateSequence

   
    /**
     * @see org.geotools.geometry.coordinatesequence.CSBuilder#setOrdinate(com.vividsolutions.jts.geom.CoordinateSequence, double, int, int)
     */
    public void setOrdinate(CoordinateSequence sequence, double value, int ordinateIndex, int coordinateIndex) {
      PackedCoordinateSequence pcs = (PackedCoordinateSequence) sequence;
      pcs.setOrdinate(coordinateIndex, ordinateIndex, value);
    }
View Full Code Here

Examples of com.vividsolutions.jts.geom.impl.PackedCoordinateSequence

public void createCurve(){
    // createCurve start
    GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory();
    CurvedGeometryFactory curvedFactory = new CurvedGeometryFactory(geometryFactory,Double.MAX_VALUE);
   
    PackedCoordinateSequence coords = new PackedCoordinateSequence.Double(
       new double[]{10,14,6,10,14,10}, 2 );
   
    CircularString arc = (CircularString) curvedFactory.createCurvedGeometry(coords);
    // createCurve end   
}
View Full Code Here

Examples of com.vividsolutions.jts.geom.impl.PackedCoordinateSequence

        return geom.contains(p);
    }

    protected Polygon createRect(double x, double y, double w, double h) {
        double[] arr = { x, y, x + w, y, x + w, y + h, x, y + h, x, y };
        PackedCoordinateSequence shell = new PackedCoordinateSequence.Double(arr, 2);
        Polygon p = fac.createPolygon(fac.createLinearRing(shell), NOSHELLS);
        return p;
    }
View Full Code Here

Examples of org.opentripplanner.common.geometry.PackedCoordinateSequence

    private void calculateElevations(Itinerary itinerary, Edge[] edges) {
        for (Edge edge : edges) {
            if (!(edge instanceof StreetEdge)) continue;

            StreetEdge edgeWithElevation = (StreetEdge) edge;
            PackedCoordinateSequence coordinates = edgeWithElevation.getElevationProfile();

            if (coordinates == null) continue;
            // TODO Check the test below, AFAIU current elevation profile has 3 dimensions.
            if (coordinates.getDimension() != 2) continue;

            for (int i = 0; i < coordinates.size() - 1; i++) {
                double change = coordinates.getOrdinate(i + 1, 1) - coordinates.getOrdinate(i, 1);

                if (change > 0) {
                    itinerary.elevationGained += change;
                } else if (change < 0) {
                    itinerary.elevationLost -= change;
View Full Code Here

Examples of org.opentripplanner.common.geometry.PackedCoordinateSequence

        v50.freeFlowing = (true);
        v52.freeFlowing = (true);
        v54.freeFlowing = (true);

        // Elevation profiles for the street edges that will be created later
        PackedCoordinateSequence elevation3 = new PackedCoordinateSequence.Double(
                new double[]{0.0, 0.0, 3.0, 9.9}, 2);
        PackedCoordinateSequence elevation39 = new PackedCoordinateSequence.Double(
                new double[]{0.0, 9.9, 2.1, 0.1}, 2);
        PackedCoordinateSequence elevation41 = new PackedCoordinateSequence.Double(
                new double[]{0.0, 0.1, 1.9, 2.8}, 2);
        PackedCoordinateSequence elevation49 = new PackedCoordinateSequence.Double(
                new double[]{0.0, 2.8, 2.0, 2.6}, 2);
        PackedCoordinateSequence elevation53 = new PackedCoordinateSequence.Double(
                new double[]{0.0, 2.6, 1.0, 6.0}, 2);

        // Coordinate sequences and line strings for those same edges
        PackedCoordinateSequence coordinates3 = new PackedCoordinateSequence.Double(
                new double[]{0, 0, 1, 1}, 2);
        PackedCoordinateSequence coordinates25 = new PackedCoordinateSequence.Double(
                new double[]{133, 67, 135, 67}, 2);
        PackedCoordinateSequence coordinates39 = new PackedCoordinateSequence.Double(
                new double[]{179, 89, 180, 89}, 2);
        PackedCoordinateSequence coordinates41 = new PackedCoordinateSequence.Double(
                new double[]{180, 89, 180, 90}, 2);
        PackedCoordinateSequence coordinates49 = new PackedCoordinateSequence.Double(
                new double[]{180, 90, 90, 90}, 2);
        PackedCoordinateSequence coordinates53 = new PackedCoordinateSequence.Double(
                new double[]{90, 90, 0, 90}, 2);

        GeometryFactory geometryFactory = new GeometryFactory();

        LineString l3 = new LineString(coordinates3, geometryFactory);
View Full Code Here

Examples of org.opentripplanner.common.geometry.PackedCoordinateSequence

        Coordinate[] profile = new Coordinate[] {
                new Coordinate(0, 0), // slope = 0.1
                new Coordinate(length / 2, length / 20.0),
                new Coordinate(length, 0) // slope = -0.1
        };
        PackedCoordinateSequence elev = new PackedCoordinateSequence.Double(profile);
        testStreet.setElevationProfile(elev, false);

        SlopeCosts costs = ElevationUtils.getSlopeCosts(elev, true);
        double trueLength = costs.lengthMultiplier * length;
        double slopeWorkLength = testStreet.getSlopeWorkCostEffectiveLength();
View Full Code Here

Examples of org.opentripplanner.common.geometry.PackedCoordinateSequence

        new StreetTransitLink(intersectionB, transitStopB, true);
        new StreetTransitLink(intersectionC, transitStopC, true);
        new StreetTransitLink(intersectionD, transitStopD, true);
        new StreetTransitLink(intersectionA, transitStopE, true);

        PackedCoordinateSequence coordinatesAB = new PackedCoordinateSequence.Double(
                new double[]{1, 1, 1, 2}, 2);
        PackedCoordinateSequence coordinatesBC = new PackedCoordinateSequence.Double(
                new double[]{1, 2, 2, 2}, 2);
        PackedCoordinateSequence coordinatesCD = new PackedCoordinateSequence.Double(
                new double[]{2, 2, 2, 1}, 2);
        PackedCoordinateSequence coordinatesAD = new PackedCoordinateSequence.Double(
                new double[]{1, 1, 2, 1}, 2);

        GeometryFactory geometryFactory = new GeometryFactory();

        LineString lineStringAB = new LineString(coordinatesAB, geometryFactory);
View Full Code Here

Examples of org.opentripplanner.common.geometry.PackedCoordinateSequence

        HashSet<Vertex> closed = new HashSet<Vertex>();

        // initialize queue with all vertices which already have known elevation
        for (StreetEdge e : edgesWithElevation) {
            PackedCoordinateSequence profile = e.getElevationProfile();

            if (!elevations.containsKey(e.getFromVertex())) {
                double firstElevation = profile.getOrdinate(0, 1);
                ElevationRepairState state = new ElevationRepairState(null, null,
                        e.getFromVertex(), 0, firstElevation);
                pq.insert(state, 0);
                elevations.put(e.getFromVertex(), firstElevation);
            }

            if (!elevations.containsKey(e.getToVertex())) {
                double lastElevation = profile.getOrdinate(profile.size() - 1, 1);
                ElevationRepairState state = new ElevationRepairState(null, null, e.getToVertex(),
                        0, lastElevation);
                pq.insert(state, 0);
                elevations.put(e.getToVertex(), lastElevation);
            }
        }

        // Grow an SPT outward from vertices with known elevations into regions where the
        // elevation is not known. when a branch hits a region with known elevation, follow the
        // back pointers through the region of unknown elevation, setting elevations via interpolation.
        while (!pq.empty()) {
            ElevationRepairState state = pq.extract_min();

            if (closed.contains(state.vertex)) continue;
            closed.add(state.vertex);

            ElevationRepairState curState = state;
            Vertex initialVertex = null;
            while (curState != null) {
                initialVertex = curState.vertex;
                curState = curState.backState;
            }

            double bestDistance = Double.MAX_VALUE;
            double bestElevation = 0;
            for (Edge e : state.vertex.getOutgoing()) {
                if (!(e instanceof StreetEdge)) {
                    continue;
                }
                StreetEdge edge = (StreetEdge) e;
                Vertex tov = e.getToVertex();
                if (tov == initialVertex)
                    continue;

                Double elevation = elevations.get(tov);
                if (elevation != null) {
                    double distance = e.getDistance();
                    if (distance < bestDistance) {
                        bestDistance = distance;
                        bestElevation = elevation;
                    }
                } else {
                    // continue
                    ElevationRepairState newState = new ElevationRepairState(edge, state, tov,
                            e.getDistance() + state.distance, state.initialElevation);
                    pq.insert(newState, e.getDistance() + state.distance);
                }
            } // end loop over outgoing edges

            for (Edge e : state.vertex.getIncoming()) {
                if (!(e instanceof StreetEdge)) {
                    continue;
                }
                StreetEdge edge = (StreetEdge) e;
                Vertex fromv = e.getFromVertex();
                if (fromv == initialVertex)
                    continue;
                Double elevation = elevations.get(fromv);
                if (elevation != null) {
                    double distance = e.getDistance();
                    if (distance < bestDistance) {
                        bestDistance = distance;
                        bestElevation = elevation;
                    }
                } else {
                    // continue
                    ElevationRepairState newState = new ElevationRepairState(edge, state, fromv,
                            e.getDistance() + state.distance, state.initialElevation);
                    pq.insert(newState, e.getDistance() + state.distance);
                }
            } // end loop over incoming edges

            //limit elevation propagation to at max 2km; this prevents an infinite loop
            //in the case of islands missing elevation (and some other cases)
            if (bestDistance == Double.MAX_VALUE && state.distance > 2000) {
                log.warn("While propagating elevations, hit 2km distance limit at " + state.vertex);
                bestDistance = state.distance;
                bestElevation = state.initialElevation;
            }
            if (bestDistance != Double.MAX_VALUE) {
                // we have found a second vertex with elevation, so we can interpolate the elevation
                // for this point
                double totalDistance = bestDistance + state.distance;
                // trace backwards, setting states as we go
                while (true) {
                    // watch out for division by 0 here, which will propagate NaNs
                    // all the way out to edge lengths
                    if (totalDistance == 0)
                        elevations.put(state.vertex, bestElevation);
                    else {
                        double elevation = (bestElevation * state.distance +
                               state.initialElevation * bestDistance) / totalDistance;
                        elevations.put(state.vertex, elevation);
                    }
                    if (state.backState == null)
                        break;
                    bestDistance += state.backEdge.getDistance();
                    state = state.backState;
                    if (elevations.containsKey(state.vertex))
                        break;
                }

            }
        } // end loop over states

        // do actual assignments
        for (Vertex v : graph.getVertices()) {
            Double fromElevation = elevations.get(v);
            for (Edge e : v.getOutgoing()) {
                if (e instanceof StreetWithElevationEdge) {
                    StreetWithElevationEdge edge = ((StreetWithElevationEdge) e);

                    Double toElevation = elevations.get(edge.getToVertex());

                    if (fromElevation == null || toElevation == null) {
                        if (!edge.isElevationFlattened() && !edge.isSlopeOverride())
                            log.warn("Unexpectedly missing elevation for edge " + edge);
                        continue;
                    }

                    if (edge.getElevationProfile() != null && edge.getElevationProfile().size() > 2) {
                        continue;
                    }

                    Coordinate[] coords = new Coordinate[2];
                    coords[0] = new Coordinate(0, fromElevation);
                    coords[1] = new Coordinate(edge.getDistance(), toElevation);

                    PackedCoordinateSequence profile = new PackedCoordinateSequence.Double(coords);

                    if (edge.setElevationProfile(profile, true)) {
                        log.trace(graph.addBuilderAnnotation(new ElevationFlattened(edge)));
                    }
                }
View Full Code Here

Examples of org.opentripplanner.common.geometry.PackedCoordinateSequence

        // final sample (x = edge length)
        coordList.add(new Coordinate(edgeLenM, getElevation(coords[coords.length - 1])));

        // construct the PCS
        Coordinate coordArr[] = new Coordinate[coordList.size()];
        PackedCoordinateSequence elevPCS = new PackedCoordinateSequence.Double(
                coordList.toArray(coordArr));

        if(ee.setElevationProfile(elevPCS, false)) {
            log.trace(graph.addBuilderAnnotation(new ElevationFlattened(ee)));
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.