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);
}
CommentFileSizeAuthor
#6 location_feeds.patch616 bytesbregtemundo

Comments

pdrake’s picture

Sorry, old (broken) code above. That should have been:

if (!is_numeric($val)) {
  $v = preg_replace ('/[^\d\s]/', '', $val);
  $dms = explode(' ', $val);
  $v = (abs($dms[0]) + ($dms[1]/60) + ($dms[2]/3600)) * ((strpos($val,'-') === 0)?-1:1);
}
elliotttf’s picture

I 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?

pdrake’s picture

That 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.

elliotttf’s picture

Status: Active » Fixed

Committed 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!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

bregtemundo’s picture

Version: 6.x-1.x-dev » 6.x-1.3
StatusFileSize
new616 bytes

I 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