tomasbedrich / pycaching

A Python 3 interface for working with Geocaching.com website.
https://pycaching.readthedocs.io/
GNU Lesser General Public License v3.0
61 stars 46 forks source link

Incorrect Point.from_string() parsing #237

Closed GeoTime61 closed 5 months ago

GeoTime61 commented 5 months ago

When parsing coordinates from various geocache web pages, the Point class does not correctly parse coordinate strings when the latitude and longitude are separated by <space><comma><space>. For example, the Geocache Description for GC6V1Y8 contains the string "N 44° 25.845 , W 72° 02.485" which Point parses as "N 72° 0.000, E 2° 29.100". This simple program shows the error.

from pycaching.geo import Point

print(Point("N 44° 25.845, W 72° 02.485"))
print(Point("N 44° 25.845 , W 72° 02.485"))

It might be as simple as changing geo.py line 69 from: m = re.match(r"\s*(-?\s*\d+)\D+(\d+[\.,]\d+)\D?\s*(-?\s*\d+)\D+(\d+[\.,]\d+)", coords)

to: m = re.match(r"\s*(-?\s*\d+)\D+(\d+[\.,]\d+)\D+(-?\s*\d+)\D+(\d+[\.,]\d+)", coords) (replace "\D?\s*" with "\D+"), but I don't know what all the supported input formats are to evaluate that change.