Search in sources :

Example 16 with LineStringDouble

use of com.revolsys.geometry.model.impl.LineStringDouble in project com.revolsys.open by revolsys.

the class ScaledNoder method rescale.

private NodedSegmentString rescale(final NodedSegmentString segment) {
    final LineString points = segment.getLineString();
    final int axisCount = points.getAxisCount();
    final int vertexCount = points.getVertexCount();
    final double[] coordinates = new double[vertexCount * axisCount];
    for (int i = 0; i < vertexCount; i++) {
        final double x = points.getX(i) / this.scaleFactor + this.offsetX;
        final double y = points.getY(i) / this.scaleFactor + this.offsetY;
        CoordinatesListUtil.setCoordinates(coordinates, axisCount, i, x, y);
        for (int axisIndex = 2; axisIndex < axisCount; axisIndex++) {
            final double value = points.getCoordinate(i, axisIndex);
            coordinates[i * axisCount + axisIndex] = value;
        }
    }
    final LineStringDouble newPoints = new LineStringDouble(axisCount, coordinates);
    final Object data = segment.getData();
    return new NodedSegmentString(newPoints, data);
}
Also used : LineString(com.revolsys.geometry.model.LineString) LineStringDouble(com.revolsys.geometry.model.impl.LineStringDouble)

Example 17 with LineStringDouble

use of com.revolsys.geometry.model.impl.LineStringDouble in project com.revolsys.open by revolsys.

the class SegmentNodeList method newSplitEdge.

/**
 * Construct a new new "split edge" with the section of points between
 * (and including) the two intersections.
 * The label for the new edge is the same as the label for the parent edge.
 */
SegmentString newSplitEdge(final SegmentNode ei0, final SegmentNode ei1) {
    // Debug.println("\ncreateSplitEdge"); Debug.print(ei0); Debug.print(ei1);
    int npts = ei1.getSegmentIndex() - ei0.getSegmentIndex() + 2;
    // if the last intersection point is not equal to the its segment start pt,
    // add it to the points list as well.
    // (This check is needed because the distance metric is not totally
    // reliable!)
    // The check for point equality is 2D only - Z values are ignored
    final boolean useIntPt1 = ei1.isInterior() || !this.edge.equalsVertex(ei1.getSegmentIndex(), ei1.getX(), ei1.getY());
    if (!useIntPt1) {
        npts--;
    }
    final int axisCount = this.edge.getLineString().getAxisCount();
    final double[] coordinates = new double[npts * axisCount];
    int ipt = 0;
    CoordinatesListUtil.setCoordinates(coordinates, axisCount, ipt++, ei0);
    for (int i = ei0.getSegmentIndex() + 1; i <= ei1.getSegmentIndex(); i++) {
        CoordinatesListUtil.setCoordinates(coordinates, axisCount, ipt++, this.edge, i);
    }
    if (useIntPt1) {
        CoordinatesListUtil.setCoordinates(coordinates, axisCount, ipt++, ei1);
    }
    final LineStringDouble points = new LineStringDouble(axisCount, coordinates);
    return new NodedSegmentString(points, this.edge.getData());
}
Also used : LineStringDouble(com.revolsys.geometry.model.impl.LineStringDouble)

Example 18 with LineStringDouble

use of com.revolsys.geometry.model.impl.LineStringDouble in project com.revolsys.open by revolsys.

the class ShapefileGeometryHandler method readMultipoint.

public Punctual readMultipoint(final GeometryFactory geometryFactory, final ByteBuffer buffer, final int recordLength) {
    buffer.getDouble();
    buffer.getDouble();
    buffer.getDouble();
    buffer.getDouble();
    final int vertexCount = buffer.getInt();
    final double[] coordinates = readXYCoordinates(buffer, vertexCount, 2);
    return geometryFactory.punctual(new LineStringDouble(2, coordinates));
}
Also used : Point(com.revolsys.geometry.model.Point) LineStringDouble(com.revolsys.geometry.model.impl.LineStringDouble)

Example 19 with LineStringDouble

use of com.revolsys.geometry.model.impl.LineStringDouble in project com.revolsys.open by revolsys.

the class ShapefileGeometryUtil method readMultipointZ.

public Punctual readMultipointZ(final GeometryFactory geometryFactory, final EndianInput in, final int recordLength) throws IOException {
    in.skipBytes(4 * MathUtil.BYTES_IN_DOUBLE);
    final int vertexCount = in.readLEInt();
    final double[] coordinates = readXYCoordinates(in, vertexCount, 3);
    in.skipBytes(2 * MathUtil.BYTES_IN_DOUBLE);
    readCoordinates(in, vertexCount, 3, coordinates, 2);
    return geometryFactory.punctual(new LineStringDouble(3, coordinates));
}
Also used : Point(com.revolsys.geometry.model.Point) LineStringDouble(com.revolsys.geometry.model.impl.LineStringDouble)

Example 20 with LineStringDouble

use of com.revolsys.geometry.model.impl.LineStringDouble in project com.revolsys.open by revolsys.

the class ShapefileGeometryUtil method readMultipoint.

public Punctual readMultipoint(final GeometryFactory geometryFactory, final EndianInput in, final int recordLength) throws IOException {
    in.skipBytes(4 * MathUtil.BYTES_IN_DOUBLE);
    final int vertexCount = in.readLEInt();
    final double[] coordinates = readXYCoordinates(in, vertexCount, 2);
    return geometryFactory.punctual(new LineStringDouble(2, coordinates));
}
Also used : Point(com.revolsys.geometry.model.Point) LineStringDouble(com.revolsys.geometry.model.impl.LineStringDouble)

Aggregations

LineStringDouble (com.revolsys.geometry.model.impl.LineStringDouble)22 Point (com.revolsys.geometry.model.Point)17 LineString (com.revolsys.geometry.model.LineString)10 ArrayList (java.util.ArrayList)7 CoordinatesDistanceComparator (com.revolsys.geometry.model.coordinates.comparator.CoordinatesDistanceComparator)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 List (java.util.List)2 TreeSet (java.util.TreeSet)2 BPlusTreeMap (com.revolsys.collection.bplus.BPlusTreeMap)1 IntHashMap (com.revolsys.collection.map.IntHashMap)1 MonotoneChainEdge (com.revolsys.geometry.geomgraph.index.MonotoneChainEdge)1 Edge (com.revolsys.geometry.graph.Edge)1 Node (com.revolsys.geometry.graph.Node)1 LineStringGraph (com.revolsys.geometry.graph.linestring.LineStringGraph)1 DelegatingLineString (com.revolsys.geometry.model.DelegatingLineString)1 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)1 Lineal (com.revolsys.geometry.model.Lineal)1 LinearRing (com.revolsys.geometry.model.LinearRing)1 Polygon (com.revolsys.geometry.model.Polygon)1