Search in sources :

Example 16 with GeometryFactory

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

the class Node method getPoint.

@Override
public Point getPoint() {
    final Graph<T> graph = getGraph();
    final GeometryFactory geometryFactory = graph.getGeometryFactory();
    return geometryFactory.point(this);
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory)

Example 17 with GeometryFactory

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

the class LineStringRelate method getOverlap.

public Lineal getOverlap() {
    final List<List<Point>> intersections = new ArrayList<>();
    final LineString points1 = this.line1;
    final List<Point> currentCoordinates = new ArrayList<>();
    Node<LineSegment> previousNode = this.graph1.getNode(this.fromPoint1);
    do {
        final List<Edge<LineSegment>> outEdges = previousNode.getOutEdges();
        if (outEdges.isEmpty()) {
            previousNode = null;
        } else if (outEdges.size() > 1) {
            System.err.println("Cannot handle overlaps\n" + getLine1() + "\n " + getLine2());
            final GeometryFactory factory = this.line1.getGeometryFactory();
            return factory.lineString();
        } else {
            final Edge<LineSegment> edge = outEdges.get(0);
            final LineSegment line = edge.getObject();
            final Node<LineSegment> nextNode = edge.getToNode();
            if (this.graph2.hasEdgeBetween(previousNode, nextNode)) {
                if (currentCoordinates.size() == 0) {
                    currentCoordinates.add(line.getPoint(0));
                }
                currentCoordinates.add(line.getPoint(1));
            } else {
                if (currentCoordinates.size() > 0) {
                    final List<Point> points = new ArrayList<>();
                    intersections.add(points);
                    currentCoordinates.clear();
                }
            }
            previousNode = nextNode;
        }
    } while (previousNode != null && !previousNode.equals(2, this.fromPoint1));
    if (currentCoordinates.size() > 0) {
        final List<Point> points = new ArrayList<>();
        intersections.add(points);
    }
    final GeometryFactory factory = this.line1.getGeometryFactory();
    return factory.lineal(intersections);
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) Node(com.revolsys.geometry.graph.Node) ArrayList(java.util.ArrayList) Point(com.revolsys.geometry.model.Point) LineString(com.revolsys.geometry.model.LineString) List(java.util.List) ArrayList(java.util.ArrayList) Edge(com.revolsys.geometry.graph.Edge) LineSegment(com.revolsys.geometry.model.segment.LineSegment)

Example 18 with GeometryFactory

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

the class Densifier method densify.

private static LineString densify(final LineString line, final double distanceTolerance) {
    final List<Point> points = densifyPoints(line, distanceTolerance);
    final GeometryFactory geometryFactory = line.getGeometryFactory();
    return geometryFactory.lineString(points);
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) Point(com.revolsys.geometry.model.Point)

Example 19 with GeometryFactory

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

the class Densifier method densify.

private static Polygonal densify(final Polygonal polygonal, final double distanceTolerance) {
    final List<Polygon> polygons = new ArrayList<>();
    for (final Polygon polygon : polygonal.getPolygons()) {
        final Polygon newPolygon = densify(polygon, distanceTolerance);
        polygons.add(newPolygon);
    }
    final GeometryFactory geometryFactory = polygonal.getGeometryFactory();
    final Polygonal newMultiPolygon = geometryFactory.polygonal(polygons);
    return (Polygonal) newMultiPolygon.buffer(0);
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) Polygonal(com.revolsys.geometry.model.Polygonal) ArrayList(java.util.ArrayList) Polygon(com.revolsys.geometry.model.Polygon)

Example 20 with GeometryFactory

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

the class LineSegment method getIntersection.

default LineSegment getIntersection(BoundingBox boundingBox) {
    final GeometryFactory geometryFactory = getGeometryFactory();
    boundingBox = boundingBox.convert(geometryFactory);
    final Point lineStart = getPoint(0);
    final Point lineEnd = getPoint(1);
    final boolean contains1 = boundingBox.covers(lineStart);
    final boolean contains2 = boundingBox.covers(lineEnd);
    if (contains1) {
        if (contains2) {
            return this;
        } else {
            final Point c1 = lineStart;
            final Point c2 = getCrossing(lineEnd, lineStart, boundingBox);
            return new LineSegmentDoubleGF(geometryFactory, c1, c2);
        }
    } else {
        if (contains2) {
            final Point c1 = getCrossing(lineStart, lineEnd, boundingBox);
            final Point c2 = lineEnd;
            return new LineSegmentDoubleGF(geometryFactory, c1, c2);
        } else {
            final Point c1 = getCrossing(lineStart, lineEnd, boundingBox);
            final Point c2 = getCrossing(lineEnd, lineStart, boundingBox);
            return new LineSegmentDoubleGF(geometryFactory, c1, c2);
        }
    }
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) Point(com.revolsys.geometry.model.Point)

Aggregations

GeometryFactory (com.revolsys.geometry.model.GeometryFactory)360 Point (com.revolsys.geometry.model.Point)142 Geometry (com.revolsys.geometry.model.Geometry)72 BoundingBox (com.revolsys.geometry.model.BoundingBox)70 LineString (com.revolsys.geometry.model.LineString)61 ArrayList (java.util.ArrayList)45 DataType (com.revolsys.datatype.DataType)25 FieldDefinition (com.revolsys.record.schema.FieldDefinition)24 Polygon (com.revolsys.geometry.model.Polygon)22 List (java.util.List)18 RecordDefinition (com.revolsys.record.schema.RecordDefinition)17 Test (org.junit.Test)16 CoordinateSystem (com.revolsys.geometry.cs.CoordinateSystem)15 Vertex (com.revolsys.geometry.model.vertex.Vertex)14 Record (com.revolsys.record.Record)14 IOException (java.io.IOException)13 PathName (com.revolsys.io.PathName)12 LinearRing (com.revolsys.geometry.model.LinearRing)10 PointDoubleXY (com.revolsys.geometry.model.impl.PointDoubleXY)10 QuadEdgeDelaunayTinBuilder (com.revolsys.elevation.tin.quadedge.QuadEdgeDelaunayTinBuilder)8