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

Wrong geometry? #559

Closed
pitommasi opened this issue Apr 10, 2018 · 3 comments
Closed

Wrong geometry? #559

pitommasi opened this issue Apr 10, 2018 · 3 comments

Comments

@pitommasi
Copy link

I am trying to create mbtiles from a geoJson, EPSG:3857.

I've tried, with partial success, different parameters, currently:
tippecanoe -o out.mbtiles -pS -s EPSG:3857 -P -f in.json -z12 -Z0

I am using tileserver-php to serve the tiles to OpenLayers:

"source": new ol.source.VectorTile({ "projection": 'EPSG:3857', format: new ol.format.MVT({ featureClass: ol.Feature }), tileGrid: new ol.tilegrid.createXYZ({ minZoom: 0, maxZoom: 12 }), tilePixelRatio: 16, urls: vectorH })

Visually the tiles are OK.
In my page, to highlight the feature hovered by the mouse, I add that feature to another vector tile (let's call that highlighted feature), that has the correct style and the I remove the feature from it when the mouse leaves the feature.

This vector style is defined as:
"source": new ol.source.Vector({ "projection": 'EPSG:3857' })

The thing works perfectly when I render the vector layer using the geoJSON directly. The future release of my webapp, however, will have more than 10.000 features, this is why I am evaluating to switch to vector tiles.
With the mbtiles, the method of adding the feature to a temporary layer is not working (no errors but the highlighted feature is not shown on the map) so I'm trying to find out why.

I've found out that the geometry of the features is somehow changed, as an example, a feature's geometry that in both the json file and the vector layer built with it, is:

[3430837.84594,3402171.50494,3429629.55149,3402171.50494,3429983.98861,3404344.33362,3426358.73065,3404344.33362...]

gets translated to

[1801, 727, 1782, 841, 2289, 841, 2252, 1069, 1872, ...]

Why is this happening?

@pitommasi
Copy link
Author

I've found the problem.
I've tried with the latest openlayers and the behavior has changed:
now that the highlighted feature is shown, although messily, I can see that at deeper zoom level, biggest features get split across tiles, hence, the feature I get is only a part of the original one.
My conclusion is, unless there is an easy way to get the full feature from different tiles, that my only resort is to separately store the geometries and take them from this store to display them on the highlight layer.

@e-n-f
Copy link
Contributor

e-n-f commented Apr 10, 2018

In the next revision of the vector tile spec, we are planning to add the ability to merge features back together across tile boundaries. mapbox/vector-tile-spec#104.

The best you can do now is to give each of your features a unique id so you can identify which features in different tiles are actually part of the same original feature.

@e-n-f e-n-f closed this as completed Apr 10, 2018
@pitommasi
Copy link
Author

Thanks for the reply, good to know that you are working on that, I've subscribed to the issue to stay up to date. Meanwhile, my features already have a unique id in the data file, so all I have to do is load the geometry from a separate store.

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

2 participants