[maplab-users] locate a address in a map

claudio c.trevisani at ig.com.br
Sun Aug 1 12:21:34 EDT 2004


Hi,

For first excuse my english. I'm from Brazil and im speaking a bad english.
I' m working on a project for public safety in my country.
I'm using maplab v2.0, mapserver 4.0.1 and PHP 4.3.3 on windows

I read the message post by Paul Spencer at 07 Oct 2002 about locate a address (see above) and I put this code in my application:

if ( $http_form_vars["parcel-number"] )
{
// the parcel number to query for
$szParcelNumber = $http_form_vars["parcel-number"];

// the current extents will be the default if we fail.
$oExtents = $oMapSession->oMap->extents;

//first we need a handle on the layer, let's assume that we have
//it's name
$oParcelLayer = $oMapSession->oMap->getLayerByName( "Parcels" );

// set up the layer for a query in ms 3.6 - in 3.7 we don't need
// to do this, we can just use querybyattribute.  Here we assume
// that the data file associated with the layer has an attribute
// called parcel_number that we are querying.
$oParcelLayer->set( "FILTERITEM", "parcel_number" );
$oParcelLayer->setFilter( $szParcelNumber );

// use querybyattribute to generate the result, assume a single
// one for simplicity but this can be extended to multiple
// results easily
$oParcelLayer->queryByAttribute( MS_SINGLE );

//now check to see if there are any results?
if ($oParcelLayer->getNumResults() > 0 )
{
//at least one result, assume only one for this example
$oResult = $oParcelLayer->getResult( 0 );
//oResult is a resultCacheMemberObj
$oShape = $oParcelLayer->getShape( $oResult->tileindex,
   $oResult->shapeid );
$oExtents = $oShape->bounds;
$oShape->free();

//at this point we might add a buffer to the extents
$nXBuffer = ( $oExtents->maxx - $oExtents->minx )*0.05;
$nYBuffer = ( $oExtents->maxy - $oExtents->miny )*0.05;
$nMinX = $oExtents->minx - $nXBuffer;
$nMaxX = $oExtents->maxx + $nXBuffer;
$nMinY = $oExtents->miny - $nYBuffer;
$nMaxY = $oExtents->maxy + $nYBuffer;
$oExtents->setExtents( $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($oExtents->minx, $oExtents->miny,
      $oExtents->maxx, $oExtents->maxy);

// alternately if it's a point and a scale ...
// $oMapNavigator->zoomScale( $nScale, $nX, $nY );
}

Whem I enter the parcel-number value, I get the error: 

Fatal error: [MapServer Error]: msCalculateScale(): Invalid image extent. in c:\......etc

What is wrong???

Claudio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/maplab-users/attachments/20040801/bac94037/attachment.htm


More information about the Maplab-users mailing list