Parsing Incident flow API response

Hello,

I’m trying to figure out how to parse the format of the incident api vector response.
The documentation of the format is very minimal: https://developer.tomtom.com/traffic-api/traffic-api-documentation-traffic-incidents/vector-incident-tiles
There is no explanation about the relation of feature tags and tile keys and values.

For example, how does the part of response below should be parsed?
What are these feature tags and how are they mapped to keys and values?

Another question - the geometry includes pairs of XY coordinates on the zoom level?
The geometry in the response below is from zoom level 14 (TMS 9775, 9734) but the numbers should be much larger and also they don’t convert to WGS84.

Any help will be appreciated.

Thank you,
Edi.

    layers {
  name: "Traffic incident flow"
  features {
    tags: 0
    tags: 3
    tags: 1
    tags: 4
    tags: 2
    tags: 5
    type: LINESTRING
    geometry: 9
    geometry: 1136
    geometry: 6564
    geometry: 18
    geometry: 92
    geometry: 95
    geometry: 472
    geometry: 467
  }
  keys: "icon_category_0"
  keys: "description_0"
  keys: "delay"  
  values {
    int_value: 8
  }
  values {
    string_value: "closed"
  }
  values {
    int_value: 0
  }  
  values {
    int_value: 6
  }
  values {
    string_value: "stationary traffic"
  }
  values {
    int_value: 200
  }
  extent: 4096
  version: 2
}

Try to decode using this proto file: http://api.tomtom.com/onlinemaps/docs/Vector_Tile.proto

Hi @maloleps,
Thanks for the help.

This is the proto file that I used to decode the binary response and I got the parsed output above.
My question is how do I look on these fields?
When there is a feature like the one below, what does every tag mean? What is 0, 3, 1, 4,… ?
features {
tags: 0
tags: 3
tags: 1
tags: 4
tags: 2
tags: 5
type: LINESTRING
geometry: 9
geometry: 1136
geometry: 6564
geometry: 18
geometry: 92
geometry: 95
geometry: 472
geometry: 467
}

Thanks,
Edi.

Tags is key-value list containing indexes to key list and value list.
Tags list size is even. Every 2 tags are interpreted as pair.
Interpretation of your tile:
tags: 0, tags: 3 -> key_index: 0, value_index: 3: -> “icon_category_0”: 6
tags: 1, tags: 4 -> key_index: 1, value_index: 4: -> “description_0”: “stationary traffic”
tags: 2, tags: 5 -> key_index: 2, value_index: 5: -> “delay”: 200
Result tags:
[“icon_category_0”: 6][“description_0”: “stationary traffic”][“delay”: 200]

Geometry values are build like this: [command_and_size][x0][y0]…[xn][yn][command_and_size][x0][y0]…[xn][yn]
Your geometry is:
geometry 9 interpretation:
command: (value & 0x7) = 1 (1 is move_to)
size: (value >> 3) = 1. It is amount of x,y pairs that follows.
geometry 1136 is ‘x’. Decoding (zigzag: (n << 1) ^ (n >> 31)):
((n << 1136) ^ (n >> 1136)) = 568;
geometry 6564 is ‘y’:
((n << 6564) ^ (n >> 6564)) = 3282;
According to first command_and_size: no more pairs of x,y.
geometry 18 is next command_and_size:
command: (18 & 0x7) = 2 (2 is line_to)
size: (18 >> 3) = 2
geometry 92 is ‘x’ (after zig zag decoding):
46
geometry 95 is ‘y’ (after zig zag decoding):
-48
geometry 472 is ‘x’ (after zig zag decoding):
236
geometry 467 is ‘y’ (after zig zag decoding):
-234

This is geometry with relative values:
[move_to (598, 3282)][line_to (46, -48)(236, -234)]
Make it absolute (e.g. current_x_absolute = previous_x_absolute + current_x_relative):
[move_to (598, 3282)][line_to (644, 3234)(880, 3000)]

This is Web Mercator projection.

Thanks @maloleps, it helped a lot!

@maloleps Is there some spec for this format? Trying to figure out whether this is OpenLR or something else. I didn’t find any command field there.
Thanks.