manuelbieh / geolib

Zero dependency library to provide some basic geo functions
MIT License
4.23k stars 342 forks source link

incorrect result from wktToPolygon #310

Open SamMaxwell opened 1 month ago

SamMaxwell commented 1 month ago

wktToPolygon( 'POLYGON(-83.094492 39.965258, -83.093337 39.963332, -83.095068 39.963332, -83.095977 39.965155, -83.094492 39.965258)' )

yields an incorrect initial point [ { longitude: 83.094492, latitude: 39.965258 }, { longitude: -83.093337, latitude: 39.963332 }, { longitude: -83.095068, latitude: 39.963332 }, { longitude: -83.095977, latitude: 39.965155 }, { longitude: -83.094492, latitude: 39.965258 } ]

(the longitude should be negative)

SamMaxwell commented 1 month ago

I use this function for that purpose (it isn't validating, it simply picks out the coordinates)

const getPoints = (polygon) =>
  polygon
    .match(/(-?\d+\.\d+)\s+(-?\d+\.\d+)/g)
    .map((pair) => pair.split(' ').map(Number));