isDoCoMo()) { $this->agent = new Mobile_GPS_DOCOMO($userAgent); } else if ($userAgent->isEZweb()) { $this->agent = new Mobile_GPS_AU($userAgent); } else if ($userAgent->isSoftBank()) { $this->agent = new Mobile_GPS_SOFTBANK($userAgent); } else { $this->agent = new Mobile_GPS_Common($userAgent); } } /** * @access private * @return Mobile_GPS */ function getInstatnce() { static $instanse; if (!$instanse) { $instanse = new Mobile_GPS(); } return $instanse; } /** * インスタンス取得 * * @return Mobile_GPS_Common */ function factory() { $ins =& Mobile_GPS::getInstatnce(); return $ins->agent; } } class Mobile_GPS_Common { /** * @access protected */ var $lat; /** * @access protected */ var $lon; /** * @var Net_UserAgent_Mobile_Common */ var $userAgent; var $address; function Mobile_GPS_COMMON(&$userAgent) { $this->userAgent = $userAgent; } function createFormTag($action, $method="post", $attr=null) { $format="
"; return sprintf($format, $method, $action, $this->_creationAttr($attr)); } function createLinkTag($url, $label, $attr=null) { $format="%s"; return sprintf($format, $url, $this->_creationAttr($attr), $label); } function load() {} /** * 緯度を取得 * @return String */ function getLat() { return $this->lat; } /** * 経度を取得 * @return String */ function getLon() { return $this->lon; } /** * @param mixed $attr * @return String */ function _creationAttr($attr) { if ($attr == null) { return ""; } if (!is_array($attr)) { return $attr; } $ret=""; foreach ($attr as $k => $v) { $ret .= $k."=\"".$v."\" "; } return $ret; } function dms2Num($dms) { //var_dump($dms); $d = explode(".",$dms); //var_dump($d); $num = $d[0] + ((($d[1]*60+$d[2]+$d[3]/10) * 1000) / 3600000); return $num; } } class Mobile_GPS_DOCOMO extends Mobile_GPS_Common { var $geo; var $x_acc; function createFormTag($action, $method="post", $attr=null) { $format=""; return sprintf($format, $method, $action, $this->_creationAttr($attr)); } function createLinkTag($url, $label, $attr=null) { $format="%s"; return sprintf($format, $url, $this->_creationAttr($attr), $label); } function load() { $this->lat = $this->dms2Num(htmlspecialchars($_GET['lat'])); $this->lon = $this->dms2Num(htmlspecialchars($_GET['lon'])); $this->geo = htmlspecialchars($_GET['geo']); $this->x_acc = htmlspecialchars($_GET['x-acc']); } } class Mobile_GPS_AU extends Mobile_GPS_Common { var $var; var $datum; var $unit; var $alt; var $time; var $smaj; var $smin; var $vert; var $majaa; var $fm; function createFormTag($action, $method="post", $attr=null) { $format = ""; $format .= ""; $format .= ""; $format .= ""; $format .= ""; $format .= ""; $format .= ""; return sprintf($format, $action); } function createLinkTag($url, $label, $attr=null) { $format = "%s"; return sprintf($format, $url, $this->_creationAttr($attr), $label); } function load() { $this->lat = trim(htmlspecialchars($_GET['lat']), "+-"); $this->lon = trim(htmlspecialchars($_GET['lon']), "+-"); $this->var = htmlspecialchars($_GET['var']); $this->datum = htmlspecialchars($_GET['datum']); $this->unit = htmlspecialchars($_GET['unit']); $this->alt = htmlspecialchars($_GET['alt']); $this->time = htmlspecialchars($_GET['time']); $this->smaj = htmlspecialchars($_GET['smaj']); $this->smin = htmlspecialchars($_GET['smin']); $this->vert = htmlspecialchars($_GET['vert']); $this->majaa = htmlspecialchars($_GET['majaa']); $this->fm = htmlspecialchars($_GET['fm']); } } class Mobile_GPS_SOFTBANK extends Mobile_GPS_Common { var $geo; var $x_acr; function createFormTag($action, $method="post", $attr=null) { if ($this->userAgent->isType3GC()) { $format=""; } else { $format=""; } return sprintf($format, $method, $action, $this->_creationAttr($attr)); } function createLinkTag($url, $label, $attr=null) { if ($this->userAgent->isType3GC()) { $format="%s"; } else { $format="%s"; } return sprintf($format, $url, $this->_creationAttr($attr), $label); } function load() { if ($this->userAgent->isType3GC()) { $pos = htmlspecialchars($_GET['pos']); ereg("[N|S]([^a-zA-Z]*)[E|W]([^a-zA-Z]*)$",$pos, $p); //var_dump($p); $this->lat = $this->dms2Num($p[1]); $this->lon = $this->dms2Num($p[2]); $this->geo = htmlspecialchars($_GET['geo']); $this->x_acr = htmlspecialchars($_GET['x-acr']); } else { $x_jphone_geocode = $_SERVER['HTTP_X_JPHONE_GEOCODE']; $geos = split("%1A", $x_jphone_geocode); if (strlen($geos[0]) > 6) { $this->lat = substr($geos[0], 0, 3).".".substr($geos[0], 3, 2).".".substr($geos[0], 5, 2); } else { $this->lat = substr($geos[0], 0, 2).".".substr($geos[0], 2, 2).".".substr($geos[0], 4, 2); } $string = urldecode($geos[2]); $this->address = mb_convert_encoding($string, "UTF-8", "SJIS"); } } } ?>