Hi,
I’m having some issues decoding the response of the API, after decoding the protocol buffer using the schema offered in the API documentation.
This is one example of the response I’m receiving:
{'tags': [0, 0, 1, 3, 2, 2],
'type': 'LINESTRING',
'geometry': [9, 5344, 4468, 18, 7, 39, 7, 11,
9, 252, 879, 10, 0, 8, 9, 388,844,18,23,23,0,3]}
I then use the zigzag decoding method mentioned in the docs to try getting the coordinates of the LineString. I use the following Python Code for this:
example = [9,5344,4468, 18,7,39,7,11,9,252,879,10,0,8,9,388,844,18,23,23,0,3]
c = 0
decoded_list = []
while c < len(example):
command_and_count = example[c]
command = command_and_count & 0x7
count = command_and_count >> 0x3
decode_x = 0
decode_y = 0
for _ in range(count):
x = example[c+1]
y = example[c+2]
decode_x += ((x >> command) ^ (-(x & command)))
decode_y += ((y >> command) ^ (-(y & command)))
decoded_list.append([decode_x, decode_y])
c += 2
c += 1
print(decoded_list)
>> [[2672, 2234], [-1, -9], [-2, -13], [126, -440], [0, 2], [194, 422], [-5, -5], [-5, -7]]
The results are not making sense. Is the zigzag method correct?
Thanks!