Closed gabimoncha closed 6 years ago
GeoJSON polygon format is an array of rings, where each ring is an array of [x, y]
pairs.
What do you mean by "file"? Are you using the original JavaScript library? In that case you should just feed the polylabel
function with an array of points where each point is an array.
example: [[1,1],[1,2],[2,2],[2,1]]
@msageryd one level deeper, because polygon has multiple rings (an outer ring and holes).
@mourner Yes, of course. Sorry for neglecting that.
Updated example for @gabrielmoncea: const p = polylabel([[[1,1],[1,2],[2,2],[2,1]]], 1.0)
(one ring)
Nice. I manage to discover how to get the point for each polygon in my geojson. Can we update the package to work with Geojsons?
We basically just need a loop over each feature getting the geometry.coordinates[0]
I tried with geojson and json. But it seems that content of the file must be specific. Can you please add in documentation what kind of file format does it accept and also, how should the content format be?