Skip to content

Commit

Permalink
Change RelateNG semantics so all EMPTY geometries are topologically e…
Browse files Browse the repository at this point in the history
…qual (#1089)
  • Loading branch information
dr-jts authored Oct 11, 2024
1 parent 7ff3367 commit 13ea27e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,6 @@ public boolean evaluate(Geometry b, TopologyPredicate predicate) {

RelateGeometry geomB = new RelateGeometry(b, boundaryNodeRule);

if (geomA.isEmpty() && geomB.isEmpty()) {
//TODO: what if predicate is disjoint? Perhaps use result on disjoint envs?
return finishValue(predicate);
}
int dimA = geomA.getDimensionReal();
int dimB = geomB.getDimensionReal();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,11 +482,20 @@ public static TopologyPredicate equalsTopo() {
@Override
public void init(int dimA, int dimB) {
super.init(dimA, dimB);
require(dimA == dimB);
//-- don't require equal dims, because EMPTY = EMPTY for all dims
}

@Override
public boolean requireInteraction() {
//-- allow EMPTY = EMPTY
return false;
};

@Override
public void init(Envelope envA, Envelope envB) {
//-- handle EMPTY = EMPTY cases
setValueIf(true, envA.isNull() && envB.isNull());

require(envA.equals(envB));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ public void testRepeatedPointAA() {
checkRelate(a, b, "212F01FF2");
}

//================ Repeated Points ==============
//================ EMPTY geometries ==============

public void testEmptyEquals() {
String empties[] = {
Expand All @@ -614,9 +614,8 @@ public void testEmptyEquals() {
for (int j = 0; j < nempty; j++) {
String a = empties[i];
String b = empties[j];
checkRelate(a, b, "FFFFFFFF2");
//-- currently in JTS empty geometries do NOT test equal
checkEquals(a, b, false);
///-- empty geometries are all topologically equal
checkEquals(a, b, true);
}
}
}
Expand Down

0 comments on commit 13ea27e

Please sign in to comment.