geopro/src/render/ground/TileMath.hpp

23 lines
727 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#pragma once
// Web Mercator(EPSG:3857) 瓦片坐标数学:天地图/XYZ 底图瓦片定位用(纯函数,无 VTK/Qt 依赖)。
// 标准 slippy-map 公式n=2^zx=(lon+180)/360*ny 用墨卡托纬度映射。
namespace geopro::render {
struct TileXY {
int z = 0, x = 0, y = 0;
};
// 瓦片地理边界west/east 经度south/north 纬度。
struct LonLatBox {
double west = 0, south = 0, east = 0, north = 0;
};
// 经纬度(度) → 指定 zoom 的瓦片行列x/y 夹紧到 [0, 2^z-1])。
TileXY lonLatToTile(double lonDeg, double latDeg, int z);
// 瓦片 (z,x,y) → 其覆盖的地理边界(度)。
LonLatBox tileBounds(int z, int x, int y);
} // namespace geopro::render