$layerName = $oLayer->name; array_push($result->layers, $layerName); $result->{$layerName}->featureCount = $oLayer->getNumResults(); //TODO: dump out the extents of the selection } if ($bExtendSelection) { } else { } } if ($bExtendSelection) { } header('Content-type: text/x-json'); header('X-JSON: true'); if ($result->hasSelection) { $oMap->savequery(getSessionSavePath() . "query.qry"); $result->queryFile = getSessionSavePath() . "query.qry"; /*holds selection array*/ $properties = NULL; $properties->layers = array(); $totalminx = 0; $totalminy = 0; $totalmaxx = 0; $totalmaxy = 0; $bFirstElement = 1; $nLayers = $oMap->numlayers; for ($i = 0; $i < $nLayers; $i++) { $oLayer = $oMap->GetLayer($i); $numResults = $oLayer->getNumResults(); if ($numResults == 0) { continue; }
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ /***************************************************************************** * Purpose: Draw a legend icon *****************************************************************************/ /* set up the session */ include dirname(__FILE__) . '/../../../common/php/Utilities.php'; include dirname(__FILE__) . '/Common.php'; include dirname(__FILE__) . '/Utilities.php'; if (!isset($mapName)) { die('mapname not set'); } $mapFile = getSessionSavePath() . $mapName . ".map"; $str = file_get_contents($mapFile); $legendIconCacheFile = ""; if ($str) { $configObj = $_SESSION['fusionConfig']; /* if the legendIconCache dir is set */ if (isset($configObj->mapserver->legendIconCacheDir)) { $legendIconCacheDir = $configObj->mapserver->legendIconCacheDir; // check for closing '/' $legendIconCacheDir = str_replace('\\', '/', trim($legendIconCacheDir)); if (substr($legendIconCacheDir, -1) != '/') { $legendIconCacheDir .= '/'; } $cacheLegendIcons = true; //$str = file_get_contents($_SESSION['maps'][$mapName]); /* create a unique location for the map icons based on
if (file_exists(realpath($oStyle->symbolname))) { $oStyle->set("symbolname", realpath($oStyle->symbolname)); } } } } } chdir($cwd); } $oMap->save($mapId); } else { $mapId = $_REQUEST['mapfile']; } } elseif (isset($_SESSION['maps']) && isset($_SESSION['maps'][$mapName])) { $oMap = ms_newMapObj($_SESSION['maps'][$mapName]); $mapId = getSessionSavePath() . $oMap->name . ".map"; } if ($configObj->mapserver->obscureMapFile) { error_log('obscuring map file'); $mapId = $oMap->name; } $mapObj = NULL; if ($oMap) { $mapName = $oMap->name; //header('Content-type: application/json'); //header('X-JSON: true'); $mapObj->sessionId = $sessionID; $mapObj->mapId = $mapId; $mapObj->metadata = NULL; if (isset($_REQUEST['map_metadata'])) { $mapMetadataKeys = explode(',', $_REQUEST['map_metadata']);
function ProcesaROI(&$aROI) { // debug //renderText(count($_SESSION['ROIRENDERER'])); $aPoints = array(); if ($aROI['type'] == 'rectangle') { //for rectangles, we assume that there are two coordinates, top left and bottom right. array_push($aPoints, $aROI['aGeoCoords'][0]); array_push($aPoints, $aROI['aGeoCoords'][1]); array_push($aPoints, $aROI['aGeoCoords'][2]); array_push($aPoints, $aROI['aGeoCoords'][1]); array_push($aPoints, $aROI['aGeoCoords'][2]); array_push($aPoints, $aROI['aGeoCoords'][3]); array_push($aPoints, $aROI['aGeoCoords'][0]); array_push($aPoints, $aROI['aGeoCoords'][3]); array_push($aPoints, $aROI['aGeoCoords'][0]); array_push($aPoints, $aROI['aGeoCoords'][1]); $nPoints = 5; // flag for poly $bPoly = true; } elseif ($aROI['type'] == 'circle') { // convert center and radius to pixel $dCenterX = $aROI['aGeoCoords'][0]; $dCenterY = $aROI['aGeoCoords'][1]; $dRadiusX = $aROI['aGeoCoords'][2]; $dRadius = abs($dRadiusX - $dCenterX); // flag for non-poly $bPoly = false; } elseif ($aROI['type'] == 'polygon') { // loop and set coordinates $nCount = count($aROI['aGeoCoords']); for ($i = 0; $i < $nCount; $i++) { array_push($aPoints, $aROI['aGeoCoords'][$i]); } array_push($aPoints, $aROI['aGeoCoords'][0]); array_push($aPoints, $aROI['aGeoCoords'][1]); $nPoints = round($nCount / 2); // flag for poly $bPoly = true; } elseif ($aROI['type'] == 'line') { // Only mode 1 and 2 (add) is supported for now. if ($aROI['mode'] != 1 and $aROI['mode'] != 2) { $this->maszErrorMsg[] = "Tipo de Elemento inválido. " . "Sólo agregar elementos está habilitado"; } // For a line, we have a pair of value for each vertex. $nVertex = count($aROI['aGeoCoords']); for ($i = 0; $i < $nVertex; $i++) { array_push($aPoints, $aROI['aGeoCoords'][$i]); } } elseif ($aROI['type'] == 'point') { // Only mode 1 and 2 (add) is supported for now. if ($aROI['mode'] != 1 and $aROI['mode'] != 2) { $this->maszErrorMsg[] = "Tipo de Elemento inválido. " . "Sólo agregar elementos está habilitado"; } array_push($aPoints, $aROI['aGeoCoords'][0]); array_push($aPoints, $aROI['aGeoCoords'][1]); } elseif ($aROI['type'] == 'feature') { $nPoints = 0; $nLayers = $GLOBALS['oMapSession']->oMap->numlayers; for ($i = 0; $i < $nLayers; $i++) { $oLayer = $GLOBALS['oMapSession']->oMap->getLayer($i); $oLayer->set('status', MS_OFF); } $oLayer = @$GLOBALS['oMapSession']->oMap->getLayerByName($aROI['selectedLayer']); if ($oLayer && $oLayer->type == MS_LAYER_POLYGON) { $nResults = 0; //create the query template that turns polygons into something useful. $szTemplatePath = getSessionSavePath() . "roirenderer_template.html"; if (!file_exists($szTemplatePath)) { $szTemplate = '[shpxy xf="," yf="," sf="|" proj="image"]'; $hTemplate = fopen($szTemplatePath, "w+"); fwrite($hTemplate, $szTemplate); fclose($hTemplate); } //put the template on each class ... is this necessary? for ($i = 0; $i < $oLayer->numclasses; $i++) { $oClass = $oLayer->getClass($i); $oClass->set("template", $szTemplatePath); } //make sure the layer is on (doh) $oLayer->set("status", MS_ON); $oLayer->set('tolerance', 0); $oLayer->set('toleranceunits', MS_PIXELS); //its a new query ... if (count($aROI['aGeoCoords']) == 2) { $aROI['aOrigCoords'] = $aROI['aGeoCoords']; $oPoint = ms_newPointObj(); $oPoint->setXY($aROI['aGeoCoords'][0], $aROI['aGeoCoords'][1]); @$oLayer->queryByPoint($oPoint, MS_SINGLE, 0); $nResults = $oLayer->getNumResults(); unset($aROI['aGeoCoords']); if ($nResults > 0) { //save the query results for future passes ... $aROI['query_file'] = getSessionSavePath() . "/" . uniqid("") . ".qry"; $GLOBALS['oMapSession']->oMap->saveQuery($aROI['query_file']); } } else { if (isset($aROI['query_file']) && file_exists($aROI['query_file'])) { //load the query and find a layer with query results ... $GLOBALS['oMapSession']->oMap->loadQuery($aROI['query_file']); $nResults = $oLayer->getNumResults(); } } if ($nResults > 0) { $szCode = $GLOBALS['oMapSession']->oMap->processQueryTemplate(array(), false); //there seems to be a bug ... query results are not getting reset ... so we //introduce a | after each shape and then only take the first shape ... $aszCode = explode("|", $szCode); $szCode = substr($aszCode[0], 0, -1); $szCode = '$' . 'aPoints = array(' . $szCode . ');'; //?? aqui se debería procesar los puntos de coord mapa a Pix eval($szCode); $nPoints = count($aPoints) / 2; $bPoly = true; } } } return $aPoints; }
function initializeSession($szSessName = "sid", $szSessSavePath = "", $szSessionID = "") { if ($GLOBALS["bDebug"]) { debug_msg("initializeSession( {$szSessName}, {$szSessSavePath}, {$szSessionID} )"); } //if session was run already don't execute again if (isset($GLOBALS['session_started'])) { return true; } if ($szSessName == "") { echo "<FONT color=#FF0000>FATAL ERROR: Sessionname not specified</FONT>"; exit; } else { ini_set("session.name", $szSessName); } if ($szSessSavePath != "") { ini_set("session.save_path", $szSessSavePath); } clearstatcache(); // Check if save path is writable if (!(file_exists(ini_get("session.save_path")) && is_writable(ini_get("session.save_path")))) { echo "<FONT COLOR=#DD0000>FATAL ERROR: Session save path (" . ini_get("session.save_path") . ") doesn't exist or is not writable</FONT>"; exit; } //turn off cookies for propagating session ids ini_set("session.use_cookies", "0"); // turn off tranparent SID (becuase of buffer problem) ini_set("session.use_trans_sid", "0"); // intialize tmp id $szTmpID = ""; // check both get and post variables if (isset($GLOBALS['_GET'][ini_get('session.name')])) { $szTmpID = $GLOBALS['_GET'][ini_get('session.name')]; } elseif (isset($GLOBALS['_POST'][ini_get('session.name')])) { $szTmpID = $GLOBALS['_POST'][ini_get('session.name')]; } // create new if necessary if (strlen($szTmpID) <= 0) { if ($GLOBALS["bDebug"]) { debug_msg("creating a new session because .{$szTmpID}. has zero characters "); } // create new and set IP flag if (strlen($szSessionID) > 0) { $szTmpID = $szSessionID; } else { $szTmpID = uniqid(""); } $bNewSession = true; if ($GLOBALS["bDebug"]) { debug_msg("creating a new session with id "); } } else { $bNewSession = false; } // initialize flag variable $bSessionOK = true; // set the session ID session_id($szTmpID); // Check if session is expired if (!$bNewSession) { $szSavePath = getSessionSavePath(); $szSessionFile = $szSavePath . "/session_file"; if (file_exists($szSessionFile)) { if ($atime = @filemtime($szSessionFile)) { if (time() > $atime + ini_get("session.gc_maxlifetime")) { $szTmpID = uniqid(""); // reset the session ID session_id($szTmpID); $bNewSession = true; $bSessionOK = false; } } } } //start the session session_start(); register_shutdown_function("session_write_close"); // set IP if a new session if ($bNewSession) { $_SESSION["gszRemoteAdd"] = $_SERVER["REMOTE_ADDR"]; } /* ============================================================================ * Check IP to see if it is the same * ========================================================================= */ // check if the IP has been set and validate if (isset($_SESSION["gszRemoteAdd"]) && strlen(trim($_SESSION["gszRemoteAdd"])) > 0) { // check if IP matches current client if (trim($_SESSION["gszRemoteAdd"]) != trim($_SERVER["REMOTE_ADDR"])) { // possible security breach void session /* if the session address is the loopback interface then it is * likely that the application was configured to use an external * address but someone is trying to test locally using localhost */ if ($_SESSION['gszRemoteAdd'] != '127.0.0.1') { $bSessionOK = false; } } } else { // possible security breach void session $bSessionOK = false; } // return success or failure and set global so we // know session has been inited. if ($bSessionOK) { $GLOBALS['session_started'] = true; } return $bSessionOK; // end intializeSession() function }