Skip to content

Commit

Permalink
Better parsing of latitude and longitude
Browse files Browse the repository at this point in the history
  • Loading branch information
rdmpage committed Nov 9, 2012
1 parent a239fa0 commit fea593a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions kml/latlong.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ function IsLatLong($str, &$latlong)
$str = str_replace("", "'", $str);

$str = trim($str, '(');
$str = trim($str, ')');
$str = rtrim($str, ')');

// 115.59E/37.64N
if (!$result)
Expand Down Expand Up @@ -397,7 +397,7 @@ function IsLatLong($str, &$latlong)

if (!$result)
{
if (preg_match('/(?<degreesLatitude>\d+)°(\s*(?<minutesLatitude>\d+(.\d+)?)\')?((?<secondsLatitude>\d+)\'\')?\s*(?<hemisphereLatitude>[S|N])(;|,|–|\/)?\s*(?<degreesLongitude>\d+)°(\s*(?<minutesLongitude>\d+(.\d+)?)\')?((?<secondsLongitude>\d+)\'\')?\s*(?<hemisphereLongitude>[W|E])/', $str, $matches))
if (preg_match('/(?<degreesLatitude>\d+)°(\s*(?<minutesLatitude>\d+(.\d+)?)\')?((?<secondsLatitude>\d+(.\d+)?)(\'\'|"))?\s*(?<hemisphereLatitude>[S|N])(;|,|–|\/)?\s*(?<degreesLongitude>\d+)°(\s*(?<minutesLongitude>\d+(.\d+)?)\')?((?<secondsLongitude>\d+(.\d+)?)(\'\'|"))?\s*(?<hemisphereLongitude>[W|E])/', $str, $matches))
// if (preg_match('/(?<degreesLatitude>\d+)°((?<minutesLatitude>\d+(.\d+)?)\')((?<secondsLatitude>\d+)\'\')?(.*)/', $str, $matches))
{
$result = true;
Expand Down

0 comments on commit fea593a

Please sign in to comment.