Skip to content

Commit

Permalink
Add selection functions
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-jts committed Nov 22, 2024
1 parent 9df69d1 commit cb6a6b2
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,25 @@ public boolean isTrue(Geometry g) {
});
}

public static Geometry contains(Geometry a, final Geometry mask)
{
return select(a, new GeometryPredicate() {
public boolean isTrue(Geometry g) {
return mask.contains(g);
}
});
}

public static Geometry containsPrep(Geometry a, final Geometry mask)
{
PreparedGeometry prep = PreparedGeometryFactory.prepare(mask);
return select(a, new GeometryPredicate() {
public boolean isTrue(Geometry g) {
return prep.contains(g);
}
});
}

public static Geometry covers(Geometry a, final Geometry mask)
{
return select(a, new GeometryPredicate() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,19 @@ public boolean isTrue(Geometry g) {
});
}

public static Geometry containsPrep(Geometry a, final Geometry mask)
{
RelateNG relateNG = RelateNG.prepare(mask);
Envelope maskEnv = mask.getEnvelopeInternal();
return SelectionFunctions.select(a, new GeometryPredicate() {
public boolean isTrue(Geometry g) {
if (maskEnv.disjoint(g.getEnvelopeInternal()))
return false;
return relateNG.evaluate(g, RelatePredicate.contains());
}
});
}

public static Geometry covers(Geometry a, final Geometry mask)
{
return SelectionFunctions.select(a, new GeometryPredicate() {
Expand Down

0 comments on commit cb6a6b2

Please sign in to comment.