Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

polyline_wkt loses precision #23

Open
SymbolixAU opened this issue May 29, 2018 · 2 comments
Open

polyline_wkt loses precision #23

SymbolixAU opened this issue May 29, 2018 · 2 comments

Comments

@SymbolixAU
Copy link
Collaborator

library(sf)
library(googlePolylines)

coords <- matrix(c(-37.1234567, -37.765321, 144.1234567, 144.7654321), ncol = 2)
sf_line <- sf::st_sf(geometry = sf::st_sfc(sf::st_linestring(coords)))

polyline_wkt(encode(sf_line))[1, ]
# [1] "LINESTRING (-37.1234 144.123, -37.7653 144.765)"
SymbolixAU pushed a commit that referenced this issue May 29, 2018
@SymbolixAU
Copy link
Collaborator Author

SymbolixAU commented May 29, 2018

precision defined and set as 12. Should this be user defined?

library(sf)
library(googlePolylines)

coords <- matrix(c(-37.1234567, -37.765321, 144.1234567, 144.7654321), ncol = 2)
sf_line <- sf::st_sf(geometry = sf::st_sfc(sf::st_linestring(coords)))

polyline_wkt(encode(sf_line))[1, ]
# [1] "LINESTRING (-37.1234474182 144.123443604, -37.7653198242 144.765426636)"

@SymbolixAU
Copy link
Collaborator Author

Or perhaps using std::to_string() is the more appropriate solution

library(sf)
library(googlePolylines)

coords <- matrix(c(-37.1234567, -37.765321, 144.1234567, 144.7654321), ncol = 2)
sf_line <- sf::st_sf(geometry = sf::st_sfc(sf::st_linestring(coords)))

polyline_wkt(encode(sf_line))[1, ]
# [1] "LINESTRING (-37.123447 144.123444, -37.765320 144.765427)"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants