Changeset 12104
- Timestamp:
- 10/09/08 10:55:36 (5 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/sfEasyGMapPlugin/trunk/lib/GMapGeocodedAddress.class.php
r12072 r12104 16 16 protected $geocoded_country = null; 17 17 protected $geocoded_address = null; 18 protected $geocoded_street = null; 19 protected $geocoded_postal_code = null; 18 20 19 21 /** … … 29 31 30 32 /** 31 * Geocodes the address using Google Maps CSV webservice33 * Geocodes the address using the Google Maps CSV webservice 32 34 * 33 35 * @param String $api_key … … 53 55 54 56 /** 55 * Geocodes the address using Google Mapx XML webservice, which has more information56 * 57 * Geocodes the address using the Google Maps XML webservice, which has more information. 58 * Unknown values will be set to NULL. 57 59 * @param String $api_key 58 60 * @return Integer $accuracy … … 75 77 76 78 $coordinates = $vals[$index['COORDINATES'][0]]['value']; 77 $coordArray = explode(',',$coordinates); 78 $this->lat = $coordArray[1]; 79 $this->lng = $coordArray[0]; 79 list($this->lng, $this->lat) = explode(',', $coordinates); 80 80 81 $this->accuracy = $vals[$index['ADDRESSDETAILS'][0]]['attributes']['ACCURACY']; 81 $this->geocoded_address = $vals[$index['ADDRESS'][0]]['value']; 82 $this->geocoded_country_code = $vals[$index['COUNTRYNAMECODE'][0]]['value']; 83 $this->geocoded_city = $vals[$index['LOCALITYNAME'][0]]['value']; 84 if ($this->geocoded_city == '') 82 83 // We voluntarily silence errors, the values will still be set to NULL if the array indexes are not defined 84 @$this->geocoded_address = $vals[$index['ADDRESS'][0]]['value']; 85 @$this->geocoded_street = $vals[$index['THOROUGHFARENAME'][0]]['value']; 86 @$this->geocoded_postal_code = $vals[$index['POSTALCODENUMBER'][0]]['value']; 87 @$this->geocoded_country = $vals[$index['COUNTRYNAME'][0]]['value']; 88 @$this->geocoded_country_code = $vals[$index['COUNTRYNAMECODE'][0]]['value']; 89 90 @$this->geocoded_city = $vals[$index['LOCALITYNAME'][0]]['value']; 91 if (empty($this->geocoded_city)) 85 92 { 86 $this->geocoded_city = $vals[$index['SUBADMINISTRATIVEAREANAME'][0]]['value'];93 @$this->geocoded_city = $vals[$index['SUBADMINISTRATIVEAREANAME'][0]]['value']; 87 94 } 88 if ( $this->geocoded_city == '')95 if (empty($this->geocoded_city)) 89 96 { 90 $this->geocoded_city = $vals[$index['ADMINISTRATIVEAREANAME'][0]]['value'];97 @$this->geocoded_city = $vals[$index['ADMINISTRATIVEAREANAME'][0]]['value']; 91 98 } 92 99 … … 96 103 97 104 /** 98 * Returns Latitude105 * Returns the latitude 99 106 * @return Decimal $latitude 100 107 */ … … 104 111 return $this->lat; 105 112 } 113 106 114 /** 107 * Returns longitude115 * Returns the longitude 108 116 * @return Decimal $longitude 109 117 */ … … 113 121 return $this->lng; 114 122 } 123 115 124 /** 116 * Returns Geocoding accuracy125 * Returns the Geocoding accuracy 117 126 * @return Integer $accuracy 118 127 */ … … 122 131 return $this->accuracy; 123 132 } 133 124 134 /** 125 * Returns address as normalized by the Google Maps web service135 * Returns the address normalized by the Google Maps web service 126 136 * @return String $geocoded_address 127 137 */ … … 131 141 return $this->geocoded_address; 132 142 } 143 133 144 /** 134 * Returns city asnormalized by the Google Maps web service145 * Returns the city normalized by the Google Maps web service 135 146 * @return String $geocoded_city 136 147 */ … … 140 151 return $this->geocoded_city; 141 152 } 153 142 154 /** 143 * Returns country code asnormalized by the Google Maps web service155 * Returns the country code normalized by the Google Maps web service 144 156 * @return String $geocoded_country_code 145 157 */ … … 150 162 } 151 163 164 /** 165 * Returns the country normalized by the Google Maps web service 166 * @return String $geocoded_country 167 */ 168 public function getGeocodedCountry() 169 { 170 171 return $this->geocoded_country; 172 } 173 174 /** 175 * Returns the postal code normalized by the Google Maps web service 176 * @return String $geocoded_postal_code 177 */ 178 public function getGeocodedPostalCode() 179 { 180 181 return $this->geocoded_postal_code; 182 } 183 184 /** 185 * Returns the street name normalized by the Google Maps web service 186 * @return String $geocoded_country_code 187 */ 188 public function getGeocodedStreet() 189 { 190 191 return $this->geocoded_street; 192 } 193 152 194 }