Open YannNeobards opened 2 years ago
Nice, that works for me although I had to rewrite it a little:
const MultiPolygon2PolygonOnly = (
geoJ: GeoJSON.FeatureCollection
): GeoJSON.FeatureCollection => {
const polyOnly: GeoJSON.FeatureCollection = {
type: "FeatureCollection",
features: [],
};
geoJ.features.forEach((f: GeoJSON.Feature) => {
const g = f.geometry;
if (!g || !g.type) return;
if (g.type == "Polygon") return polyOnly.features.push(f);
if (g.type != "MultiPolygon") return;
for (let i = 0, m = g.coordinates.length; i < m; i++) {
polyOnly.features.push({
...f,
geometry: { ...g, type: "Polygon", coordinates: g.coordinates[i] },
});
}
});
return polyOnly;
};
Hi, shapes() function doesn't display
MultiPolygon
using npm leaflet.glify 3.2.0for the moment i solve it by converting in
Polygon
only the geojson beforesample of geojson that contains
Polygon
andMultiPolygon
https://raw.githubusercontent.com/gregoiredavid/france-geojson/master/departements-version-simplifiee.geojson