你是说你不知道如何查询 z 阶曲线?维基百科页面描述了您如何进行范围搜索。
z 曲线将您的空间划分为嵌套的矩形,其中键中的每个附加位将空间分成两半。要搜索一个点:
Start with the largest rectangle that might contain your point.
Recursively:
Create a result set of rectangles
For each rectangle in your set
If the rectangle is a single point, you are done, it is what you are looking for.
Otherwise, divide the rectangle in two (specify one additional bit of the z-curve)
If both halves contain a point
If one half is better
Add that rectangle to your result set of rectangles
Otherwise
Add both rectangles to your result set of rectangles
Otherwise, only one half contains a point
Add that rectangle to your result set of rectangles
Search your result set of rectangles
当然,最坏情况下的性能很差。您可以通过更改构建 z 顺序索引的方式来调整它。