_city = ""; $this->_zipCode = ""; $this->_regionName = ""; $this->_regionCode = ""; $this->_countryName = ""; $this->_countryCode = ""; $this->_longitude = 0; $this->_latitude = 0; $this->_timeZone = ""; $this->setCity($city); $this->setZipCode($zipCode); $this->setRegion($regionName, $regionCode); $this->setCountry($countryName, $countryCode); $this->setLocation($longitude, $latitude); $this->setTimezone($timeZone); } public function setCity($name){ $this->_city = $name; } public function city(){ return $this->_city; } public function setZipCode($code){ $this->_zipCode = $code; } public function zipCode(){ return $this->_zipCode; } 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(is_numeric($latitude) && ($latitude > -90.0 && $latitude < 90.0)) $this->_latitude = $latitude; if(is_numeric($longitude) && ($longitude > -180.0 && $longitude < 180.0)) $this->_longitude = $longitude; } public function latitude(){ return $this->_latitude; } public function longitude(){ return $this->_longitude; } public function locationWkt(){ return $this->longitude() ." ". $this->latitude(); } 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 $_zipCode; private $_timeZone; private $_latitude; private $_longitude; } ?>