Skip to content

Commit

Permalink
Add more Selection functions
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-jts committed May 27, 2024
1 parent e6b4599 commit 4845375
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@ public boolean isTrue(Geometry g) {
});
}

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

public static Geometry disjoint(Geometry a, Geometry mask)
{
List selected = new ArrayList();
Expand All @@ -81,6 +90,16 @@ public static Geometry disjoint(Geometry a, Geometry mask)
}
return a.getFactory().buildGeometry(selected);
}

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

public static Geometry valid(Geometry a)
{
List selected = new ArrayList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,28 @@ public boolean isTrue(Geometry g) {
});
}

public static Geometry touches(Geometry a, final Geometry mask)
{
return SelectionFunctions.select(a, new GeometryPredicate() {
public boolean isTrue(Geometry g) {
return RelateNG.relate(mask, g, RelatePredicate.touches());
}
});
}

public static Geometry touchesPrep(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.touches());
}
});
}

public static Geometry adjacent(Geometry a, final Geometry mask)
{
return SelectionFunctions.select(a, new GeometryPredicate() {
Expand All @@ -91,6 +113,26 @@ public boolean isTrue(Geometry g) {
}
});
}

public static Geometry relatePattern(Geometry a, final Geometry mask, String pattern)
{
return SelectionFunctions.select(a, new GeometryPredicate() {
public boolean isTrue(Geometry g) {
return RelateNG.relate(mask, g, RelatePredicate.matches(pattern));
}
});
}

public static Geometry relatePatternPrep(Geometry a, final Geometry mask, String pattern)
{
RelateNG relateNG = RelateNG.prepare(mask);
return SelectionFunctions.select(a, new GeometryPredicate() {
public boolean isTrue(Geometry g) {
return relateNG.evaluate(g, RelatePredicate.matches(pattern));
}
});
}

}


0 comments on commit 4845375

Please sign in to comment.