use of com.revolsys.record.filter.RecordGeometryFilter in project com.revolsys.open by revolsys.
the class LineStringLessThanDistanceFilter method getFilter.
public static Predicate<Record> getFilter(final Record object, final double maxDistance) {
final LineString line = object.getGeometry();
final LineStringLessThanDistanceFilter lineFilter = new LineStringLessThanDistanceFilter(line, maxDistance);
return new RecordGeometryFilter<>(lineFilter);
}
use of com.revolsys.record.filter.RecordGeometryFilter in project com.revolsys.open by revolsys.
the class CompareProcessor method processExactLineMatch.
private void processExactLineMatch(final Record sourceObject) {
final LineString sourceLine = sourceObject.getGeometry();
final LineEqualIgnoreDirectionFilter lineEqualFilter = new LineEqualIgnoreDirectionFilter(sourceLine, 3);
final Predicate<Record> geometryFilter = new RecordGeometryFilter<>(lineEqualFilter);
final Predicate<Record> equalFilter = this.equalFilterFactory.apply(sourceObject);
final Predicate<Record> filter = equalFilter.and(geometryFilter);
final Record otherObject = this.otherIndex.queryFirst(sourceObject, filter);
if (otherObject != null) {
this.equalStatistics.addCount(sourceObject);
removeObject(sourceObject);
removeOtherObject(otherObject);
}
}
use of com.revolsys.record.filter.RecordGeometryFilter 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.record.filter.RecordGeometryFilter in project com.revolsys.open by revolsys.
the class LinearIntersectionNotEqualLineEdgeCleanupVisitor method accept.
@Override
public void accept(final Edge<Record> edge) {
final String typePath = edge.getTypeName();
final Graph<Record> graph = edge.getGraph();
final LineString line = edge.getLineString();
Predicate<Edge<Record>> attributeAndGeometryFilter = new EdgeTypeNameFilter<>(typePath);
final Predicate<Edge<Record>> filter = getPredicate();
if (filter != null) {
attributeAndGeometryFilter = attributeAndGeometryFilter.and(filter);
}
final Predicate<Record> notEqualLineFilter = new RecordGeometryFilter<>(new EqualFilter<>(line)).negate();
final RecordGeometryFilter<LineString> linearIntersectionFilter = new RecordGeometryFilter<>(new LinearIntersectionFilter(line));
attributeAndGeometryFilter = attributeAndGeometryFilter.and(new EdgeObjectFilter<>(notEqualLineFilter.and(linearIntersectionFilter)));
final List<Edge<Record>> intersectingEdges = graph.getEdges(line, attributeAndGeometryFilter);
if (!intersectingEdges.isEmpty()) {
if (intersectingEdges.size() == 1 && line.getLength() > 10) {
if (line.getVertexCount() > 2) {
final Edge<Record> edge2 = intersectingEdges.get(0);
final LineString line2 = edge2.getLineString();
if (middleCoordinatesEqual(line, line2)) {
final boolean firstEqual = line.equalsVertex(2, 0, line2, 0);
if (!firstEqual) {
final Node<Record> fromNode1 = edge.getFromNode();
final Node<Record> fromNode2 = edge2.getFromNode();
if (fromNode1.distancePoint(fromNode2) < 2) {
graph.moveNodesToMidpoint(typePath, fromNode1, fromNode2);
return;
}
}
final boolean lastEqual = line.equalsVertex(2, line.getVertexCount() - 1, line2, line.getVertexCount() - 1);
if (!lastEqual) {
final Node<Record> toNode1 = edge.getToNode();
final Node<Record> toNode2 = edge2.getToNode();
if (toNode1.distancePoint(toNode2) < 2) {
graph.moveNodesToMidpoint(typePath, toNode1, toNode2);
return;
}
}
}
}
}
Logs.error(this, "Has intersecting edges " + line);
}
}
use of com.revolsys.record.filter.RecordGeometryFilter in project com.revolsys.open by revolsys.
the class EqualTypeAndLineEdgeCleanupVisitor method accept.
@Override
public void accept(final Edge<Record> edge) {
if (edge.getProperty(EDGE_PROCESSED) == null) {
final String typePath = edge.getTypeName();
final Graph<Record> graph = edge.getGraph();
final LineString line = edge.getLineString();
Predicate<Edge<Record>> attributeAndGeometryFilter = new EdgeTypeNameFilter<>(typePath);
final Predicate<Edge<Record>> filter = getPredicate();
if (filter != null) {
attributeAndGeometryFilter = attributeAndGeometryFilter.and(filter);
}
final Predicate<Record> equalLineFilter = new RecordGeometryFilter<>(new LineEqualIgnoreDirectionFilter(line, 2));
final EdgeObjectFilter<Record> edgeFilter = new EdgeObjectFilter<>(equalLineFilter);
attributeAndGeometryFilter = attributeAndGeometryFilter.and(edgeFilter);
final List<Edge<Record>> equalEdges;
if (getComparator() == null) {
equalEdges = graph.getEdges(line, attributeAndGeometryFilter);
} else {
equalEdges = graph.getEdges(line, attributeAndGeometryFilter, getComparator());
}
processEqualEdges(equalEdges);
}
}
Aggregations