valhalla瓦片标准和相关代码

Hierarchies/Levels

Tiles are split up into three levels or hierarchies. Hierarchy 0 contains edges pertaining to roads that are considered highway (motorway, trunk, and primary) roads and are stored in 4 degree tiles. Hierarchy 1 contains roads that are at a arterial level (secondary and tertiary) and are saved in 1 degree tiles. Finally, Hierarchy 2 contains roads that are considered at a local level (unclassified, residential, and service or other). These tiles are saved in .25 degree tiles.

So in python, the levels are defined as:

valhalla_tiles = [{'level': 2, 'size': 0.25}, {'level': 1, 'size': 1.0}, {'level': 0, 'size': 4.0}]

The World at Level 0

The following image shows the world at level 0. Using a world bounding box (-180, -90, 180, 90) the world is split up into 4 degree tiles. The rows and columns start from the bottom left and increase to the top right. Tiles are row ordered increasing from west to east.

 

 


Image generated using http://geojson.io

 

Using a bounding box for Germany, Pennsylvania, and NYC we can show how the regions would be split up into the 3 levels. Level 0 is colored in light blue. Level 1 is light green and level 2 is light red.

 

Tiles<PointLL> tiles(AABB2<PointLL>(PointLL(-180, -90), PointLL(180, 90)), 1);瓦片范围,瓦片大小
AABB2<PointLL> bbox(PointLL(-99.5f, 30.5f), PointLL(-90.5f, 39.5f));
std::vector<int32_t> tilelist = tiles.TileList(bbox);
std::vector<valhalla::baldr::GraphId> get_graphid(double pt1_lng, double pt1_lat, double pt2_lng, double pt2_lat, int level) {
AABB2<PointLL> bbox(PointLL(pt1_lng, pt1_lat), PointLL(pt2_lng, pt2_lat));
//auto local_level = valhalla::baldr::TileHierarchy::levels().back().level;
auto graphIds = valhalla::baldr::TileHierarchy::GetGraphIds(bbox, level);
return graphIds;
}


posted @ 2023-04-18 09:27  ZN大叔  阅读(59)  评论(0编辑  收藏  举报