Catching error of getShape - php_mapscript

Jacob Delfos jacob.delfos at MAUNSELL.COM
Thu Jun 16 18:35:55 PDT 2005


Hi Julien,

Thanks for your suggestion. I have tried it, but it didn't work. I have tried using my own error handler (with set_error_handler), but even if I do that, my php log says:

[17-Jun-2005 09:23:21] PHP Fatal error:  [MapServer Error]: msLayerGetShape(): Invalid feature id.

I also get this when using the mapserver error object. I guess it's because the getShape function generates a fatal error, which in php will always result in script termination. 

I guess my problem is using php_mapscript_44 and php4. If I used php 5 I could use a "try catch" statement....

Regards,

Jacob


-----Original Message-----
From: Julien-Samuel Lacroix [mailto:jlacroix at dmsolutions.ca] 
Sent: 16 June 2005 23:00
To: Jacob Delfos
Cc: MAPSERVER-USERS at LISTS.UMN.EDU
Subject: Re: [UMN_MAPSERVER-USERS] Catching error of getShape - php_mapscript

Hi,

With Mapscript there's the errorObj object that can do exactly what you 
want I think. There's an example of how to use it in the doc.

http://mapserver.gis.umn.edu/doc44/phpmapscript-class-guide.html#errorobj

Julien

On 06/16/2005 03:04 AM, Jacob Delfos wrote:
> Hi all,
> 
> Can anyone tell me if there is a way to catch the error that getShape 
> throws if you request a shape that is out of range?
> 
> Reason is I'm trying to iterate through a layer. At this stage, I need 
> to use an object count to make the loop stop. Getting an object count 
> either requires me to use the shpfileobj->numshapes variable (which 
> obviously only works on shapefiles), or doing a query (which would only 
> work on layers with templates, which would need a reprojected rectangle, 
> uses overhead, etc..).
> 
> Would it be possible to make getShape return MS_FAILURE if the object is 
> out of range, or throw a warning that can be caught using '@' error 
> suppression? That way one could iterate through a whole layer without 
> needing a layer count.
> 
> Regards,
> 
> Jacob
> 
>  
> 
> * *
> 
> *JACOB DELFOS
> SPATIAL INFORMATION ANALYST
> *Maunsell Australia Pty Ltd
> 629 Newcastle Street, Leederville, WA 6007
> 
> PO Box 81, Leederville, WA 6902
> 
> Western Australia
> 
> ABN 20 093 846 925
> 
> Tel     + 61 8 9281 6185
> Fax    + 61 8 9281 6297
> _jacob.delfos at maunsell.com_
> 

-- 
------------------------------------------------------------
Julien-Samuel Lacroix            jlacroix at dmsolutions.ca
DM Solutions Group               http://www.dmsolutions.ca/
------------------------------------------------------------

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20050617/be6ebbc9/attachment.htm>


More information about the MapServer-users mailing list