koenderks / rcityviews

rcityviews is a user-friendly R interface for creating stylized city maps using OpenStreetMap (www.openstreetmap.org) data, implemented as an R package and a Shiny web application.
https://koenderks.github.io/rcityviews/
GNU General Public License v3.0
163 stars 22 forks source link

implementing geocoding #30

Closed pokyah closed 2 weeks ago

pokyah commented 3 weeks ago

Hi @koenderks ,

I have implemented a geocoding function that would allow to pass any location name.

Minimal example :

name = "Namur"
country = "Belgium"
theme = "original"
city = geocode(location = paste0(name, " ", country))

city <- new_city(
  name = name,
  country = country,
  lat = city[1, 3],
  long = city[1, 4]
)

map = cityview(
  name = city,
  license = F,
  theme = theme,
  timeout = 1000,
  legend = F,
  zoom = 3.75,
  border = "circle",
  halftone = "#ffffff",cache = T
)

Let me know if something is unclear or if I should implement it in another manner.

Thanks

pokyah commented 3 weeks ago

Example of the current implementation :

map = cityview(
 name = "Ixelles",
 license = F,
 theme = "vintage",
timeout = 1000,
legend = F,
zoom = 3.5,
border = "circle",
cache = T)

returns (as expected):

Error in .resolveConflicts(name, indexes, dataset) : 
  There is no city called 'Ixelles' in the available data.
 Use new_city function() to geocode the location

thus using new_city with implemented geocoder :

name = new_city(name = "Ixelles", country = "Belgium")
map = cityview(
 name = name ,
 license = F,
 theme = "vintage",
timeout = 1000,
legend = F,
zoom = 3.5,
border = "circle",
cache = T)

perfectly works :

[=======================================] 1/1 (100%) Elapsed:  1s Remaining:  0s
Discovered the city of Ixelles, Belgium at 50.8331141° / 4.3668279°!

[=======================================] 1/1 (100%) Elapsed:  1s Remaining:  0s
Discovered the city of Ixelles, Belgium at 50.8331141° / 4.3668279°!
koenderks commented 3 weeks ago

Can you perform a rebase on the development branch to get the most up-to-date code?

Open terminal:

git fetch upstream
git rebase upstream/developent
git push

If you encounter any conflicts with the daily.png and name.txt file, simply choose the use the modified file option.

koenderks commented 2 weeks ago

Merging this into geocoding and then into development, thanks! For the themes, I prefer to keep only the 10 rcityviews themes (prettymaps is nice, but I want to keep rcityviews something original), but I have made a persistent storage mechanism using the city_themes() function if you want to store them!

pokyah commented 2 weeks ago

Not sure what you want me to do with the new geocoding branch? Can you explain me the full workflow?

koenderks commented 2 weeks ago

Nothing ;) I diverted your pull request to https://github.com/koenderks/rcityviews/tree/geocoding and merged it into that branch! I just merged the geocoding branch into development, so you should have the new functionality in the package if you run.

remotes::install_github("koenderks/rcityviews", dependencies = TRUE)

Thanks for the effort and the new addition, it is very cool!

pokyah commented 2 weeks ago

Nothing ;) I diverted your pull request to https://github.com/koenderks/rcityviews/tree/geocoding and merged it into that branch! I just merged the geocoding branch into development, so you should have the new functionality in the package if you run.

remotes::install_github("koenderks/rcityviews", dependencies = TRUE)

Thanks for the effort and the new addition, it is very cool!

Thanks for letting me contribute to the package! I really enjoyed contributing on in and have learnt quite a few things on the way!