[mapserver-users] Re: Opening layer with PHP/Mapscript

Natán natancalzolari at gmail.com
Wed Sep 2 19:25:52 EDT 2009


Thank you for answering. The problem was that the shapefile was named
"distrito.dbf" and the DBF file was named "Distrito.dbf", and Linux is
case sensitive, so it didn't really find the file.

Sorry for wasting your time, and thanks again.

Natán

> Natán,
> I cannot reproduce this error, but normally I query the layer first (query functions are queryByPoint, queryByRect, queryByShape ...) then I invoke the open() function to read attributes of shapes:
>
>
>                $qLay = $oMap->getLayerByName('europa');
>                $qLay->queryByRect($oMap->extent);
>                $results = $qLay->getNumResults();
>                echo $results."<br>\n";
>                if ($results > 0) {
>                        $qLay->open();
>                        for ($i=0;$i<$results;$i++){
>                                $res = $qLay->getresult($i);
>                                $feature = $qLay->getShape($res->tileindex,$res->shapeindex);
>                                if ($feature){
>                                        echo "country: ".$feature->values['CNTRYNAME']."<br>\n";
>                                }
>                        }
>                        $qLay->close();
>                }
>
>
> This works in MapServer 5.2.1.
> Bye.
> ..................................pg
>
> Pietro Giannini
> Bytewise srl - Area GIS
> 41°50'38.58"N 12°29'13.39"E
>
> -----Messaggio originale-----
> Da: mapserver-users-bounces at lists.osgeo.org [mailto:mapserver-users-bounces at lists.osgeo.org] Per conto di Natán
> Inviato: mercoledì 2 settembre 2009 9.46
> A: mapserver-users at lists.osgeo.org
> Oggetto: [mapserver-users] Opening layer with PHP/Mapscript
>
> In my PHP code I do:
>
> $map = ms_newMapObj("docs/distrito.map");
> $layer = $map->getLayerByName("Distrito");
> $layer->open();
>
> The open() method returns me a warning like this:
>
> Warning: [MapServer Error]: msShapefileOpen():
> (/var/www/ajax/docs/distrito.dbf) in /var/www/ajax/index.php on line 6
>
> I know the map has loaded properly because I tried echoing
> $map->numlayers and it outputs the number of layers correctly.
> Also, the layer has loaded properly; I tried echoing
> $layer->numclasses and it outputs correctly.
>
> But when trying to use the open method, I get that problem. It points
> at the .DBF file, I don't know which could be the problem.
>
> Any help would be amazing.
>
> Natán


More information about the mapserver-users mailing list