I am trying to calculate the x and y tile coordinates from a given longitude and latitude using the Web Mercator Tiling Scheme in Cesium. Below is the code snippet I am using to get the coordinates:
const lg = <longitude>;
const lt = <latitude>;
const ts = new WebMercatorTilingScheme();
const pos = new Cartographic(CesiumMath.toRadians(lg), CesiumMath.toRadians(lt), 50);
const position = ts.positionToTileXY(pos, 4);
and then used the x
and y
values from position
to fetch the appropriate tileset using a REST API. Here is the URL format I attempted:
https://assets.ion.cesium.com/ap-northeast-1/asset_depot/96188/OpenStreetMap/CWT/2024-03-04/{z}-{x}-{y}.json?v=57181480-e706-11ee-857d-e18e4a3674dc