<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman,new york,times,serif;font-size:12pt"><div>This worked perfectly!&nbsp; Thanks Daniel. <br><br>I'm now looking at something like <br><br>&nbsp;if(@$shpA-&gt;intersection($shapeB)==FALSE){<br>&nbsp;&nbsp;&nbsp; //flag as bad geometry<br>}else {<br>&nbsp;&nbsp;&nbsp; $clippedShpA = $shpA-&gt;intersection($shapeB);<br>&nbsp;&nbsp;&nbsp; // ... the rest<br>}<br></div><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><br>Cheers, <br><br>Josh<br><div style="font-family: arial,helvetica,sans-serif; font-size: 13px;"><font face="Tahoma" size="2"><hr size="1"><b><span style="font-weight: bold;">From:</span></b> Daniel Morissette &lt;dmorissette@mapgears.com&gt;<br><b><span style="font-weight: bold;">To:</span></b> mapser all users &lt;mapserver-users@lists.osgeo.org&gt;<br><b><span style="font-weight:
 bold;">Sent:</span></b> Wed, October 14, 2009 7:30:32 PM<br><b><span style="font-weight: bold;">Subject:</span></b> Re: [mapserver-users] catching GEOS errors in PHP mapscript<br></font><br>Joshua Hevenor wrote:<br>&gt; I'm doing a fairly simple geo-processing script in PHP but I'm running into some trouble.&nbsp; I have two polygon layers and I'm trying to look up all polygons from layer A that are not disjoint from layer B.&nbsp; 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.&nbsp;  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?&nbsp; I don't see one in the PHP documentation. Can I catch these errors somehow? <br><br>That depends on which error
 you get. You can usually catch errors in PHP using the "@" Error Control Operator, see:<br><a href="http://www.php.net/manual/en/language.operators.errorcontrol.php" target="_blank">http://www.php.net/manual/en/language.operators.errorcontrol.php</a><br><br>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:<br><br>if (@$shape1-&gt;intersection($shape2) == FALSE)<br>{<br>&nbsp; // Handle error situation<br>}<br><br>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.<br><br>Daniel<br>-- Daniel Morissette<br><a href="http://www.mapgears.com/" target="_blank">http://www.mapgears.com/</a><br>_______________________________________________<br>mapserver-users mailing list<br><a ymailto="mailto:mapserver-users@lists.osgeo.org" href="mailto:mapserver-users@lists.osgeo.org">mapserver-users@lists.osgeo.org</a><br><a href="http://lists.osgeo.org/mailman/listinfo/mapserver-users" target="_blank">http://lists.osgeo.org/mailman/listinfo/mapserver-users</a><br></div></div></div></body></html>