[maplab-users] locate a address in a map

Zak James zak-ms at hoppsan.org
Tue Aug 3 14:52:50 EDT 2004


Claudio,

Try using a debugger, a print_r or echo statement near this line:
> $oExtents = $oShape->bounds;
to see what extents are being set. Are the parcel attribute in your dbf 
file and the mapfile layer name the same as those in the code? You 
could also check that the bounds of your shapefile fit within the map 
extents.

In your error message, where you have "etc" it would be helpful to know 
to which code it was referring.

Also, I don't think this is related to your problem, but Maplab 2.0 
isn't designed to work with Mapserver 4+. You need at least version 
2.1RC3 for that.

zak

--
Zak James
Applications and Software Development
DM Solutions Group Inc.
http://www.dmsolutions.ca


On Aug 1, 2004, at 12:21 PM, claudio wrote:

> 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
> _______________________________________________
> Maplab-users mailing list
> Maplab-users at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/maplab-users



More information about the Maplab-users mailing list