Skip to content

Commit

Permalink
Merge pull request #105 from munterfinger/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
munterfi committed Jan 1, 2021
2 parents d93845f + 13fc00b commit c1b37fb
Show file tree
Hide file tree
Showing 41 changed files with 1,236 additions and 695 deletions.
76 changes: 76 additions & 0 deletions .github/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at info@munterfinger.ch. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
101 changes: 101 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# How to contribute?

This document contains guidelines for the collaboration in the **hereR** R package.

## Getting started

Ready to contribute? Here's how to set up **hereR** for local development.

1. Fork the repository to your GitHub account and clone the forked repository locally.
2. Install the dependencies (check the `DESCRIPTION` file).
3. Create a feature or bugfix branch as appropriate: `git checkout -b feature/<feature-description> develop` or `git checkout -b bugfix/<bugfix-description> develop`
4. Work locally on the feature, make sure to add or adjust:
- entries in `NEWS.md`
- function documentation (run `devtools::document()` before commit)
- tests for the feature (run `export HERE_API_KEY="<YOUR-KEY>" && Rscript data-raw/internal.R && unset HERE_API_KEY` to recreate package example data and API mocks)
- vignettes
5. Push changes to the new branch.
6. If CI tests are passing, create a pull request on GitHub of your `feature/...` or `bugfix/...` branch into the `develop` branch of the original repository.

## Gitflow workflow

### Master and develop

The [gitflow workflow](https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow) uses two branches to
record the history of the project. The `master` branch stores the official release history, and the `develop` branch serves
as an integration branch for features. It's also convenient to tag all commits in the `master` branch with a version number.

### Features

Each new feature should reside in its own branch. But, instead of branching off of `master`, feature branches use
`develop` as their parent branch. When a feature is complete, it gets merged back into `develop`. Features should never interact directly with `master`.

### Release

This packages uses [semantic versions](https://semver.org/). Once `develop` has aquired enough features for a release,
fork a release (`release/v<major>.<minor>.<patch>)` branch off of `develop`. When CRAN has accepted the package submission,
the release branch gets merged into `master` and tagged with a version number. In addition, it should be merged back into `develop`,
which may have progressed since the release was initiated.

## Documentation and coding style

### Naming convention

Use `snake_case` for variable, argument and function name definitions and avoid capital letters.
Dots (`.`) in function definitions are reserved for the functions and method dispatch in the S3 object system (e.g. `print.my_class`) or as prefix to hide functions (e.g. `.my_hidden_function`).

### Package documentation

This packages uses [roxygen2](https://cran.r-project.org/web/packages/roxygen2/vignettes/roxygen2.html) for the package documentation.

Example:

``` r
#' Add together two numbers
#'
#' @param x A number
#' @param y A number
#' @return The sum of \code{x} and \code{y}
#' @examples
#' add(1, 1)
#' add(10, 1)
add <- function(x, y) {
x + y
}
```

### Script header template

Add a header to CLI scripts according to the following template:

``` r
#!/usr/bin/env Rscript
# -----------------------------------------------------------------------------
# Name :example_script.R
# Description :Short description of the scripts purpose.
# Author :Name <your@email.ch>
# Date :YYYY-MM-DD
# Version :0.1.0
# Usage :./example_script.R
# Notes :Is there something important to consider when executing the
# script?
# =============================================================================
```

## Credits

Add your GitHub username to the bugfix or feature entry in the `NEWS.md` to ensure credits are given correctly:

```
# version x.x.x.9000
* Added <feature description> (@<github_username>, [#1](https://github.com/munterfinger/hereR/pull/1)).
* Bugfix: <description> (@<github_username>, closes [#2](https://github.com/munterfinger/hereR/issues/2)).
```

## Code of conduct

Please note that this project is released with a
[Contributor Code of Conduct](CODE_OF_CONDUCT.md). By contributing to this
project you agree to abide by its terms.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Bug report
about: Create a report to help improving the package
title: 'Bug: <Title>'
labels: 'bug'
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**Reproducible example**
Include R code to reproduce the bug. Use the [reprex package](https://reprex.tidyverse.org/).

**Expected behavior**
A clear and concise description of what you expected to happen.

**Optionally: R session info**
Include session info: `devtools::session_info()`.
11 changes: 11 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
name: Feature request
about: Suggest an idea for the package
title: 'Feature: <Title>'
labels: 'feature'
assignees: ''

---

**Description**
A description of what you want to happen and if your feature request is related to a problem.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,3 @@ vignettes/*.pdf

# macOS
*.DS_Store

4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: hereR
Type: Package
Title: 'sf'-Based Interface to the 'HERE' REST APIs
Version: 0.5.2
Version: 0.5.2.9000
Authors@R: c(
person("Merlin", "Unterfinger", role = c("aut", "cre"), email = "info@munterfinger.ch", comment = c(ORCID = "0000-0003-2020-2366")),
person("Daniel", "Possenriede", role = "ctb", comment = c(ORCID = "0000-0002-6738-9845")))
Expand All @@ -21,7 +21,7 @@ Depends: R (>= 3.3.0)
Imports:
curl (>= 4.3),
data.table (>= 1.12.6),
flexpolyline (>= 0.1.1),
flexpolyline (>= 0.2.0),
jsonlite (>= 1.7.0),
sf (>= 0.9-0),
stringr (>= 1.4.0)
Expand Down
19 changes: 14 additions & 5 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# version 0.5.2.9000

* Update `route_matrix()` from **Routing API v7.2** (calculatematrix) to **Matrix Routing API v8** (see [#87](https://github.com/munterfinger/hereR/issues/87)).
* Update `isoline()` from **Routing API v7.2** (calculateisoline) to **Isoline Routing API v8** (see [#87](https://github.com/munterfinger/hereR/issues/87)).
* Update `route()` from **Routing API v7.2** (calculateroute) to **Routing API v8**, which brings the elevation to the route geometries (closes [#87](https://github.com/munterfinger/hereR/issues/87)). **Note:** Currently arrival time is not yet supported.
* Return ISO state and country code in `geocode()` with the updated API v7.2 as it did with the previous API v6 (closes [#98](https://github.com/munterfinger/hereR/issues/98)).
* Deprecate parameters `mode` and `type` in `route()`, `route_matrix()` and `isoline()`, use `transport_mode` and `routing_mode` instead.
* Fix parsing of timezones in `connection()` and `intermodal_route()` (closes [#94](https://github.com/munterfinger/hereR/issues/94)).
* Fix not conditional use of suggested packages in vignettes (closes [#101](https://github.com/munterfinger/hereR/issues/101)).
* Fix issue with delimiter for POST requests by changing it from a space `" "` to a space pipe combination `" | "` (closes [#102](https://github.com/munterfinger/hereR/issues/102)).
* Added contribution guidelines, code of conduct and issue templates.

# version 0.5.2

* Send timezone offset in requests to the HERE APIs to avoid conversion to local timezone (closes [#85](https://github.com/munterfinger/hereR/issues/85)).
Expand Down Expand Up @@ -29,15 +41,12 @@
* Changed CI from Travis to GitHub actions.
* Added automated pkgdown page build after pull requests and commits on master.
* Extended test coverage on defunct function calls.
* Added `sf` argument to `geocode()` function. If `TRUE`, the default, an {sf}
object is returned, if `FALSE` a data.frame with `lng` and `lat` columns.
(@dpprdan, [#44](https://github.com/munterfinger/hereR/pull/44))
* Added `sf` argument to `geocode()` function. If `TRUE`, the default, an {sf} object is returned, if `FALSE` a data.frame with `lng` and `lat` columns. (@dpprdan, [#44](https://github.com/munterfinger/hereR/pull/44))
* **Intermodal Routing API: Routes** The new feature `intermodal_route()` adds support for requesting intermodal routes between given pairs of locations.

# version 0.3.3

* Added `set_verbose()` function to define (for the current R session) if the **hereR** package
should message information about the number of requests sent and data received (default = `FALSE`).
* Added `set_verbose()` function to define (for the current R session) if the **hereR** package should message information about the number of requests sent and data received (default = `FALSE`).
* Reactivate maps with multiple layers since the **mapview** issue [#271](https://github.com/r-spatial/mapview/issues/271) is fixed.
* **lwgeom** no longer exports `st_make_valid()`, but **sf** does. Therefore `lwgeom` is moved from the package dependencies to the suggestions (see [#38](https://github.com/munterfinger/hereR/issues/38)).

Expand Down
2 changes: 1 addition & 1 deletion R/autosuggest.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#' HERE Geocoder API: Autosuggest
#' HERE Geocoding & Search API: Autosuggest
#'
#' Completes addresses using the HERE 'Geocoder Autosuggest' API.
#'
Expand Down
88 changes: 24 additions & 64 deletions R/checks.R
Original file line number Diff line number Diff line change
Expand Up @@ -96,35 +96,28 @@
}
}

.check_mode <- function(mode, request) {
.check_transport_mode <- function(transport_mode, request) {
modes <- c(
"car",
"pedestrian",
"carHOV",
"publicTransport",
"publicTransportTimeTable",
"truck",
"bicycle"
"car", "truck", "pedestrian", "bicycle", "scooter"
)
if (request == "calculateisoline") {
modes <- modes[c(1, 2, 6)]
if (!mode %in% modes) {
stop(.stop_print_modes(mode = mode, modes = modes, request = request))
if (request == "isoline") {
modes <- modes[c(1, 2, 3)]
if (!transport_mode %in% modes) {
stop(.stop_print_transport_modes(mode = transport_mode, modes = modes, request = request))
}
} else if (request == "calculatematrix") {
modes <- modes[c(1, 2, 3, 6)]
if (!mode %in% modes) {
stop(.stop_print_modes(mode = mode, modes = modes, request = request))
} else if (request == "matrix") {
modes <- modes[c(1, 2, 3, 4)]
if (!transport_mode %in% modes) {
stop(.stop_print_transport_modes(mode = transport_mode, modes = modes, request = request))
}
} else if (request == "calculateroute") {
modes <- modes[c(1, 2, 3, 4, 6, 7)]
if (!mode %in% modes) {
stop(.stop_print_modes(mode = mode, modes = modes, request = request))
} else if (request == "route") {
if (!transport_mode %in% modes) {
stop(.stop_print_transport_modes(mode = transport_mode, modes = modes, request = request))
}
}
}

.stop_print_modes <- function(mode, modes, request) {
.stop_print_transport_modes <- function(mode, modes, request) {
sprintf(
"Transport mode '%s' not valid. For '%s' requests the mode must be in ('%s').",
mode,
Expand All @@ -133,39 +126,16 @@
)
}

.check_type <- function(type, request) {
types <- c("fastest", "shortest", "balanced")
if (request == "calculateisoline") {
types <- types[c(1, 2)]
if (!type %in% types) {
stop(.stop_print_types(type = type, types = types, request = request))
}
} else if (request == "calculatematrix" |
request == "calculateroute") {
if (!type %in% types) {
stop(.stop_print_types(type = type, types = types, request = request))
}
} else {
stop(sprintf("'%s' is an invalid request type.", request))
}
}

.stop_print_types <- function(type, types, request) {
sprintf(
"Routing type '%s' not valid. For '%s' requests the type must be in ('%s').",
type,
request,
paste(types, collapse = "', '")
)
}

.check_attributes <- function(attribute) {
attributes <- c("distance", "traveltime")
if (any(!attribute %in% attributes)) {
stop(sprintf(
"'attribute' must be in '%s'.",
paste(attributes, collapse = "', '")
))
.check_routing_mode <- function(routing_mode) {
modes <- c("fast", "short")
if (!routing_mode %in% modes) {
stop(
sprintf(
"Routing mode '%s' not valid, must be in ('%s').",
routing_mode,
paste(modes, collapse = "', '")
)
)
}
}

Expand All @@ -188,16 +158,6 @@
}
}

.check_vehicle_type <- function(vehicle_type) {
vehicle_types <- c("diesel", "gasoline", "electric")
if (!strsplit(vehicle_type, ",")[[1]][1] %in% vehicle_types) {
stop(sprintf(
"'vehicle_type' must be '%s'.",
paste(vehicle_types, collapse = "', '")
))
}
}

.check_weather_product <- function(product) {
weather_product_types <-
c(
Expand Down
Loading

0 comments on commit c1b37fb

Please sign in to comment.