/** * 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; }
public function create_grid($request) { global $dbini; $db = ezcDbInstance::get(); session_write_close(); ignore_user_abort(); //transaction $gridSize = (int) $request['sg_size']; $db->beginTransaction(); R3EcoGisCustomerHelper::createGrid((int) $request['do_id'], $gridSize); $dnName = R3EcoGisHelper::getDomainCodeFromID($request['do_id']); $dbini2 = clone $dbini; $dbini2->setDomainName($dnName); $dbini2->setValue('APPLICATION', 'STAT_GRID_SIZE', $gridSize > 0 ? $gridSize : null); $db->commit(); return array('status' => R3_AJAX_NO_ERROR); }
case 'paes': eco_gisclient::copyFeatureToEditTable('global_subcategory', $_GET['mapoper_id']); $digitizeTarget = eco_gisclient::getDigitizeTarget($_GET['layer']); break; default: throw new Exception('Missing or invalid layer parameter'); } $smarty->assign('customDigitizeTarget', $digitizeTarget); } $gc = array('tools' => $tools); $smarty->assign('gc', $gc); $smarty->assign('proj4js', eco_gisclient::getProj4List()); if (R3_IS_MULTIDOMAIN) { // Read data for current domain $dbiniDomain = clone $dbini; $dbiniDomain->setDomainName(R3EcoGisHelper::getDomainCodeFromID($_SESSION['do_id'])); $gisclientOptions = array('project' => $dbiniDomain->getValue('GISCLIENT', 'PROJECT'), 'mapset' => $dbiniDomain->getValue('GISCLIENT', 'MAPSET'), 'has_streeview' => $dbiniDomain->getValue('GISCLIENT', 'HAS_STREETVIEW') != 'F', 'streeview_options' => $dbiniDomain->getValue('GISCLIENT', 'STREETVIEW_OPTIONS', '{"correctionParameters": {"x":0, "y":0}}'), 'has_quick_search' => $dbiniDomain->getValue('GISCLIENT', 'HAS_QUICK_SEARCH') != 'F', 'has_fractional_zoom' => $dbiniDomain->getValue('GISCLIENT', 'FRACTIONAL_ZOOM') != 'F', 'digitize_has_selection' => $dbiniDomain->getValue('GISCLIENT', 'DIGITIZE_HAS_SELECTION') != 'F' ? 'true' : 'false', 'do_gc_digitize_has_editing' => $dbiniDomain->getValue('GISCLIENT', 'DIGITIZE_HAS_EDITING') != 'F' ? 'true' : 'false'); } else { $gisclientOptions = array('project' => $auth->getConfigValue('GISCLIENT', 'PROJECT'), 'mapset' => $auth->getConfigValue('GISCLIENT', 'MAPSET'), 'has_streeview' => $auth->getConfigValue('GISCLIENT', 'HAS_STREETVIEW') != 'F', 'streeview_options' => $auth->getConfigValue('GISCLIENT', 'STREETVIEW_OPTIONS', '{"correctionParameters": {"x":0, "y":0}}'), 'has_quick_search' => $auth->getConfigValue('GISCLIENT', 'HAS_QUICK_SEARCH') != 'F', 'fractional_zoom' => $auth->getConfigValue('GISCLIENT', 'FRACTIONAL_ZOOM') != 'F', 'digitize_has_selection' => $auth->getConfigValue('GISCLIENT', 'DIGITIZE_HAS_SELECTION') != 'F' ? 'true' : 'false', 'do_gc_digitize_has_editing' => $auth->getConfigValue('GISCLIENT', 'DIGITIZE_HAS_EDITING') != 'F' ? 'true' : 'false'); } $smarty->assign('gisclientOptions', $gisclientOptions); if (isset($mapCallbacks)) { $smarty->assign('mapCallbacks', $mapCallbacks); } if (isset($zoomOn)) { $smarty->assign('zoomOn', $zoomOn); } else { if (isset($goToCenterZoom)) { $smarty->assign('goToCenterZoom', $goToCenterZoom); } }