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;
}
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);
}
}
}
}
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();
}
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);
}
}
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);
}
}
Aggregations