Search in sources :

Example 1 with Lineal

use of com.revolsys.geometry.model.Lineal in project com.revolsys.open by revolsys.

the class MultiLineStringSegment method next.

@Override
public Segment next() {
    final Lineal lineal = this.lineal;
    this.segmentIndex++;
    while (this.partIndex < lineal.getGeometryCount()) {
        final LineString part = getPart();
        if (this.segmentIndex < part.getSegmentCount()) {
            return this;
        } else {
            this.partIndex++;
            this.segmentIndex = 0;
        }
    }
    throw new NoSuchElementException();
}
Also used : Lineal(com.revolsys.geometry.model.Lineal) LineString(com.revolsys.geometry.model.LineString) AbstractLineString(com.revolsys.geometry.model.impl.AbstractLineString) NoSuchElementException(java.util.NoSuchElementException)

Example 2 with Lineal

use of com.revolsys.geometry.model.Lineal in project com.revolsys.open by revolsys.

the class MultiLineStringSegment method hasNext.

@Override
public boolean hasNext() {
    if (getGeometry().isEmpty()) {
        return false;
    } else {
        final Lineal line = this.lineal;
        int partIndex = this.partIndex;
        int segmentIndex = this.segmentIndex + 1;
        final int geometryCount = line.getGeometryCount();
        while (partIndex < geometryCount) {
            final LineString part = line.getGeometry(partIndex);
            final int segmentCount = part.getSegmentCount();
            if (segmentIndex < segmentCount) {
                return true;
            } else {
                partIndex++;
                segmentIndex = 0;
            }
        }
        return false;
    }
}
Also used : Lineal(com.revolsys.geometry.model.Lineal) LineString(com.revolsys.geometry.model.LineString) AbstractLineString(com.revolsys.geometry.model.impl.AbstractLineString)

Example 3 with Lineal

use of com.revolsys.geometry.model.Lineal in project com.revolsys.open by revolsys.

the class MultiLineStringVertex method hasNext.

@Override
public boolean hasNext() {
    if (getGeometry().isEmpty()) {
        return false;
    } else {
        final Lineal lineal = getLineal();
        int partIndex = this.partIndex;
        int vertexIndex = this.vertexIndex + 1;
        while (partIndex < lineal.getGeometryCount()) {
            final LineString lineString = lineal.getLineString(partIndex);
            if (vertexIndex < lineString.getVertexCount()) {
                return true;
            } else {
                partIndex++;
                vertexIndex = 0;
            }
        }
        return false;
    }
}
Also used : Lineal(com.revolsys.geometry.model.Lineal) LineString(com.revolsys.geometry.model.LineString)

Example 4 with Lineal

use of com.revolsys.geometry.model.Lineal in project com.revolsys.open by revolsys.

the class LineSequencer method isSequenced.

/**
 * Tests whether a {@link Geometry} is sequenced correctly.
 * {@link LineString}s are trivially sequenced.
 * {@link Lineal}s are checked for correct sequencing.
 * Otherwise, <code>isSequenced</code> is defined
 * to be <code>true</code> for geometries that are not lineal.
 *
 * @param geom the geometry to test
 * @return <code>true</code> if the geometry is sequenced or is not lineal
 */
public static boolean isSequenced(final Geometry geom) {
    if (!(geom instanceof Lineal) || geom instanceof LineString) {
        return true;
    }
    final Lineal lineal = (Lineal) geom;
    // the nodes in all subgraphs which have been completely scanned
    final Set prevSubgraphNodes = new TreeSet();
    Point lastNode = null;
    final List currNodes = new ArrayList();
    for (int i = 0; i < lineal.getGeometryCount(); i++) {
        final LineString line = (LineString) lineal.getGeometry(i);
        final Point startNode = line.getPoint(0);
        final Point endNode = line.getPoint(line.getVertexCount() - 1);
        /**
         * If this linestring is connected to a previous subgraph, geom is not sequenced
         */
        if (prevSubgraphNodes.contains(startNode)) {
            return false;
        }
        if (prevSubgraphNodes.contains(endNode)) {
            return false;
        }
        if (lastNode != null) {
            if (!startNode.equals(lastNode)) {
                // start new connected sequence
                prevSubgraphNodes.addAll(currNodes);
                currNodes.clear();
            }
        }
        currNodes.add(startNode);
        currNodes.add(endNode);
        lastNode = endNode;
    }
    return true;
}
Also used : Set(java.util.Set) TreeSet(java.util.TreeSet) Lineal(com.revolsys.geometry.model.Lineal) LineString(com.revolsys.geometry.model.LineString) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) LinkedList(java.util.LinkedList) Point(com.revolsys.geometry.model.Point) Point(com.revolsys.geometry.model.Point)

Example 5 with Lineal

use of com.revolsys.geometry.model.Lineal in project com.revolsys.open by revolsys.

the class LineSequencer method computeSequence.

private void computeSequence() {
    if (this.isRun) {
        return;
    }
    this.isRun = true;
    final List sequences = findSequences();
    if (sequences == null) {
        return;
    }
    this.sequencedGeometry = buildSequencedGeometry(sequences);
    this.isSequenceable = true;
    final int finalLineCount = this.sequencedGeometry.getGeometryCount();
    Assert.isTrue(this.lineCount == finalLineCount, "Lines were missing from result");
    Assert.isTrue(this.sequencedGeometry instanceof Lineal, "Result is not lineal");
}
Also used : Lineal(com.revolsys.geometry.model.Lineal) ArrayList(java.util.ArrayList) List(java.util.List) LinkedList(java.util.LinkedList) Point(com.revolsys.geometry.model.Point)

Aggregations

Lineal (com.revolsys.geometry.model.Lineal)38 LineString (com.revolsys.geometry.model.LineString)20 Point (com.revolsys.geometry.model.Point)19 Polygon (com.revolsys.geometry.model.Polygon)11 Punctual (com.revolsys.geometry.model.Punctual)11 Polygonal (com.revolsys.geometry.model.Polygonal)9 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)8 LinearRing (com.revolsys.geometry.model.LinearRing)7 Test (org.junit.Test)7 LinealEditor (com.revolsys.geometry.model.editor.LinealEditor)6 BoundingBox (com.revolsys.geometry.model.BoundingBox)5 Geometry (com.revolsys.geometry.model.Geometry)5 ArrayList (java.util.ArrayList)4 QuadEdgeDelaunayTinBuilder (com.revolsys.elevation.tin.quadedge.QuadEdgeDelaunayTinBuilder)2 Edge (com.revolsys.geometry.graph.Edge)2 AbstractLineString (com.revolsys.geometry.model.impl.AbstractLineString)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 NoSuchElementException (java.util.NoSuchElementException)2 DataType (com.revolsys.datatype.DataType)1