Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/munterfi/flexpolyline
The flexpolyline R package provides a binding to the C++ implementation of the flexible polyline encoding by HERE. The encoding is a lossy compressed representation of a list of coordinate pairs or coordinate triples.
https://github.com/munterfi/flexpolyline
gis heremaps polyline polyline-decoder polyline-encoder rspatial rstats
Last synced: 18 days ago
JSON representation
The flexpolyline R package provides a binding to the C++ implementation of the flexible polyline encoding by HERE. The encoding is a lossy compressed representation of a list of coordinate pairs or coordinate triples.
- Host: GitHub
- URL: https://github.com/munterfi/flexpolyline
- Owner: munterfi
- License: gpl-3.0
- Created: 2020-06-07T12:12:00.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-07-19T09:28:29.000Z (over 1 year ago)
- Last Synced: 2024-10-05T15:36:06.235Z (about 1 month ago)
- Topics: gis, heremaps, polyline, polyline-decoder, polyline-encoder, rspatial, rstats
- Language: C++
- Homepage: https://munterfi.github.io/flexpolyline/
- Size: 10.3 MB
- Stars: 9
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: .github/CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Flexible Polyline Encoding for R
[![CRAN status](https://www.r-pkg.org/badges/version/flexpolyline)](https://CRAN.R-project.org/package=flexpolyline)
[![CRAN checks](https://badges.cranchecks.info/worst/flexpolyline.svg)](https://cran.r-project.org/web/checks/check_results_flexpolyline.html)
[![CRAN downloads](https://cranlogs.r-pkg.org/badges/last-month/flexpolyline?color=brightgreen)](https://CRAN.R-project.org/package=flexpolyline)
[![R-CMD-check](https://github.com/munterfi/flexpolyline/actions/workflows/check-standard.yaml/badge.svg)](https://github.com/munterfi/flexpolyline/actions/workflows/check-standard.yaml)
[![Codecov test coverage](https://codecov.io/gh/munterfi/flexpolyline/branch/master/graph/badge.svg)](https://app.codecov.io/gh/munterfi/flexpolyline?branch=master)
[![CodeFactor](https://www.codefactor.io/repository/github/munterfi/flexpolyline/badge)](https://www.codefactor.io/repository/github/munterfi/flexpolyline)The **flexpolyline** R package provides a binding to the
[C++ implementation](https://github.com/heremaps/flexible-polyline/tree/master/cpp) of the
flexible polyline encoding by [HERE](https://github.com/heremaps/flexible-polyline).
The flexible polyline encoding is a lossy compressed representation of a list of
coordinate pairs or coordinate triples. The encoding is achieved by:
(1) Reducing the decimal digits of each value;
(2) encoding only the offset from the previous point;
(3) using variable length for each coordinate delta; and
(4) using 64 URL-safe characters to display the result.
The flexible polyline encoding is a variant of the [Encoded Polyline Algorithm Format](https://developers.google.com/maps/documentation/utilities/polylinealgorithm) by Google.**Note:**
- The order of the coordinates (lng, lat) does not correspond to the original
C++ implementation (lat, lng). This enables direct conversion to **sf**
objects, without reordering the columns.
- The encoding is lossy, this means the encoding process could reduce the
precision of your data.## Installation
Install the released version of **flexpolyline** from [CRAN](https://CRAN.R-project.org/package=flexpolyline):
```r
install.packages("flexpolyline")
```To install the development version from [GitHub](https://github.com/munterfi/flexpolyline):
```r
remotes::install_github("munterfi/flexpolyline")
```## C++ binding
Encoding and decoding in R is straight forward by using `encode()` and
`decode()`. These functions are binding to the flexpolyline C++ implementation
and reflect the arguments and return values of their counterparts
(`hf::flexpolyline::polyline_encode` and `hf::flexpolyline::polyline_decode`):```r
line <- matrix(
c(8.69821, 50.10228, 10,
8.69567, 50.10201, 20,
8.69150, 50.10063, 30,
8.68752, 50.09878, 40),
ncol = 3, byrow = TRUE
)encode(line)
decode("BlBoz5xJ67i1BU1B7PUzIhaUxL7YU")
```## Simple feature support
The **flexpolyline** package integrates with the popular
[sf](https://CRAN.R-project.org/package=sf) package for working with spatial
data in R, which is built on the concept of simple features. The package
provides additional functions for encoding and decoding sf objects directly:```r
sfg <- sf::st_linestring(line, dim = "XYZ")encode_sf(sfg)
decode_sf("BlBoz5xJ67i1BU1B7PUzIhaUxL7YU")
```## Contributing
- Contributions to this package are welcome, issues and pull requests are the
preferred ways to share them. Please see the [Contribution Guidelines](https://github.com/munterfi/flexpolyline/blob/master/.github/CONTRIBUTING.md).
- This project is released with a [Contributor Code of Conduct](https://github.com/munterfi/flexpolyline/blob/master/.github/CODE_OF_CONDUCT.md).
By participating in this project you agree to abide by its terms.## References
- [Flexible Polyline Encoding by HERE](https://github.com/heremaps/flexible-polyline)
- [Encoded Polyline Algorithm Format](https://developers.google.com/maps/documentation/utilities/polylinealgorithm)
- [Simple Features for R](https://CRAN.R-project.org/package=sf)
- Inspired by the [googlePolylines](https://github.com/SymbolixAU/googlePolylines) package## License
The **flexpolyline** R package is licensed under GNU GPL v3.0. The C++
implementation by HERE Europe B.V. is licensed under MIT.