]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Display lat/lon in DMS format
authorCraig Andrews <candrews@integralblue.com>
Fri, 20 Nov 2009 23:20:23 +0000 (18:20 -0500)
committerCraig Andrews <candrews@integralblue.com>
Fri, 20 Nov 2009 23:20:23 +0000 (18:20 -0500)
lib/noticelist.php

index 167ba994bc4cf92daaa360094f7ac35e58a48f69..43aa2ca1bdc583b813cc787de70f4c6db500cc06 100644 (file)
@@ -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
      *