[postgis-users] Bug? Strange code in lwline_crossing_direction()
Darafei "Komяpa" Praliaskouski
me at komzpa.net
Sun Apr 19 23:46:17 PDT 2020
The code was born in 2009 by Paul Ramsey.
https://github.com/postgis/postgis/commit/6adec1b2be11e7d0fe5c482e50ce0872c400cfd6#diff-5705dd09236e9a6e8fa456b7b9599ed7R205-R211
Either a comment is needed on this, or a patch. Easiest way to check a
hypothesis that this may be a bug is to change L526 (github - Edit - change
- pull request) and see that CI says that everything failed (then it needs
docs) or that everything passed (then a trac ticket and a fix, which would
be a test that pins the correct behavior of that branch).
On Mon, Apr 20, 2020 at 7:42 AM Kohei KaiGai <kaigai at heterodb.com> wrote:
> Hello Darafei,
>
> It looks to me the first_cross should be SEG_CROSS_RIGHT, not
> SEG_CROSS_LEFT here.
> If it is expected, L574 shall never become true. Right?
>
> | at L526:
> | if ( this_cross == SEG_CROSS_RIGHT )
> | {
> | LWDEBUG(4,"this_cross == SEG_CROSS_RIGHT");
> | cross_right++;
> | if ( ! first_cross )
> | first_cross = SEG_CROSS_LEFT;
> | }
>
> Thanks,
>
> 2020年4月19日(日) 23:31 Darafei "Komяpa" Praliaskouski <me at komzpa.net>:
> >
> > Hi,
> >
> > the link you have is setting variable this_cross, and L526 sets
> > first_cross from it if it was not set and there is LEFT or RIGHT cross
> > (not no-cross and not COLLINEAR). Looks expected to me.
> >
> > On Sat, Apr 18, 2020 at 6:32 PM Kohei KaiGai <kaigai at heterodb.com>
> wrote:
> > >
> > > Hello,
> > >
> > > I noticed a strange code at liblwgeom/lwalgorithm.c
> > >
> https://github.com/postgis/postgis/blob/master/liblwgeom/lwalgorithm.c#L509
> > >
> > > lwline_crossing_direction() is the main logic of
> ST_LineCrossingDirection.
> > > It walks on all the edges of the supplied geometry (line), and calls
> > > lw_segment_intersects to check intersections.
> > >
> > > It looks to me the local variable 'first_cross' is used to remember
> the first
> > > result from the lw_segment_intersects, however, it saves different
> value
> > > on the second if-block at L526.
> > >
> > > Is it expected? Or, just mistake by copy & paste?
> > >
> > > Best regards,
> > > --
> > > HeteroDB, Inc / The PG-Strom Project
> > > KaiGai Kohei <kaigai at heterodb.com>
> > > _______________________________________________
> > > postgis-users mailing list
> > > postgis-users at lists.osgeo.org
> > > https://lists.osgeo.org/mailman/listinfo/postgis-users
> >
> >
> >
> > --
> > Darafei Praliaskouski
> > Support me: http://patreon.com/komzpa
> > _______________________________________________
> > postgis-users mailing list
> > postgis-users at lists.osgeo.org
> > https://lists.osgeo.org/mailman/listinfo/postgis-users
>
>
>
> --
> HeteroDB, Inc / The PG-Strom Project
> KaiGai Kohei <kaigai at heterodb.com>
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/postgis-users
--
Darafei Praliaskouski
Support me: http://patreon.com/komzpa
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20200420/31315787/attachment.html>
More information about the postgis-users
mailing list