You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We've been using CARTO-VL to draw geometries on a map using our own MVT server and it seems that the current implementation takes the bottom-left corner of the tile as the origin of the tile.
In particular, we've been diving into this function that transforms the tile's coordinates space (0 to 4096 for example) to a new coordinates space from -1 to 1:
It seems that this function is inverting the y coordinate, making the bottom edge of the tile the origin of the y axis. We have written a quick Python test to prove our point:
>>> # Original CARTO-VL definition
... def transform(x, y, mvtExtent=4096):
... x = 2 * x / mvtExtent - 1
... y = 2 * (1 - y / mvtExtent) - 1
... return [x, y]
...
>>> # "Fixed"
... def transform_fix(x, y, mvtExtent=4096):
... x = 2 * x / mvtExtent - 1
... y = 2 * y / mvtExtent - 1
... return [x, y]
...
>>> transform(0, 0)
[-1.0, 1.0]
>>> transform_fix(0, 0)
[-1.0, -1.0]
>>> transform(4096, 4096)
[1.0, -1.0]
>>> transform_fix(4096, 4096)
[1.0, 1.0]
Taking a look at the Mapbox Vector Tile Specification, it seems that from version 2.0, Geometry data in a Vector Tile is defined in a screen coordinate system. The upper left corner of the tile (as displayed by default) is the origin of the coordinate system. The X axis is positive to the right, and the Y axis is positive downward. (https://github.com/mapbox/vector-tile-spec/tree/master/2.0). We haven't found anything similar for versions 1.0.0 and 1.0.1.
Is it a bug or is this the intended behavior and we need to fix it in our server?
We've been using CARTO-VL to draw geometries on a map using our own MVT server and it seems that the current implementation takes the bottom-left corner of the tile as the origin of the tile.
In particular, we've been diving into this function that transforms the tile's coordinates space (0 to 4096 for example) to a new coordinates space from -1 to 1:
carto-vl/src/client/mvt/feature-decoder.js
Lines 189 to 199 in c374e0e
It seems that this function is inverting the
y
coordinate, making the bottom edge of the tile the origin of they
axis. We have written a quick Python test to prove our point:Taking a look at the Mapbox Vector Tile Specification, it seems that from version 2.0, Geometry data in a Vector Tile is defined in a screen coordinate system. The upper left corner of the tile (as displayed by default) is the origin of the coordinate system. The X axis is positive to the right, and the Y axis is positive downward. (https://github.com/mapbox/vector-tile-spec/tree/master/2.0). We haven't found anything similar for versions 1.0.0 and 1.0.1.
Is it a bug or is this the intended behavior and we need to fix it in our server?
cc @VictorVelarde @juanignaciosl
The text was updated successfully, but these errors were encountered: