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

Improve ./scripts/dump to use custom .proto #95

Open
springmeyer opened this issue Apr 3, 2018 · 0 comments
Open

Improve ./scripts/dump to use custom .proto #95

springmeyer opened this issue Apr 3, 2018 · 0 comments

Comments

@springmeyer
Copy link
Contributor

It is possible to use a custom .proto when generating new fixtures, like fixture 11 does:

proto: proto_string
.

It is also possible to later reference this custom .proto since it is embedded into the info.json like

"proto": "\npackage vector_tile;\n\noption optimize_for = LITE_RUNTIME;\n\nmessage Tile {\n\n // GeomType is described in section 4.3.4 of the specification\n enum GeomType {\n UNKNOWN = 0;\n POINT = 1;\n LINESTRING = 2;\n POLYGON = 3;\n }\n // THIS IS NEW\n message NewMessageInValue {\n required string name = 1;\n }\n\n // Variant type encoding\n // The use of values is described in section 4.1 of the specification\n message Value {\n // Exactly one of these values must be present in a valid message\n optional string string_value = 1;\n optional float float_value = 2;\n optional double double_value = 3;\n optional int64 int_value = 4;\n optional uint64 uint_value = 5;\n optional sint64 sint_value = 6;\n optional bool bool_value = 7;\n optional NewMessageInValue custom_value = 8; // THIS IS NEW\n }\n\n // Features are described in section 4.2 of the specification\n message Feature {\n optional uint64 id = 1 [ default = 0 ];\n\n // Tags of this feature are encoded as repeated pairs of\n // integers.\n // A detailed description of tags is located in sections\n // 4.2 and 4.4 of the specification\n repeated uint32 tags = 2 [ packed = true ];\n\n // The type of geometry stored in this feature.\n optional GeomType type = 3 [ default = UNKNOWN ];\n\n // Contains a stream of commands and parameters (vertices).\n // A detailed description on geometry encoding is located in\n // section 4.3 of the specification.\n repeated uint32 geometry = 4 [ packed = true ];\n }\n\n // Layers are described in section 4.1 of the specification\n message Layer {\n // Any compliant implementation must first read the version\n // number encoded in this message and choose the correct\n // implementation for this version number before proceeding to\n // decode other parts of this message.\n required uint32 version = 15 [ default = 1 ];\n\n required string name = 1;\n\n // The actual features in this tile.\n repeated Feature features = 2;\n\n // Dictionary encoding for keys\n repeated string keys = 3;\n\n // Dictionary encoding for values\n repeated Value values = 4;\n\n // Although this is an \"optional\" field it is required by the specification.\n // See https://github.com/mapbox/vector-tile-spec/issues/47\n optional uint32 extent = 5 [ default = 4096 ];\n\n extensions 16 to max;\n }\n\n repeated Layer layers = 3;\n\n extensions 16 to 8191;\n}\n"
.

But the ./scripts/dump currently hardcodes to .proto used to decode the tile at

vector-tile-spec/2.1/vector_tile.proto \
. This hardcoding means that if a custom .proto where to add a new field, the scripts/dump would not be able to display the correct field name.

So, to improve this we should enhance scripts/dump to find a way to read the .proto via the info.json. Perhaps the ./scripts/dump could be changed to simply:

  • accept an argument of a number (to denote a fixture id) rather than the path to the tile.mvt
  • then it would find both the tile.mvt and the info.json for a given fixture and dump the data using the correct, potentially custom, .proto string.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant