Search in sources :

Example 1 with LineString

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

the class QuadEdgeSubdivision method getEdgesLineal.

/**
 * Gets the geometry for the edges in the subdivision as a {@link Lineal}
 * containing 2-point lines.
 *
 * @param geometryFactory the GeometryFactory to use
 * @return a MultiLineString
 */
public Lineal getEdgesLineal(final GeometryFactory geometryFactory) {
    final List<QuadEdge> quadEdges = getPrimaryEdges(false);
    final LineString[] lines = new LineString[quadEdges.size()];
    int i = 0;
    for (final QuadEdge edge : quadEdges) {
        lines[i++] = edge.newLineString(geometryFactory);
    }
    return geometryFactory.lineal(lines);
}
Also used : LineString(com.revolsys.geometry.model.LineString) Point(com.revolsys.geometry.model.Point)

Example 2 with LineString

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

the class QuadEdgeConformingDelaunayTinBuilder method newConstraintSegments.

private static List<LineSegmentDoubleData> newConstraintSegments(final Geometry geom) {
    final List<LineString> lines = geom.getGeometryComponents(LineString.class);
    final List<LineSegmentDoubleData> constraintSegs = new ArrayList<>();
    for (final LineString line : lines) {
        newConstraintSegments(line, constraintSegs);
    }
    return constraintSegs;
}
Also used : LineString(com.revolsys.geometry.model.LineString) ArrayList(java.util.ArrayList)

Example 3 with LineString

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

the class Graph method splitEdge.

public List<Edge<T>> splitEdge(final Edge<T> edge, final Point point) {
    if (!edge.isRemoved()) {
        final LineString line = edge.getLineString();
        final List<LineString> lines = line.split(point);
        if (lines.size() == 1) {
            return Collections.singletonList(edge);
        } else {
            final List<Edge<T>> newEdges = replaceEdge(edge, lines);
            return newEdges;
        }
    } else {
        return Collections.emptyList();
    }
}
Also used : LineString(com.revolsys.geometry.model.LineString)

Example 4 with LineString

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

the class Graph method replaceEdge.

public List<Edge<T>> replaceEdge(final Edge<T> edge, final List<LineString> lines) {
    if (!edge.isRemoved()) {
        final List<Edge<T>> edges = new ArrayList<>();
        final T object = edge.getObject();
        remove(edge);
        for (final LineString line : lines) {
            final T newObject = clone(object, line);
            final Edge<T> newEdge = addEdge(newObject, line);
            edges.add(newEdge);
        }
        return edges;
    } else {
        return Collections.emptyList();
    }
}
Also used : LineString(com.revolsys.geometry.model.LineString) ArrayList(java.util.ArrayList)

Example 5 with LineString

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

the class Graph method getEdges.

public List<Edge<T>> getEdges(final Point point, final double maxDistance) {
    if (point == null) {
        return Collections.emptyList();
    } else {
        BoundingBox boundingBox = point.getBoundingBox();
        boundingBox = boundingBox.expand(maxDistance);
        final double x = point.getX();
        final double y = point.getY();
        final Predicate<Edge<T>> filter = (edge) -> {
            final LineString line = edge.getLineString();
            final double distance = line.distance(x, y);
            if (distance <= maxDistance) {
                return true;
            } else {
                return false;
            }
        };
        return BoundingBox.newArraySorted(this::forEachEdge, boundingBox, filter);
    }
}
Also used : Arrays(java.util.Arrays) ComparatorProxy(com.revolsys.comparator.ComparatorProxy) IdObjectIndex(com.revolsys.geometry.index.IdObjectIndex) LineSegmentUtil(com.revolsys.geometry.model.coordinates.LineSegmentUtil) EdgeEvent(com.revolsys.geometry.graph.event.EdgeEvent) PreDestroy(javax.annotation.PreDestroy) GeometryFactoryProxy(com.revolsys.geometry.model.GeometryFactoryProxy) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Map(java.util.Map) PredicateProxy(com.revolsys.predicate.PredicateProxy) Method(java.lang.reflect.Method) PointComparators(com.revolsys.geometry.model.coordinates.comparator.PointComparators) NodeProperties(com.revolsys.geometry.graph.attribute.NodeProperties) Predicate(java.util.function.Predicate) Collection(java.util.Collection) Set(java.util.Set) IntHashMap(com.revolsys.collection.map.IntHashMap) EdgeEventListenerList(com.revolsys.geometry.graph.event.EdgeEventListenerList) PointDoubleXYZ(com.revolsys.geometry.model.impl.PointDoubleXYZ) List(java.util.List) NodeEventListener(com.revolsys.geometry.graph.event.NodeEventListener) Entry(java.util.Map.Entry) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) ExitLoopException(com.revolsys.util.ExitLoopException) Point(com.revolsys.geometry.model.Point) EdgeEventListener(com.revolsys.geometry.graph.event.EdgeEventListener) NodeWithinBoundingBoxVisitor(com.revolsys.geometry.graph.visitor.NodeWithinBoundingBoxVisitor) LineString(com.revolsys.geometry.model.LineString) HashMap(java.util.HashMap) CreateListVisitor(com.revolsys.visitor.CreateListVisitor) Record(com.revolsys.record.Record) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) BPlusTreeMap(com.revolsys.collection.bplus.BPlusTreeMap) CoordinatesDistanceComparator(com.revolsys.geometry.model.coordinates.comparator.CoordinatesDistanceComparator) MapEx(com.revolsys.collection.map.MapEx) SerializablePageValueManager(com.revolsys.io.page.SerializablePageValueManager) WeakReference(java.lang.ref.WeakReference) LinkedList(java.util.LinkedList) Iterator(java.util.Iterator) PageValueManager(com.revolsys.io.page.PageValueManager) IsPointOnLineEdgeFilter(com.revolsys.geometry.graph.filter.IsPointOnLineEdgeFilter) LineStringDouble(com.revolsys.geometry.model.impl.LineStringDouble) NodeEvent(com.revolsys.geometry.graph.event.NodeEvent) Consumer(java.util.function.Consumer) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY) TreeMap(java.util.TreeMap) BoundingBoxProxy(com.revolsys.geometry.model.BoundingBoxProxy) Predicates(com.revolsys.predicate.Predicates) NodeDistanceComparator(com.revolsys.geometry.graph.comparator.NodeDistanceComparator) Comparator(java.util.Comparator) NodeEventListenerList(com.revolsys.geometry.graph.event.NodeEventListenerList) Geometry(com.revolsys.geometry.model.Geometry) BaseObjectWithProperties(com.revolsys.properties.BaseObjectWithProperties) Collections(java.util.Collections) BoundingBox(com.revolsys.geometry.model.BoundingBox) LineString(com.revolsys.geometry.model.LineString) BoundingBox(com.revolsys.geometry.model.BoundingBox)

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