Skip to content

Commit 587b06a

Browse files
committed
handle invalide geometry in imported feature-collection
1 parent 1da47ee commit 587b06a

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

‎src/map-controls.tsx‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ function FileInput(props: any): ReactElement {
139139

140140
//add imported geojson & KML file to terradraw
141141
if (geojsonFeatures.type === "FeatureCollection" && Array.isArray(geojsonFeatures.features)) {
142+
const n_features_before = geojsonFeatures.features.length
143+
geojsonFeatures.features = geojsonFeatures.features.filter((feature) => feature.geometry !== null);
144+
console.log(`${geojsonFeatures.features.length} / ${n_features_before} features have valid geometry and will be added to TerraDraw.`);
142145

143146
//round coordinates to solve the 'coordinates too precise error' of terradraw
144147
var truncated = turf_truncate(geojsonFeatures, { precision: 6, coordinates: 2 });

0 commit comments

Comments
 (0)