R/noExport_typeGeom.R

#' This function obtains the geometry type of a vector table in a postgreSQL database.
#' @title Obtains the geometry type of a vector table
#' @name typeGeom
#' @param con An object of class "connectPG" generated by dbConnectPG()
#' @param vecTable Name of vectorial table in the database
#' @return The type of the geometry as a string. For example: "LINESTRING", "POLYGON", etc.
#' @author Bruno Silva
typeGeom <- function(con, vecTable){
  if(class(con)!= 'pgConnect') stop('An object of class "pgConnect" is required to connect with the database')
  type <- 
    checkGeom(con, vecTable) %>%
    sprintf('SELECT GeometryType(%s) FROM %s', ., vecTable) %>%
    RPostgreSQL::dbGetQuery(con[[1]], .)
  return(as.character(unique(type)))
}
berdinazzi/easyPostGIS documentation built on May 12, 2019, 3:04 p.m.