Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What kind of file format does polylabel accept? #43

Closed
gabimoncha opened this issue Aug 20, 2018 · 5 comments
Closed

What kind of file format does polylabel accept? #43

gabimoncha opened this issue Aug 20, 2018 · 5 comments

Comments

@gabimoncha
Copy link

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?

@mourner
Copy link
Member

mourner commented Aug 20, 2018

GeoJSON polygon format is an array of rings, where each ring is an array of [x, y] pairs.

@mourner mourner closed this as completed Aug 20, 2018
@msageryd
Copy link

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]]

@mourner
Copy link
Member

mourner commented Aug 20, 2018

@msageryd one level deeper, because polygon has multiple rings (an outer ring and holes).

@msageryd
Copy link

@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)

@gabimoncha
Copy link
Author

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]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants