r51693 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r51692‎ | r51693 | r51694 >
Date:13:31, 10 June 2009
Author:yaron
Status:deferred
Tags:
Comment:
Added Eugene Mednikov's handling of additional coordinate characters; some formatting improvements
Modified paths:
  • /trunk/extensions/SemanticGoogleMaps/SGM_Utils.inc (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticGoogleMaps/SGM_Utils.inc
@@ -21,6 +21,9 @@
2222 if (!$wgGoogleMapsOnThisPage) {$wgGoogleMapsOnThisPage = 0;}
2323 $wgGoogleMapsOnThisPage++;
2424
 25+ $coordinates = str_replace('″', '"', $coordinates);
 26+ $coordinates = str_replace('′', "'", $coordinates);
 27+
2528 list($lat, $lon) = SGMUtils::getLatLon($coordinates);
2629
2730 $output =<<<END
@@ -44,20 +47,20 @@
4548 return array(null, null);
4649 }
4750
48 - function degree2Decimal($deg_coord="") {
49 - $dpos=strpos($deg_coord,'°');
50 - $mpos=strpos($deg_coord,'.');
51 - $spos=strpos($deg_coord,'"');
52 - $mlen=(($mpos-$dpos)-1);
53 - $slen=(($spos-$mpos)-1);
54 - $direction=substr(strrev($deg_coord),0,1);
55 - $degrees=substr($deg_coord,0,$dpos);
56 - $minutes=substr($deg_coord,$dpos+1,$mlen);
57 - $seconds=substr($deg_coord,$mpos+1,$slen);
58 - $seconds=($seconds/60);
59 - $minutes=($minutes+$seconds);
60 - $minutes=($minutes/60);
61 - $decimal=($degrees+$minutes);
 51+ function degree2Decimal($deg_coord = "") {
 52+ $dpos = mb_strpos($deg_coord, '°');
 53+ $mpos = mb_strpos($deg_coord, '.');
 54+ $spos = mb_strpos($deg_coord, '"');
 55+ $mlen = ($mpos - $dpos) - 1;
 56+ $slen = ($spos - $mpos) - 1;
 57+ $direction = substr(strrev($deg_coord), 0, 1);
 58+ $degrees = mb_substr($deg_coord, 0,$dpos);
 59+ $minutes = mb_substr($deg_coord, $dpos + 1, $mlen);
 60+ $seconds = mb_substr($deg_coord, $mpos + 1, $slen);
 61+ $seconds = $seconds / 60;
 62+ $minutes = $minutes + $seconds;
 63+ $minutes = $minutes / 60;
 64+ $decimal = $degrees + $minutes;
6265 //South latitudes and West longitudes need to return a negative result
6366 if (($direction=="S") or ($direction=="W")) {
6467 $decimal *= -1;

Status & tagging log