ConservationMetrics / guardianconnector-views

A Nuxt.js tool that reads data from a SQL database and renders it on different views (map, gallery, alerts dashboard)
MIT License
3 stars 0 forks source link

Handle geographic centroid calculation for MultiPolygon geometries #33

Closed rudokemper closed 5 months ago

rudokemper commented 5 months ago

This PR resolves a minor bug where the geographic centroid for MultiPolygon features was shown in the dashboard as "NaN, NaN" because the calculateCentroid() function was only set up to handle single Polygon GeoJSON features.

Now, the function (which has been moved to take place server-side, and converted to TypeScript) checks if the incoming coordinates are MultiPolygon (3 dimensional array) versus Polygon (array of array) and applies additional flattening for the former.