Search in sources :

Example 16 with LineString

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

the class Edge method addEdgeToEdgesByLine.

public static <T> void addEdgeToEdgesByLine(final Map<LineString, Set<Edge<T>>> lineEdgeMap, final Edge<T> edge) {
    final LineString line = edge.getLineString();
    for (final Entry<LineString, Set<Edge<T>>> entry : lineEdgeMap.entrySet()) {
        final LineString keyLine = entry.getKey();
        if (LineStringUtil.equalsIgnoreDirection2d(line, keyLine)) {
            final Set<Edge<T>> edges = entry.getValue();
            edges.add(edge);
            return;
        }
    }
    final HashSet<Edge<T>> edges = new HashSet<>();
    edges.add(edge);
    lineEdgeMap.put(line, edges);
}
Also used : HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) Set(java.util.Set) DelegatingLineString(com.revolsys.geometry.model.DelegatingLineString) LineString(com.revolsys.geometry.model.LineString) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 17 with LineString

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

the class Edge method compareTo.

@Override
public int compareTo(final Object other) {
    if (other instanceof Edge<?>) {
        final Edge<?> edge = (Edge<?>) other;
        if (this == edge) {
            return 0;
        } else if (isRemoved()) {
            return 1;
        } else if (edge.isRemoved()) {
            return -1;
        } else {
            final Node<?> otherFromNode = edge.getFromNode();
            final Node<?> fromNode = getFromNode();
            final int fromCompare = fromNode.compareTo(otherFromNode.getX(), otherFromNode.getY());
            if (fromCompare == 0) {
                final Node<?> otherToNode = edge.getToNode();
                final Node<T> toNode = getToNode();
                final int toCompare = toNode.compareTo(otherToNode.getX(), otherToNode.getY());
                if (toCompare == 0) {
                    final double otherLength = edge.getLength();
                    final double length = getLength();
                    final int lengthCompare = Double.compare(length, otherLength);
                    if (lengthCompare == 0) {
                        final String name = toSuperString();
                        final String otherName = edge.toSuperString();
                        final int nameCompare = name.compareTo(otherName);
                        if (nameCompare == 0) {
                            return ((Integer) this.id).compareTo(edge.id);
                        } else {
                            return nameCompare;
                        }
                    }
                    return lengthCompare;
                } else {
                    return toCompare;
                }
            } else {
                return fromCompare;
            }
        }
    } else if (other instanceof LineString) {
        final LineString otherLine = (LineString) other;
        final LineString line = getLineString();
        return line.compareTo(otherLine);
    }
    return 1;
}
Also used : DelegatingLineString(com.revolsys.geometry.model.DelegatingLineString) LineString(com.revolsys.geometry.model.LineString) DelegatingLineString(com.revolsys.geometry.model.DelegatingLineString) LineString(com.revolsys.geometry.model.LineString) Point(com.revolsys.geometry.model.Point)

Example 18 with LineString

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

the class Edge method getFromAngle.

public double getFromAngle() {
    final LineString line = getLineString();
    final LineString points = line;
    return CoordinatesListUtil.angleToNext(points, 0);
}
Also used : DelegatingLineString(com.revolsys.geometry.model.DelegatingLineString) LineString(com.revolsys.geometry.model.LineString)

Example 19 with LineString

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

the class MonotoneChainEdge method computeIntersectsForChain.

public void computeIntersectsForChain(final int chainIndex0, final MonotoneChainEdge mce, final int chainIndex1, final SegmentIntersector si) {
    final Edge edge1 = this.edge;
    final Edge edge2 = mce.edge;
    final LineString line1 = edge1.getLineString();
    final LineString line2 = edge2.getLineString();
    computeIntersectsForChain(edge1, line1, this.startIndex[chainIndex0], this.startIndex[chainIndex0 + 1], edge2, line2, mce.startIndex[chainIndex1], mce.startIndex[chainIndex1 + 1], si);
}
Also used : LineString(com.revolsys.geometry.model.LineString) Edge(com.revolsys.geometry.geomgraph.Edge)

Example 20 with LineString

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

the class LineContainsWithinToleranceFilter method test.

@Override
public boolean test(final LineString line) {
    if (this.envelope.intersects(line.getBoundingBox())) {
        final LineString points = line;
        final boolean contains;
        if (this.flip) {
            contains = CoordinatesListUtil.containsWithinTolerance(points, this.points, this.tolerance);
        } else {
            contains = CoordinatesListUtil.containsWithinTolerance(this.points, points, this.tolerance);
        }
        if (contains) {
            return true;
        } else {
            return false;
        }
    } else {
        return false;
    }
}
Also used : LineString(com.revolsys.geometry.model.LineString)

Aggregations

LineString (com.revolsys.geometry.model.LineString)380 Point (com.revolsys.geometry.model.Point)184 Geometry (com.revolsys.geometry.model.Geometry)65 ArrayList (java.util.ArrayList)62 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)51 Polygon (com.revolsys.geometry.model.Polygon)37 LineStringGraph (com.revolsys.geometry.graph.linestring.LineStringGraph)24 Edge (com.revolsys.geometry.graph.Edge)22 List (java.util.List)22 BoundingBox (com.revolsys.geometry.model.BoundingBox)20 Lineal (com.revolsys.geometry.model.Lineal)20 Test (org.junit.Test)20 LinearRing (com.revolsys.geometry.model.LinearRing)19 Record (com.revolsys.record.Record)17 Iterator (java.util.Iterator)14 LineStringEditor (com.revolsys.geometry.model.editor.LineStringEditor)13 Punctual (com.revolsys.geometry.model.Punctual)12 LineStringDouble (com.revolsys.geometry.model.impl.LineStringDouble)12 LineSegment (com.revolsys.geometry.model.segment.LineSegment)10 Polygonal (com.revolsys.geometry.model.Polygonal)9