コード例 #1
0
ファイル: obj.customer.php プロジェクト: r3-gis/EcoGIS
 public static function getFullExtent($do_id, $srid)
 {
     $db = ezcDbInstance::get();
     $sql = "SELECT ST_Extent(the_geom) FROM municipality WHERE do_id={$do_id}";
     $result = array();
     foreach (ST_FetchBox($db->query($sql)->fetchColumn()) as $key => $val) {
         $result[$key] = (int) round($val);
     }
     return $result;
 }
コード例 #2
0
ファイル: eco_utils.php プロジェクト: r3-gis/EcoGIS
 /**
  * Generate the preview map
  */
 static function generateMapPreview($layer, $key, $lang, $tollerance = '10%')
 {
     require_once R3_LIB_DIR . 'maplib.php';
     require_once R3_LIB_DIR . 'custom.map.php';
     global $languages;
     ezcLog::getInstance()->log(__METHOD__ . "({$layer}, {$key}, {$lang}, {$tollerance}) called", ezcLog::DEBUG);
     $db = ezcDbInstance::get();
     $auth = R3AuthInstance::get();
     list($width, $height) = explode('x', $auth->getConfigValue('APPLICATION', 'MAP_PREVIEW_SIZE', '200x200'));
     $cus_schema = R3EcoGisHelper::getGeoSchema();
     $domain_name = strtolower(R3EcoGisHelper::getDomainCodeFromID($_SESSION['do_id']));
     $mapfileDir = R3_CONFIG_DIR . $domain_name . '/map/';
     $mapPrev = new mapPreview($mapfileDir, $languages[$lang], $width, $height);
     if (function_exists('custom_map_edit_map_file')) {
         custom_map_edit_map_file($mapPrev->map);
     }
     switch ($layer) {
         case 'building':
             $opt = $auth->getConfigValue('APPLICATION', 'BUILDING_TABLE');
             $options['outlinecolor'] = isset($opt['outlinecolor']) ? $opt['outlinecolor'] : array();
             $sql = "SELECT ST_Extent(the_geom) FROM building WHERE bu_id=" . (int) $key;
             $mapPrev->highlight('ecogis_building_outline_selected', "the_geom FROM (SELECT * FROM {$cus_schema}.building WHERE bu_id=" . (int) $key . ") AS foo USING UNIQUE bu_id ", $options);
             break;
         case 'edit_building':
             // Edit building
             $opt = $auth->getConfigValue('APPLICATION', 'BUILDING_TABLE');
             $options['outlinecolor'] = isset($opt['outlinecolor']) ? $opt['outlinecolor'] : array();
             $sql = "SELECT ST_Extent(the_geom) FROM edit_tmp_polygon WHERE session_id=" . $db->quote($key);
             $mapPrev->highlight('ecogis_building_outline_selected', "the_geom FROM (SELECT gid AS bu_id, the_geom FROM ecogis.edit_tmp_polygon WHERE session_id=" . $db->quote($key) . ") AS foo USING UNIQUE bu_id ", $options);
             break;
         case 'street_lighting':
             $opt = $auth->getConfigValue('APPLICATION', 'STREET_LIGHTING_TABLE');
             $options['outlinecolor'] = isset($opt['outlinecolor']) ? $opt['outlinecolor'] : array();
             $sql = "SELECT ST_Extent(the_geom) FROM street_lighting WHERE sl_id=" . (int) $key;
             $mapPrev->highlight('ecogis_street_lighting_outline_selected', "the_geom FROM (SELECT * FROM {$cus_schema}.street_lighting WHERE sl_id=" . (int) $key . ") AS foo USING UNIQUE sl_id ", $options);
             break;
         case 'edit_street_lighting':
             $opt = $auth->getConfigValue('APPLICATION', 'BUILDING_TABLE');
             $options['outlinecolor'] = isset($opt['outlinecolor']) ? $opt['outlinecolor'] : array();
             $sql = "SELECT ST_Extent(the_geom) FROM edit_tmp_polygon WHERE session_id=" . $db->quote($key);
             $mapPrev->highlight('ecogis_street_lighting_outline_selected', "the_geom FROM (SELECT gid AS sl_id, the_geom FROM ecogis.edit_tmp_polygon WHERE session_id=" . $db->quote($key) . ") AS foo USING UNIQUE sl_id ", $options);
             break;
         default:
             $this->deliverError(sprintf(_("Il layer \"{$this->layer}\" non e' valido")));
             die;
     }
     $the_geom = $db->query($sql)->fetchColumn(0);
     if ($the_geom != '') {
         $extentArr = array();
         $extentArr = ST_FetchBox($the_geom);
         $extentArr['geox1'] = $extentArr[0];
         $extentArr['geoy1'] = $extentArr[1];
         $extentArr['geox2'] = $extentArr[2];
         $extentArr['geoy2'] = $extentArr[3];
         $deltaX = $deltaY = $tollerance;
         $layer = @$mapPrev->map->getLayerByName('comuni_overlay');
         if ($layer) {
             $class0 = @$layer->getClass(0);
             if ($class0) {
                 $class0->setExpression("('[istat]' != '" . $vlu['mu_id'] . "')");
             }
         }
         $PrevFile = $mapPrev->getMapImgByBox($extentArr['geox1'], $extentArr['geoy1'], $extentArr['geox2'], $extentArr['geoy2'], max($deltaX, $deltaY));
         return $PrevFile;
     }
     return null;
 }