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

selectFeatures draws on world map even if crs = NA (for mode = "click" only) #110

Closed
tim-salabim opened this issue Apr 4, 2020 · 7 comments

Comments

@tim-salabim
Copy link
Member

When using selectFeatures with sf features with no crs (i.e. NA) only mode = "draw" renders the features correctly without a background map. mode = "click" tries to plot things on a world map in web mercator. Should behave as mode = "draw"

library(mapedit)
library(mapview)
library(leaflet)
library(sf)

fran = st_set_crs(franconia, NA)

## as expected
selectFeatures(fran, mode = "draw")

## drawing on world map - not what should happen
selectFeatures(fran)
@timelyportfolio
Copy link
Contributor

timelyportfolio commented Apr 8, 2020

@tim-salabim I think the only difference is in lines for "click" and no extent in line for "draw". If I understand correctly, you prefer "draw", which would mean we remove lines 72-80. Is this correct?

@tim-salabim
Copy link
Member Author

I'll look into this soon. We simply need to adhere to the crs of the data, should be an easy fix

@tim-salabim
Copy link
Member Author

OK, this is fixed and merged in master

@timelyportfolio
Copy link
Contributor

@tim-salabim thanks! do we also need the change here

drawn = editMap(mapview::mapView(x, map = map, layer.name = nm, ...), title = title)
?

@tim-salabim
Copy link
Member Author

@timelyportfolio no, the mapview call will automatically set up the map according to the projection of x.

@timelyportfolio
Copy link
Contributor

@tim-salabim after rhub::check_for_cran I discovered this uses unexported mapview:::initMap. I added a copy in mapedit similar to other unexported. Is this ok with you? Will you verify that this copy works on your side?

This was the only issue from rhub::check_for_cran(). Did you see anything on winbuilder?

Thanks!

@tim-salabim
Copy link
Member Author

tim-salabim commented Apr 14, 2020

@timelyportfolio good catch! Sorry for the oversight... I just had a closer look at the package code (it's been a while) and I think we have a similar issue to this for editFeatures. I will investigate shortly.

Turns out, we're handling this correctly, as we can only allow editing if projection is 4326 (longlat). So we reproject if data is in different projection or through a descriptive error if no projection information is present.

I just tested on winbuilder (R-devel-ATC, normal R-devel wasn't accepting upload) and status is OK. See https://win-builder.r-project.org/B54RObZ26z92/ for details (only valid for about 72hrs).

Likely not for the next CRAN release of mapedit but I will also investigate whether it makes sense to export initMap from mapview. I don't quite like the code duplication as a long-term solution (I have similar issues throughout other packages).

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

2 participants