[maplab-users] Query Error (Wrong parameter count for ms_layer_obj)

Zak James zak4ms at gmail.com
Sun Jan 28 14:30:49 EST 2007


Hi Adriano,

Have you checked the value of $oMapSession->oMap->shapepath? Take a
look in the mapserver-users archive for more info on this, for
instance:

http://old-mapserver.gis.umn.edu/data2/wilma/mapserver-users/0206/msg00405.html

zak

On 1/19/07, Adriano Hantequeste Gomes <adrianohg at gmail.com> wrote:
> Hi All,
>
>
> I put this code im my Aplication.php:
>
> if ( $http_form_vars["nome_b"])
> {
>         // the parcel number to query for
>         $szParcelNumber = $http_form_vars["nome_b"];
>
>         // the current extents will be the default if we fail.
>         $oExtents = $oMapSession->oMap->extent;
>         $oldExtents=$oExtents;
>
>         //first we need a handle on the layer, let's assume that we have
>         //it's name
>         $oParcelLayer = $oMapSession->oMap->getLayerByName( "Bairros" );
>
>         // 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", "Nummer" );
>         $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->queryByAttributes("NOME_BAIRR",$szParcelNumber,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
>                 $oParcelLayer->open($oMapSession->oMap->shapepath);
>                 $oShape =
> $oParcelLayer->getShape($oResult->tileindex,$oResult->shapeindex);
>                 $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->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.
>         $breite=$oMapSession->oMap->width;
>         $hoehe=$oMapSession->oMap->height;
>
>         $px1=$breite/($oldExtents->maxx-$oldExtents->minx)*($oExtents->minx-$oldExtents->minx);
>
>         $px2=$breite/($oldExtents->maxx-$oldExtents->minx)*($oExtents->maxx-$oldExtents->minx);
>
>         $py1=$hoehe/($oldExtents->maxy-$oldExtents->miny)*($oldExtents->maxy-$oExtents->maxy);
>
>         $py2=$hoehe/($oldExtents->maxy-$oldExtents->miny)*($oldExtents->maxy-$oExtents->miny);
>
>         $oMapNavigator->zoomRectangle($px1, $py2, $px2, $py1);
>
>         // alternately if it's a point and a scale ...
>         //$oMapNavigator->zoomScale( 1000, 100, 100 );
> }
>
> ##################
>
>
> When i query retur this error:
>
> Warning: Wrong parameter count for ms_layer_obj::open() in
> D:\ms4w\apps\maplab-2.2.1\projects\gmf_apps\Geo\Geo.php on line 880
>
> Fatal error: [MapServer Error]: msLayerGetShape(): Shapefile layer has
> not been opened. in
> D:\ms4w\apps\maplab-2.2.1\projects\gmf_apps\Geo\Geo.php on line 881
>
>
>
> --
> Atenciosamente,
> Adriano Hantequeste Gomes
> CREA 080047648-4
> Departamento de Geoprocessamento - GEO
> Gerência de Estatística e Analise Criminal - GEAC
> Secretaria de Estado da Segurança Pública e Defesa Social - SESP
> Av. Marechal Mascarenhas de Moraes, 2355
> Bento Ferreira - Vitória - Espírito Santo
> CEP: 29.052-121
> Telefone: 55 27 3334-4736
> Fax:       55 27 3334-4735
> Celular:   55 27 9225-4852
>
>
> --
> Atenciosamente,
> Adriano Hantequeste Gomes
> CREA 080047648-4
> Departamento de Geoprocessamento - GEO
> Gerência de Estatística e Analise Criminal - GEAC
> Secretaria de Estado da Segurança Pública e Defesa Social - SESP
> Av. Marechal Mascarenhas de Moraes, 2355
> Bento Ferreira - Vitória - Espírito Santo
> CEP: 29.052-121
> Telefone: 55 27 3334-4736
> Fax:       55 27 3334-4735
> Celular:   55 27 9225-4852
>
> _______________________________________________
> Maplab-users mailing list
> Maplab-users at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/maplab-users
>


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



More information about the Maplab-users mailing list