(feature)
| 118 | } |
| 119 | |
| 120 | function getCentroid(feature) { |
| 121 | const { type } = feature.geometry; |
| 122 | const projection = geoIdentity(); |
| 123 | const geoPathGenerator = geoPath(projection); |
| 124 | |
| 125 | if (type === 'MultiPolygon') { |
| 126 | let maxArea = -Infinity; |
| 127 | |
| 128 | for (const coordinates of feature.geometry.coordinates) { |
| 129 | const polygon = { type: 'Polygon', coordinates }; |
| 130 | const area = geoPathGenerator.area(polygon); |
| 131 | if (area > maxArea) { |
| 132 | maxArea = area; |
| 133 | feature = polygon; |
| 134 | } |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | return geoPathGenerator.centroid(feature).map((coord) => +coord.toFixed(2)); |
| 139 | } |
| 140 | |
| 141 | async function createCountriesLayer({ bounds, filter, name, resolution, source }) { |
| 142 | const inputFilePath = `${outputDirGeojson}/${unFilename}_${resolution}m/${source}.geojson`; |
no outgoing calls
no test coverage detected
searching dependent graphs…