<html><body><div style="color:#000; background-color:#fff; font-family:garamond, new york, times, serif;font-size:14px"><div dir="ltr" id="yui_3_16_0_1_1424883046678_3031"><span>Hello,</span></div><div id="yui_3_16_0_1_1424883046678_3312" dir="ltr"><span id="yui_3_16_0_1_1424883046678_3313">I have a perl script which uses a geoJSON as input, and queries a table to see if any polygons exist in the table with any points in common. If any matches are found, they are returned as geoJSON. It's been working great, but yesterday I got an error. Here's my query:</span></div><div id="yui_3_16_0_1_1424883046678_3197" dir="ltr"><br><span></span></div><div id="yui_3_16_0_1_1424883046678_3169" dir="ltr"><span id="yui_3_16_0_1_1424883046678_3200">select ST_Asgeojson( geom ) from dynamic.polys where ST_Intersects(ST_GeomFromGeoJSON('$jsonPoly'), geom)=TRUE and ST_Area(ST_Intersection(ST_GeomFromGeoJSON('$jsonPoly')::geography, geom::geography))>500</span></div><div id="yui_3_16_0_1_1424883046678_3233" dir="ltr"><br></div><div id="yui_3_16_0_1_1424883046678_3432" dir="ltr">With my current issue, the $jsonPoly is the state of Californina. The select from dynamic.polys should return any polys in my database which have any points in common with California.<br></div><div id="yui_3_16_0_1_1424883046678_3449" dir="ltr"><br></div><div id="yui_3_16_0_1_1424883046678_3311" dir="ltr">However, yesterday I had a query which resulted in the following error:</div><div id="yui_3_16_0_1_1424883046678_3260" dir="ltr"><br></div><div id="yui_3_16_0_1_1424883046678_3259" dir="ltr">DBD::Pg::st execute failed: ERROR: Error performing intersection: TopologyException: Input geom 1 is invalid: Self-intersection at or near point -381688.06935935974 -1206669.4272876547 at -381688.06935935974 -1206669.4272876547 at ./test.pl line 151.<br style="" class="">DBD::Pg::st execute failed: ERROR: Error performing intersection: TopologyException: Input geom 1 is invalid: Self-intersection at or near point -381688.06935935974 -1206669.4272876547 at -381688.06935935974 -1206669.4272876547 at ./test.pl line 151.<br style="" class=""></div><div id="yui_3_16_0_1_1424883046678_3286" dir="ltr"><br></div><div id="yui_3_16_0_1_1424883046678_3297" dir="ltr"> ( line 151 is the perl code: $sth->execute(); )</div><div id="yui_3_16_0_1_1424883046678_3310" dir="ltr"><br></div><div id="yui_3_16_0_1_1424883046678_3309" dir="ltr">I isolated which JSON poly was causing the issue, and saved it here: <a id="yui_3_16_0_1_1424883046678_3337" href="http://microflush.org/stuff/json/nwsZone.json">http://microflush.org/stuff/json/nwsZone.json</a></div><div id="yui_3_16_0_1_1424883046678_3339" dir="ltr"><br></div><div id="yui_3_16_0_1_1424883046678_3518" dir="ltr">I verified the geoJSON, and verified it plots entirely within California using <a id="yui_3_16_0_1_1424883046678_3520" href="http://geojsonlint.com/">http://geojsonlint.com/</a></div><div id="yui_3_16_0_1_1424883046678_3522" dir="ltr"><br></div><div id="yui_3_16_0_1_1424883046678_3554" dir="ltr">The state of Californina, which I got from NWS, can be found here: <a id="yui_3_16_0_1_1424883046678_3584" href="http://microflush.org/stuff/json/CA.json">http://microflush.org/stuff/json/CA.json</a></div><div id="yui_3_16_0_1_1424883046678_3615" dir="ltr"><br></div><div id="yui_3_16_0_1_1424883046678_3616" dir="ltr">Can anyone see why this one nwsZone.json polygon is returning the error?</div><div id="yui_3_16_0_1_1424883046678_3617" dir="ltr"><br></div><div id="yui_3_16_0_1_1424883046678_3343" dir="ltr"><br><span id="yui_3_16_0_1_1424883046678_3200"></span></div><div id="yui_3_16_0_1_1424883046678_3222" dir="ltr"><span id="yui_3_16_0_1_1424883046678_3200">Any help would be great.</span></div><div id="yui_3_16_0_1_1424883046678_3686" dir="ltr"><br><span id="yui_3_16_0_1_1424883046678_3200"></span></div><div id="yui_3_16_0_1_1424883046678_3682" dir="ltr"><span id="yui_3_16_0_1_1424883046678_3200">Thanks!</span></div><div id="yui_3_16_0_1_1424883046678_3680" dir="ltr"><br><span id="yui_3_16_0_1_1424883046678_3200"></span></div><div id="yui_3_16_0_1_1424883046678_3681" dir="ltr"><span id="yui_3_16_0_1_1424883046678_3200">Regards,</span></div><div id="yui_3_16_0_1_1424883046678_3683" dir="ltr"><span id="yui_3_16_0_1_1424883046678_3200">Joseph Spenner</span><br></div><div id="yui_3_16_0_1_1424883046678_2934"><br><div id="yui_3_16_0_1_1424883046678_3112">
<br></div></div></div></body></html>