[postgis-devel] Postgis "Split" with tolerance
Rémi Cura
remi.cura at gmail.com
Fri Nov 29 01:48:54 PST 2013
ST_Split(line,point) is currently broken.
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 )!
The only work around I can think about are
_ 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
_ 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).
(Why? because in the code distance=0 is almost always false, because of
round error with double precision.
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))
I understand PostGIS is a big project and we have to be conservative,
that is "we don't break a fine function with changes bringing unknown
consequences for unproven benefits",
but this function is broken, and we could change it to a function working
most of the time !
*Pros of this change :*
_a line will be split by a point correctly (p_error < 10^6)
_no heavy changes in code or methods
*Cons of this change :*
_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
!).
All of this being said,
*I would also like adding ST_Split(geom,geom,tolerance).*
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)
Cheers,
Rémi-C
2013/11/28 Sandro Santilli <strk at keybit.net>
> On Thu, Nov 28, 2013 at 05:22:11PM +0100, Rémi Cura wrote:
> > Hey everybody,
> >
> > again tolerance issue ! what ! ;-)
> >
> > In the liblwgeom.c file ,
> > I changed
> > "if ( dist > 0) /* TODO: accept a tolerance ? */"
> >
> > to
> >
> > //@TOTEST @CHECK change by Remi-C : adding a small tolerance
> > vstol = ptarray_length_2d(lwline_in->points) / 1e12; //note : we don't
> > really need to compute length, we could just compute
> > //max (abs(max(x)-min(x)) , abs(max(y)-min(y)) ), it would be way faster
> > if ( dist > vstol ) /* TODO: accept a tolerance ? */
> >
> >
> > So know we can split a line by a point !
> > Any thought?
>
> Again, "accept" != "calculate".
>
> I'm happy with exposing tolerance-computing functions, as I did
> for topology with the _st_mintolerance or whatever I called it
> (ok, that's not really "exposed"), but the point of that comment
> is that ST_Split could take an optional tolerance from the user.
>
> --strk;
> _______________________________________________
> postgis-devel mailing list
> postgis-devel at lists.osgeo.org
> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-devel/attachments/20131129/8dc69a2e/attachment.html>
More information about the postgis-devel
mailing list