[mapserver-users] catching GEOS errors in PHP mapscript
Joshua Hevenor
jhevenor at rogers.com
Thu Oct 15 07:15:52 PDT 2009
This worked perfectly! Thanks Daniel.
I'm now looking at something like
if(@$shpA->intersection($shapeB)==FALSE){
//flag as bad geometry
}else {
$clippedShpA = $shpA->intersection($shapeB);
// ... the rest
}
Cheers,
Josh
________________________________
From: Daniel Morissette <dmorissette at mapgears.com>
To: mapser all users <mapserver-users at lists.osgeo.org>
Sent: Wed, October 14, 2009 7:30:32 PM
Subject: Re: [mapserver-users] catching GEOS errors in PHP mapscript
Joshua Hevenor wrote:
> I'm doing a fairly simple geo-processing script in PHP but I'm running into some trouble. I have two polygon layers and I'm trying to look up all polygons from layer A that are not disjoint from layer B. I'm also looking at specific area so if the polygon from layer B is bigger than my map extent I'm trying to clip (using shapeobj::intersection) to the map extent. On occasion I'm getting GEOS errors that show up in my PHP error log and kill my script. The errors are from bad shapes (things like a rectangle built wrong so that it looks more like an hour glass). Is there a function to verify the shape? I don't see one in the PHP documentation. Can I catch these errors somehow?
That depends on which error you get. You can usually catch errors in PHP using the "@" Error Control Operator, see:
http://www.php.net/manual/en/language.operators.errorcontrol.php
Unfortunately some functions in PHP MapScript produce fatal PHP errors that cannot be trapped this way, and we fix them as problems are reported. However based on a quick browse of the PHP MapScript source code that doesn't seem to be the case of GEOS operators which seem to simply return FALSE in case of errors, so it should be possible to handle those errors using something like:
if (@$shape1->intersection($shape2) == FALSE)
{
// Handle error situation
}
I didn't test this with the GEOS operators myself, but I'd suggest you try and see if that solves your issue. If not then we will need more specific error messages and some sample code in order to help you further.
Daniel
-- Daniel Morissette
http://www.mapgears.com/
_______________________________________________
mapserver-users mailing list
mapserver-users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20091015/e5df054b/attachment.htm>
More information about the MapServer-users
mailing list