Created
September 15, 2010 10:50
-
-
Save wtnabe/580554 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -27,35 +27,41 @@ class Geomobilejp_Mobile | |
return (strlen($this->latitude) > 1 && strlen($this->longitude) > 1); | |
} | |
+ public function normalize( $params ) { | |
+ return array_combine( array_map( 'strtolower', array_keys( $params ) ), | |
+ array_values( $params ) ); | |
+ } | |
+ | |
protected function parse() | |
{ | |
$latitude = ''; | |
$longitude = ''; | |
$datum = ''; | |
- if (array_key_exists('lat', $_REQUEST) | |
- && array_key_exists('lon', $_REQUEST)) { | |
- $latitude = $_REQUEST['lat']; | |
- $longitude = $_REQUEST['lon']; | |
- } elseif (array_key_exists('pos', $_REQUEST)) { | |
+ $params = $this->normalize( $_REQUEST ); | |
+ if (array_key_exists('lat', $params) | |
+ && array_key_exists('lon', $params)) { | |
+ $latitude = $params['lat']; | |
+ $longitude = $params['lon']; | |
+ } elseif (array_key_exists('pos', $params)) { | |
preg_match( | |
'/^([NS]\d+\.\d+\.\d+\.\d+)([EW]\d+\.\d+\.\d+\.\d+)$/i', | |
- $_REQUEST['pos'], $matches); | |
+ $params['pos'], $matches); | |
if (count($matches) === 3) { | |
$latitude = $matches[1]; | |
$longitude = $matches[2]; | |
} | |
} | |
- if (array_key_exists('datum', $_REQUEST)) { | |
- $datum = $_REQUEST['datum']; | |
+ if (array_key_exists('datum', $params)) { | |
+ $datum = $params['datum']; | |
if ($datum == 0) { | |
$datum = 'wgs84'; | |
} elseif ($datum == 1) { | |
$datum = 'tokyo'; | |
} | |
- } elseif (array_key_exists('geo', $_REQUEST)) { | |
- $datum = $_REQUEST['geo']; | |
+ } elseif (array_key_exists('geo', $params)) { | |
+ $datum = $params['geo']; | |
} else { | |
$datum = 'tokyo'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment