gabzim / circle-to-polygon

Receives a Coordinate, a Radius and a Number of edges and aproximates a circle by creating a polygon that fills its area
ISC License
113 stars 29 forks source link

Allow center argument to be of type `object` or `array` #12

Closed johachi closed 4 years ago

johachi commented 4 years ago

Problem Description

There has been several issues where the user has passed the longitude and latitude in opposite order in the array passed as the center argument. This has been a cause that users has gotten "incorrect" circles.

The problem might already have been mitigated some since circleToPolygon since version 2.0.0 reject latitude values larger than ±90, but can still occur when a longitude smaller than ±90 is passed as the latitude value.

Proposed solution

The problem could be further mitigated by letting the user pass the coordinates as an object (in addition to passing it as an array).

Expand the function to allow the parameter center to be an Object of any of the following compositions.

center = { latitude: latValue, longitude: lngValue }

OR

center = { lat: latValue, lon: lngValue }

OR

center = { lat: latValue, lng: lngValue }

where latValue and lngValue are valid latitude and longitude values as stated earlier.

circleToPolygon's Current Parameters (for reference)