Skip to content

Commit a96f95b

Browse files
committed
closes #93
1 parent 304022f commit a96f95b

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ Collate:
4444
geod.R
4545
wkt.R
4646
wrap_x.R
47-
RoxygenNote: 7.3.1
47+
RoxygenNote: 7.3.2

R/geohash.R

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,20 @@
44
#' @param precision integer; precision (length) of geohash returned. From the liblwgeom source: ``where the precision is non-positive, a precision based on the bounds of the feature. Big features have loose precision. Small features have tight precision.''
55
#' @export
66
#' @details see \url{http://geohash.org/} or \url{https://en.wikipedia.org/wiki/Geohash}.
7-
#' @return `st_geohash` returns a character vector with geohashes
7+
#' @return `st_geohash` returns a character vector with geohashes; empty or full geometries result in `NA`
88
#'
99
#' `st_geom_from_geohash` returns a (bounding box) polygon for each geohash if `raw` is `FALSE`, if `raw` is `TRUE` a matrix is returned with bounding box coordinates on each row.
1010
#' @examples
1111
#' library(sf)
1212
#' lwgeom::st_geohash(st_sfc(st_point(c(1.5,3.5)), st_point(c(0,90))), 2)
1313
#' lwgeom::st_geohash(st_sfc(st_point(c(1.5,3.5)), st_point(c(0,90))), 10)
1414
st_geohash = function(x, precision = 0) {
15-
CPL_geohash(st_geometry(x), precision)
15+
x = st_geometry(x)
16+
ret = vector("character", length(x))
17+
is_na = st_is_empty(x) | st_is_full(x)
18+
ret[is_na] = NA_character_
19+
ret[!is_na] = CPL_geohash(x[!is_na], precision)
20+
ret
1621
}
1722

1823
#' @export

man/st_geohash.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)