njtierney / geotargets

Targets extensions for geospatial data
https://njtierney.github.io/geotargets/
Other
49 stars 4 forks source link

Multiple calls to `geotargets_option_set()` nulls out existing options #64

Closed brownag closed 2 months ago

brownag commented 2 months ago

One more thing I noticed after #45

library(geotargets)

# set an option
geotargets_option_set(gdal_raster_driver = "GPKG")

# as expected
geotargets_option_get("gdal_raster_driver")
#> [1] "GPKG"

# set a different option
geotargets_option_set(gdal_vector_driver = "GPKG")

# both should be "GPKG"
geotargets_option_get("gdal_vector_driver")
#> NULL
geotargets_option_get("gdal_raster_driver")
#> NULL

This way of setting options all at once is the issue, due to default NULL argument values: https://github.com/njtierney/geotargets/blob/c148f7b9d7e8a94430133f1e978fce2d96d84110/R/geotargets-option.R#L40-L45

Note also that the wrong arguments are set for the vector options. Should use

        "geotargets.gdal.vector.driver" = gdal_vector_driver,
        "geotargets.gdal.vector.creation.options" = gdal_vector_creation_options
Aariq commented 2 months ago

Thanks, I can work on this

Aariq commented 2 months ago

Did a blunt-force solution to this in e1b039f which I accidentally pushed to master. I feel like there has to be a more programmatic way to do this though, so I'll keep this open for a bit in case I think of anything or anyone has any suggestions.