Lat/Lon should be supported in DMS. This code snippet does a decent job of recognizing DMS as long as they include positive and negative values, not directional references:
if (!is_numeric($val)) {
$val = preg_replace ('/[^\d\s\-]/', '', $val);
$dms = explode(' ', $val);
$val = (abs($dms[0]) + ($dms[1]/60) + ($dms[2]/3600)) * (($d[0] < 0)?-1:1);
}
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | location_feeds.patch | 616 bytes | bregtemundo |
Comments
Comment #1
pdrake commentedSorry, old (broken) code above. That should have been:
Comment #2
elliotttf commentedI wonder if it would make more sense to just add an additional target for DMS values rather than trying to figure out if a value is DMS or not. What do you think?
Comment #3
pdrake commentedThat definitely makes sense from a technical user's perspective. However, there may be non-technical users who do not know whether they should be importing using Lat/Lon Dec or Lat/Lon DMS without further explanation. If we could somehow include an example of the format in the mapper selection (eg. Lat/Lon ##.##### or Lat/Lon ## ## ##), that might work. Ideally, DMS should support the use of letters (eg. N and W) as well as negative numbers.
Comment #4
elliotttf commentedCommitted your patch for numeric dms values. Feel free to write a patch for the letters and assuming it works I'll drop it in. Thanks!
Comment #6
bregtemundo commentedI was using this module to import an xml with locations.
The lat/long contained decimal numbers like:
50° 48' 26.8236" N
5° 25' 51.5028" E
The dot was filtered out though , so i created a patch for it