Package com.vividsolutions.jts.geom

Examples of com.vividsolutions.jts.geom.CoordinateList


  private Coordinate[] getCoordinates() {
    if (coordinates == null) {
      int forwardDirectedEdges = 0;
      int reverseDirectedEdges = 0;
      CoordinateList coordinateList = new CoordinateList();
      for (Iterator i = directedEdges.iterator(); i.hasNext();) {
        LineMergeDirectedEdge directedEdge = (LineMergeDirectedEdge) i.next();
        if (directedEdge.getEdgeDirection()) {
          forwardDirectedEdges++;
        }
        else {
          reverseDirectedEdges++;
        }
        coordinateList.add(((LineMergeEdge) directedEdge.getEdge()).getLine()
                            .getCoordinates(), false,
          directedEdge.getEdgeDirection());
      }
      coordinates = coordinateList.toCoordinateArray();
      if (reverseDirectedEdges > forwardDirectedEdges) {
        CoordinateArrays.reverse(coordinates);
      }
    }
View Full Code Here


      Coordinate coord = new Coordinate(coordinates[i]);
      targetPM.makePrecise(coord);
      reducedCoords[i] = coord;
    }
    // remove repeated points, to simplify returned geometry as much as possible
    CoordinateList noRepeatedCoordList = new CoordinateList(reducedCoords,
        false);
    Coordinate[] noRepeatedCoords = noRepeatedCoordList.toCoordinateArray();

    /**
     * Check to see if the removal of repeated points collapsed the coordinate
     * List to an invalid length for the type of the parent geometry. It is not
     * necessary to check for Point collapses, since the coordinate list can
View Full Code Here

     * @param node
     * @return
     */
    public static CoordinateList extractCurveMemberCoordinates(Node node) {
        List curveMembers = node.getChildren("curveMember");
        CoordinateList clist = new CoordinateList();
        for (int i = 0; i < curveMembers.size(); i++) {
            List curves = ((Node) curveMembers.get(i))
                    .getChildren(MultiLineString.class);
            for (int j = 0; j < curves.size(); j++) {
                MultiLineString mls = (MultiLineString) ((Node) curves.get(j))
                        .getValue();
                clist.add(mls.getCoordinates(), false);
            }
        }
        return clist;
    }
View Full Code Here

    @SuppressWarnings("unchecked")
    protected Object readGeometry(int instancesCount, int dimensionality,
        boolean readDoubles) throws IOException {
        Object result = null;
        Coordinate coordinate = null;
        CoordinateList coordinates = new CoordinateList();
        GeometryFactory factory = new GeometryFactory();

        for (int inx = 0; inx < instancesCount; inx++) {
            switch (dimensionality) {
            case 2:
                coordinate = new Coordinate(readDoubles ? readDouble()
                                                        : readFloat(),
                        readDoubles ? readDouble() : readFloat());

                break;

            case 3:
                coordinate = new Coordinate(readDoubles ? readDouble()
                                                        : readFloat(),
                        readDoubles ? readDouble() : readFloat(),
                        readDoubles ? readDouble() : readFloat());

                break;

            default:
                //WTF???
            }

            coordinates.add(coordinate);
        }

        // Special handling for text primitives per the VPF spec.
        // The first 2 points are the endpoints of the line, the following
        // points fill in between the first 2 points. 
        if (pathName.endsWith(TEXT_PRIMITIVE) && coordinates.size() > 2) {
            Object o = coordinates.remove(1);
            coordinates.add(o);
        }

        if (instancesCount == 1) {
            result = factory.createPoint(coordinate);
        } else {
            result = factory.createLineString(new CoordinateArraySequence(coordinates
                    .toCoordinateArray()));
        }

        return result;
    }
View Full Code Here

    }
  }

  public Geometry decodeGeometry(PropertyContainer container) {
    Node node = testIsNode(container);
    CoordinateList coordinates = new CoordinateList();
    for (Node point : node.traverse(Order.DEPTH_FIRST, StopEvaluator.END_OF_GRAPH, ReturnableEvaluator.ALL_BUT_START_NODE,
            SimpleRelationshipTypes.FIRST, Direction.OUTGOING, SimpleRelationshipTypes.NEXT, Direction.OUTGOING)) {
      coordinates.add(new Coordinate((Double) point.getProperty("x"), (Double) point.getProperty("y"), (Double) point.getProperty("z")), false);
    }
    return getGeometryFactory().createLineString(coordinates.toCoordinateArray());
  }
View Full Code Here

        assertTrue( "Should be a dynamic layer", layer instanceof EditableLayer );
        layer = (EditableLayer) spatialService.getLayer( layer.getName() );
        assertNotNull( layer );
        assertTrue( "Should be a dynamic layer", layer instanceof EditableLayer );

        CoordinateList coordinates = new CoordinateList();
        coordinates.add( new Coordinate( 13.1, 56.2 ), false );
        coordinates.add( new Coordinate( 13.2, 56.0 ), false );
        coordinates.add( new Coordinate( 13.3, 56.2 ), false );
        coordinates.add( new Coordinate( 13.2, 56.0 ), false );
        coordinates.add( new Coordinate( 13.1, 56.2 ), false );
        coordinates.add( new Coordinate( 13.0, 56.0 ), false );
        layer.add( layer.getGeometryFactory().createLineString(
                coordinates.toCoordinateArray() ) );

        coordinates = new CoordinateList();
        coordinates.add( new Coordinate( 14.1, 56.0 ), false );
        coordinates.add( new Coordinate( 14.3, 56.1 ), false );
        coordinates.add( new Coordinate( 14.2, 56.1 ), false );
        coordinates.add( new Coordinate( 14.0, 56.0 ), false );
        layer.add( layer.getGeometryFactory().createLineString(
                coordinates.toCoordinateArray() ) );

        // TODO this test is not complete

        try (Transaction tx = graphDb().beginTx()) {
            printResults(layer, GeoPipeline
View Full Code Here

    }
  }

  @SuppressWarnings("unchecked")
  private static Coordinate[] makeCoordinateDataFromTextFile(String textFile, Coordinate origin) {
    CoordinateList data = new CoordinateList();
    try {
      BufferedReader reader = new BufferedReader(new FileReader("src/main/resources/"+textFile));
      String line;
      int row = 0;
      while ((line = reader.readLine()) != null) {
        int col = 0;
        for (String character : line.split("")) {
          if (col > 0 && !character.matches("\\s")) {
            Coordinate coordinate = new Coordinate(origin.x + (double) col / 100.0, origin.y - (double) row / 100.0);
            data.add(coordinate);
          }
          col++;
        }
        row++;
      }
    } catch (IOException e) {
      throw new AssertionFailedError("Input data for string test invalid: " + e.getMessage());
    }
    return data.toCoordinateArray();
  }
View Full Code Here

    return data.toCoordinateArray();
  }

  @SuppressWarnings("unchecked")
  private static Coordinate[] makeDensePointData() {
    CoordinateList data = new CoordinateList();
    Coordinate origin = new Coordinate(13.0, 55.6);
    for (int row = 0; row < 40; row++) {
      for (int col = 0; col < 40; col++) {
        Coordinate coordinate = new Coordinate(origin.x + (double) col / 100.0, origin.y - (double) row / 100.0);
        data.add(coordinate);
      }
    }
    return data.toCoordinateArray();
  }
View Full Code Here

TOP

Related Classes of com.vividsolutions.jts.geom.CoordinateList

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.