You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First of all, I'd like to say that it's really a pleasure to use this library.
I am having a use case for which I need to identify "border cells" below a certain distance, e.g. all cells with resolution of about 2.4x2.4 m^2 (geohash lenght = 9) on the border between cells "b" and "c".
What I would require in this case is, being able to extract all cells of geohash length n+1 (e.g. lenght 2 starting from cells of length 1) by direction, so to have the rightmost column of sub-cells in "b" of geohash length, say, 9, and the leftmost column of subcells of "c" of the same geohash length.
The text was updated successfully, but these errors were encountered:
I'd like to get n-level neighbours. Current GeoHash.neighbours() returns n=1 level as does gridAsString. Chatbot says:
To find the n-level neighbors of a geohash, you can use a recursive approach. Here's an example implementation:
fun getNLevelNeighbors(geohash: String, level: Int): Set<String> {
return when (level) {
0 -> setOf(geohash)
else -> {
val neighbors = GeoHash.neighbours(geohash)
val result = HashSet<String>()
for (i in 0 until 8) {
result.addAll(getNeighbors(neighbors[i], level - 1))
}
result
}
}
}
In this implementation, we define a getNLevelNeighbors function that takes a geohash and an integer n as input. If n is 0, we return a set containing only the original geohash. Otherwise, we use the neighbours() method of the GeoHash class to get the immediate neighbors of the geohash. We then create an empty set to store the n-level neighbors and loop over the immediate neighbors. For each immediate neighbor, we recursively call the getNLevelNeighbors function with n - 1 as the new value of n. We add the resulting set of n-level neighbors to the result set. Finally, we return the result set containing all n-level neighbors.
Here's an example usage of the getNLevelNeighbors function:
val geohash = "u4pruydqqvj"
val n = 2
val nLevelNeighbors = getNLevelNeighbors(geohash, n)
println(nLevelNeighbors)
This will print a set of all geohashes that are within 2 levels of the u4pruydqqvj geohash. You can adjust the value of n to get neighbors at different levels.
First of all, I'd like to say that it's really a pleasure to use this library.
I am having a use case for which I need to identify "border cells" below a certain distance, e.g. all cells with resolution of about 2.4x2.4 m^2 (geohash lenght = 9) on the border between cells "b" and "c".
What I would require in this case is, being able to extract all cells of geohash length n+1 (e.g. lenght 2 starting from cells of length 1) by direction, so to have the rightmost column of sub-cells in "b" of geohash length, say, 9, and the leftmost column of subcells of "c" of the same geohash length.
The text was updated successfully, but these errors were encountered: