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)
centerArray*required has to contain two OR three elements,
First element is the longitudeNumber. Has to be >=-180 and <=180
Second element is the latitudeNumber. Has to be >=-90 and <=90
Third element is ignored but allowed to follow RFC 7946
Problem Description
There has been several issues where the user has passed the
longitude
andlatitude
in opposite order in the array passed as thecenter
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.where
latValue
andlngValue
are valid latitude and longitude values as stated earlier.circleToPolygon's Current Parameters (for reference)
center
Array *required has to contain two OR three elements,longitude
Number. Has to be>=-180
and<=180
latitude
Number. Has to be>=-90
and<=90
radius
Number *required has to be>0
.numberofSegments
Number has to be>=3
if passed to the function. Will default to32
.