ropensci / osmextract

Download and import OpenStreetMap data from Geofabrik and other providers
https://docs.ropensci.org/osmextract
GNU General Public License v3.0
170 stars 12 forks source link

Improve oe_get_keys #257

Closed agila5 closed 2 years ago

agila5 commented 2 years ago

Fix #251. The result of the following commit is summarised below:

1) Informative error when the selected layer does not exist:

library(osmextract)
#> Data (c) OpenStreetMap contributors, ODbL 1.0. https://www.openstreetmap.org/copyright.
#> Check the package website, https://docs.ropensci.org/osmextract/, for more details.
oe_get("ITS Leeds", download_only = TRUE, quiet = TRUE, download_directory = tempdir())
oe_get_keys("ITS Leeds", layer = "points", download_directory = tempdir())
#> Error: The matched file does not contain the selected layer. Check the examples in the docs to see how to add it.

oe_get("ITS Leeds", layer = "points", download_only = TRUE, quiet = TRUE, download_directory = tempdir())
oe_get_keys("ITS Leeds", layer = "points", download_directory = tempdir())
#>  [1] "amenity"                 "addr:postcode"          
#>  [3] "addr:street"             "addr:city"              
#>  [5] "fhrs:id"                 "capacity"               
#>  ...

Created on 2022-05-06 by the reprex package (v2.0.1)

  1. Warning when the keys were already extracted from the other-tags field
library(osmextract)
#> Data (c) OpenStreetMap contributors, ODbL 1.0. https://www.openstreetmap.org/copyright.
#> Check the package website, https://docs.ropensci.org/osmextract/, for more details.
oe_get(
  "ITS Leeds", download_only = TRUE, quiet = TRUE, 
  download_directory = tempdir(), extra_tags = c("foot", "lanes")
)
#> [1] "C:\\Users\\gilardi\\AppData\\Local\\Temp\\Rtmpi2s2FD\\test_its-example.gpkg"
oe_get_keys("ITS Leeds", download_directory = tempdir())
#>  [1] "surface"             "bicycle"             "lit"                
#>  [4] "access"              "oneway"              "maxspeed"           
#>  ... 

#> Warning: The following keys were already extracted from the other_tags field:
#> foot - lanes

Created on 2022-05-06 by the reprex package (v2.0.1)

I will write the tests after we merge #255

Robinlovelace commented 2 years ago

These look like really nice changes.

agila5 commented 2 years ago

Thanks, done!