Skip to content

Commit

Permalink
v.in.ogr: rename option location to project (#3576)
Browse files Browse the repository at this point in the history
  • Loading branch information
petrasovaa committed Apr 11, 2024
1 parent 8bf604c commit 324ef27
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 39 deletions.
1 change: 1 addition & 0 deletions lib/gis/renamed_options
Original file line number Diff line number Diff line change
Expand Up @@ -732,3 +732,4 @@ g.download.location|location:project
v.proj|location:project
r.in.gdal|location:project
g.proj|location:project
v.in.ogr|location:project
14 changes: 7 additions & 7 deletions scripts/v.import/v.import.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,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 CRS)
# % description: Assume that the dataset has the same coordinate reference system (CRS) as the current project
# %end

import sys
Expand Down Expand Up @@ -240,7 +240,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 @@ -261,7 +261,7 @@ def main():
tgtsrs = grass.read_command("g.proj", flags="j", quiet=True)

# create temp location from input without import
grass.verbose(_("Creating temporary location for <%s>...") % OGRdatasource)
grass.verbose(_("Creating temporary project for <%s>...") % OGRdatasource)
try:
if OGRdatasource.lower().endswith("gml"):
try:
Expand All @@ -277,15 +277,15 @@ def main():
grass.run_command(
"v.in.ogr",
input=OGRdatasource,
location=TMPLOC,
project=TMPLOC,
flags="i",
quiet=True,
overwrite=overwrite,
**vopts,
)
except CalledModuleError:
grass.fatal(
_("Unable to create location from OGR datasource <%s>") % OGRdatasource
_("Unable to create project from OGR datasource <%s>") % OGRdatasource
)

# switch to temp location
Expand Down Expand Up @@ -330,7 +330,7 @@ def main():
overwrite=overwrite,
)
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", res="1")
Expand Down
23 changes: 12 additions & 11 deletions vector/v.in.ogr/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ int main(int argc, char *argv[])
G_add_keyword(_("topology"));
G_add_keyword(_("geometry"));
G_add_keyword(_("snapping"));
G_add_keyword(_("create location"));
G_add_keyword(_("create project"));
module->description =
_("Imports vector data into a GRASS vector map using OGR library.");

Expand Down Expand Up @@ -307,10 +307,10 @@ int main(int argc, char *argv[])
param.snap->description = _("'-1' for no snap");

param.outloc = G_define_option();
param.outloc->key = "location";
param.outloc->key = "project";
param.outloc->type = TYPE_STRING;
param.outloc->required = NO;
param.outloc->description = _("Name for new location to create");
param.outloc->description = _("Name for new project (location) to create");
param.outloc->key_desc = "name";
param.outloc->guisection = _("Output");

Expand Down Expand Up @@ -377,9 +377,10 @@ int main(int argc, char *argv[])
flag.over = G_define_flag();
flag.over->key = 'o';
flag.over->label =
_("Override projection check (use current location's projection)");
flag.over->description = _("Assume that the dataset has the same "
"projection as the current location");
_("Override projection check (use current project's CRS)");
flag.over->description =
_("Assume that the dataset has the same "
"coordinate reference system (CRS) as the current project");

flag.proj = G_define_flag();
flag.proj->key = 'j';
Expand All @@ -406,9 +407,9 @@ int main(int argc, char *argv[])

flag.no_import = G_define_flag();
flag.no_import->key = 'i';
flag.no_import->description = _(
"Create the location specified by the \"location\" parameter and exit."
" Do not import the vector data.");
flag.no_import->description =
_("Create the project specified by the \"project\" parameter and exit."
" Do not import the vector data.");
flag.no_import->guisection = _("Output");

/* The parser checks if the map already exists in current mapset, this is
Expand Down Expand Up @@ -715,7 +716,7 @@ int main(int argc, char *argv[])

/* create spatial filters */
if (param.outloc->answer && flag.region->answer) {
G_warning(_("When creating a new location, the current region "
G_warning(_("When creating a new project, the current region "
"can not be used as spatial filter, disabling"));
flag.region->answer = 0;
}
Expand Down Expand Up @@ -1972,7 +1973,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
43 changes: 23 additions & 20 deletions vector/v.in.ogr/proj.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,14 +298,14 @@ void check_projection(struct Cell_head *cellhd, GDALDatasetH hDS, int layer,
* real SRS has not been recognized or is missing */
if (proj_trouble) {
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 @@ -364,14 +364,15 @@ void check_projection(struct Cell_head *cellhd, GDALDatasetH hDS, int layer,
proj_info, proj_units)) != 1) {
int i_value;

strcpy(error_msg, _("Projection of dataset does not"
" appear to match current location.\n\n"));
strcpy(error_msg,
_("Coordinate reference system of dataset does not"
" 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 @@ -380,22 +381,22 @@ void check_projection(struct Cell_head *cellhd, GDALDatasetH hDS, int layer,
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 @@ -469,7 +470,7 @@ void check_projection(struct Cell_head *cellhd, GDALDatasetH hDS, int layer,
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 @@ -487,13 +488,14 @@ void check_projection(struct Cell_head *cellhd, GDALDatasetH hDS, int layer,
}
}
if (!check_only) {
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"));
strcat(error_msg, _("Consider generating a new location from "
strcat(error_msg,
_("\nIn case of no significant differences "
"in the coordinate reference system definitions,"
" use the -o flag to ignore them and use"
" current project definition.\n"));
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 @@ -511,8 +513,9 @@ void check_projection(struct Cell_head *cellhd, GDALDatasetH hDS, int layer,
msg_fn = G_message;
else
msg_fn = G_verbose_message;
msg_fn(_("Projection of input dataset and current location "
"appear to match"));
msg_fn(_("Coordinate reference system of input dataset and current "
"project appear to match"));

if (check_only) {
GDALClose(hDS);
exit(EXIT_SUCCESS);
Expand Down
2 changes: 1 addition & 1 deletion vector/v.in.ogr/v.in.ogr.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ <h2>Location Creation</h2>
definition, it is possible to have <em>v.in.ogr</em> 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> parameter. Upon completion
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 vector map will have been imported with the
indicated <b>output</b> name into the PERMANENT mapset.
Expand Down

0 comments on commit 324ef27

Please sign in to comment.