summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Andrews <candrews@integralblue.com>2009-11-20 18:20:23 -0500
committerCraig Andrews <candrews@integralblue.com>2009-11-20 18:20:23 -0500
commitf32fb65c6d11df9847a384a1d723111beebbc665 (patch)
tree074582b2d7001176711dd9a5dd73326937c41107
parent05a0f45de569d7a779da128ca45042ebc5fc3cb7 (diff)
Display lat/lon in DMS format
-rw-r--r--lib/noticelist.php17
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/noticelist.php b/lib/noticelist.php
index 167ba994b..43aa2ca1b 100644
--- a/lib/noticelist.php
+++ b/lib/noticelist.php
@@ -397,7 +397,7 @@ class NoticeListItem extends Widget
$latlon = (!empty($lat) && !empty($lon)) ? $lat.';'.$lon : '';
if (empty($name)) {
- $name = $lat . ' ' . $lon; //TODO tranform to N/S deg/min/sec format
+ $name = $this->decimalDegreesToDMS(abs($lat)) . ($lat>0?'N ':'S ') . $this->decimalDegreesToDMS(abs($lon)) . ($lon>0?'E':'W');
}
$url = $location->getUrl();
@@ -417,6 +417,21 @@ class NoticeListItem extends Widget
$this->out->elementEnd('span');
}
+ function decimalDegreesToDMS($dec)
+ {
+
+ $vars = explode(".",$dec);
+ $deg = $vars[0];
+ $tempma = "0.".$vars[1];
+
+ $tempma = $tempma * 3600;
+ $min = floor($tempma / 60);
+ $sec = $tempma - ($min*60);
+
+ return $deg . '°' . $min . "'" . $sec . "\"";
+ return array("deg"=>$deg,"min"=>$min,"sec"=>$sec);
+ }
+
/**
* Show the source of the notice
*