# This function returns the crs code for the projection indicated in
# 'proj_name' depending on the version of GDAL and proj.4, to be used
# in the PlotRobinson() function

get_proj_code <- function(proj_name) {
  # Define list with the grs codes for each projection
  code_list <- list(robinson = c(54030, "ESRI:53030"),
                    stereographic = c(3995, "EPSG:3995"),
                    lambert_europe = c(102014, paste("+proj=lcc +lat_0=30",
                                                     "+lon_0=10 +lat_1=43",
                                                     "+lat_2=62 +x_0=0 +y_0=0",
                                                     "+ellps=intl +units=m",
                                                     "+no_defs +type=crs")))
  # Get crs code version depending on GDAL and PROJ version
  if ((sf_extSoftVersion()[['GDAL']] < "3.0.0") &&
      (sf_extSoftVersion()[['PROJ']] < "6.0.0")) {
    proj_code <- as.integer(code_list[[proj_name]][1])
  } else {
    proj_code <- code_list[[proj_name]][2]
  }
  return(proj_code)
}
