diff --git a/DESCRIPTION b/DESCRIPTION index 2f208d49449e8839e3d9185efe15f7d8f4c0c56c..ace4835962738c80cfca65345725d845ef2844f8 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: datalibaba Title: Interface De Connexion a Une Base Posgres Postgis -Version: 0.0.0.9001 +Version: 0.0.0.9002 Authors@R: c(person(given = "Maël", family = "Theulière", diff --git a/NEWS.md b/NEWS.md index 927e5492349710e279e8881039632166d2d82a9c..7b75826ab798f1b76fe2e386ac40adc939693943 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,9 @@ +# datalibaba 0.0.0.9002 +- Correction d'un bug dans la fonction `importer_data()` : nommage du champ geo tel qu'il avait été chargé + # datalibaba 0.0.0.9001 - Correction d'un bug dans la fonction `poster_data()` : paramétrage des contraintes géo selon le nom de la colonne géo. (auparavant utilisation de 'geometry' pour toutes les tables, ce qui provoquait des plantages). -- Ajout de message pour le post de datatset geo afin d'identifier quelle étape est en cours. +- Ajout de message pour le post de dataset geo afin d'identifier quelle étape est en cours. # datalibaba 0.0.0.9000 diff --git a/R/get_data.R b/R/get_data.R index b7def292220ca97109c1256d4107b45faf5bba10..cd665ea3940ad6a1e677b7d19bf2ec369c341e6c 100644 --- a/R/get_data.R +++ b/R/get_data.R @@ -172,6 +172,10 @@ importer_data <- function(table = NULL, schema = NULL, db = "public", server = # remettre le champ geometrie (au bon endroit) if(exists("data_sf") & nrow(def_table) > 0) { sf::st_geometry(data) <- sf::st_geometry(data_sf) + # renommage du champ geo a l'identique + data <- dplyr::rename_with(data, ~gsub("^geometry$", sf_col_name, .x)) + sf::st_geometry(data) <- attributes(data_sf)$sf_column + data <- dplyr::relocate(data, dplyr::all_of(defs$nms)) } diff --git a/R/post_data.R b/R/post_data.R index 34fd1c40c471a158c5789fda4a1e04cced160d65..82e940071b31f1595cdcde8836807defce386909 100644 --- a/R/post_data.R +++ b/R/post_data.R @@ -244,12 +244,11 @@ poster_data <- function(data = NULL, # } # Ajout index geo - nom_champ_geo <- - rpostgis::dbIndex(conn = con, name = c(schema, table), colname = attributes(d)$sf_column, - idxname = paste0("gix_", table), unique = FALSE, method = "gist", - display = FALSE, exec = TRUE) + index_spatial <- rpostgis::dbIndex(conn = con, name = c(schema, table), colname = nom_col_geo, + idxname = paste0("gix_", table), unique = FALSE, method = "gist", + display = FALSE, exec = TRUE) mess <- "spatial " - mess2 <- paste0(" - index spatial declar\u00e9 sur '", attributes(d)$sf_column, "'") + mess2 <- ifelse(index_spatial, paste0(" - index spatial declar\u00e9 sur '", nom_col_geo, "'"), "") } else { DBI::dbWriteTable(con, name = c(schema, table), d, row.names = FALSE, overwrite = overwrite) mess <- ""