Skip to content

Commit

Permalink
0.8.3
Browse files Browse the repository at this point in the history
  • Loading branch information
dcooley committed Apr 2, 2023
1 parent 0edd739 commit 94a5e9b
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 23 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
^revdep$
^LICENSE\.md$
^\.github$
^CRAN-SUBMISSION$
12 changes: 7 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: googlePolylines
Type: Package
Title: Encoding Coordinates into 'Google' Polylines
Version: 0.8.2
Date: 2020-12-15
Version: 0.8.3
Date: 2023-04-02
Authors@R: c(
person("David", "Cooley", ,"[email protected]", role = c("aut", "cre")),
person("Paulo", "Barcelos", role = "ctb", comment = "Author of c++ decode_polyline"),
Expand All @@ -12,10 +12,12 @@ Description: Encodes simple feature ('sf') objects and coordinates, and decodes
using the 'Google' polyline encoding algorithm (<https://developers.google.com/maps/documentation/utilities/polylinealgorithm>).
License: MIT + file LICENSE
Encoding: UTF-8
SystemRequirements: C++14
SystemRequirements: C++17
Imports:
Rcpp (>= 0.12.13)
LinkingTo: Rcpp, BH
Rcpp (>= 1.0.10)
LinkingTo:
BH,
Rcpp
RoxygenNote: 7.1.1
Suggests:
covr,
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# v0.8.3

* updated s3 generic method arguments

# v0.8.2

Expand Down
30 changes: 15 additions & 15 deletions R/Utils_sf.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ sfGeometryAttributes <- function(sf) UseMethod("sfGeometryAttributes")
sfGeometryAttributes.sf <- function(sf) sfGeometryAttributes(sf[[sfGeometryColumn(sf)]])

#' @export
sfGeometryAttributes.sfc <- function(sfc) {
sfGeometryAttributes.sfc <- function(sf) {

list(
type = sfGeometryType(sfc),
dim = sfDimension(sfc),
bbox = sfBbox(sfc),
epsg = sfEpsg(sfc),
proj = sfProj(sfc),
prec = sfPrecision(sfc),
n_em = sfNEmpty(sfc)
type = sfGeometryType(sf),
dim = sfDimension(sf),
bbox = sfBbox(sf),
epsg = sfEpsg(sf),
proj = sfProj(sf),
prec = sfPrecision(sf),
n_em = sfNEmpty(sf)
)
}

Expand All @@ -42,42 +42,42 @@ sfGeometryColumn.sf <- function(sf) attr(sf, "sf_column")
sfGeometryType <- function(sf) UseMethod("sfGeometryType")

#' @export
sfGeometryType.sfc <- function(sfc) substr(class(sfc)[1], 5, nchar(class(sfc)[1]))
sfGeometryType.sfc <- function(sf) substr(class(sf)[1], 5, nchar(class(sf)[1]))

### DIMENSION
sfDimension <- function(sf) UseMethod("sfDimension")

#' @export
sfDimension.sfc <- function(sfc) class(sfc[[1]])[1]
sfDimension.sfc <- function(sf) class(sf[[1]])[1]

### BBOX
sfBbox <- function(sf) UseMethod("sfBbox")

sfBbox.sfc <- function(sfc) attr(sfc, "bbox")
sfBbox.sfc <- function(sf) attr(sf, "bbox")

### EPSG
sfEpsg <- function(sf) UseMethod("sfEpsg")

#' @export
sfEpsg.sfc <- function(sfc) attr(sfc, "crs")$epsg
sfEpsg.sfc <- function(sf) attr(sf, "crs")$epsg

### PROJ4STRINg
sfProj <- function(sf) UseMethod("sfProj")

#' @export
sfProj.sfc <- function(sfc) attr(sfc, "crs")$proj4string
sfProj.sfc <- function(sf) attr(sf, "crs")$proj4string

### PRECISION
sfPrecision <- function(sf) UseMethod("sfPrecision")

#' @export
sfPrecision.sfc <- function(sfc) attr(sfc, "precision")
sfPrecision.sfc <- function(sf) attr(sf, "precision")

### N_EMPTY
sfNEmpty <- function(sf) UseMethod("sfNEmpty")

#' @export
sfNEmpty.sfc <- function(sfc) attr(sfc, "n_empty")
sfNEmpty.sfc <- function(sf) attr(sf, "n_empty")


#' Geometry Row
Expand Down
2 changes: 1 addition & 1 deletion src/Makevars
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
CXX_STD = CXX14
CXX_STD = CXX17

PKG_CPPFLAGS = -I../inst/include
5 changes: 5 additions & 0 deletions src/RcppExports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@

using namespace Rcpp;

#ifdef RCPP_USE_GLOBAL_ROSTREAM
Rcpp::Rostream<true>& Rcpp::Rcout = Rcpp::Rcpp_cout_get();
Rcpp::Rostream<false>& Rcpp::Rcerr = Rcpp::Rcpp_cerr_get();
#endif

// rcpp_encodeSfGeometry
Rcpp::List rcpp_encodeSfGeometry(Rcpp::List sfc, bool strip);
RcppExport SEXP _googlePolylines_rcpp_encodeSfGeometry(SEXP sfcSEXP, SEXP stripSEXP) {
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-Encode.R
Original file line number Diff line number Diff line change
Expand Up @@ -417,9 +417,9 @@ test_that("emptry geometries are handled", {
sfempl <- sf::st_sf(geometry = empl)

enc <- encode(ept)
expect_true(enc[[1]] == ">>")
expect_true(enc[[1]] == "??")
enc <- encode(sfept)
expect_true(enc$geometry[[1]] == ">>")
expect_true(enc$geometry[[1]] == "??")

enc <- encode(emp)
expect_true(length(enc[[1]]) == 0)
Expand Down

0 comments on commit 94a5e9b

Please sign in to comment.