[Mapserver-users] QueryByAttribute

Ganesh Pulicherla ganesh at cs.und.edu
Thu Apr 29 15:13:55 EDT 2004


I hope you figured out the mistake by now. If not, check the if condition, you 
are assigning the value instead of comparing...:

 if ( $oQueryStatus == MS_FAILURE )
 {
  echo  "<td ><b> Query Failed ... \"".$szPincode."\" </b></td>";
  echo "<td> Query Status = ".$oQueryStatus."</td>";
 }

Regards
Ganesh


Quoting "Ryan, Adam" <ARyan at co.linn.or.us>:

>  
> Just a hunch, I needed parentheses.  Instead of 
>  
> $oQueryStatus = $oPincodeLayer->queryByAttributes("OUT_CODE",
> "\"".$szPincode."\"",MS_SINGLE);
> 
>  
> try
>  
> $oQueryStatus = $oPincodeLayer->queryByAttributes("OUT_CODE",
> "(\"".$szPincode."\")",MS_SINGLE);
> 
>  
> Hope it helps,
>  
> Adam
>  
> 
> -----Original Message-----
> From: Satyajit [mailto:satyajit.gantayat at aurovision.com] 
> Sent: Wednesday, April 28, 2004 12:39 AM
> To: mapserver-users at lists.gis.umn.edu
> Subject: [Mapserver-users] QueryByAttribute
> 
> 
>  Hi Folks,
> 
>        I have been banging my head since a couple of days with this code. I
> am trying to build an application where the user can search for a specific
> postcode and then the map will zoom into that particular extent. 
>  When the user enters a postcode ( I call it PINCODE) in the inputbox we
> search the pincode in the pincode shape file and set the map's extent to
> that of the shape found.
> But the following code is not working. The queryByAttributes function is
> reporting MS_FAILURE. This code is some what similar to that in one of the
> listings. It would beb great if somebody guide me through step by step
> procedure of developing this kind of QueryByAttribute feature using
> Mapserver.
>  
>  
> if ($http_form_vars["Pincode"])
> {
>  // the pincode to query for
>  $szPincode = $http_form_vars["Pincode"];
>  
>  $oPincodeLayer = $oMapSession->oMap->getLayerByName("Pincode");
>  
> // OUT_CODE is the field name which contains the value which would be
> queried. 
>  
> $oQueryStatus = $oPincodeLayer->queryByAttributes("OUT_CODE",
> "\"".$szPincode."\"",MS_SINGLE);
>  
>  if ( $oQueryStatus = MS_FAILURE )
>  {
>   echo  "<td ><b> Query Failed ... \"".$szPincode."\" </b></td>";
>   echo "<td> Query Status = ".$oQueryStatus."</td>";
>  }
>  else
>  {
>   if ($oPincodeLayer->getNumResults() > 0)
>   {
>    $oResult = $oPincodeLayer->getResult(0);
>    $oOpen = $oPincodeLayer->open();
>    
>    $oShape = $oPincodeLayer->getShape($oResult->tileindex,
> $oResult->shapeid);
>    
>    $oExtents = $oShape->bounds;
>    
>    $oShape->free();
>  
>    //at this point we might add a buffer to the extents
>    $nMinX = $oExtents->minx;
>    $nMaxX = $oExtents->maxx;
>    $nMinY = $oExtents->miny;
>    $nMaxY = $oExtents->maxy;
>    
>    $oExtents->setExtent( $nMinX, $nMinY, $nMaxX, $nMaxY );
>   }
>   // now use $oMapNavigator to navigate to the parcel
>   // location.  There are two useful options now.  We
>   // can zoom to a rectangle which we have calculated or
>   // to a point and scale.  Let's assume we have calculated
>   // a rectangle and put a buffer around it if necessary.
>   //$oMapNavigator->zoomRectangle($nMinX,  $nMinY,
>         //$nMaxX, $nMaxY);
>    $oMapSession->oMap->setExtent( $oExtents->minx, $oExtents->miny,
> $oExtents->maxx, $oExtents->maxy );
>  }
> }
>  
> 
>  I am using
>     MapServer/MapScript 4.0
>     PHP 4.3
>     MapLab 2.1
>    
>  
> Thanks and Regards
> Satyajit G.
>     
>  
> 
> 
> 
> 	Imaging the way ahead ...	
> 	
> 
> Satyajit Gantayat
> Sr. Specialist GIS 	
> Aurovision Pvt. Ltd.
> 101, Swati
> North Avenue
> Santacuz (w)
> Mumbai - 400054
> India 
> 	
> tel: 	91-22-56982010 	
>  	
> 
> 	 	
> 	
> 	
>  <https://www.plaxo.com/add_me?u=25769950220&v0=291241&k0=719474838> 
	
>  
> 
> 







More information about the mapserver-users mailing list