-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add outers/inners filter + slight adjustment to vertices filter
- Loading branch information
Showing
7 changed files
with
153 additions
and
6 deletions.
There are no files selected for viewing
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
31 changes: 31 additions & 0 deletions
31
oshdb-filter/src/main/java/org/heigit/ohsome/oshdb/filter/GeometryFilterInnerRings.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,31 @@ | ||
package org.heigit.ohsome.oshdb.filter; | ||
|
||
import javax.annotation.Nonnull; | ||
import org.locationtech.jts.geom.MultiPolygon; | ||
import org.locationtech.jts.geom.Polygon; | ||
|
||
/** | ||
* A filter which checks the number of inner rings of a multipolygon relation. | ||
*/ | ||
public class GeometryFilterInnerRings extends GeometryFilter { | ||
/** | ||
* Creates a new inner rings filter object. | ||
* | ||
* @param range the allowed range (inclusive) of values to pass the filter | ||
*/ | ||
public GeometryFilterInnerRings(@Nonnull ValueRange range) { | ||
super(range, GeometryMetricEvaluator.fromLambda(geometry -> { | ||
if (geometry instanceof Polygon) { | ||
return ((Polygon) geometry).getNumInteriorRing(); | ||
} else if (geometry instanceof MultiPolygon) { | ||
var counter = 0; | ||
for (var i = 0; i < geometry.getNumGeometries(); i++) { | ||
counter += ((Polygon) geometry.getGeometryN(i)).getNumInteriorRing(); | ||
} | ||
return counter; | ||
} else { | ||
return -1; | ||
} | ||
}, "outers")); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
oshdb-filter/src/main/java/org/heigit/ohsome/oshdb/filter/GeometryFilterOuterRings.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,20 @@ | ||
package org.heigit.ohsome.oshdb.filter; | ||
|
||
import javax.annotation.Nonnull; | ||
import org.locationtech.jts.geom.Polygonal; | ||
|
||
/** | ||
* A filter which checks the number of outer rings of a multipolygon relation. | ||
*/ | ||
public class GeometryFilterOuterRings extends GeometryFilter { | ||
/** | ||
* Creates a new outer rings filter object. | ||
* | ||
* @param range the allowed range (inclusive) of values to pass the filter | ||
*/ | ||
public GeometryFilterOuterRings(@Nonnull ValueRange range) { | ||
super(range, GeometryMetricEvaluator.fromLambda(geometry -> | ||
geometry instanceof Polygonal ? geometry.getNumGeometries() : -1, | ||
"outers")); | ||
} | ||
} |
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
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