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

This package is giving invalid geocodes as polygon coordintaes, when calling with some edge geocode #6

Closed
sanjaykumarns opened this issue Oct 12, 2018 · 2 comments

Comments

@sanjaykumarns
Copy link

sanjaykumarns commented Oct 12, 2018

If we call this package with the below values, it's is giving some point which cannot be plotted in the google map.

var circleToPolygon = require("circle-to-polygon")
const coordinates = [ -179.9745, -22.3023]; //[lon, lat]
const radius = 50000;                           // in meters
const numberOfEdges = 500;                     //optional that defaults to 32

let polygon = circleToPolygon(coordinates, radius, numberOfEdges);

In the result, there are some point like:

[-180.02911542185794, -21.856002776317947] (long lat format) which cannot be plotted in the google map.

@johachi
Copy link
Collaborator

johachi commented Nov 24, 2019

I have started to do a lot of plotting of data on maps and have been reading up on this.

Any longitude value less than -180 or bigger than 180 is obviously an invalid longitude value. However, the current geoJSON specification has a problem. This problem is easiest to explain with a LineString, and then expanded to include polygons.

Let's say that you have 2 lines

  • Line X goes from [179, 90] to [-179, 90]
  • Line X goes east and do cross the International Date Time Line
  • Line Y goes from [179, 90] to [-179, 90]
  • Line Y goes west and do not cross the International Date Time Line

How do you tell these two lines apart? Please remember that direction is important. Line [[179, 90], [-179, 90] ] is not the same line as [[-179, 90], [179, 90]].

One popular solution is to break the rule, and write line X as [[179, 90], [181, 90]]. However, the recommended solution is to break the lines into a MultiLine and have it as [[[179, 90], [180, 90]], [[-180, 90], [-179, 90]]].
The same problem occur for polygons and are solved in the same way.

This software seem to be using the first approach to this problem. I don't know if that is intended behavior from @gabzim or not.

@johachi
Copy link
Collaborator

johachi commented Feb 2, 2020

I will close this issue since it is a duplicate of #4 . I have also added #4 to the TODO list hand hope to have it solved for the next version release.

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

No branches or pull requests

2 participants