demarches-normaliennes/app/javascript/old_design/carto/polygon_area.js

20 lines
393 B
JavaScript
Raw Normal View History

2018-10-13 10:55:40 +02:00
import area from '@turf/area';
export default function polygonArea(latLngs) {
return area({
type: 'FeatureCollection',
features: latLngs.map(featurePolygonLatLngs)
});
}
function featurePolygonLatLngs(latLngs) {
return {
type: 'Feature',
properties: {},
geometry: {
type: 'Polygon',
coordinates: [latLngs.map(({ lng, lat }) => [lng, lat])]
}
};
}