Search in sources :

Example 16 with Lineal

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

the class LineMatchGraph method getOverlappingMatches.

public Lineal getOverlappingMatches() {
    final List<LineString> overlappingLines = new ArrayList<>();
    final Set<Edge<LineSegmentMatch>> processedEdges = new HashSet<>();
    for (Node<LineSegmentMatch> currentNode : getStartNodes(0)) {
        while (currentNode != null) {
            Node<LineSegmentMatch> nextNode = null;
            final List<Edge<LineSegmentMatch>> edges = currentNode.getOutEdges();
            for (final Edge<LineSegmentMatch> edge : edges) {
                final LineSegmentMatch lineSegmentMatch = edge.getObject();
                if (lineSegmentMatch.hasSegment(0) && !processedEdges.contains(edge)) {
                    if (lineSegmentMatch.getMatchCount(0) > 2) {
                        for (int i = 1; i < lineSegmentMatch.getSegmentCount() && lineSegmentMatch.getMatchCount(0) > 2; i++) {
                            if (lineSegmentMatch.hasSegment(i)) {
                                if (!hasMatch(currentNode, false, 0, i)) {
                                    final Node<LineSegmentMatch> toNode = edge.getToNode();
                                    if (!hasMatch(toNode, true, 0, i)) {
                                        lineSegmentMatch.removeSegment(i);
                                    } else {
                                        final double matchLength = getMatchLength(currentNode, false, 0, i);
                                        final double duplicateMatchLength = getDuplicateMatchLength(currentNode, true, 0, i);
                                        if (matchLength + duplicateMatchLength <= 2) {
                                            lineSegmentMatch.removeSegment(i);
                                        }
                                    }
                                }
                            }
                        }
                        if (lineSegmentMatch.getMatchCount(0) > 2) {
                            overlappingLines.add(lineSegmentMatch.getLine());
                        }
                    }
                    processedEdges.add(edge);
                    nextNode = edge.getToNode();
                }
            }
            currentNode = nextNode;
        }
    }
    final Lineal lines = this.geometryFactory.lineal(overlappingLines);
    return lines;
}
Also used : ArrayList(java.util.ArrayList) Point(com.revolsys.geometry.model.Point) Lineal(com.revolsys.geometry.model.Lineal) LineString(com.revolsys.geometry.model.LineString) Edge(com.revolsys.geometry.graph.Edge) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 17 with Lineal

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

the class CompareProcessor method processPartialMatch.

private void processPartialMatch(final Record sourceObject) {
    final Geometry sourceGeometry = sourceObject.getGeometry();
    if (sourceGeometry instanceof LineString) {
        final LineString sourceLine = (LineString) sourceGeometry;
        final LineIntersectsFilter intersectsFilter = new LineIntersectsFilter(sourceLine);
        final Predicate<Record> geometryFilter = new RecordGeometryFilter<>(intersectsFilter);
        final Predicate<Record> equalFilter = this.equalFilterFactory.apply(sourceObject);
        final Predicate<Record> filter = equalFilter.and(geometryFilter);
        final List<Record> otherObjects = this.otherIndex.queryList(sourceGeometry, filter);
        if (!otherObjects.isEmpty()) {
            final LineMatchGraph<Record> graph = new LineMatchGraph<>(sourceObject, sourceLine);
            for (final Record otherObject : otherObjects) {
                final LineString otherLine = otherObject.getGeometry();
                graph.add(otherLine);
            }
            final Lineal nonMatchedLines = graph.getNonMatchedLines(0);
            if (nonMatchedLines.isEmpty()) {
                removeObject(sourceObject);
            } else {
                removeObject(sourceObject);
                if (nonMatchedLines.getGeometryCount() == 1 && nonMatchedLines.getGeometry(0).getLength() == 1) {
                } else {
                    for (int j = 0; j < nonMatchedLines.getGeometryCount(); j++) {
                        final Geometry newGeometry = nonMatchedLines.getGeometry(j);
                        final Record newObject = Records.copy(sourceObject, newGeometry);
                        addSourceObject(newObject);
                    }
                }
            }
            for (int i = 0; i < otherObjects.size(); i++) {
                final Record otherObject = otherObjects.get(i);
                final Lineal otherNonMatched = graph.getNonMatchedLines(i + 1, 0);
                for (int j = 0; j < otherNonMatched.getGeometryCount(); j++) {
                    final Geometry newGeometry = otherNonMatched.getGeometry(j);
                    final Record newOtherObject = Records.copy(otherObject, newGeometry);
                    addOtherObject(newOtherObject);
                }
                removeOtherObject(otherObject);
            }
        }
    }
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) RecordGeometryFilter(com.revolsys.record.filter.RecordGeometryFilter) Lineal(com.revolsys.geometry.model.Lineal) LineString(com.revolsys.geometry.model.LineString) Record(com.revolsys.record.Record) LineMatchGraph(com.revolsys.geometry.algorithm.linematch.LineMatchGraph) LineIntersectsFilter(com.revolsys.geometry.filter.LineIntersectsFilter) Point(com.revolsys.geometry.model.Point)

Example 18 with Lineal

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

the class GeoJsonRecordWriter method geometry.

private void geometry(final Geometry geometry) {
    this.out.startObject();
    if (geometry instanceof Point) {
        final Point point = (Point) geometry;
        point(point);
    } else if (geometry instanceof LineString) {
        final LineString line = (LineString) geometry;
        line(line);
    } else if (geometry instanceof Polygon) {
        final Polygon polygon = (Polygon) geometry;
        polygon(polygon);
    } else if (geometry instanceof Punctual) {
        final Punctual punctual = (Punctual) geometry;
        multiPoint(punctual);
    } else if (geometry instanceof Lineal) {
        final Lineal lineal = (Lineal) geometry;
        multiLineString(lineal);
    } else if (geometry instanceof Polygonal) {
        final Polygonal polygonal = (Polygonal) geometry;
        multiPolygon(polygonal);
    } else if (geometry.isGeometryCollection()) {
        geometryCollection(geometry);
    }
    this.out.endObject();
}
Also used : Punctual(com.revolsys.geometry.model.Punctual) Lineal(com.revolsys.geometry.model.Lineal) LineString(com.revolsys.geometry.model.LineString) Polygonal(com.revolsys.geometry.model.Polygonal) Point(com.revolsys.geometry.model.Point) Polygon(com.revolsys.geometry.model.Polygon)

Example 19 with Lineal

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

the class XmlGeometryFieldType method writeValueText.

@Override
protected void writeValueText(final XmlWriter out, final Object value) {
    if (value instanceof Point) {
        final Point point = (Point) value;
        writePoint(out, point);
    } else if (value instanceof LineString) {
        final LineString line = (LineString) value;
        writeLineString(out, line);
    } else if (value instanceof Polygon) {
        final Polygon polygon = (Polygon) value;
        writePolygon(out, polygon);
    } else if (value instanceof Lineal) {
        final Lineal multiLine = (Lineal) value;
        writeMultiLineString(out, multiLine);
    }
}
Also used : Lineal(com.revolsys.geometry.model.Lineal) LineString(com.revolsys.geometry.model.LineString) Point(com.revolsys.geometry.model.Point) Polygon(com.revolsys.geometry.model.Polygon)

Example 20 with Lineal

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

the class ShapefileGeometryUtil method writePolyline.

private void writePolyline(final EndianOutput out, final Geometry geometry, final int shapeType, final int wordsPerPoint) throws IOException {
    if (geometry instanceof Lineal) {
        final int numCoordinates = geometry.getVertexCount();
        final int numGeometries = geometry.getGeometryCount();
        final BoundingBox envelope = geometry.getBoundingBox();
        if (this.writeLength) {
            // final int recordLength = ((3 + numGeometries) * BYTES_IN_INT + (4 + 2
            // * numCoordinates)
            // * BYTES_IN_DOUBLE) / 2;
            final int recordLength = 22 + numGeometries * 2 + numCoordinates * wordsPerPoint;
            out.writeInt(recordLength);
        }
        out.writeLEInt(shapeType);
        writeEnvelope(out, envelope);
        out.writeLEInt(numGeometries);
        out.writeLEInt(numCoordinates);
        writePolylinePartIndexes(out, geometry);
        writeXYCoordinates(out, geometry);
    } else {
        throw new IllegalArgumentException("Expecting Lineal geometry got " + geometry.getGeometryType() + "\n" + geometry);
    }
}
Also used : Lineal(com.revolsys.geometry.model.Lineal) BoundingBox(com.revolsys.geometry.model.BoundingBox) 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