Skip to content

Commit f664e0f

Browse files
committed
Add RelateNG prepared test for matches P/A
1 parent 489dfbb commit f664e0f

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

modules/core/src/test/java/org/locationtech/jts/operation/relateng/RelateNGTest.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
*/
1212
package org.locationtech.jts.operation.relateng;
1313

14+
import org.locationtech.jts.geom.IntersectionMatrix;
15+
1416
import junit.textui.TestRunner;
1517

1618
public class RelateNGTest extends RelateNGTestCase {
@@ -668,5 +670,17 @@ public void testPreparedAA() {
668670
checkPrepared(a, b);
669671
}
670672

671-
673+
public void testPreparedPA() {
674+
String a = "POINT (5 5)";
675+
String b = "POLYGON ((1 9, 9 9, 9 1, 1 1, 1 9))";
676+
checkPrepared(a, b);
677+
checkPrepared(b, a);
678+
679+
//-- see https://github.com/libgeos/geos/issues/1275 (not a bug, but a good test to have)
680+
String pattern = "T*****FF*";
681+
String patternTrans = IntersectionMatrix.transpose(pattern); // T*F**F***
682+
checkPreparedMatches(a, b, pattern);
683+
checkPreparedMatches(b, a, patternTrans); //
684+
}
685+
672686
}

modules/core/src/test/java/org/locationtech/jts/operation/relateng/RelateNGTestCase.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,16 @@ void checkPrepared(String wkta, String wktb)
113113
RelateNG.relate(a, b).toString());
114114
}
115115

116+
void checkPreparedMatches(String wkta, String wktb, String pattern) {
117+
Geometry a = read(wkta);
118+
Geometry b = read(wktb);
119+
RelateNG prep_a = RelateNG.prepare(a);
120+
121+
assertEquals("matches " + pattern, prep_a.evaluate(b, RelatePredicate.matches(pattern) ),
122+
RelateNG.relate(a, b, RelatePredicate.matches(pattern) )
123+
);
124+
}
125+
116126
TopologyPredicate trace(TopologyPredicate pred) {
117127
if (! isTrace)
118128
return pred;

0 commit comments

Comments
 (0)