One function

iter_dict_decode in heremaps/flexible-polyline

The author described this change as Python: Fix iter_dict_decode (#80). It counts as a record because the check below fails on the code as it stood at 9badae348 and passes on 42ece0017, with nothing else changed between the two runs.

Fix saved2024-06-12
Sharing licenceMIT · LICENSE
Change size+5 3

What the code was meant to do, written into the code itself as a docstring

Return an iterator over coordinates dicts. The dict contains always the keys 'lat', 'lng' and depending on the polyline can contain a third key ('elv', 'lvl', 'alt', ...).

The change

11 def iter_dict_decode(encoded):
22 """Return an iterator over coordinates dicts. The dict contains always the keys 'lat', 'lng' and
33 depending on the polyline can contain a third key ('elv', 'lvl', 'alt', ...)."""
4- third_dim_key = THIRD_DIM_MAP[get_third_dimension(encoded)]
4+ third_dim_key = THIRD_DIM_MAP.get(get_third_dimension(encoded))
55 for row in iter_decode(encoded):
6- yield {
6+ coordinate = {
77 'lat': row[0],
88 'lng': row[1],
9- third_dim_key: row[2]
109 }
10+ if third_dim_key is not None:
11+ coordinate[third_dim_key] = row[2]
12+ yield coordinate

The check that tells the two apart

failpass·python/test_flexpolyline.py::TestFlexPolyline::test_dict_decode_2d

Check file python/test_flexpolyline.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before it9badae3486ce8ba4c4106d5dd117e45ec8901097
Broken version dated2024-06-06
Modulepython.flexpolyline.__init__
Units changediter_dict_decode
Fingerprintdd7066897cac801a
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.