Closed ccallendar closed 2 years ago
Thanks Chris, yes the parser will throw that as an error. The assumption I built in is that decimal coordinates without decimal places are treated as incorrect (except two decimal places, which is then treated as degrees and minutes as these are often written as decimals, very confusing!). In your example, there is a very high level of precision on the latitude, which is not matched on the longitude. The likelihood of having a coordinate that is exactly -124.000000 is very small, and likely represents a transcription error or something like that. Same for something like 0,0 (see issue #2). So, the solution is either to use the parser to throw these kinds of values as errors that need to be checked and handle them accordingly, or if you're happy to accept coordinates like this as correct, put your own regex in place to catch them, either before they get to the parser, or in the catch statement after the parser. Something like /^-?\d+(\.\d{1,2})?[,;\s]+-?\d+(\.\d{1,2})?$/.test(coords)
should work (but I haven't tested it!).
Thanks for the reply! That sound reasonable, I'll give that regex a try. And thanks for your effort making this package!
Hi, I'm noticing the error
invalid coordinates format
when I try to parse a string like48.437316, -124
. Looking at the regular expressions I guess the above string doesn't match the DD regex because it has less than 3 decimal digits. Any suggestions?Thanks.