[fusion-commits] r2164 - sandbox/jxlib-3.0/layers/MapServer/php

svn_fusion at osgeo.org svn_fusion at osgeo.org
Thu May 20 16:41:33 EDT 2010


Author: assefa
Date: 2010-05-20 16:41:30 -0400 (Thu, 20 May 2010)
New Revision: 2164

Modified:
   sandbox/jxlib-3.0/layers/MapServer/php/Query.php
   sandbox/jxlib-3.0/layers/MapServer/php/Selection.php
Log:
Initial support for raster queries fr MapServer

Modified: sandbox/jxlib-3.0/layers/MapServer/php/Query.php
===================================================================
--- sandbox/jxlib-3.0/layers/MapServer/php/Query.php	2010-05-20 20:17:34 UTC (rev 2163)
+++ sandbox/jxlib-3.0/layers/MapServer/php/Query.php	2010-05-20 20:41:30 UTC (rev 2164)
@@ -149,10 +149,69 @@
 if ($bExtendSelection) {
 }
 
+/************************************************************************/
+/*         Save the query file here before doing any raster queries     */
+/************************************************************************/
 if ($result->hasSelection) {
     $oMap->savequery(getSessionSavePath()."query.qy");
     $result->queryFile = getSessionSavePath()."query.qy";
+ }
 
+/*raster query: limit the result to 100 if it is not already set in the map fle*/
+for ($i=0; $i<$nLayers; $i++) {
+    if (!$bAllLayers) {
+        $oLayer = $oMap->GetLayerByName($layers[$i]);
+    } else {
+        $oLayer = $oMap->GetLayer($i);
+    }
+    $oLayer->set('tolerance', 0);
+    if ($oLayer->type != MS_LAYER_RASTER)
+        continue;            
+    
+    $aProcessings = $oLayer->getprocessing();
+
+    $nCount = count($aProcessings);
+    $bRasterMaxSet = 0;
+    for ($i=0;$i<$nCount; $i++)
+    {
+        $aKeyVal = explode("=", $aProcessings[$i]);
+        if (count($aKeyVal) == 2 && 
+            strcasecmp(trim($aKeyVal[0]), "RASTER_QUERY_MAX_RESULT") == 0)
+        {
+            $bRasterMaxSet = 1;
+            break;
+        }
+    }
+
+    if (!$bRasterMaxSet)
+      $oLayer->setprocessing("RASTER_QUERY_MAX_RESULT=100");
+
+    /*are we doing a point query? In that case maxfeatures was set to 1*/
+    /*this is not ideal but It is better to use querybypoint when we do point query and
+      a query by shape when we do other type of queries*/
+    if (isset($_REQUEST['maxfeatures']) && $_REQUEST['maxfeatures'] == '1')
+    {
+        $oCenterPoint = ms_newpointobj();
+        $oPoint = $oSpatialFilter->getCentroid();
+        $status = $oLayer->queryByPoint($oPoint, MS_SINGLE, -1);
+    }
+    else
+      $status = @$oLayer->queryByShape($oSpatialFilter);
+
+    if ($status == MS_SUCCESS) {
+        $result->hasSelection = true;
+        $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 ($result->hasSelection) {
     /*holds selection array*/
     $properties = NULL;
     $properties->layers = array();

Modified: sandbox/jxlib-3.0/layers/MapServer/php/Selection.php
===================================================================
--- sandbox/jxlib-3.0/layers/MapServer/php/Selection.php	2010-05-20 20:17:34 UTC (rev 2163)
+++ sandbox/jxlib-3.0/layers/MapServer/php/Selection.php	2010-05-20 20:41:30 UTC (rev 2164)
@@ -44,9 +44,12 @@
 
 
 
-if (isset($_REQUEST['queryfile']) && $_REQUEST['queryfile'] != "")
+if ((isset($_REQUEST['queryfile']) && $_REQUEST['queryfile'] != "") ||
+    isset($_SESSION['selection_array']))
+  
 {
-    $oMap->loadquery($_REQUEST['queryfile']);
+    if (isset($_REQUEST['queryfile']) && $_REQUEST['queryfile'] != "")
+      $oMap->loadquery($_REQUEST['queryfile']);
 
 
     if (isset($_SESSION['selection_array']))



More information about the fusion-commits mailing list