Skip to content

Commit 02d5c3c

Browse files
committed
Handle topology exception when splitting a Layer by another Layer
1 parent 0c6d508 commit 02d5c3c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/main/groovy/geoscript/layer/Layer.groovy

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import org.geotools.feature.FeatureCollection
2626
import org.geotools.feature.FeatureIterator
2727
import org.geotools.map.FeatureLayer
2828
import org.geotools.process.vector.VectorToRasterProcess
29+
import org.locationtech.jts.geom.TopologyException
2930
import org.opengis.filter.sort.SortOrder
3031
import org.opengis.feature.simple.SimpleFeatureType
3132
import org.opengis.feature.simple.SimpleFeature
@@ -1368,7 +1369,12 @@ class Layer implements Renderable {
13681369
// Make sure it actually intersects the Geometry of a Feature in the spatial index
13691370
if (f.geom.intersects(layerFeature.geom)) {
13701371
// Clip the geometry from the input Layer
1371-
Geometry intersection = layerFeature.geom.intersection(f.geom)
1372+
Geometry intersection = null
1373+
try {
1374+
intersection = layerFeature.geom.intersection(f.geom)
1375+
} catch(TopologyException ex) {
1376+
intersection = layerFeature.geom.buffer(0).intersection(f.geom.buffer(0))
1377+
}
13721378
// Create a new Feature and add if to the clipped Layer
13731379
Map values = layerFeature.attributes
13741380
values[outLayer.schema.geom.name] = intersection

0 commit comments

Comments
 (0)