Skip to content

Commit

Permalink
Remove dependency on archived R package 'geojsonlint'
Browse files Browse the repository at this point in the history
Fixes #79.
  • Loading branch information
aoles committed Sep 20, 2023
1 parent 855890b commit b840b4a
Show file tree
Hide file tree
Showing 11 changed files with 438 additions and 14 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
Package: openrouteservice
Title: Openrouteservice API Client
Version: 0.4.1
Version: 0.4.2
Authors@R: person("Andrzej", "Oleś", email = "[email protected]", comment = c(ORCID = "0000-0003-0285-2787"), role = c("aut", "cre"))
Description: The package streamlines access to the services provided by openrouteservice.org.
It allows you to painlessly query for directions, geocoding, isochrones, time-distance matrices, and POIs.
URL: https://github.com/GIScience/openrouteservice-r
BugReports: https://github.com/GIScience/openrouteservice-r/issues
Imports: geojsonlint, geojsonsf, httr, jsonlite, keyring, leaflet, utils, xml2
Imports: geojsonsf, httr, jsonlite, jsonvalidate, keyring, leaflet, utils, V8, xml2
Suggests: covr, ggforce, ggplot2, googlePolylines, lwgeom, knitr, mapview, pkgdown, RColorBrewer, rmarkdown, roxygen2, sf, testthat, units
License: Apache License 2.0 | file LICENSE
Encoding: UTF-8
LazyData: true
VignetteBuilder: knitr
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.1.2
RoxygenNote: 7.2.3
3 changes: 2 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export(ors_optimization)
export(ors_pois)
export(ors_profile)
export(vehicles)
importFrom(geojsonlint,geojson_validate)
importFrom(V8,v8)
importFrom(geojsonsf,geojson_sf)
importFrom(httr,GET)
importFrom(httr,POST)
Expand All @@ -31,6 +31,7 @@ importFrom(httr,verbose)
importFrom(jsonlite,fromJSON)
importFrom(jsonlite,toJSON)
importFrom(jsonlite,validate)
importFrom(jsonvalidate,json_validator)
importFrom(keyring,key_get)
importFrom(keyring,key_list)
importFrom(keyring,key_set_with_value)
Expand Down
10 changes: 5 additions & 5 deletions R/api_call.R
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ error_message <- function(code, details) {
msg
}

#' @importFrom geojsonlint geojson_validate
#' @importFrom geojsonsf geojson_sf
#' @importFrom jsonlite fromJSON toJSON validate
#' @importFrom xml2 read_xml xml_validate
Expand Down Expand Up @@ -224,10 +223,7 @@ parse_content <- function (content,
}
}

## check for geojson as some endpoints respond with generic json content type
## until https://github.com/GIScience/openpoiservice/issues/111 is resolved
## assume pois returns GeoJSON
is_geojson <- format=="json" && (endpoint=="pois" || isTRUE(geojson_validate(content)))
is_geojson <- format=="json" && isTRUE(validate_geojson(content))

## raw text output
if (output=="text") {
Expand Down Expand Up @@ -274,3 +270,7 @@ print.ors_api <- function(x, give.attr = FALSE, list.len = 6L, ...) {
str(unclass(x), list.len = list.len, give.attr = give.attr, ...)
invisible(x)
}

#' @importFrom jsonvalidate json_validator
#' @importFrom V8 v8
validate_geojson <- NULL
4 changes: 2 additions & 2 deletions R/profiles.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
#' @seealso [ors_directions()], [ors_isochrones()], [ors_matrix()]
#' @template author
#' @export
ors_profile <- function(mode = c("car", "hgv", "bike", "roadbike", "e-bike", "walking", "hiking", "wheelchair")) {
ors_profile <- function(mode = c("car", "hgv", "bike", "roadbike", "mtb", "e-bike", "walking", "hiking", "wheelchair")) {
profiles <- c(
`car` = 'driving-car',
`hgv` = 'driving-hgv',
`bike` = 'cycling-regular',
`roadbike` = 'cycling-road',
`mountainbike` = 'cycling-mountain',
`mtb` = 'cycling-mountain',
`e-bike` = 'cycling-electric',
`walking` = 'foot-walking',
`hiking`= 'foot-hiking',
Expand Down
3 changes: 3 additions & 0 deletions R/zzz.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.onLoad <- function(lib, pkg) {
validate_geojson <<- jsonvalidate::json_validator(system.file("schema/geojson.json", package = pkg))
}
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
output: rmarkdown::md_document
---
[![R-CMD-check](https://github.com/GIScience/openrouteservice-r/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/GIScience/openrouteservice-r/actions/workflows/R-CMD-check.yaml)
[![Coverage Status](https://img.shields.io/codecov/c/github/GIScience/openrouteservice-r/master.svg)](https://codecov.io/github/GIScience/openrouteservice-r?branch=master)
[![Coverage Status](https://img.shields.io/codecov/c/github/GIScience/openrouteservice-r/master.svg)](https://app.codecov.io/github/GIScience/openrouteservice-r?branch=master)
[![lifecycle](https://lifecycle.r-lib.org/articles/figures/lifecycle-experimental.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)

# openrouteservice R client
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![R-CMD-check](https://github.com/GIScience/openrouteservice-r/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/GIScience/openrouteservice-r/actions/workflows/R-CMD-check.yaml)
[![Coverage
Status](https://img.shields.io/codecov/c/github/GIScience/openrouteservice-r/master.svg)](https://codecov.io/github/GIScience/openrouteservice-r?branch=master)
Status](https://img.shields.io/codecov/c/github/GIScience/openrouteservice-r/master.svg)](https://app.codecov.io/github/GIScience/openrouteservice-r?branch=master)
[![lifecycle](https://lifecycle.r-lib.org/articles/figures/lifecycle-experimental.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)

openrouteservice R client
Expand Down
7 changes: 7 additions & 0 deletions inst/schema/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2014 Mads Kristensen

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
1 change: 1 addition & 0 deletions inst/schema/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The geojson schema here is taken from the [SchemaStore](https://github.com/SchemaStore/schemastore) repository. It is distributed under the Apache 2.0 license (see LICENSE.md)
Loading

0 comments on commit b840b4a

Please sign in to comment.