" . gmdate("D, d M Y H:i:s") . "

"; echo "

Search string:

" . $_REQUEST['searchstring'] . "

"; /** * Mapscript query example, with both POSTGIS and SHAPEFILE * in this example we want to query all the map layers with layer metadata * value searchfield **/ //include_once ('../../../../include/ka-map/config.php'); include_once ('../../ka-map/include/config.php'); //Delamo Edit if (!extension_loaded('MapScript')) { dl($szPHPMapScriptModule); } $oMap = ms_newMapObj($szMapFile); $oMap->preparequery(); $tot = $oMap->numlayers; //number of layers in map ?> 100001){ echo " Identify system has 100000 as minimum scale"; die; } */ echo "
"; $totResults = 0; //LOOP ON LAYERS for ($i = 0; $i < $tot; $i++) { $oLayer = $oMap->getLayer($i); //CHECKING GROUPS FOR VISIBILITY if ($oLayer->type != MS_LAYER_RASTER && $oLayer->getMetaData('searchfield') != "") { //echo($oLayer->group); //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); if (!$oLayer->isVisible() && ($oLayer->minscale < $scale && $oLayer->maxscale > $scale)) { $oLayer->set("minscale", 0); $oLayer->set("maxscale", (200000000)); // has to be greater that map maximum scale } } else { $oLayer->set('status', MS_OFF); if (!$oLayer->isVisible() && ($oLayer->minscale < $scale && $oLayer->maxscale > $scale)) { $oLayer->set("minscale", 0); $oLayer->set("maxscale", (200000000)); // has to be greater that map maximum scale } continue; }*/ $szSearchfield = $oLayer->getMetaData('searchfield'); //PRINTING STUFF if($oLayer->connectiontype == MS_POSTGIS){ //$searchstring = "\"".$szSearchfield."~* '".$searchstring."'\""; //Kumar Edit $searchstring = "($szSearchfield ilike '%$psearch%')"; } else { $searchstring = "\"".$szSearchfield."~* '".$psearch."'\""; } if ($oLayer->queryByAttributes($szSearchfield, $searchstring, MS_MULTIPLE) == MS_SUCCESS) { //echo "
num records:".$oLayer->getNumResults(); $totR = $oLayer->getNumResults(); $totResults = $totResults + $totR; echo "

Layer Name:

" . $oLayer->name . "
"; if($max_results_per_layer < $totR) echo "

results: $max_results_per_layer of $totR (limited output)

"; else echo "

results: $totR

"; $oLayer->open(); // METADATA $szFields = $oLayer->getMetaData("fields"); //echo "
Fields".$szFields; if ($szFields != '') { $aField = explode(',', $szFields); foreach ($aField as $key => $value) { $field = explode(':', $value); $fields[$field[0]] = (count($field) == 2) ? $field[1] : null; } } //get hyiperlink $szHyperlink = $oLayer->getMetaData("hyperlink"); if ($szHyperlink != '') { $hyperlink = explode('|', $szHyperlink); } else $hyperlink = null; //END METADATA echo ""; if ($totR) { $oResultCache = $oLayer->getResult(0); $oShape = $oLayer->getShape($oResultCache->tileindex, $oResultCache->shapeindex); $aKeys = array_keys($oShape->values); foreach ($aKeys as $key) { $aKeysNormal[] = strtoupper($key); } echo ""; foreach ($fields as $key => $value) { if (in_array(strtoupper($key), $aKeysNormal)) { echo ""; } else unset ($fields[$key]); } if ($hyperlink) { if (in_array($hyperlink[0], $aKeys)) echo ""; else $hyperlink = null; } echo ""; echo ""; /* //ALL FIELDS echo ""; foreach($aKeys as $key){ echo ""; } echo "";*/ $oShape->free(); } if ($totR > $max_results_per_layer) $totR = $max_results_per_layer; for ($a = 0; $a < $totR; $a++) { $oResultCache = $oLayer->getResult($a); $oShape = $oLayer->getShape($oResultCache->tileindex, $oResultCache->shapeindex); $aValues = $oShape->values; //Calculate centroid for example tooltipe needs $x_c = ($oShape->bounds->minx + $oShape->bounds->maxx) / 2; $y_c = ($oShape->bounds->miny + $oShape->bounds->maxy) / 2; //$aTmp = array_merge( $aTmp , array('x' => $x,'y' => $y, 'id' => $result->shapeindex)); //Calculate area coordinates for example function gotorectangle $xmin = $oShape->bounds->minx; $xmax = $oShape->bounds->maxx; $ymin = $oShape->bounds->miny; $ymax = $oShape->bounds->maxy; echo ""; //echo ""; foreach ($fields as $key => $value) { if ($aValues[strtoupper($key)]) { $val = $aValues[strtoupper($key)]; } else if ($aValues[strtolower($key)]) { $val = $aValues[strtolower($key)]; } else if ($aValues[$key]) { $val = $aValues[$key]; } else { $val = " "; } echo ""; } echo ""; //if($value)echo ""; //else echo ""; echo ""; $oShape->free(); } echo "
" . $fields[$key] . "" . $hyperlink[0] . " - hyperlinkZoom to
$key
".print_r($aValues)."$val\"zoom$value 

"; if ($totR > $max_results_per_layer) echo "Too many values to output, please reduce the request."; $oLayer->close(); $fields = array (); } } } //$image=$oMap->drawQuery(); //$url=$image->saveWebImage(); if ($totResults) { // echo "
tot res:$totResults
"; } else echo "
no matching results

"; ?>