<div dir="ltr"><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jun 25, 2020 at 2:55 AM Nyall Dawson <<a href="mailto:nyall.dawson@gmail.com">nyall.dawson@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi list!<br>
<br>
I've a situation where I've got ~millions of lines (each consisting of<br>
a single segment only) which I need to intersect against a complex<br>
polygon.<br>
<br>
Trying the naive way of multiple calls to GEOSIntersection_r gives<br>
predictably horrendous performance. Is there a better way I can<br>
approach this situation using the GEOS c api?<br></blockquote><div><br></div><div><div dir="ltr">There's an algorithm in PDAL that does this for point-in-polygon, but all the guts are there to do segment intersections. You're welcome to take it and modify to your liking:<div><br><div><a href="https://github.com/PDAL/PDAL/tree/master/filters/private/pnp">https://github.com/PDAL/PDAL/tree/master/filters/private/pnp</a><br><br>How much better it would from a more brute-force approach depends a lot on the data.</div></div><div><br></div></div></div></div>-- <br><div dir="ltr" class="gmail_signature">Andrew Bell<br><a href="mailto:andrew.bell.ia@gmail.com" target="_blank">andrew.bell.ia@gmail.com</a></div></div>