_city = ""; $this->_postalCode = ""; $this->_regionName = ""; $this->_regionCode = ""; $this->_countryName = ""; $this->_countryCode = ""; $this->_longitude = 0; $this->_latitude = 0; $this->_timeZone = ""; $this->setCity($city); $this->setPostalCode($postalCode); $this->setRegion($regionName, $regionCode); $this->setCountry($countryName, $countryCode); $this->setLocation($latitude, $longitude); $this->setTimezone($timeZone); } public function setCity($name){ $this->_city = $name; } public function city(){ return $this->_city; } public function setPostalCode($code){ $this->_postalCode = $code; } public function postalCode(){ return $this->_postalCode; } public function setRegion($name, $code){ $this->_regionName = $name; if(strlen($code) == 2) $this->_regionCode = $code; } public function regionName(){ return $this->_regionName; } public function regionCode(){ return $this->_regionCode; } public function setCountry($name, $code){ $this->_countryName = $name; if(strlen($code) == 2) $this->_countryCode = $code; } public function countryName(){ return $this->_countryName; } public function countryCode(){ return $this->_countryCode; } /** * @brief Sets the location to @p $latitude and @p $longitude * * @note Please note that this functions arguments are in the typical order of * city coordinates, whereas the WKT format turned around those values * (WKT(Longitude Latitude)). * * @see latitude() * @see longitude() * @see locationWkt() */ public function setLocation($latitude, $longitude){ if(self::validLatitude($latitude)) $this->_latitude = $latitude; if(self::validLongitude($longitude)) $this->_longitude = $longitude; } public function latitude(){ return $this->_latitude; } public function longitude(){ return $this->_longitude; } public function locationWkt(){ return $this->longitude() ." ". $this->latitude(); } public static function validLatitude($latitude){ if(is_numeric($latitude) && (-90.0 <= $latitude && $latitude <= 90.0)) return true; return false; } public static function validLongitude($longitude){ if(is_numeric($longitude) && (-180.0 <= $longitude && $longitude <= 180.0)) return true; return false; } public function setTimeZone($zone){ if(preg_match("/^[\D]+\/[\D]+$/", $zone) > 0) $this->_timeZone = $zone; } public function timeZone(){ return $this->_timeZone; } private $_countryCode; private $_countryName; private $_regionCode; private $_regionName; private $_city; private $_postalCode; private $_timeZone; private $_latitude; private $_longitude; } ?>