<div dir="ltr">Hi,<div><br></div><div>Simplest way would be to read definition of ST_DWithin and use index lookups for smaller box, but rechecks for bigger. Don't ST_Simplify, it's just wasting cycles.</div><div><br></div><div>select ... where geom && ST_Expand(other_geom, 100) and _ST_DWithin(geom, other_geom, 110)<br><br>It will exit loop in ST_DWithin faster as threshold is higher.</div><div><br></div><div>Alternatively this is a case (lookup of indexed points closest to linestring) where building ST_SimplifyPreserveTopology(ST_Buffer(geom, (110+100)/2), (110-100)/2) in advance and then looking ST_Intersects of that once-calculated buffer and points will be faster. Also note how your condition is defined: you buffer on half of your tolerance more, and then simplify by half of your tolerance, so that result shape is covering your "non-simplified" buffer for sure.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Feb 22, 2019 at 1:57 PM Michal Palenik <<a href="mailto:michal.palenik@oma.sk">michal.palenik@oma.sk</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 all,<br>
<br>
I use postgis to query nearby points to a linestring using st_dwithin()<br>
<br>
however, in my usecase, the linestrings are too detailed and I do not<br>
need very exact results. I would like function like:<br>
st_dwithin(g1,g2, 100, 110) which:<br>
return true if distance is less than 100<br>
return false if distance is more than 110<br>
return whatever you want if the distance is between 100-110 (but make it fast)<br>
<br>
similarly, query points that are within a polygon (or "close" to it)<br>
<br>
currently, I use triggers to store simplified version of the linestring,<br>
using trial-and-error paremeters for st_simplify and st_expand (or<br>
larger distance parameter for st_dwithin), with an index on this<br>
simplified line.<br>
<br>
apart from problems resulting from two versions of the same line, I do<br>
not know how to control the max-error parameters (110 in the above<br>
example), due to st_simplify working only on geometries, etc.<br>
<br>
<br>
how would you approach this?<br>
<br>
<br>
thanks, Michal<br>
<br>
-- <br>
michal palenik<br>
<a href="http://www.freemap.sk" rel="noreferrer" target="_blank">www.freemap.sk</a><br>
<a href="http://www.oma.sk" rel="noreferrer" target="_blank">www.oma.sk</a><br>
<br>
_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/postgis-users" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/postgis-users</a></blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div>Darafei Praliaskouski</div><div>Support me: <a href="http://patreon.com/komzpa" target="_blank">http://patreon.com/komzpa</a></div></div></div></div>