/** * Reverse geocoding sample * * @param sfWebRequest $request * @author Vincent Guillon <*****@*****.**> * @since 2009-10-30 17:30:11 */ public function executeSample9() { // Initialize the google map $this->gMap = new GMap(); $this->gMap->setWidth(512); $this->gMap->setHeight(400); $this->gMap->setZoom(16); $this->gMap->setCenter(48.857939, 2.346611); // Marker $marker = new GMapMarker($this->gMap->getCenterLat(), $this->gMap->getCenterLng()); $this->gMap->addMarker($marker); // Reverse geocoding of the center of the map $geocoded_addr = new GMapGeocodedAddress(null); $geocoded_addr->setLat($this->gMap->getCenterLat()); $geocoded_addr->setLng($this->gMap->getCenterLng()); $geocoded_addr->reverseGeocode($this->gMap->getGMapClient()); $this->setTemplate('sample1'); // END OF ACTION $this->message = 'Reverse geocoding sample'; $this->action_source = $this->functionToString('executeSample9'); // Construct console message $values = array('Reverse geocoding of coordinates \\"' . $this->gMap->getCenterLat() . ', ' . $this->gMap->getCenterLng() . '\\" : ', '<i>raw_address : </i>' . $geocoded_addr->getRawAddress(), '<i>accuracy : </i>' . $geocoded_addr->getAccuracy(), '<i>geocoded_city : </i>' . $geocoded_addr->getGeocodedCity(), '<i>geocoded_country_code : </i>' . $geocoded_addr->getGeocodedCountryCode(), '<i>geocoded_country : </i>' . $geocoded_addr->getGeocodedCountry(), '<i>geocoded_address : </i>' . $geocoded_addr->getGeocodedAddress(), '<i>geocoded_street : </i>' . $geocoded_addr->getGeocodedStreet(), '<i>geocoded_postal_code : </i>' . $geocoded_addr->getGeocodedPostalCode()); foreach ($values as $value) { $this->gMap->addAfterInitJs('gmapSample_AddConsoleLine("' . $value . '");'); } }
/** * Teste la sauvegarde d'équipes dans le backend * @author fabriceb * @since Feb 16, 2009 fabriceb */ include dirname(__FILE__) . '/../bootstrap/unit.php'; $t = new lime_test(15, new lime_output_color()); $t->diag('GMapGeocodedAddress Tests'); $gAddress = new GMapGeocodedAddress('60 rue de Seine, Paris'); $t->diag('->getRawAddress'); $t->is($gAddress->getRawAddress(), '60 rue de Seine, Paris', '->getRawAddress ok'); require_once dirname(__FILE__) . '/../../lib/GMapClientTestCache.class.php'; $gMapClient = new GMapClient('test'); $gMapClientTestCache = new GMapClientTestCache(); $gMapClient->setCache($gMapClientTestCache); $t->diag('->geocode'); $t->is($gAddress->geocode($gMapClient), 8, 'Geocoded returned accuracy 8'); $t->is($gAddress->getLat(), 48.853795, 'Lat ok'); $t->is($gAddress->getLng(), 2.3369433, 'Lng ok'); $t->is($gAddress->getAccuracy(), 8, 'Accuracy ok'); $t->is($gAddress->geocodeXml($gMapClient), 8, 'Geocoded returned accuracy 8'); $t->is($gAddress->getLat(), 48.853795, 'Lat ok'); $t->is($gAddress->getLng(), 2.3369433, 'Lng ok'); $t->is($gAddress->getAccuracy(), 8, 'Accuracy ok'); $t->is($gAddress->getGeocodedAddress(), '60 Rue de Seine, 75006 Paris, France', 'Normalized address ok'); $t->is($gAddress->getGeocodedCity(), 'Paris', 'Normalized City ok'); $t->is($gAddress->getGeocodedCountry(), 'France', 'Normalized Country ok'); $t->is($gAddress->getGeocodedCountryCode(), 'FR', 'Normalized Country code ok'); $t->is($gAddress->getGeocodedPostalCode(), '75006', 'Normalized postal code ok'); $t->is($gAddress->getGeocodedStreet(), '60 Rue de Seine', 'Normalized street ok');