in modules/editor/src/lib/exporter.ts [95:127]
function getPolygonalStats(geometry: Geometry) {
if (geometry.type !== 'Polygon' && geometry.type !== 'MultiPolygon') {
return {
pointCount: -1,
ringCount: -1,
polygonCount: -1,
};
}
const polygonal = geometry;
let pointCount = 0;
let ringCount = 0;
let polygonCount = 0;
for (const ringOrPolygon of polygonal.coordinates) {
if (geometry.type === 'Polygon') {
polygonCount = 1;
ringCount++;
pointCount += ringOrPolygon.length;
} else if (geometry.type === 'MultiPolygon') {
polygonCount++;
for (const ring of ringOrPolygon) {
ringCount++;
pointCount += ring.length;
}
}
}
return {
pointCount,
ringCount,
polygonCount,
};
}