[mapserver-users] getLayer dies without error, php mapscript

Daniel Morissette morissette at dmsolutions.ca
Mon Apr 29 08:22:12 EDT 2002


Robert,

I tried your script and couldn't produce a crash.  All I got was an
"invalid shape id" error from the getShape() call which was due to the
fact that the layer was not opened before the call to getShape()... I
added a call to $thislayer->open($map->shapepath); before the getShape()
call, and the script works fine for me.

I tested this on Linux with the MapServer CVS source from end of last
week.  Which version of MapServer are you using and on which OS?

Daniel



Robert Burgholzer wrote:
> 
>  Hello,
> I am trying to retrieve and work on a shape from a layer (see code below
> and map files snippet). All works well with my map, including showing
> the map, and verifying that I can grab layers objects, etc. When I try
> to retrieve a shape from a layer though, my script dies without warning.
> I know that the layer 'microhup' exists in my map, and I know that it
> has 125 data lines, which I assume are shapes (microhup is an esri
> polygon shape file, with all of its subordinate files, .dbf, .shx,
> etc.), and I also know that the column "ID" exists in this file. In the
> code below, I have queried for record 1 (see getShape(-1,1), it is an
> untiled layer), to see if I can view its props. Can anyone tell me what
> I am missing, or point me to something which might explain teh process
> of retrieving individual shapes from a layer?
> 
> <start php mapscript snippet.... >
>      $map = ms_newMapObj($map_path.$map_file);
>        $lname = "microhup";
>        $thislayer = $map->getLayerByName($lname);
>        $lci = $thislayer->classitem;
>        $data = $thislayer->data;
>        $res = $thislayer->getShape(-1,1);
>        $reso = $res->type;
>        $resi = $res->values["ID"];
>        print("$reso: $resi,");
>        $res->free();
> <... edn php mapscript snippet>
> <start map file snip>
> LAYER
>    NAME microhup
>    TYPE POLYGON
>    STATUS ON
>    DATA microhup
>    FILTER "1 = 1"
>    TOLERANCE 10
>    CLASS
>       TEMPLATE void
>       COLOR -1 -1 -1
>       OUTLINECOLOR 200 200 200
>       #EXPRESSION ([ID] <= 20)
>    END
> 
> END
> <... end map file snip>
> 
> --
> Robert Burgholzer
> al·go·rithm  n.
>        A step-by-step problem-solving procedure, especially an
> established, recursive computational
>        procedure for solving a problem in a finite number of steps.
> Invented by Al Gore.
> rburghol at vt.edu
> http://www.soulswimmer.net/



More information about the mapserver-users mailing list