fortyninemaps / karta

A tidy Python package for geospatial computation
https://karta.fortyninemaps.com
MIT License
100 stars 11 forks source link

intersection code is wrong #5

Closed njwilson23 closed 11 years ago

njwilson23 commented 11 years ago

The following test gives incorrect results.

interx1 and interx2 should be identical, and the plots show that 3/4 of the identified intersections are false positives.

L = Line(((0,0), (1,2.5), (2,4), (3, 1)))
L2 = Line(((0.25,3), (0.1, 1.5), (1.5, 1.7), (2.2, 1.0)))
interx1 = L.intersections(L2)
interx2 = L2.intersections(L)

plot(*L.get_coordinate_lists()[:2])
plot(*L2.get_coordinate_lists()[:2])
for _x,_y in interx1: plot(_x,_y, 'ob')
for _x,_y in interx2: plot(_x,_y, 'or')
njwilson23 commented 11 years ago

Problem was due to an indexing typo in the calling python function. Fixed by 42cbcfb50f08500af09390b4104db51234ba23d2