- $SFields[$i_mapfield] = new MapSField('mapid', array('map.parent'), array('adresses','geoloc_city_in_maps','geoloc_maps'), array('am','gcim','map'), array(getadr_join('am'), 'am.cityid = gcim.city_id', 'map.map_id = gcim.map_id'));
-
- $fields = new SFieldGroup(true, $SFields);
- $where = $fields->get_where_statement();
- if ($where) $where = " WHERE ".$where;
-
- $countryres = XDB::iterator("
- SELECT 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
- FROM auth_user_md5 AS u
- INNER JOIN auth_user_quick AS q ON(u.user_id = q.user_id)
- ".$fields->get_select_statement()."
- $where
- GROUP BY map.map_id ORDER BY NULL", $hierarchy);
-
- $maxpop = 0;
- $nbentities = $nbcities + $countryres->total();
- while ($c = $countryres->next())
- {
- $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']);
- $countries[$c['id']] = array_merge($countries[$c['id']], $c);
-
- $nbcities += $c['nbCities'];
- }
-
- if ($nocity && $nbcities < $minentities)
- {
- foreach($countries as $i => $c)
- {
- $countries[$i]['nbPop'] = 0;
- if ($c['nbCities'] > 0)
- geoloc_getData_subcities($c['id'], $SFields, $cities, false);
- }
- }
-
- foreach ($countries as $i => $c) if ($c['nbPop'] > 0)
- {
- $lambda = pow($c['nbPop'] / $maxpop,0.3);
- $countries[$i]['color'] = 0x0000FF + round((1-$lambda) * 0xFF)*0x010100;
- }
-
+ $SFields[$i_mapfield] = new MapSField('mapid', array('map.parent'), array('adresses','geoloc_city_in_maps','geoloc_maps'), array('am','gcim','map'), array(getadr_join('am'), 'am.cityid = gcim.city_id', 'map.map_id = gcim.map_id'));
+
+ $fields = new SFieldGroup(true, $SFields);
+ $where = $fields->get_where_statement();
+ if ($where) $where = " WHERE ".$where;
+
+ $countryres = XDB::iterator("
+ SELECT 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
+ FROM auth_user_md5 AS u
+ INNER JOIN auth_user_quick AS q ON(u.user_id = q.user_id)
+ ".$fields->get_select_statement()."
+ $where
+ GROUP BY map.map_id ORDER BY NULL", $hierarchy);
+
+ $maxpop = 0;
+ $nbentities = $nbcities + $countryres->total();
+ while ($c = $countryres->next())
+ {
+ $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']);
+ $countries[$c['id']] = array_merge($countries[$c['id']], $c);
+
+ $nbcities += $c['nbCities'];
+ }
+
+ if ($nocity && $nbcities < $minentities)
+ {
+ foreach($countries as $i => $c)
+ {
+ $countries[$i]['nbPop'] = 0;
+ if ($c['nbCities'] > 0)
+ geoloc_getData_subcities($c['id'], $SFields, $cities, false);
+ }
+ }
+
+ foreach ($countries as $i => $c) if ($c['nbPop'] > 0)
+ {
+ $lambda = pow($c['nbPop'] / $maxpop,0.3);
+ $countries[$i]['color'] = 0x0000FF + round((1-$lambda) * 0xFF)*0x010100;
+ }
+