Bug fix tile_to_bbox(): use pixel_width instead of extent.#333
Bug fix tile_to_bbox(): use pixel_width instead of extent.#333nyurik merged 2 commits intoopenmaptiles:masterfrom
Conversation
|
I could be wrong, but I suspect this was a bug in Mapnik in that case. My understanding is that I do not understand what dividing by |
|
Hi @nyurik |
|
@lazaa32 what are the units of measurements for the pixel_scale and buffer_size? I think the legacy tile is 256x256 pixels (raster), whereas the vector tile is (i guess) 4096x4096 (extent). If the measurement for buffer_size was in pixels, than yes - we need to convert 256 to be the width of a tile. I can't recall if we have 256 hardcoded anywhere. |
|
@nyurik I think that We probably don't want to modify the |
|
please re-run |
This PR fixes two issues: 1. Before `ST_AsMVTGeom(geometry, ST_TileEnvelope(zoom, x, y), extent, buffer, true)` function read `buffer` from layer yaml definition `buffer_size` (e.g. 256 for layer place). Which is in pixels but should be in vector tile unit because it is compared to `extent` (4096). Related to PR #333. 2. When replacing `!pixel_width!` and `!pixel_height!` in Mapnik query, `self.pixel_width` and `self.pixel_height` are used. That means that a constant value `pixel_scale` is used throughout all zooms. However I checked logs from Mapnik rendering and following values for `pixel_width` are used: Zoom|pixel_width | --|------------| 1| 78271.5| 2| 39135.8| 3| 19567.9| 4| 9783.94| 5| 4891.97| 6| 2445.98| 7| 1222.99| 8| 611.496| 9| 305.748| 10| 152.874| 11| 76.437 | 12| 38.2185| 13| 19.1093| 14| 9.55463| I modified the tool so it calculates pixel_width (which is actually zoom resolution meters/pixel) for each zoom_level. Using constant value for `pixel_width` leads to having different number of features in a same tile rendered via PgQuery and Mapnik.
When PgQuery makes a query into postgres it uses smaller tile buffer than Mapnik.
In example below layer
placehas abuffer_sizeset to 256.Example:

Queried tile: 7/69/43
Queried layer:
layer_placeGreen: bbox of tile
Purple: bbox of PgQuery query of
layer_placebefore bug fixBlue dash: bbox of PgQuery query of
layer_placeafter bug fixRed dot dash: bbox of Mapnik query of
layer_placeBlue: