2018-10-11 00:25:40 +03:00
|
|
|
package clip
|
|
|
|
|
2020-03-26 01:35:31 +03:00
|
|
|
import (
|
|
|
|
"github.com/tidwall/geojson"
|
|
|
|
"github.com/tidwall/geojson/geometry"
|
|
|
|
)
|
2018-10-11 00:25:40 +03:00
|
|
|
|
|
|
|
func clipCollection(
|
|
|
|
collection geojson.Collection, clipper geojson.Object,
|
2020-03-26 01:35:31 +03:00
|
|
|
opts *geometry.IndexOptions,
|
2018-10-11 00:25:40 +03:00
|
|
|
) geojson.Object {
|
|
|
|
var features []geojson.Object
|
|
|
|
for _, feature := range collection.Children() {
|
2020-03-26 01:35:31 +03:00
|
|
|
feature = Clip(feature, clipper, opts)
|
2018-10-11 00:25:40 +03:00
|
|
|
if feature.Empty() {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if _, ok := feature.(*geojson.Feature); !ok {
|
|
|
|
feature = geojson.NewFeature(feature, "")
|
|
|
|
}
|
|
|
|
features = append(features, feature)
|
|
|
|
}
|
|
|
|
return geojson.NewFeatureCollection(features)
|
|
|
|
}
|