Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

r.in.gdal: rename option location to project #3575

Merged
merged 3 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/gis/renamed_options
Original file line number Diff line number Diff line change
Expand Up @@ -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
51 changes: 25 additions & 26 deletions raster/r.in.gdal/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.");

Expand All @@ -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");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"projection from for GCPs transformation");
"CRS from for GCPs transformation");

parm.target->key_desc = "name";
parm.target->guisection = _("Projection");
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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");
Comment on lines +217 to +219
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
_("Override projection check (use current project's projection)");
flag_o->description =
_("Assume that the dataset has same projection as the current project");
_("Override projection check (use current project's CRS)");
flag_o->description =
_("Assume that the dataset has same CRS as the current project");

flag_o->guisection = _("Projection");

flag_j = G_define_flag();
Expand Down Expand Up @@ -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';
Expand Down Expand Up @@ -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 "
Expand All @@ -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;
}

Expand Down Expand Up @@ -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 "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
_("Unable to convert input map projection to GRASS "
_("Unable to convert input map CRS to GRASS "

"format; cannot create new location."));
"format; cannot create new project."));
}
else {
const char *authkey, *authname, *authcode;
Expand Down Expand Up @@ -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 <PERMANENT>."),
"project <%s>, mapset <PERMANENT>."),
output, parm.target->answer);
}
}
Expand Down Expand Up @@ -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"));
Expand Down Expand Up @@ -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"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
G_fatal_error(_("Unable to get projection info of target project"));
G_fatal_error(_("Unable to get CRS 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"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
_("Unable to get projection units of target project"));
_("Unable to get CRS 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"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
_("Unable to get projection key values of target project"));
_("Unable to get CRS key values of target project"));

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if CRS key values makes sense though

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"));
Expand Down
28 changes: 14 additions & 14 deletions raster/r.in.gdal/proj.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
strcpy(error_msg, _("Projection of dataset does not"
strcpy(error_msg, _("Dataset CRS 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",
Expand All @@ -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);
}

Expand Down Expand Up @@ -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",
Expand All @@ -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,"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"in the projection definitions,"
"in the CRS 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 "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
strcat(error_msg, _("Consider generating a new location from "
strcat(error_msg, _("Consider generating a new project from "

"the input dataset using "
"the 'location' parameter.\n"));
"the 'project' parameter.\n"));
}

if (check_only)
Expand All @@ -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 "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
msg_fn(_("Projection of input dataset and current project "
msg_fn(_("CRS of input dataset and current project "

"appear to match"));
if (check_only) {
GDALClose(hDS);
Expand Down
4 changes: 2 additions & 2 deletions raster/r.in.gdal/r.in.gdal.html
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ <h3>Location Creation</h3>
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 <b>location</b>
by passing the name to be used for the new location via the <b>project</b>
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 <b>output</b> name into the PERMANENT mapset.
Expand Down Expand Up @@ -263,7 +263,7 @@ <h3>Error Messages</h3>
<i>"ERROR: Projection of dataset does not appear to match the current location."</i><br>

You need to create a location whose projection matches the data you
wish to import. Try using <b>location</b> parameter to create a new
wish to import. Try using <b>project</b> 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 <em>r.proj</em>.
Alternatively you can override this error by using the <b>-o</b> flag.
Expand Down
14 changes: 7 additions & 7 deletions scripts/r.import/r.import.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment on lines +109 to +110
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# % label: Override projection check (use current project's projection)
# % description: Assume that the dataset has the same projection as the current project
# % label: Override projection check (use current project's CRS)
# % description: Assume that the dataset has the same coordinate reference system (CRS) as the current project

# %end
# %rules
# % required: output,-e
Expand Down Expand Up @@ -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
)

Expand All @@ -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)
Expand All @@ -238,7 +238,7 @@ def main():
memory=memory,
flags="c",
title=title,
location=TMPLOC,
project=TMPLOC,
quiet=True,
)
if bands:
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
Loading