- Timestamp:
- Aug 31, 2015, 11:02:06 PM (11 years ago)
- Branches:
- master
- Children:
- 69c8290
- Parents:
- a0f5395
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/webservice/htdocs/SiWeather/Webservice/Location.php
ra0f5395 rb5ebb8d 29 29 class Location 30 30 { 31 public function __construct($city, $ zipCode = "",31 public function __construct($city, $postalCode = "", 32 32 $regionName = "", $regionCode = "", 33 33 $countryName = "", $countryCode = "", … … 36 36 37 37 $this->_city = ""; 38 $this->_ zipCode = "";38 $this->_postalCode = ""; 39 39 $this->_regionName = ""; 40 40 $this->_regionCode = ""; … … 47 47 48 48 $this->setCity($city); 49 $this->set ZipCode($zipCode);49 $this->setPostalCode($postalCode); 50 50 $this->setRegion($regionName, $regionCode); 51 51 $this->setCountry($countryName, $countryCode); … … 62 62 } 63 63 64 public function set ZipCode($code){65 $this->_ zipCode = $code;64 public function setPostalCode($code){ 65 $this->_postalCode = $code; 66 66 } 67 67 68 public function zipCode(){69 return $this->_ zipCode;68 public function postalCode(){ 69 return $this->_postalCode; 70 70 } 71 71 … … 110 110 */ 111 111 public function setLocation($latitude, $longitude){ 112 if( is_numeric($latitude) && ($latitude > -90.0 && $latitude < 90.0))112 if(self::validLatitude($latitude)) 113 113 $this->_latitude = $latitude; 114 if( is_numeric($longitude) && ($longitude > -180.0 && $longitude < 180.0))114 if(self::validLongitude($longitude)) 115 115 $this->_longitude = $longitude; 116 116 } … … 127 127 return $this->longitude() ." ". $this->latitude(); 128 128 } 129 129 130 public static function validLatitude($latitude){ 131 if(is_numeric($latitude) && (-90.0 <= $latitude && $latitude <= 90.0)) 132 return true; 133 return false; 134 } 135 136 public static function validLongitude($longitude){ 137 if(is_numeric($longitude) && (-180.0 <= $longitude && $longitude <= 180.0)) 138 return true; 139 return false; 140 } 141 130 142 public function setTimeZone($zone){ 131 143 if(preg_match("/^[\D]+\/[\D]+$/", $zone) > 0) … … 142 154 private $_regionName; 143 155 private $_city; 144 private $_ zipCode;156 private $_postalCode; 145 157 private $_timeZone; 146 158 private $_latitude;
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/siweather/chrome/site/your_project_logo.png)