-
Notifications
You must be signed in to change notification settings - Fork 447
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RelateNG algorithm for DE-9IM relationship evaluation (#1052)
- Loading branch information
Showing
44 changed files
with
7,845 additions
and
6 deletions.
There are no files selected for viewing
89 changes: 89 additions & 0 deletions
89
modules/app/src/main/java/org/locationtech/jtstest/function/SelectionNGFunctions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* | ||
* Copyright (c) 2024 Martin Davis. | ||
* | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* and Eclipse Distribution License v. 1.0 which accompanies this distribution. | ||
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v20.html | ||
* and the Eclipse Distribution License is available at | ||
* | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
*/ | ||
|
||
package org.locationtech.jtstest.function; | ||
|
||
import org.locationtech.jts.geom.Geometry; | ||
import org.locationtech.jts.operation.relateng.IntersectionMatrixPattern; | ||
import org.locationtech.jts.operation.relateng.RelateNG; | ||
import org.locationtech.jts.operation.relateng.RelatePredicate; | ||
|
||
public class SelectionNGFunctions | ||
{ | ||
public static Geometry intersects(Geometry a, final Geometry mask) | ||
{ | ||
return SelectionFunctions.select(a, new GeometryPredicate() { | ||
public boolean isTrue(Geometry g) { | ||
return RelateNG.relate(mask, g, RelatePredicate.intersects()); | ||
} | ||
}); | ||
} | ||
|
||
public static Geometry intersectsPrep(Geometry a, final Geometry mask) | ||
{ | ||
RelateNG relateNG = RelateNG.prepare(mask); | ||
return SelectionFunctions.select(a, new GeometryPredicate() { | ||
public boolean isTrue(Geometry g) { | ||
return relateNG.evaluate(g, RelatePredicate.intersects()); | ||
} | ||
}); | ||
} | ||
|
||
public static Geometry contains(Geometry a, final Geometry mask) | ||
{ | ||
return SelectionFunctions.select(a, new GeometryPredicate() { | ||
public boolean isTrue(Geometry g) { | ||
return RelateNG.relate(mask, g, RelatePredicate.contains()); | ||
} | ||
}); | ||
} | ||
|
||
public static Geometry covers(Geometry a, final Geometry mask) | ||
{ | ||
return SelectionFunctions.select(a, new GeometryPredicate() { | ||
public boolean isTrue(Geometry g) { | ||
return RelateNG.relate(mask, g, RelatePredicate.covers()); | ||
} | ||
}); | ||
} | ||
|
||
public static Geometry coversPrep(Geometry a, final Geometry mask) | ||
{ | ||
RelateNG relateNG = RelateNG.prepare(mask); | ||
return SelectionFunctions.select(a, new GeometryPredicate() { | ||
public boolean isTrue(Geometry g) { | ||
return relateNG.evaluate(g, RelatePredicate.covers()); | ||
} | ||
}); | ||
} | ||
|
||
public static Geometry adjacent(Geometry a, final Geometry mask) | ||
{ | ||
return SelectionFunctions.select(a, new GeometryPredicate() { | ||
public boolean isTrue(Geometry g) { | ||
return RelateNG.relate(mask, g, RelatePredicate.matches(IntersectionMatrixPattern.ADJACENT)); | ||
} | ||
}); | ||
} | ||
|
||
public static Geometry adjacentPrep(Geometry a, final Geometry mask) | ||
{ | ||
RelateNG relateNG = RelateNG.prepare(mask); | ||
return SelectionFunctions.select(a, new GeometryPredicate() { | ||
public boolean isTrue(Geometry g) { | ||
return relateNG.evaluate(g, RelatePredicate.matches(IntersectionMatrixPattern.ADJACENT)); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
modules/app/src/main/java/org/locationtech/jtstest/function/SpatialPredicateNGFunctions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* Copyright (c) 2023 Martin Davis. | ||
* | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* and Eclipse Distribution License v. 1.0 which accompanies this distribution. | ||
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v20.html | ||
* and the Eclipse Distribution License is available at | ||
* | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
*/ | ||
package org.locationtech.jtstest.function; | ||
|
||
import org.locationtech.jts.algorithm.BoundaryNodeRule; | ||
import org.locationtech.jts.geom.Geometry; | ||
import org.locationtech.jts.operation.relateng.IntersectionMatrixPattern; | ||
import org.locationtech.jts.operation.relateng.RelateNG; | ||
import org.locationtech.jts.operation.relateng.RelatePredicate; | ||
|
||
public class SpatialPredicateNGFunctions { | ||
public static boolean contains(Geometry a, Geometry b) { | ||
return RelateNG.relate(a, b, RelatePredicate.contains()); | ||
} | ||
public static boolean covers(Geometry a, Geometry b) { | ||
return RelateNG.relate(a, b, RelatePredicate.covers()); | ||
} | ||
public static boolean coveredBy(Geometry a, Geometry b) { | ||
return RelateNG.relate(a, b, RelatePredicate.coveredBy()); | ||
} | ||
public static boolean disjoint(Geometry a, Geometry b) { | ||
return RelateNG.relate(a, b, RelatePredicate.disjoint()); | ||
} | ||
public static boolean equals(Geometry a, Geometry b) { | ||
return RelateNG.relate(a, b, RelatePredicate.equalsTopo()); | ||
} | ||
public static boolean equalsTopo(Geometry a, Geometry b) { | ||
return RelateNG.relate(a, b, RelatePredicate.equalsTopo()); | ||
} | ||
public static boolean intersects(Geometry a, Geometry b) { | ||
return RelateNG.relate(a, b, RelatePredicate.intersects()); | ||
} | ||
public static boolean crosses(Geometry a, Geometry b) { | ||
return RelateNG.relate(a, b, RelatePredicate.crosses()); | ||
} | ||
public static boolean overlaps(Geometry a, Geometry b) { | ||
return RelateNG.relate(a, b, RelatePredicate.overlaps()); | ||
} | ||
public static boolean touches(Geometry a, Geometry b) { | ||
return RelateNG.relate(a, b, RelatePredicate.touches()); | ||
} | ||
public static boolean within(Geometry a, Geometry b) { | ||
return RelateNG.relate(a, b, RelatePredicate.within()); | ||
} | ||
|
||
public static boolean adjacent(Geometry a, Geometry b) { | ||
return RelateNG.relate(a, b, RelatePredicate.matches(IntersectionMatrixPattern.ADJACENT)); | ||
} | ||
|
||
public static boolean containsProperly(Geometry a, Geometry b) { | ||
return RelateNG.relate(a, b, RelatePredicate.matches(IntersectionMatrixPattern.CONTAINS_PROPERLY)); | ||
} | ||
|
||
public static boolean interiorIntersects(Geometry a, Geometry b) { | ||
return RelateNG.relate(a, b, RelatePredicate.matches(IntersectionMatrixPattern.INTERIOR_INTERSECTS)); | ||
} | ||
|
||
public static boolean relate(Geometry a, Geometry b, String mask) { | ||
return RelateNG.relate(a, b, mask); | ||
} | ||
public static String relateMatrix(Geometry a, Geometry b) { | ||
return RelateNG.relate(a, b).toString(); | ||
} | ||
public static String relateEndpoint(Geometry a, Geometry b) { | ||
return RelateNG.relate(a, b, BoundaryNodeRule.ENDPOINT_BOUNDARY_RULE).toString(); | ||
} | ||
public static String relateMultiValent(Geometry a, Geometry b) { | ||
return RelateNG.relate(a, b, BoundaryNodeRule.MULTIVALENT_ENDPOINT_BOUNDARY_RULE).toString(); | ||
} | ||
public static String relateMonoValent(Geometry a, Geometry b) { | ||
return RelateNG.relate(a, b, BoundaryNodeRule.MONOVALENT_ENDPOINT_BOUNDARY_RULE).toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.