[ka-Map-users] query system

Lorenzo Becchi ka-map at ominiverdi.com
Tue Aug 30 14:45:53 EDT 2005


Hola Renè,
I've already tried to post our query system but I don't know what  
happened it's not in the list.

anyway

this PHP page expects some $_REQUEST variables
mX (X coordinate of the point clicked)
mY (Y coordinate of the point clicked)
groups (CSV for active layers)
extent ( the extend to show in the little map)

Es:
map_query.php? 
mX=1677457.42&mY=4838168.22&groups=&extent=1382182.5869547366|4641318.32 
7021438|1946273.9490120679|4975751.4797608685

you can use our rischio.js class to query this page or you can develop  
your own.
We hope to hoffer a better code soon (with a better name than RISCHIO,  
maybe).

------------------------------------------------------------------------ 
---------------------------------------
<?php
//ERROR HANDLING
if(isset($_REQUEST['debug'])) error_reporting ( E_ALL );
else error_reporting( E_ERROR );

include_once( 'config.php' );

if (!extension_loaded('MapScript'))
{
     dl( $szPHPMapScriptModule );
}




$oMap = ms_newMapObj($szMapFile);

if (isset($_REQUEST['mX']) && isset($_REQUEST['mY']))
{
     $mX= $_REQUEST['mX'];
     $mY= $_REQUEST['mY'];
} else
{
     echo "non ci sono mX e mY. bona";
         die;
}
if (isset($_REQUEST['groups']))$groups=$_REQUEST['groups'];
else $groups="";
$aGroup=explode(',',$groups);

if (isset($_REQUEST['extent']))$extent=$_REQUEST['extent'];
else $extent="";
$aExtent=explode('|',$extent);


//SETTING MAP EXTENT.
$mapExtent = $oMap->extent;
if ((abs($mapExtent->maxx - $mapExtent->minx) -  
abs($aExtent[2]-$aExtent[0]))>0){
     $oMap->setExtent($aExtent[0],$aExtent[1],$aExtent[2],$aExtent[3]);
}

// SETTING QUERY POINT
$point = ms_newPointObj();
$point->setXY($mX,$mY);

$oMap->preparequery();



?>
<html>
<head>
<title>
Query for: <?=$mX?> - <?=$mY?>
</title>
<style type="text/css">
body {
padding:0;
margin:0;
  font:arial,serif;
}

h2 {
     border:1px solid black;
     font-size:1.2em;
     padding:0.2em;
     background: gray;
     color: white;
}
th {
     border:1px solid black;
     font-size:0.9em;
     padding:0.2em;
     background: rgb(170,170,170);
     color: white;
     font-weight:bold;
}
td {
     border-bottom:1px solid black;
     font-size:0.9em;
     padding:0.2em;
}
#data{
     position:absolute;
     top:320px;
}
#image{
     position:absolute;
     top:0;
     border-top:2px solid black;
     border-bottom:2px solid black;
     width:100%;
     text-align:center;
     margin-top:10px;
     margin-bottom:10px;

}
img {
     padding:5px;
     margin:2px;
     border:1px solid black;
}
</style>
</head>
<body>
<div id="data">
<?php


//LOOP ON LAYERS
$tot = $oMap->numlayers;
for($i=0;$i<$tot;$i++){
         $oLayer= $oMap->getLayer($i);
         //CHECKING GROUPS FOR VISIBILITY
         if($oLayer->type != MS_LAYER_RASTER ){
                 //if BASE group
                 if($oLayer->group=="")$oLayer->set('status',MS_ON);
                 //if on visible group
                 elseif  
(in_array($oLayer->group,$aGroup))$oLayer->set('status',MS_ON);
                 else{
                 $oLayer->set('status',MS_OFF);
                 continue;
                 }

                 //PRINTING STUFF

                 if($oLayer->queryByPoint($point,MS_MULTIPLE,50.0) ==  
MS_SUCCESS){
                         echo "<h2>Layer Name:".$oLayer->name."</h2>";
                         //echo "<br>num  
records:".$oLayer->getNumResults();
                         $totR = $oLayer->getNumResults();
                         //echo "<br> totR:".$totR;
                         $oLayer->open();
                         echo "<table>";
                         if($totR){
                                 $oResultCache = $oLayer->getResult($a);
                                 $oShape =  
$oLayer->getShape($oResultCache->tileindex,$oResultCache->shapeindex);
                                 $aKeys = array_keys($oShape->values);
                                 echo "<tr>";
                                 foreach($aKeys as $key){
                                     echo "<th>$key</th>";
                                 }
                                 echo "<tr>";
                                 $oShape->free();
                         }

                         for($a=0;$a<$totR;$a++){
                                 $oResultCache = $oLayer->getResult($a);
                                 $oShape =  
$oLayer->getShape($oResultCache->tileindex,$oResultCache->shapeindex);
                                 $aValues =  
array_values($oShape->values);
                                 echo "<tr>";
                                 foreach($aValues as $value){
                                     if($value)echo "<td>$value</td>";
                                     else echo "<td>&nbsp;</td>";
                                 }
                                 echo "<tr>";
                                 $oShape->free();
                         }
                         echo "</table>";
                         $oLayer->close();
                 }
         } else if($oLayer->type == MS_LAYER_RASTER)
         {
                 if($oLayer->group=="")$oLayer->set('status',MS_ON);
                 //if on visible group
                 elseif  
(in_array($oLayer->group,$aGroup))$oLayer->set('status',MS_ON);
                 else{
                 $oLayer->set('status',MS_OFF);
                 continue;
                 }
         }
}

$image=$oMap->drawQuery();
$url=$image->saveWebImage();
?>
</div>
<div id="image">
<img src="<?=$url?>">
</div>
</body>
</html>
------------------------------------------------------------------------ 
----------------------------------------------------

ciao


Date: Mon, 29 Aug 2005 16:50:57 -0400
From: Ren? F. Viancos S. <rviancos at gmail.com>
Subject: [ka-Map-users] coordinates
To: ka-map-users at lists.maptools.org
Message-ID: <842c1e6605082913507c2c1e77 at mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

Hi Lorenzo, I'm searching for a query system for kamap and i found your  
post
in the list, and its very vell...

My question is: can you share your new query class ???

Best Regards

-- 
René F. Viáncos S.
Ingeniero Consultor en Geomática y TIC
Vicerrectoría de Investigación y Desarrollo
Universidad de Chile
Tel (56-2) 632 51 15
Cel (56 9) 933 72 66
rviancos at uchile.cl
rviancos at gmail.com
www.investigacion.uchile.cl <http://www.investigacion.uchile.cl>




More information about the ka-Map-users mailing list