/** * Class constructor */ function __construct($map, $mapW, $mapH, $scale, $printType, $imgDPI, $imgFormat = false, $prefmap = true, $printSettings = array()) { parent::__construct($map); $this->mapW = $mapW; $this->mapH = $mapH; $this->scale = $scale; $this->groups = $_SESSION["groups"]; // Check for custom layers $this->pmap_addCustomLayers(); // Set active groups/layers PMCommon::setGroups($map, $this->groups, $scale, 1); // Check and if necessary add result layers to map $this->pmap_checkResultLayers(); // Check for XY Layers (event layers) $this->existsXYLayer = $_SESSION["existsXYLayer"] ? 1 : 0; // Set width and height $this->map->set("width", $this->mapW); $this->map->set("height", $this->mapH); // ZOOM TO PRE-DEFINED SCALE OR MAP EXTENT FROM SESSIONID $this->zoom2scale(); // if needed, add legend to map $this->applyLegendObjToMap($map, $printSettings); // to allow to redefine images drawing // All the previous code in now contains in drawImages member function $this->drawImages($printType, $imgDPI, $imgFormat, $prefmap); }
public function __construct($map) { $this->map = $map; if (isset($_REQUEST["mode"])) { $this->mode = $_REQUEST["mode"]; } else { $this->mode = "search"; } if (isset($_REQUEST["imgxy"])) { $imgxy_str = $_REQUEST["imgxy"]; $this->imgxy_arr = explode(" ", $imgxy_str); } // Take groups for query from URL or SESSION-ID if (isset($_REQUEST["groups"])) { $this->querygroups[] = $_REQUEST["groups"]; } else { $this->querygroups = $_SESSION["groups"]; } $this->highlightSelected = $_SESSION["highlightSelected"]; $this->limitResult = $_SESSION["limitResult"]; $this->scale = $_SESSION["geo_scale"]; $this->infoWin = $_SESSION["infoWin"]; $this->mapwidth = $_SESSION["mapwidth"]; $this->mapheight = $_SESSION["mapheight"]; $this->GEOEXT = $_SESSION["GEOEXT"]; $this->autoZoom = $_SESSION["autoZoom"]; $this->zoomAll = $_SESSION["zoomAll"]; $this->grouplist = $_SESSION["grouplist"]; $_SESSION["mode"] = $this->mode; // RESTRICT QUERY TO VISIBLE LAYERS IN THE SCOPE OF CURRENT SCALE if ($this->mode != "search") { PMCommon::setGroups($this->map, $this->querygroups, $this->scale, 0, 1); } }
/** * Main function to launch all methgods in right order */ public function pmap_create() { $this->pmap_addCustomLayers(); $this->pmap_getGroups(); $this->activeGroups = PMCommon::setGroups($this->map, $this->groups, 0, 1); $this->pmap_setGeoExt(); $this->pmap_setMapWH(); $this->pmap_createMap(); $this->pmap_createMapImage(); $this->pmap_setHistory(); $this->pmap_registerSession(); }
/** * EXECUTE QUERY */ public function q_execMapQuery() { //-------------------------------- // Initialize tolerance to 0 //-------------------------------- $msLayers = array(); // query in specified groups only: if (isset($_REQUEST['groups']) && $_REQUEST['groups']) { $msLayers = getLayersByGroupOrLayerName($this->map, $_REQUEST['groups']); // all groups: } else { for ($i = 0; $i < $this->map->numlayers; $i++) { $msLayers[] = $this->map->getLayer($i); } } foreach ($msLayers as $msLayer) { // change tolerance only for buffer zone search. if ($this->queryType == 'object') { $msLayer->set('tolerance', 0); } } // Modified by Thomas RAFFIN (SIRAP) // to test (substitution) // query by point // Modified by Thomas RAFFIN (SIRAP) // use layers with complex queries that are too long to select results // cause maxscaledenom is not used... $oldDatas = array(); for ($i = 0; $i < $this->map->numlayers; $i++) { $qLayer = $this->map->getLayer($i); $layerName = $qLayer->name; if ($qLayer->getMetaData('PM_RESULT_DATASUBSTITION') != '') { $oldDatas[$layerName] = $qLayer->data; $qLayer->set('data', $qLayer->getMetaData('PM_RESULT_DATASUBSTITION')); } } // few lines from incphp/query/query.php // Patch from Alessandro Pasotti for fixing problems with result returned $this->map->setSize($this->mapwidth, $this->mapheight); // Set $this->map->extent to values of current map extent // otherwise values of TOLERANCE in map file are not interpreted correctly $this->map->setExtent($this->GEOEXT['minx'], $this->GEOEXT['miny'], $this->GEOEXT['maxx'], $this->GEOEXT['maxy']); $this->map->preparequery(); if ($this->queryType == 'object') { if (isset($_SESSION['pluginsConfig']['graphicalqueries']) && isset($_SESSION['pluginsConfig']['graphicalqueries']['bufferOnlyWithScale'])) { $bufferOnlyWithScale = $_SESSION['pluginsConfig']['graphicalqueries']['bufferOnlyWithScale'] == 1; } else { $bufferOnlyWithScale = true; } if (!$bufferOnlyWithScale) { // PMCommon::setGroups($this->map, $this->querygroups, $this->scale, 0, 1); PMCommon::setGroups($this->map, $this->querygroups, 0, 0, 1); } // Search selected object $jsonPMResult = $_SESSION['JSON_Results']; // "[...]" ou "{...}" $PMResult = json_decode($jsonPMResult); // array ou class if ($PMResult) { $objUnion = false; // List layer of selected object $layersWithResult = $PMResult[0]; // be carreful : 0.000000001 is too small !! $smallBuffer = 1.0E-8; $mapProjStr = $this->map->getProjection(); if ($_SESSION['MS_VERSION'] < 6) { $mapProjObj = ms_newprojectionobj($mapProjStr); } else { $mapProjObj = new projectionObj($mapProjStr); } // Loop on layers $layerName = ''; foreach ($layersWithResult as $layerWithResult) { $objUnionLayer = false; // init layer to close the last open one $layer = false; $layerProjObj = false; // Loop on layer objects foreach ($layerWithResult->values as $selectedObject) { // layer name $currentLayerName = $selectedObject[0]->shplink[0]; if ($currentLayerName != $layerName) { if ($layer) { $layer->close(); } $layerName = $currentLayerName; $layer = $this->map->getLayerByName($layerName); $layerProjObj = false; $layerProjStr = $layer->getProjection(); if ($mapProjStr && $layerProjStr && $mapProjStr != $layerProjStr) { if ($_SESSION['MS_VERSION'] < 6) { $layerProjObj = ms_newprojectionobj($layerProjStr); } else { $layerProjObj = new projectionObj($layerProjStr); } } $layer->open(); } $shpIndex = $selectedObject[0]->shplink[1]; // Retrieve shape by its index. $objShape = PMCommon::resultGetShape($_SESSION['MS_VERSION'], $layer, null, $shpIndex, -1); // changed for compatibility with PG layers and MS >= 5.6 // reproject if ($layerProjObj) { $objShape->project($layerProjObj, $mapProjObj); } // Union of the shapes if ($objUnionLayer) { $objUnionLayer = $objShape->union($objUnionLayer); } else { $objUnionLayer = $objShape; } } // End foreach : Loop of the layer // close layer if exists if ($layer) { $layer->close(); } if ($objUnionLayer) { // Line : Buffer to convert Line or Point to Polygon if ($objUnionLayer->type == MS_SHAPE_LINE && isset($_REQUEST['select_buffer']) && $_REQUEST['select_buffer'] > 0 || $objUnionLayer->type == MS_SHAPE_POINT) { $objUnionLayer = $objUnionLayer->buffer($smallBuffer); // if polygon -> the outline is removed to not select contiguous objects } else { if ($objUnionLayer->type == MS_SHAPE_POLYGON && !isset($_REQUEST['select_buffer'])) { $objBoundary = $objUnionLayer->boundary(); $objBoundary = $objBoundary->buffer($smallBuffer); $objUnionLayer = $objUnionLayer->difference($objBoundary); } } } if ($objUnionLayer) { if ($objUnion) { $objUnion = $objUnion->union($objUnionLayer); } else { $objUnion = $objUnionLayer; } } // End if($objUnionLayer) } // End foreach : loop of layers // Buffer -> Buffer zone if (isset($_REQUEST['select_buffer'])) { if ($objUnion) { $objUnion = $objUnion->buffer($_REQUEST['select_buffer']); unset($_REQUEST['select_buffer']); } } if ($objUnion) { // Query @$this->map->queryByShape($objUnion); } } // Query by point } else { if ($this->queryType == 'point') { $tmpPoint = ms_newPointObj(); $tmpPoint->setXYZ($_REQUEST['select_pointX'], $_REQUEST['select_pointY'], 0); if (isset($_REQUEST['select_buffer'])) { @$this->map->queryByPoint($tmpPoint, MS_MULTIPLE, $_REQUEST['select_buffer']); } else { @$this->map->queryByPoint($tmpPoint, MS_MULTIPLE, -1); } PMCommon::freeMsObj($tmpPoint); // query by Shape } else { if ($this->queryType == 'polygon') { //'shape') $poly = $_REQUEST['select_poly']; $tmpLine = ms_newLineObj(); $tmpPoly = explode(',', $poly); foreach ($tmpPoly as $point) { $tmpTab = explode(' ', $point); $tmpLine->addXY($tmpTab[0], $tmpTab[1]); } $objPoly = ms_newShapeObj(MS_SHAPE_POLYGON); $objPoly->add($tmpLine); // Buffer -> Buffer zone if (isset($_REQUEST['select_buffer'])) { $objPoly = $objPoly->buffer($_REQUEST['select_buffer']); unset($_REQUEST['select_buffer']); } @$this->map->queryByShape($objPoly); PMCommon::freeMsObj($tmpLine); PMCommon::freeMsObj($objPoly); // query by PolyLine } else { if ($this->queryType == 'line') { $poly = $_REQUEST['select_line']; $tmpLine = ms_newLineObj(); $tmpPoly = explode(',', $poly); foreach ($tmpPoly as $point) { $tmpTab = explode(' ', $point); $tmpLine->addXY($tmpTab[0], $tmpTab[1]); } // Reduce the polygon to a polyline for ($i = count($tmpPoly) - 1; $i >= 0; $i--) { $tmpTab = explode(' ', $tmpPoly[$i]); $tmpLine->addXY($tmpTab[0], $tmpTab[1]); } $objPoly = ms_newShapeObj(MS_SHAPE_POLYGON); $objPoly->add($tmpLine); // Buffer -> Buffer zone if (isset($_REQUEST['select_buffer'])) { $bufferLocal = $_REQUEST['select_buffer']; if ($bufferLocal < 0) { $bufferLocal = 0; } $objPoly = $objPoly->buffer($bufferLocal); unset($_REQUEST['select_buffer']); } @$this->map->queryByShape($objPoly); PMCommon::freeMsObj($tmpLine); PMCommon::freeMsObj($objPoly); // query by circle } else { if ($this->queryType == 'circle') { $point = $_REQUEST['select_point']; $radius = $_REQUEST['select_radius']; $tmpPoint = ms_newPointObj(); $tmpTab = explode(' ', $point); $tmpPoint->setXYZ($tmpTab[0], $tmpTab[1], 0); if (isset($_REQUEST['select_buffer'])) { @$this->map->queryByPoint($tmpPoint, MS_MULTIPLE, $radius + $_REQUEST['select_buffer']); } else { @$this->map->queryByPoint($tmpPoint, MS_MULTIPLE, $radius); } PMCommon::freeMsObj($tmpPoint); } } } } } // Modified by Thomas RAFFIN (SIRAP) // use layers with complex queries that are too long to select results // cause maxscaledenom is not used... // reset data tag foreach ($oldDatas as $qLayer => $oldData) { $qLayer = $this->map->getLayerByName($qLayer); $qLayer->set('data', $oldData); } }