From 7a121b4d1dedca88e31f236b24f18ec690320072 Mon Sep 17 00:00:00 2001 From: Anna Petrasova Date: Tue, 9 Apr 2024 14:30:17 -0400 Subject: [PATCH 1/2] r.in.gdal: rename option location to project --- lib/gis/renamed_options | 1 + raster/r.in.gdal/main.c | 51 ++++++++++++++++----------------- raster/r.in.gdal/r.in.gdal.html | 4 +-- scripts/r.import/r.import.py | 14 ++++----- 4 files changed, 35 insertions(+), 35 deletions(-) diff --git a/lib/gis/renamed_options b/lib/gis/renamed_options index e996126a9b0..488dea1eb19 100644 --- a/lib/gis/renamed_options +++ b/lib/gis/renamed_options @@ -730,3 +730,4 @@ r.proj|location:project i.ortho.elev|location:project g.download.location|location:project v.proj|location:project +r.in.gdal|location:project diff --git a/raster/r.in.gdal/main.c b/raster/r.in.gdal/main.c index 372bda483e2..8606ea6c939 100644 --- a/raster/r.in.gdal/main.c +++ b/raster/r.in.gdal/main.c @@ -113,7 +113,7 @@ int main(int argc, char *argv[]) module = G_define_module(); G_add_keyword(_("raster")); G_add_keyword(_("import")); - G_add_keyword(_("create location")); + G_add_keyword(_("create project")); module->description = _("Imports raster data into a GRASS raster map using GDAL library."); @@ -139,8 +139,8 @@ int main(int argc, char *argv[]) parm.target->key = "target"; parm.target->type = TYPE_STRING; parm.target->required = NO; - parm.target->label = _("Name of GCPs target location"); - parm.target->description = _("Name of location to create or to read " + parm.target->label = _("Name of GCPs target project (location)"); + parm.target->description = _("Name of project to create or to read " "projection from for GCPs transformation"); parm.target->key_desc = "name"; parm.target->guisection = _("Projection"); @@ -182,10 +182,10 @@ int main(int argc, char *argv[]) parm.map_names_file->guisection = _("Metadata"); parm.outloc = G_define_option(); - parm.outloc->key = "location"; + parm.outloc->key = "project"; parm.outloc->type = TYPE_STRING; parm.outloc->required = NO; - parm.outloc->description = _("Name for new location to create"); + parm.outloc->description = _("Name for new project (location) to create"); parm.outloc->key_desc = "name"; parm.rat = G_define_option(); @@ -214,9 +214,9 @@ int main(int argc, char *argv[]) flag_o = G_define_flag(); flag_o->key = 'o'; flag_o->label = - _("Override projection check (use current location's projection)"); - flag_o->description = _( - "Assume that the dataset has same projection as the current location"); + _("Override projection check (use current project's projection)"); + flag_o->description = + _("Assume that the dataset has same projection as the current project"); flag_o->guisection = _("Projection"); flag_j = G_define_flag(); @@ -258,9 +258,9 @@ int main(int argc, char *argv[]) flag_c = G_define_flag(); flag_c->key = 'c'; - flag_c->description = _( - "Create the location specified by the \"location\" parameter and exit." - " Do not import the raster file."); + flag_c->description = + _("Create the project specified by the \"project\" parameter and exit." + " Do not import the raster file."); flag_r = G_define_flag(); flag_r->key = 'r'; @@ -343,16 +343,16 @@ int main(int argc, char *argv[]) /* -------------------------------------------------------------------- */ if (parm.target->answer && parm.outloc->answer && strcmp(parm.target->answer, parm.outloc->answer) == 0) { - G_fatal_error(_("You have to specify a target location different from " - "output location")); + G_fatal_error(_("You have to specify a target project different from " + "output project")); } if (flag_c->answer && parm.outloc->answer == NULL) { - G_fatal_error(_("You need to specify valid location name.")); + G_fatal_error(_("You need to specify valid project name.")); } if (flag_l->answer && G_projection() != PROJECTION_LL) - G_fatal_error(_("The '-l' flag only works in Lat/Lon locations")); + G_fatal_error(_("The '-l' flag only works in Lat/Lon projects")); if (num_digits < 0) G_fatal_error(_("The number of digits for band numbering must be equal " @@ -369,7 +369,7 @@ int main(int argc, char *argv[]) croptoregion = flag_r->answer; if (flag_r->answer && parm.outloc->answer) { - G_warning(_("Disabling '-r' flag for new location")); + G_warning(_("Disabling '-r' flag for new project")); croptoregion = 0; } @@ -979,7 +979,7 @@ int main(int argc, char *argv[]) &proj_units, hSRS, 0) == 1) { G_warning( _("Unable to convert input map projection to GRASS " - "format; cannot create new location.")); + "format; cannot create new project.")); } else { const char *authkey, *authname, *authcode; @@ -1034,18 +1034,18 @@ int main(int argc, char *argv[]) if (0 != G_make_location_crs( parm.target->answer, &gcpcellhd, proj_info, proj_units, gdalsrid, gdalwkt)) { - G_fatal_error(_("Unable to create new location <%s>"), + G_fatal_error(_("Unable to create new project <%s>"), parm.target->answer); } /* switch back to import location */ G_switch_env(); - G_message(_("Location <%s> created"), parm.target->answer); + G_message(_("Project <%s> created"), parm.target->answer); /* set the group's target */ I_put_target(output, parm.target->answer, "PERMANENT"); G_message(_("The target for the output group <%s> has been " "set to " - "location <%s>, mapset ."), + "project <%s>, mapset ."), output, parm.target->answer); } } @@ -1084,7 +1084,7 @@ int main(int argc, char *argv[]) if (strcmp(G_mapset(), "PERMANENT") == 0) { G_put_element_window(&cur_wind, "", "DEFAULT_WIND"); - G_message(_("Default region for this location updated")); + G_message(_("Default region for this project updated")); } G_put_window(&cur_wind); G_message(_("Region for the current mapset updated")); @@ -1133,21 +1133,20 @@ static void SetupReprojector(const char *pszSrcWKT, const char *pszDstLoc, /* Get projection info from target location */ if ((out_proj_info = G_get_projinfo()) == NULL) - G_fatal_error( - _("Unable to get projection info of target location")); + G_fatal_error(_("Unable to get projection info of target project")); if ((out_unit_info = G_get_projunits()) == NULL) G_fatal_error( - _("Unable to get projection units of target location")); + _("Unable to get projection units of target project")); if (pj_get_kv(oproj, out_proj_info, out_unit_info) < 0) G_fatal_error( - _("Unable to get projection key values of target location")); + _("Unable to get projection key values of target project")); tproj->def = NULL; if (GPJ_init_transform(iproj, oproj, tproj) < 0) G_fatal_error(_("Unable to initialize coordinate transformation")); } else { /* can't access target mapset */ /* access to mapset PERMANENT in target location is not required */ - sprintf(errbuf, _("Mapset <%s> in target location <%s> - "), + sprintf(errbuf, _("Mapset <%s> in target project <%s> - "), target_mapset, pszDstLoc); strcat(errbuf, permissions == 0 ? _("permission denied") : _("not found")); diff --git a/raster/r.in.gdal/r.in.gdal.html b/raster/r.in.gdal/r.in.gdal.html index 0fa7899290c..44a1ea8d78b 100644 --- a/raster/r.in.gdal/r.in.gdal.html +++ b/raster/r.in.gdal/r.in.gdal.html @@ -144,7 +144,7 @@

Location Creation

If the user wishes to import the data with the full projection definition, it is possible to have r.in.gdal automatically create a new location based on the projection and extents of the file being read. This is accomplished -by passing the name to be used for the new location via the location +by passing the name to be used for the new location via the project parameter. Upon completion of the command, a new location will have been created (with only a PERMANENT mapset), and the raster will have been imported with the indicated output name into the PERMANENT mapset. @@ -263,7 +263,7 @@

Error Messages

"ERROR: Projection of dataset does not appear to match the current location."
You need to create a location whose projection matches the data you -wish to import. Try using location parameter to create a new +wish to import. Try using project parameter to create a new location based upon the projection information in the file. If desired, you can then re-project it to another location with r.proj. Alternatively you can override this error by using the -o flag. diff --git a/scripts/r.import/r.import.py b/scripts/r.import/r.import.py index 2515c9178e6..9022f668d33 100644 --- a/scripts/r.import/r.import.py +++ b/scripts/r.import/r.import.py @@ -106,8 +106,8 @@ # %end # %flag # % key: o -# % label: Override projection check (use current location's projection) -# % description: Assume that the dataset has the same projection as the current location +# % label: Override projection check (use current project's projection) +# % description: Assume that the dataset has the same projection as the current project # %end # %rules # % required: output,-e @@ -215,7 +215,7 @@ def main(): # make sure target is not xy if grass.parse_command("g.proj", flags="g")["name"] == "xy_location_unprojected": grass.fatal( - _("Coordinate reference system not available for current location <%s>") + _("Coordinate reference system not available for current project <%s>") % tgtloc ) @@ -228,7 +228,7 @@ def main(): SRCGISRC, src_env = grass.create_environment(GISDBASE, TMPLOC, "PERMANENT") # create temp location from input without import - grass.verbose(_("Creating temporary location for <%s>...") % GDALdatasource) + grass.verbose(_("Creating temporary project for <%s>...") % GDALdatasource) # creating a new location with r.in.gdal requires a sanitized env env = os.environ.copy() env = grass.sanitize_mapset_environment(env) @@ -238,7 +238,7 @@ def main(): memory=memory, flags="c", title=title, - location=TMPLOC, + project=TMPLOC, quiet=True, ) if bands: @@ -271,7 +271,7 @@ def main(): ) # import into temp location - grass.verbose(_("Importing <%s> to temporary location...") % GDALdatasource) + grass.verbose(_("Importing <%s> to temporary project...") % GDALdatasource) parameters = dict( input=GDALdatasource, output=output, @@ -387,7 +387,7 @@ def main(): if grass.vector_info_topo(vreg, env=src_env)["areas"] != 1: grass.fatal(_("Please check the 'extent' parameter")) except CalledModuleError: - grass.fatal(_("Unable to reproject to source location")) + grass.fatal(_("Unable to reproject to source project")) # set region from region vector grass.run_command("g.region", raster=outfile, env=src_env) From 764d59d1e956bcdf5cb14e4497755f8c4c31e4d2 Mon Sep 17 00:00:00 2001 From: Anna Petrasova Date: Tue, 9 Apr 2024 14:49:50 -0400 Subject: [PATCH 2/2] additional renaming --- raster/r.in.gdal/proj.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/raster/r.in.gdal/proj.c b/raster/r.in.gdal/proj.c index 5f5f3a903ac..eb447576651 100644 --- a/raster/r.in.gdal/proj.c +++ b/raster/r.in.gdal/proj.c @@ -131,14 +131,14 @@ void check_projection(struct Cell_head *cellhd, GDALDatasetH hDS, char *outloc, /* do not create a xy location if an existing SRS was unreadable */ if (proj_trouble == 2) { G_fatal_error(_("Unable to convert input map projection to GRASS " - "format; cannot create new location.")); + "format; cannot create new project.")); } else { if (0 != G_make_location_crs(outloc, cellhd, proj_info, proj_units, srid, wkt)) { - G_fatal_error(_("Unable to create new location <%s>"), outloc); + G_fatal_error(_("Unable to create new project <%s>"), outloc); } - G_message(_("Location <%s> created"), outloc); + G_message(_("Project <%s> created"), outloc); G_unset_window(); /* new location, projection, and window */ G_get_window(cellhd); @@ -197,13 +197,13 @@ void check_projection(struct Cell_head *cellhd, GDALDatasetH hDS, char *outloc, int i_value; strcpy(error_msg, _("Projection of dataset does not" - " appear to match current location.\n\n")); + " appear to match current project.\n\n")); /* TODO: output this info sorted by key: */ if (loc_wind.proj != cellhd->proj || err != -2) { /* error in proj_info */ if (loc_proj_info != NULL) { - strcat(error_msg, _("Location PROJ_INFO is:\n")); + strcat(error_msg, _("Project PROJ_INFO is:\n")); for (i_value = 0; i_value < loc_proj_info->nitems; i_value++) sprintf(error_msg + strlen(error_msg), "%s: %s\n", @@ -212,22 +212,22 @@ void check_projection(struct Cell_head *cellhd, GDALDatasetH hDS, char *outloc, strcat(error_msg, "\n"); } else { - strcat(error_msg, _("Location PROJ_INFO is:\n")); + strcat(error_msg, _("Project PROJ_INFO is:\n")); if (loc_wind.proj == PROJECTION_XY) sprintf(error_msg + strlen(error_msg), - "Location proj = %d (unreferenced/unknown)\n", + "Project proj = %d (unreferenced/unknown)\n", loc_wind.proj); else if (loc_wind.proj == PROJECTION_LL) sprintf(error_msg + strlen(error_msg), - "Location proj = %d (lat/long)\n", + "Project proj = %d (lat/long)\n", loc_wind.proj); else if (loc_wind.proj == PROJECTION_UTM) sprintf(error_msg + strlen(error_msg), - "Location proj = %d (UTM), zone = %d\n", + "Project proj = %d (UTM), zone = %d\n", loc_wind.proj, cellhd->zone); else sprintf(error_msg + strlen(error_msg), - "Location proj = %d (unknown), zone = %d\n", + "Project proj = %d (unknown), zone = %d\n", loc_wind.proj, cellhd->zone); } @@ -301,7 +301,7 @@ void check_projection(struct Cell_head *cellhd, GDALDatasetH hDS, char *outloc, else { /* error in proj_units */ if (loc_proj_units != NULL) { - strcat(error_msg, "Location PROJ_UNITS is:\n"); + strcat(error_msg, "Project PROJ_UNITS is:\n"); for (i_value = 0; i_value < loc_proj_units->nitems; i_value++) sprintf(error_msg + strlen(error_msg), "%s: %s\n", @@ -322,10 +322,10 @@ void check_projection(struct Cell_head *cellhd, GDALDatasetH hDS, char *outloc, strcat(error_msg, _("\nIn case of no significant differences " "in the projection definitions," " use the -o flag to ignore them and use" - " current location definition.\n")); + " current project definition.\n")); strcat(error_msg, _("Consider generating a new location from " "the input dataset using " - "the 'location' parameter.\n")); + "the 'project' parameter.\n")); } if (check_only) @@ -343,7 +343,7 @@ void check_projection(struct Cell_head *cellhd, GDALDatasetH hDS, char *outloc, msg_fn = G_message; else msg_fn = G_verbose_message; - msg_fn(_("Projection of input dataset and current location " + msg_fn(_("Projection of input dataset and current project " "appear to match")); if (check_only) { GDALClose(hDS);