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

Giannini Pietro PGiannini at bytewise.it
Wed Sep 2 03:51:08 PDT 2009


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



More information about the MapServer-users mailing list