<div dir="ltr"><div>ST_Split(line,point) is currently broken.</div><div>This is quite a neutral statement, because given a random point on a random line, split won't do anything (p_correct_answer<1/10k )!</div><div>
<br>
</div><div>The only work around I can think about are</div><div>_ snap the line to the point : it implies moving the line, which is not an option if you do it several times with different points, and is more abstractly a very bad idea</div>

<div>_ change the point to a very small line in the perpendicular direction of the line we want to split, then use split(line,line). Again not a very good option because you would possibiliy split the line in more than one point (and anyway split(line,line) has also precision issues).</div>

<div><br></div><div>(Why? because in the code distance=0 is almost always false, because of round error with double precision.</div><div>Anyway computing the distance is not a good idea, the power will divide the number of usable digits by 2, thus becoming a simple float precision (at least wihtout special care))</div>
<div><br></div><div>I understand PostGIS is a big project and we have to be conservative, </div><div>that is "we don't break a fine function with changes bringing unknown consequences for unproven benefits", </div>
<div>but this function is broken, and we could change it to a function working most of the time   !</div><div><br></div><div><br></div><div><b>Pros of this change :</b></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px">
<div>_a line will be split by a point correctly (p_error < 10^6)</div><div>_no heavy changes in code or methods</div></blockquote><div><br></div><div><b>Cons of this change :</b></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px">
<div>_the line would be split by any points close enough (lengthofline/10^12). (that is all points less than 10 micro meters away from a line 1000 km long !). </div></blockquote><div><br></div><div><br></div><div>All of this being said,</div>
<div><b>I would also like adding ST_Split(geom,geom,tolerance).</b></div><div>In fact it could be an easy wrapper around ST_Split(geom,geom) if this function was working. (something like: if the point is DWithin, split the closest part of the line)</div>
<div><br></div><div>Cheers,</div><div><br></div><div>Rémi-C</div>
<div><br></div><div><br></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/11/28 Sandro Santilli <span dir="ltr"><<a href="mailto:strk@keybit.net" target="_blank">strk@keybit.net</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Thu, Nov 28, 2013 at 05:22:11PM +0100, Rémi Cura wrote:<br>
> Hey everybody,<br>
><br>
> again tolerance issue ! what !  ;-)<br>
><br>
> In the liblwgeom.c file ,<br>
> I changed<br>
> "if ( dist > 0)   /* TODO: accept a tolerance ? */"<br>
><br>
> to<br>
><br>
> //@TOTEST @CHECK change by Remi-C : adding a small tolerance<br>
> vstol = ptarray_length_2d(lwline_in->points) / 1e12; //note : we don't<br>
> really need to compute length, we could just compute<br>
> //max (abs(max(x)-min(x)) , abs(max(y)-min(y)) ), it would be way faster<br>
> if ( dist > vstol )   /* TODO: accept a tolerance ? */<br>
><br>
><br>
> So know we can split a line by a point !<br>
> Any thought?<br>
<br>
</div></div>Again, "accept" != "calculate".<br>
<br>
I'm happy with exposing tolerance-computing functions, as I did<br>
for topology with the _st_mintolerance or whatever I called it<br>
(ok, that's not really "exposed"), but the point of that comment<br>
is that ST_Split could take an optional tolerance from the user.<br>
<br>
--strk;<br>
_______________________________________________<br>
postgis-devel mailing list<br>
<a href="mailto:postgis-devel@lists.osgeo.org">postgis-devel@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-devel" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-devel</a><br>
</blockquote></div><br></div>