Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complex Properties Overhaul #121

Closed
wants to merge 12 commits into from
46 changes: 46 additions & 0 deletions 3.0/vector_tile.proto
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,46 @@ message Tile {
// A detailed description on geometry encoding is located in
// section 4.3 of the specification.
repeated uint32 geometry = 4 [ packed = true ];

// Properties replace existing tags field and
// uses the properties field instead. This would only be used if version
// for a layer is 3 or greater and tags should not be used at that point
//
// The properties field is much like the tags value in the it is two integers
// pairs that reference key and value pairs however, it is broken out into a
// "key_index" and an "complex_value".
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: had to read many times to understand the sentence. the -> that? also, ; before "however" would help

//
// The "key_index" is much like the key index in the use for tags, but instead
// of pointing to "keys" field in the Layers, it points to the "string_values".
// This is the same value store as strings for use in values, so duplicates here
// will be pointing to the same indexed position.
//
// An complex value has two parts, the first 4 bits are the type bits
// and the remaining bits are the parameter bits. What is stored in the parameter
// bits is dependant on what the type bit is selected. For example for inline values,
// the parameter field is not an index but simply a value. For other types it might
// be an index position into a value storage of the layer.
//
// uint64t type = complex_value & 0x0F; // First 4 Bits
// uint64t parameter = complex_value >> 4;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uint64_t

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, will fix

//
// Type | Id | Parameter
// ---------------------------------
// inline sint | 0 | value of integer ( values between -2^59+1 to 2^59-1 )
// inline uint | 1 | value of unsigned integer ( values between 0 to 2^60-1 )
// bool/null | 2 | value of 0 = false, 1 = true, 2 = null
// float | 3 | index to float_values in layer
// double | 4 | index to double_values in layer
// string | 5 | index to string_values in layer
// int | 6 | index to int_values in layer
// uint | 7 | index to uint_values in layer
// list / map | 8 | (if 4th bit is 0 is list)
// | | remaining bits are length of the list where
// | | each item in the list is a complex value
// | | (if 4th bit is 1 is map)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit confusing — the id 8 is 0b1000, but if the 4th bit is 1 (so that it becomes 0b1001), the id equals 9. Then why not just indicate 8 for list and 9 for map instead of mentioning the fourth bit?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was attempting to get away with just using 3 bits so that we could represent higher int values with out having to using the int index system. I am not against 4 bits.

// | | remaining bits are the number of key_index and
// | | complex_value pairs to follow (same as properties)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we simply make these list -> 8, map > 9? The extra bit is confusing and doesn't buy us anything, because we already have 9 values (0-8) for the Id anyway.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me, since we have enough type fields to spare. I think they were combined only because it looked like the types would fit in 3 bits.

repeated uint64 properties = 5 [ packed = true ];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will try an experimental implementation of this so we can see if it actually makes the tiles significantly smaller.

}

// Layers are described in section 4.1 of the specification
Expand All @@ -69,6 +109,12 @@ message Tile {
// See https://github.com/mapbox/vector-tile-spec/issues/47
optional uint32 extent = 5 [ default = 4096 ];

repeated string string_values = 7;
repeated double double_values = 8 [ packed = true ];
repeated float float_values = 9 [ packed = true ];
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we try to keep the types ordered consistently throughout the .proto file, ie some places have float first, then double, others in different order.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me. I'll make that edit.

repeated sint64 sint64_values = 10 [ packed = true ];
repeated uint64 uint64_values = 11 [ packed = true ];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use sint64 instead of int64 since this would only be preferred over uint64 when the value is negative.


Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest these should get "logical" names like signed_integer_values or so instead of ones based on the encoding sfixed....

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also fine with me.

extensions 16 to max;
}

Expand Down