Opened 2 years ago

Closed 22 months ago

Last modified 22 months ago

#5288 closed defect (fixed)

ST_LineCrossingDirection defect on LINE MULTICROSS END SAME FIRST LEFT ?

Reported by: arthurbazin Owned by: pramsey
Priority: medium Milestone: PostGIS 3.1.9
Component: postgis Version: 3.2.x
Keywords: Cc: arthurbazin

Description (last modified by arthurbazin)

With the ST_LineCrossingDirection, I have unexpected results.

Using this request, I can simulate some crossing but the result is unexpected for the line 2 and 4 :

SELECT 
  line_number,
  ST_LineCrossingDirection(geom_a, geom_b) "a_/_b",
  ST_LineCrossingDirection(geom_b, geom_a) "b_/_a",
  geom_a,
  geom_b
FROM (
  VALUES 
    (
      'LINESTRING (1 0, 1 1, 2 2, 2 3)'::geometry,
      'LINESTRING (2 0, 2 1, 1 2, 1 3)'::geometry,
      1
    ),
    (
      'LINESTRING (1 0, 1 1, 2 2, 1 3, 1 4)'::geometry,
      'LINESTRING (2 0, 2 1, 1 2, 2 3, 2 4)'::geometry,
      2
    ),
    (
      'LINESTRING (1 0, 1 1, 2 2, 1 3, 2 4, 2 5)'::geometry,
      'LINESTRING (2 0, 2 1, 1 2, 2 3, 1 4, 1 5)'::geometry,
      3
    ),
    (
      'LINESTRING (1 0, 1 1, 2 2, 1 3, 2 4, 1 5, 1 6)'::geometry,
      'LINESTRING (2 0, 2 1, 1 2, 2 3, 1 4, 2 5, 2 6)'::geometry,
      4
    )
) AS t1 ("geom_a", "geom_b", line_number)
;

Result :

 line_number | a_/_b | b_/_a | geom_a                                         | geom_b                                         |
-------------+-------+-------+------------------------------------------------+------------------------------------------------+
           1 |    -1 |     1 | LINESTRING (1 0, 1 1, 2 2, 2 3)                | LINESTRING (2 0, 2 1, 1 2, 1 3)                |
           2 |    -3 |    -3 | LINESTRING (1 0, 1 1, 2 2, 1 3, 1 4)           | LINESTRING (2 0, 2 1, 1 2, 2 3, 2 4)           |
           3 |    -2 |     2 | LINESTRING (1 0, 1 1, 2 2, 1 3, 2 4, 2 5)      | LINESTRING (2 0, 2 1, 1 2, 2 3, 1 4, 1 5)      |
           4 |    -3 |    -3 | LINESTRING (1 0, 1 1, 2 2, 1 3, 2 4, 1 5, 1 6) | LINESTRING (2 0, 2 1, 1 2, 2 3, 1 4, 2 5, 2 6) |

Will the column "b_/_a" be "3" instead of "-3" on lines 2 and 4 ? The A line comes from the left of B and the B line comes from the right of A

Maybe I don't understand correctly this function but I can not explain how it works with this result.

My version of PostGIS : POSTGIS="3.2.1 3.2.1" [EXTENSION] PGSQL="130" GEOS="3.10.2-CAPI-1.16.0" PROJ="7.2.1" GDAL="GDAL 3.4.2, released 2022/03/08 GDAL_DATA not found" LIBXML="2.9.9" LIBJSON="0.12" LIBPROTOBUF="1.2.1" WAGYU="0.5.0 (Internal)" RASTER

Change History (9)

comment:1 by arthurbazin, 2 years ago

Description: modified (diff)

Anyone can confirm that this is a bug and not my "misunderstanding" of this function that gives me this result ?

Will the result have to be 3 instead of -3 for the lines 2 and 4 on column b_/_a ? Thank you :-)

Last edited 2 years ago by arthurbazin (previous) (diff)

comment:2 by mdavis, 2 years ago

I think you are right, the answer for line pairs 2 and 4 should be 3, not -3.

So this looks like a bug.

comment:3 by arthurbazin, 2 years ago

@mdavis Thank's, I will adjust my scripts to take this into account.

comment:4 by robe, 2 years ago

Milestone: PostGIS 3.1.9

comment:5 by Paul Ramsey <pramsey@…>, 22 months ago

Resolution: fixed
Status: newclosed

In f0cdb5a/git:

Correctly handle multi-cross case in ST_LineCrossingDirection. Closes #5288

comment:6 by Paul Ramsey <pramsey@…>, 22 months ago

In 75f4aa5/git:

Correctly handle multi-cross case in ST_LineCrossingDirection. Closes #5288

comment:7 by Paul Ramsey <pramsey@…>, 22 months ago

In 6b6f6cf/git:

Correctly handle multi-cross case in ST_LineCrossingDirection. Closes #5288

comment:8 by Paul Ramsey <pramsey@…>, 22 months ago

In db40f6e/git:

Correctly handle multi-cross case in ST_LineCrossingDirection. Closes #5288

comment:9 by Paul Ramsey <pramsey@…>, 22 months ago

In 99eac803/git:

Correctly handle multi-cross case in ST_LineCrossingDirection. Closes #5288

Note: See TracTickets for help on using tickets.