[mapserver-users] Fwd: php mapscript bug when using getshape

Michael Schulz mschulz at webgis.de
Wed Jul 31 11:08:05 EDT 2002


Hi Sylvain,

i think you have to use $layer->open() explicitly before using getshape() and when
finished $layer->close()

from the php/mapscript docs:
---
layerObj
    ...
    int open(string shapepath)
         Open the layer for use with getShape().
         Returns MS_SUCCESS/MS_FAILURE
    ...

    void close()
         Close layer previously opened with open().
---

Cheers, Michael



Steve Lime schrieb:

> Betreff: php mapscript bug when using getshape
> Datum: Wed, 31 Jul 2002 16:01:24 +0200
> Von: Sylvain Pasche <sylvain_pasche at yahoo.fr>
> An: mapserver-bugs at lists.gis.umn.edu
>
> Hello,
>
> I had a discussion with some developers recently, about a bug using
> getshape in php, but the thread ended without response.
>
> When running the code below, mapserver segfaults.
>
> The problem is caused by the fact that msquerybypoint closes the layer
> upon completion. But php mapscript still has a reference on the
> corresponding layer. So, when it make a getshape request with the
> freed layer, as the shapefile is closed, it segfaults.
>
> Uncommenting the following line prevents mapserver from segfaulting,
> this is just to identify the problem.
>
> line 929 in mapquery.c
>
> //msLayerClose(lp);
>
> Sylvain
>
> PS: is this mail adress a mailing list, or just an alias ?
>
> -----------------BEGIN testcase.php
>
> dl("php_mapscript.so");
>
> $Map =
> ms_newMapObj("/home/sypasche/public_html/cartoserver/mapfiles/testcase/testcase.map");
>
> $Map->setextent(530000.610972,76797.7871943,610002.242216,156799.418438);
>
> $layer = $Map->getlayerbyname("cabanes");
>
>
> $click_geo = ms_newPointObj();
> $click_geo->setxy(558401.190064, 112598.517176);
>
> $res = $layer->queryByPoint($click_geo, MS_MULTIPLE, -1);
>
> print  "num res " .  $layer->getNumResults() . " <br />";
>
> $cache = $layer->getResult(0);
>
> var_dump($cache);
>
> // here the cache contains shapeindex 2, tileindex -1
>
> // using $num in getshape, produces:
> // 2 -> segfault
> // 50 -> Assertion failed, Could not set shape values: 0, 0
>
> $num = 2;
>
> if(1)
> $shape = $layer->getShape(-1,
>                           $num);
>
> $map_img = $Map->draw();
> $url =  $map_img->saveWebImage(MS_PNG,0,0,60);
>
> echo "<br /> <img src=\"http://localhost$url\" />";
>
> ---------------END testcase.php

--
-----------------------------------------------------------
Michael Schulz                                in medias res
Dipl.-Geologe                              Gesellschaft für
                                Informationstechnologie mbH
                             Sautierstr. 38, 79104 Freiburg
                                     0761 55695-95 (Fax 96)
mschulz at webgis.de                             www.webgis.de





More information about the mapserver-users mailing list