-
-
Notifications
You must be signed in to change notification settings - Fork 327
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -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"); | ||||||||||||||
Comment on lines
+217
to
+219
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
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 " | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
"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 <PERMANENT>."), | ||||||||||||||
"project <%s>, mapset <PERMANENT>."), | ||||||||||||||
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")); | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
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")); | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
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")); | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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")); | ||||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -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" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
" 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," | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
" 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 " | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
"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 " | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
"appear to match")); | ||||||
if (check_only) { | ||||||
GDALClose(hDS); | ||||||
|
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
# %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) | ||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.