将 Uber 的 H3 六边形分层地理空间索引系统中的基本六边形映射到地球的原点在哪里?
Where is the origin that maps the base hexagons in Uber's H3 Hexagonal hierarchical geospatial indexing system to the globe?
我刚刚了解 H3 并且想基本上得到“标准参考”点,在每个分辨率下参考每个六边形(和 12 个五边形),然后确定 lat/lng坐标是每个六边形。这是如何工作的?
The H3 grid is constructed on the icosahedron by recursively creating increasingly higher precision hexagon grids until the desired resolution is achieved. Note that it is impossible to tile the sphere/icosahedron completely with hexagons; each resolution of an icosahedral hexagon grid must contain exactly 12 pentagons at every resolution, with one pentagon centered on each of the icosahedron vertices.
The first H3 resolution (resolution 0) consists of 122 cells (110 hexagons and 12 icosahedron vertex-centered pentagons), referred to as the base cells. These were chosen to capture as much of the symmetry of the spherical icosahedron as possible. These base cells are assigned numbers from 0 to 121 based on the latitude of their center points; base cell 0 has the northern most center point, while base cell 121 has the southern most center point.
Each subsequent resolution beyond resolution 0 is created using an aperture 7 resolution spacing (aperture refers to the number of cells in the next finer resolution grid for each cell); as resolution increases the unit length is scaled by sqrt(7) and each hexagon has 1/7th the area of a hexagon at the next coarser resolution (as measured on the icosahedron). H3 provides 15 finer grid resolutions in addition to the resolution 0 base cells. The finest resolution, resolution 15, has cells with an area of less than 1 m2.
我想下到resolution 10,大约15m^2的面积。我想在此分辨率下为每个六边形存储一个自定义生成的密钥,将密钥与六边形的索引或哈希相关联,我假设它以某种方式与系统的 origin 相关联,并且以某种方式将原点硬编码到地球上的特定位置。
所以它 appears that h3.getRes0Indexes
will give us the 122 origin cells at base 0. And the hierarchy docs 在 JavaScript 库中显示了至少如何遍历分辨率。
function example() {
const h = '85283473fffffff';
return h3.h3ToCenterChild(h, 10);
}
所以如果我已经弄清楚原始哈希是什么,那将使我以分辨率 10 为中心。在遍历代码中,我没有看到遍历每个节点一次的直接方法。应该怎么做?
Ah 没关系,只是不是跳到分辨率 10 的中心 child,而是请求基本节点内的所有 children 吗?
const baseCells = h3.getRes0Indexes();
for (const index of baseCells) {
yield* await getChildrenAtRes(index, h3Res);
}
async function* getChildrenAtRes(h3Index, targetRes) {
const nextRes = h3.h3GetResolution(h3Index) + 1;
// Iterate over all direct children of the current index
for (const child of h3.h3ToChildren(h3Index, nextRes)) {
if (nextRes >= targetRes) {
await Promises.delay(300);
yield child;
} else {
yield* getChildrenAtRes(child, targetRes);
}
}
}
也许我可以尝试直接从分辨率 0 跳到分辨率 10 并获得所有数百 children?我会试试的。
Also 可以这样用:
// Get the vertices of an H3 index as lat/lng points
h3.h3ToGeoBoundary("8928342e20fffff")
所以我想我已经回答了我所有的问题,除了 原点在哪里? 将这些东西映射到实际地球的部分在哪里?那是在代码库的某个地方以某种方式硬编码的吗?我怎么知道当我今天使用该库时,我从 API 中获得的 122 个基本六边形将具有与我上次使用它时相同的哈希值?
where is the origin?
没有单一的起源。网格基于正二十面体在地球表面的投影(使用球形模型)。
Where is the part where it maps the stuff to the actual Earth globe? Is that hardcoded somehow in the codebase somewhere?
二十面体的方向相对于地球是固定的 - 你可以看到 center coordinates of each face here(正如你所建议的,这些是硬编码在代码库中)。
How do I know that when I use the library today, the 122 base hexagons I get from the API will have the same hash as the last time I used it?
所有 H3 索引都是稳定的 - 这是我们用来创建索引的算法的一个功能,也是 API 我们提供的保证,我们不会对库进行任何更改以更改单元格索引或地理位置。
可以看到more info on the methodology of the indexing function here.
我刚刚了解 H3 并且想基本上得到“标准参考”点,在每个分辨率下参考每个六边形(和 12 个五边形),然后确定 lat/lng坐标是每个六边形。这是如何工作的?
The H3 grid is constructed on the icosahedron by recursively creating increasingly higher precision hexagon grids until the desired resolution is achieved. Note that it is impossible to tile the sphere/icosahedron completely with hexagons; each resolution of an icosahedral hexagon grid must contain exactly 12 pentagons at every resolution, with one pentagon centered on each of the icosahedron vertices.
The first H3 resolution (resolution 0) consists of 122 cells (110 hexagons and 12 icosahedron vertex-centered pentagons), referred to as the base cells. These were chosen to capture as much of the symmetry of the spherical icosahedron as possible. These base cells are assigned numbers from 0 to 121 based on the latitude of their center points; base cell 0 has the northern most center point, while base cell 121 has the southern most center point.
Each subsequent resolution beyond resolution 0 is created using an aperture 7 resolution spacing (aperture refers to the number of cells in the next finer resolution grid for each cell); as resolution increases the unit length is scaled by sqrt(7) and each hexagon has 1/7th the area of a hexagon at the next coarser resolution (as measured on the icosahedron). H3 provides 15 finer grid resolutions in addition to the resolution 0 base cells. The finest resolution, resolution 15, has cells with an area of less than 1 m2.
我想下到resolution 10,大约15m^2的面积。我想在此分辨率下为每个六边形存储一个自定义生成的密钥,将密钥与六边形的索引或哈希相关联,我假设它以某种方式与系统的 origin 相关联,并且以某种方式将原点硬编码到地球上的特定位置。
所以它 appears that h3.getRes0Indexes
will give us the 122 origin cells at base 0. And the hierarchy docs 在 JavaScript 库中显示了至少如何遍历分辨率。
function example() {
const h = '85283473fffffff';
return h3.h3ToCenterChild(h, 10);
}
所以如果我已经弄清楚原始哈希是什么,那将使我以分辨率 10 为中心。在遍历代码中,我没有看到遍历每个节点一次的直接方法。应该怎么做?
Ah 没关系,只是不是跳到分辨率 10 的中心 child,而是请求基本节点内的所有 children 吗?
const baseCells = h3.getRes0Indexes();
for (const index of baseCells) {
yield* await getChildrenAtRes(index, h3Res);
}
async function* getChildrenAtRes(h3Index, targetRes) {
const nextRes = h3.h3GetResolution(h3Index) + 1;
// Iterate over all direct children of the current index
for (const child of h3.h3ToChildren(h3Index, nextRes)) {
if (nextRes >= targetRes) {
await Promises.delay(300);
yield child;
} else {
yield* getChildrenAtRes(child, targetRes);
}
}
}
也许我可以尝试直接从分辨率 0 跳到分辨率 10 并获得所有数百 children?我会试试的。
Also 可以这样用:
// Get the vertices of an H3 index as lat/lng points
h3.h3ToGeoBoundary("8928342e20fffff")
所以我想我已经回答了我所有的问题,除了 原点在哪里? 将这些东西映射到实际地球的部分在哪里?那是在代码库的某个地方以某种方式硬编码的吗?我怎么知道当我今天使用该库时,我从 API 中获得的 122 个基本六边形将具有与我上次使用它时相同的哈希值?
where is the origin?
没有单一的起源。网格基于正二十面体在地球表面的投影(使用球形模型)。
Where is the part where it maps the stuff to the actual Earth globe? Is that hardcoded somehow in the codebase somewhere?
二十面体的方向相对于地球是固定的 - 你可以看到 center coordinates of each face here(正如你所建议的,这些是硬编码在代码库中)。
How do I know that when I use the library today, the 122 base hexagons I get from the API will have the same hash as the last time I used it?
所有 H3 索引都是稳定的 - 这是我们用来创建索引的算法的一个功能,也是 API 我们提供的保证,我们不会对库进行任何更改以更改单元格索引或地理位置。
可以看到more info on the methodology of the indexing function here.