function handler_map_url($page) { pl_content_headers('text/plain'); if (Post::has('text')) { $address = new Address(array('text' => Post::t('text'))); $gmapsGeocoder = new GMapsGeocoder(); $gmapsGeocoder->getGeocodedAddress($address); echo GMapsGeocoder::buildStaticMapURL($address->latitude, $address->longitude, Post::t('color')); } exit; }
function smarty_insert_getStaticMapURL(array $data) { return GMapsGeocoder::buildStaticMapURL($data['latitude'], $data['longitude'], $data['color'], '&'); }
$globals->debug = 0; // Do not store backtraces. $res = XDB::query('SELECT MIN(pid), MAX(pid) FROM profiles'); $pids = $res->fetchOneRow(); $minPid = $pids[0]; $maxPid = $pids[1]; echo "Filling the 'text' fied is over. Geocoding will start now and will take a few days.\n"; // Tries to geocode all the addresses. for ($pid = $minPid; $pid < $maxPid + 1; ++$pid) { $res = XDB::iterator('SELECT * FROM profile_addresses WHERE pid = {?}', $pid); while ($address = $res->next()) { $updateTime = $address['updateTime']; $gmapsGeocoder = new GMapsGeocoder(); $address = $gmapsGeocoder->getGeocodedAddress($address); if (!isset($address['geoloc'])) { // TODO: use address and phone classes to update profile_job_enum and profile_phones once they are done. XDB::execute('DELETE FROM profile_addresses WHERE pid = {?} AND id = {?} AND type = {?}', $address['pid'], $address['id'], $address['type']); Geocoder::getAreaId($address, 'administrativeArea'); Geocoder::getAreaId($address, 'subAdministrativeArea'); Geocoder::getAreaId($address, 'locality'); XDB::execute('INSERT INTO profile_addresses (pid, type, id, flags, accuracy, text, postalText, postalCode, localityId, subAdministrativeAreaId, administrativeAreaId, countryId, latitude, longitude, updateTime, pub, comment, north, south, east, west) VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, FROM_UNIXTIME({?}), {?}, {?}, {?}, {?}, {?}, {?})', $address['pid'], $address['type'], $address['id'], $flags, $address['accuracy'], $address['text'], $address['postalText'], $address['postalCode'], $address['localityId'], $address['subAdministrativeAreaId'], $address['administrativeAreaId'], $address['countryId'], $address['latitude'], $address['longitude'], $updateTime, $address['pub'], $address['comment'], $address['north'], $address['south'], $address['east'], $address['west']);
public function format() { $this->text = trim($this->text); $this->phones = Phone::formatFormArray($this->phones, $this->error, $this->pub); if ($this->removed == 1) { if (!S::user()->checkPerms('directory_private') && Phone::hasPrivate($this->phones)) { Platal::page()->trigWarning("L'adresse ne peut être supprimée car elle contient des informations pour lesquelles vous n'avez le droit d'édition."); } else { $this->text = ''; return true; } } $this->formatPostalAddress(); if ($this->changed == 1) { $gmapsGeocoder = new GMapsGeocoder(); $gmapsGeocoder->getGeocodedAddress($this); $componants = array(); foreach ($this->components as $component) { $componants[] = Geocoder::getComponentId($component); } $this->componentsIds = implode(',', $componants); } if ($this->componentsIds == '') { $this->latitude = null; $this->longitude = null; } return true; }
#!/usr/bin/php5 <?php require_once 'connect.db.inc.php'; require_once '../../classes/address.php'; require_once '../../classes/gmapsgeocoder.php'; require_once '../../classes/geocoder.php'; $globals->debug = 0; // Do not store backtraces. $it = XDB::iterator('SELECT gl.language, gc.country, gc.iso_3166_1_a2 FROM geoloc_languages AS gl INNER JOIN geoloc_countries AS gc ON (gl.iso_3166_1_a2 = gc.iso_3166_1_a2)'); echo $it->total() . " pays à remplir.\n"; while ($item = $it->next()) { if ($item['language'] != 'fr') { $address = new Address(array('text' => $item['country'])); $gmapsGeocoder = new GMapsGeocoder(); $gmapsGeocoder->getGeocodedAddress($address, $item['language'], true); $country = $address->country; } else { $country = $item['country']; } $countryPlain = mb_strtoupper(replace_accent($country)); XDB::execute('UPDATE geoloc_languages SET country = {?}, countryPlain = {?} WHERE iso_3166_1_a2 = {?} AND language = {?}', $country, $countryPlain, $item['iso_3166_1_a2'], $item['language']); sleep(1); } $it = XDB::rawIterator('SELECT country, iso_3166_1_a2 FROM geoloc_countries'); echo $it->total() . " pays à simplifier.\n"; while ($item = $it->next()) {