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

What format is returned by get_tile ? #2

Open
eLvErDe opened this issue Jun 22, 2020 · 6 comments
Open

What format is returned by get_tile ? #2

eLvErDe opened this issue Jun 22, 2020 · 6 comments

Comments

@eLvErDe
Copy link

eLvErDe commented Jun 22, 2020

Hello,

I used you library to implement a VectorTile server from GeoJSON however I've been unable to display the resulting tile with OpenLayers.
I get a dict with keys likes minX, maxY... and I have no idea what format this is. I tried MVP, GeoJSON and TopoJSON in OpenLayers, none managed to load these tiles.

Thanks

@hixi
Copy link
Collaborator

hixi commented Jun 22, 2020

It should comply with the vector-tile-spec that can be found here: https://github.com/mapbox/vector-tile-spec/blob/master/README.md.
I'm not sure about the viewers that support this format, though, and someone more qualified might be able to help. The JavaScript package reference https://github.com/mapbox/mapbox-gl-js as an example, maybe that helps.

@eLvErDe
Copy link
Author

eLvErDe commented Jun 23, 2020

Hello,

I'm not sure about that, MVT file are supposed to be protobuf, or maybe I should then encode the dict payload to protobuf ?

Thanks

@hixi
Copy link
Collaborator

hixi commented Jun 29, 2020

Seems I misunderstood the spec. This is a python port of the javascript equivalent geojson-vt which states:

Resulting tiles conform to the JSON equivalent of the vector tile specification.

I'm not sure, but in theory it should be possible to encode in protobuf to be conformant with the spec.

@snickell
Copy link

snickell commented Jul 29, 2021

@Murthy10 I have the same question... I'm not quite sure how to get from the not-quite-GeoJSON but also not-quite-vt-protobuf output to something I can load as a real honest vector tile.... this code illustrates I believe the same "what now?" question that has us scratching our heads

# This is a large half-gigabyte FeatureCollection, load once at startup
geojson_path = 'big-featurecollection.geojson'
geojson_data = get_json(geojson_path)
mvt = geojson2vt(geojson_data, {'maxZoom': 20})

@app.route(f"{URL_BASE}/vector_tiles/<int:z>/<int:x>/<int:y>")
def vector_tiles(z=None, x=None, y=None, geojson_key=None):
    tile_dict = mvt.get_tile(z, x, y)

    # So.... Now what????
    #
    # OK, I don't think /this/ is right.... this JSON is now a LOT
    # more like the spec in vector_tile.proto but I'm missing some
    # step to convert this to an actual binary ProtoBuf, but tile_dict
    # is still not suitable to call google.protobuf.json_format.ParseDict
    # according to the vector_tile.proto spec.... so how do we get
    # from point A to something mapboxGL will see as a binary protobuf MVT???
    
    return jsonify(tile_dict)

Any hints? :-)

@SulimanLab
Copy link

@Murthy10 I have the same question... I'm not quite sure how to get from the not-quite-GeoJSON but also not-quite-vt-protobuf output to something I can load as a real honest vector tile.... this code illustrates I believe the same "what now?" question that has us scratching our heads

# This is a large half-gigabyte FeatureCollection, load once at startup
geojson_path = 'big-featurecollection.geojson'
geojson_data = get_json(geojson_path)
mvt = geojson2vt(geojson_data, {'maxZoom': 20})

@app.route(f"{URL_BASE}/vector_tiles/<int:z>/<int:x>/<int:y>")
def vector_tiles(z=None, x=None, y=None, geojson_key=None):
    tile_dict = mvt.get_tile(z, x, y)

    # So.... Now what????
    #
    # OK, I don't think /this/ is right.... this JSON is now a LOT
    # more like the spec in vector_tile.proto but I'm missing some
    # step to convert this to an actual binary ProtoBuf, but tile_dict
    # is still not suitable to call google.protobuf.json_format.ParseDict
    # according to the vector_tile.proto spec.... so how do we get
    # from point A to something mapboxGL will see as a binary protobuf MVT???
    
    return jsonify(tile_dict)

Any hints? :-)

did you managed to figuring it out? I am stuck here.

@pumelo
Copy link

pumelo commented Jan 3, 2023

old issue but still relevant:
here for reference you need to encode as bpf with something like this: https://github.com/DenysMoskalenko/vt2pbf

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

5 participants