* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
-function _geoloc_country_smarty($params)
-{
- echo "miqjfmeij";
- if(!isset($params['country'])) {
- return;
- }
- return geoloc_country($params['country'], @$params['available']);
-}
-
-$GLOBALS['page']->register_function('geoloc_country', '_geoloc_country_smarty');
-
/** donne la liste deroulante des regions pour un pays
* @param $pays le pays dont on veut afficher les regions
* @param $current la region actuellement selectionnee
/** donne la liste deroulante des regions pour un pays
* @param $pays le pays dont on veut afficher les regions
* @param $current la region actuellement selectionnee
-
-function _geoloc_region_smarty($params, &$smarty)
-{
- if(!isset($params['country']) || !isset($params['region'])) {
- return;
- }
- return geoloc_region($params['country'], $params['region'], @$params['available']);
-}
-$GLOBALS['page']->register_function('geoloc_region', '_geoloc_region_smarty');
- XDB::execute("UPDATE geoloc_pays SET display = {?} WHERE a2 = {?}", $infos['display'], $infos['country']);
- if (isset($infos['cityid']))
+ XDB::execute("UPDATE geoloc_pays
+ SET display = {?}
+ WHERE a2 = {?}", $infos['display'], $infos['country']);
+ if (isset($infos['cityid'])) {
+ if (floatval($infos['precise_lat']) && floatval($infos['precise_lon'])) {
+ $res = XDB::query("SELECT c.lat / 100000, c.lon / 100000
+ FROM geoloc_city AS c
+ WHERE c.id = {?}", $infos['cityid']);
+ if ($res->numRows()) {
+ list($glat, $glng) = $res->fetchOneRow();
+ $infos['precise_lat'] = $glat;
+ $infos['precise_lon'] = $glng;
+ }
+ }
+ }
/** make the text of an address that can be read by a mailman
* @param $adr an array with all the usual fields
*/
/** make the text of an address that can be read by a mailman
* @param $adr an array with all the usual fields
*/
{
$ta = strtoupper(preg_replace(array("/[0-9,\"'#~:;_\- ]/", "/\r\n/"), array("", "\n"), $a));
$tb = strtoupper(preg_replace(array("/[0-9,\"'#~:;_\- ]/", "/\r\n/"), array("", "\n"), $b));
{
$ta = strtoupper(preg_replace(array("/[0-9,\"'#~:;_\- ]/", "/\r\n/"), array("", "\n"), $a));
$tb = strtoupper(preg_replace(array("/[0-9,\"'#~:;_\- ]/", "/\r\n/"), array("", "\n"), $b));
$la = explode("\n", $ta);
$lb = explode("\n", $tb);
$la = explode("\n", $ta);
$lb = explode("\n", $tb);
/** synchronise the local geoloc_city base to geoloc.org
* @param $id the id of the city to synchronize
*/
/** synchronise the local geoloc_city base to geoloc.org
* @param $id the id of the city to synchronize
*/
$mapid);
$fields = new SFieldGroup(true, $SFields);
$where = $fields->get_where_statement();
$mapid);
$fields = new SFieldGroup(true, $SFields);
$where = $fields->get_where_statement();
LEFT JOIN geoloc_city AS gc ON(gcim.city_id = gc.id)",
$where . ($direct ? "gcim.infos = 'smallest'" : '1'),
'gc.id, gc.alias',
'pop DESC');
LEFT JOIN geoloc_city AS gc ON(gcim.city_id = gc.id)",
$where . ($direct ? "gcim.infos = 'smallest'" : '1'),
'gc.id, gc.alias',
'pop DESC');
if ($mapid === false) {
$wheremapid = "WHERE gm.parent IS NULL";
} else {
$wheremapid = "WHERE gm.parent = {?}";
}
$submapres = XDB::iterator(
if ($mapid === false) {
$wheremapid = "WHERE gm.parent IS NULL";
} else {
$wheremapid = "WHERE gm.parent = {?}";
}
$submapres = XDB::iterator(
- "SELECT gm.map_id AS id, gm.name, gm.x, gm.y, gm.xclip, gm.yclip,
+ "SELECT gm.map_id AS id, gm.name, gm.x, gm.y, gm.xclip, gm.yclip,
gm.width, gm.height, gm.scale, 1 AS rat
FROM geoloc_maps AS gm
". $wheremapid, Env::v('mapid',''));
gm.width, gm.height, gm.scale, 1 AS rat
FROM geoloc_maps AS gm
". $wheremapid, Env::v('mapid',''));
$country['swf'] = $globals->geoloc->webservice_url."maps/mercator/map_".$c['id'].".swf";
$countries[$c['id']] = $country;
}
$country['swf'] = $globals->geoloc->webservice_url."maps/mercator/map_".$c['id'].".swf";
$countries[$c['id']] = $country;
}
array('map.parent'),
array('adresses','geoloc_city_in_maps','geoloc_maps'),
array('am','gcim','map'),
array('map.parent'),
array('adresses','geoloc_city_in_maps','geoloc_maps'),
array('am','gcim','map'),
- array(getadr_join('am'),
- 'am.cityid = gcim.city_id',
+ array(getadr_join('am'),
+ 'am.cityid = gcim.city_id',
'map.map_id = gcim.map_id'));
$fields = new SFieldGroup(true, $SFields);
'map.map_id = gcim.map_id'));
$fields = new SFieldGroup(true, $SFields);
$countryres = $set->get('map.map_id AS id,
COUNT(u.user_id) AS nbPop,
SUM(u.promo % 2) AS yellow,
COUNT(DISTINCT gcim.city_id) AS nbCities,
SUM(IF(u.user_id IS NULL,0,am.glng)) AS lonPop,
SUM(IF(u.user_id IS NULL, 0,am.glat)) AS latPop',
$countryres = $set->get('map.map_id AS id,
COUNT(u.user_id) AS nbPop,
SUM(u.promo % 2) AS yellow,
COUNT(DISTINCT gcim.city_id) AS nbCities,
SUM(IF(u.user_id IS NULL,0,am.glng)) AS lonPop,
SUM(IF(u.user_id IS NULL, 0,am.glat)) AS latPop',
$c['latPop'] /= $c['nbPop'];
$c['lonPop'] /= $c['nbPop'];
$c['rad'] = size_of_territory($c['nbPop']);
if ($maxpop < $c['nbPop']) $maxpop = $c['nbPop'];
$c['xPop'] = geoloc_to_x($c['lonPop'], $c['latPop']);
$c['yPop'] = geoloc_to_y($c['lonPop'], $c['latPop']);
$c['latPop'] /= $c['nbPop'];
$c['lonPop'] /= $c['nbPop'];
$c['rad'] = size_of_territory($c['nbPop']);
if ($maxpop < $c['nbPop']) $maxpop = $c['nbPop'];
$c['xPop'] = geoloc_to_x($c['lonPop'], $c['latPop']);
$c['yPop'] = geoloc_to_y($c['lonPop'], $c['latPop']);
if ($nocity && $nbcities < $minentities){
foreach($countries as $i => $c) {
$countries[$i]['nbPop'] = 0;
if ($nocity && $nbcities < $minentities){
foreach($countries as $i => $c) {
$countries[$i]['nbPop'] = 0;
geoloc_getData_subcities($c['id'], $sin, $cities, false);
geoloc_getData_subcities($c['id'], $sin, $cities, false);
$lambda = pow($c['nbPop'] / $maxpop,0.3);
$countries[$i]['color'] = 0x0000FF + round((1-$lambda) * 0xFF)*0x010100;
}
}
$lambda = pow($c['nbPop'] / $maxpop,0.3);
$countries[$i]['color'] = 0x0000FF + round((1-$lambda) * 0xFF)*0x010100;
}
}