vector-tile-base icon indicating copy to clipboard operation
vector-tile-base copied to clipboard

`_points_equal` incorrectly compares floats with `is not`

Open craigds opened this issue 4 years ago • 1 comments

I noticed add_ring is not treating my closed ring like a closed ring:

ipdb> pt1
(19188372.37109346, -5402212.477493137)
ipdb> pt2
(19188372.37109346, -5402212.477493137)
ipdb> n
> /Users/cdestigter/checkout/sno/sno/pyvendor/vector_tile_base/engine.py(314)_points_equal()
    313         if pt1[0] is not pt2[0] or pt1[1] is not pt2[1] or (self._has_elevation and pt1[2] is not pt2[2]):
--> 314             return False
    315         return True

ipdb> pt1[0] == pt2[0]
True
ipdb> pt1[0] is pt2[0]
False

is not isn't the appropriate comparator here, it shoudl be !=. python doesn't guarantee two equal floats are the same float.

craigds avatar Jul 14 '20 22:07 craigds

As I understand, within an mvt the coordinates are all ints, no?

pumelo avatar Dec 17 '21 10:12 pumelo