## #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 )

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 , 17 months ago

Description: | modified (diff) |
---|

### comment:2 by , 17 months 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:4 by , 17 months ago

Milestone: | → PostGIS 3.1.9 |
---|

**Note:**See TracTickets for help on using tickets.

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