use of com.revolsys.geometry.algorithm.linematch.LineMatchGraph 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);
}
}
}
}
Aggregations