如何在不同索引周围重现相同的单元格模式?

问题描述 投票:0回答:1

我正在使用H3空间索引实现h3o。我想编码本地单元格模式以围绕给定索引绘制它。

第一个问题是我不可避免地要与五边形战斗,但我不在乎扭曲它们周围的图案。因此减少对五边形的处理以防止恐慌。

第二个问题是,据我了解,不可能修复在

grid_disk_distances_safe
调用期间单元格的行走顺序。因此我无法通过枚举相邻单元格来对模式进行编码。

我认为索引中也没有任何信息可以帮助我。 索引通过层对从基本单元到所需单元的路径进行编码,并且不包含有关邻居顺序的空间信息。

问题

如何对单元格模式进行编码以在给定索引周围重现它?

rust geospatial h3
1个回答
0
投票
解决方案和相关讨论是

这里。转换函数的代码如下。

fn transpose_pattern(src: CellIndex, dst: CellIndex, pattern: &[CellIndex]) -> Vec<CellIndex> { // Compute translation offset. let src_coord = src.to_local_ij(src).expect("src coord"); let dst_coord = dst.to_local_ij(dst).expect("dst coord"); let i_offset = dst_coord.i() - src_coord.i(); let j_offset = dst_coord.j() - src_coord.j(); // Transpose the pattern from src to dst. pattern .iter() .copied() .map(|cell| { // Compute the local IJ coordinate wrt original center cell. let src_ij = cell.to_local_ij(src).expect("local IJ"); // Apply translation and re-anchor at destination center cell. let dst_ij = LocalIJ::new_unchecked(dst, src_ij.i() + i_offset, src_ij.j() + j_offset); // Convert back to cell index. CellIndex::try_from(dst_ij).expect("dst cell") }) .collect::<Vec<_>>() }
所提供解决方案的所有功劳都归于

grim7reaper

© www.soinside.com 2019 - 2024. All rights reserved.