[GRASS-SVN] r33161 - in grass/trunk/vector: v.buffer v.build
v.build.polylines v.category v.class v.clean v.db.connect
v.db.select v.distance v.drape v.edit v.extract v.extrude
v.generalize v.hull v.info
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Aug 29 18:27:02 EDT 2008
Author: glynn
Date: 2008-08-29 18:27:02 -0400 (Fri, 29 Aug 2008)
New Revision: 33161
Modified:
grass/trunk/vector/v.buffer/main.c
grass/trunk/vector/v.build.polylines/main.c
grass/trunk/vector/v.build/main.c
grass/trunk/vector/v.category/main.c
grass/trunk/vector/v.class/main.c
grass/trunk/vector/v.clean/main.c
grass/trunk/vector/v.db.connect/main.c
grass/trunk/vector/v.db.select/main.c
grass/trunk/vector/v.distance/main.c
grass/trunk/vector/v.drape/main.c
grass/trunk/vector/v.edit/main.c
grass/trunk/vector/v.extract/main.c
grass/trunk/vector/v.extrude/main.c
grass/trunk/vector/v.generalize/main.c
grass/trunk/vector/v.hull/main.c
grass/trunk/vector/v.info/main.c
Log:
Remove explicit mapset references and G_find_* calls
Modified: grass/trunk/vector/v.buffer/main.c
===================================================================
--- grass/trunk/vector/v.buffer/main.c 2008-08-29 20:57:26 UTC (rev 33160)
+++ grass/trunk/vector/v.buffer/main.c 2008-08-29 22:27:02 UTC (rev 33161)
@@ -232,7 +232,6 @@
struct Map_info In, Out;
struct line_pnts *Points, *BPoints;
struct line_cats *Cats, *BCats;
- char *mapset;
struct GModule *module;
struct Option *in_opt, *out_opt, *type_opt, *buffer_opt, *tolerance_opt,
*bufcol_opt, *scale_opt, *debug_opt, *field_opt;
@@ -362,12 +361,8 @@
BCats = Vect_new_cats_struct();
/* open input vector */
- if ((mapset = G_find_vector2(in_opt->answer, "")) == NULL) {
- G_fatal_error(_("Vector map <%s> not found"), in_opt->answer);
- }
-
Vect_set_open_level(2);
- Vect_open_old(&In, in_opt->answer, mapset);
+ Vect_open_old(&In, in_opt->answer, "");
Vect_set_fatal_error(GV_FATAL_PRINT);
if (0 > Vect_open_new(&Out, out_opt->answer, 0)) {
Modified: grass/trunk/vector/v.build/main.c
===================================================================
--- grass/trunk/vector/v.build/main.c 2008-08-29 20:57:26 UTC (rev 33160)
+++ grass/trunk/vector/v.build/main.c 2008-08-29 22:27:02 UTC (rev 33161)
@@ -79,11 +79,6 @@
/* build topology */
if (build) {
- /* open input vector */
- if (G_find_vector2(map_opt->answer, G_mapset()) == NULL)
- G_fatal_error(_("Vector map <%s> not found in the current mapset"),
- map_opt->answer);
-
Vect_set_open_level(1);
Vect_open_old(&Map, map_opt->answer, G_mapset());
Modified: grass/trunk/vector/v.build.polylines/main.c
===================================================================
--- grass/trunk/vector/v.build.polylines/main.c 2008-08-29 20:57:26 UTC (rev 33160)
+++ grass/trunk/vector/v.build.polylines/main.c 2008-08-29 22:27:02 UTC (rev 33161)
@@ -101,7 +101,6 @@
int nlines, type;
int write_cats;
- char *mapset;
int start_type;
/* Initialize the GIS calls */
@@ -137,11 +136,8 @@
GV_FATAL_EXIT);
/* Open binary vector map at level 2 */
- mapset = G_find_vector2(input->answer, "");
- if (mapset == NULL)
- G_fatal_error(_("Vector map <%s> not found"), input->answer);
Vect_set_open_level(2);
- Vect_open_old(&map, input->answer, mapset);
+ Vect_open_old(&map, input->answer, "");
/* Open new vector */
G_find_vector2(output->answer, "");
Modified: grass/trunk/vector/v.category/main.c
===================================================================
--- grass/trunk/vector/v.category/main.c 2008-08-29 20:57:26 UTC (rev 33160)
+++ grass/trunk/vector/v.category/main.c 2008-08-29 22:27:02 UTC (rev 33161)
@@ -180,16 +180,12 @@
G_fatal_error(_("2 layers must be specified"));
if ((option != O_REP) && (option != O_PRN)) {
- if (out_opt->answer == NULL) {
+ if (out_opt->answer == NULL)
G_fatal_error(_("Output vector wasn't entered"));
- }
+
Vect_check_input_output_name(in_opt->answer, out_opt->answer,
GV_FATAL_EXIT);
}
- else {
- if (G_find_vector2(in_opt->answer, "") == NULL)
- G_fatal_error(_("Vector map <%s> not found"), in_opt->answer);
- }
Points = Vect_new_line_struct();
Cats = Vect_new_cats_struct();
Modified: grass/trunk/vector/v.class/main.c
===================================================================
--- grass/trunk/vector/v.class/main.c 2008-08-29 20:57:26 UTC (rev 33160)
+++ grass/trunk/vector/v.class/main.c 2008-08-29 22:27:02 UTC (rev 33161)
@@ -29,7 +29,6 @@
struct Option *map_opt, *field_opt, *col_opt, *where_opt;
struct Option *algo_opt, *nbclass_opt;
struct Flag *shell_flag;
- char *mapset;
struct Map_info Map;
struct field_info *Fi;
dbDriver *Driver;
@@ -91,11 +90,8 @@
ofield = atoi(field_opt->answer);
/* open input vector */
- if ((mapset = G_find_vector2(map_opt->answer, "")) == NULL)
- G_fatal_error(_("Vector map <%s> not found"), map_opt->answer);
-
Vect_set_open_level(2);
- Vect_open_old(&Map, map_opt->answer, mapset);
+ Vect_open_old(&Map, map_opt->answer, "");
/* Read attributes */
db_CatValArray_init(&Cvarr);
Modified: grass/trunk/vector/v.clean/main.c
===================================================================
--- grass/trunk/vector/v.clean/main.c 2008-08-29 20:57:26 UTC (rev 33160)
+++ grass/trunk/vector/v.clean/main.c 2008-08-29 22:27:02 UTC (rev 33161)
@@ -26,7 +26,6 @@
{
struct Map_info In, Out, Err, *pErr;
int i, otype, with_z;
- char *mapset;
struct GModule *module;
struct Option *in_opt, *out_opt, *type_opt, *tool_opt, *thresh_opt,
*err_opt;
@@ -237,16 +236,11 @@
G_message(SEP);
- /* open input vector */
- if ((mapset = G_find_vector2(in_opt->answer, "")) == NULL) {
- G_fatal_error(_("Vector map <%s> not found"), in_opt->answer);
- }
-
/* Input vector may be both on level 1 and 2. Level 2 is necessary for
* virtual centroids (shapefile/OGR) and level 1 is better if input is too big
* and build in previous module (like v.in.ogr or other call to v.clean) would take
* a long time */
- level = Vect_open_old(&In, in_opt->answer, mapset);
+ level = Vect_open_old(&In, in_opt->answer, "");
with_z = Vect_is_3d(&In);
Modified: grass/trunk/vector/v.db.connect/main.c
===================================================================
--- grass/trunk/vector/v.db.connect/main.c 2008-08-29 20:57:26 UTC (rev 33160)
+++ grass/trunk/vector/v.db.connect/main.c 2008-08-29 22:27:02 UTC (rev 33161)
@@ -30,7 +30,7 @@
int main(int argc, char **argv)
{
- char *input, *mapset;
+ char *input;
struct GModule *module;
struct Option *inopt, *dbdriver, *dbdatabase, *dbtable, *field_opt,
*dbkey;
@@ -112,24 +112,19 @@
}
*/
- /* set input vector map name and mapset */
+ /* set input vector map name */
input = inopt->answer;
- mapset = G_find_vector2(input, "");
- if (!mapset)
- G_fatal_error(_("Vector map <%s> not found"), input);
if (field_opt->answer)
field = atoi(field_opt->answer);
else
field = 1;
- G_debug(3, "Mapset = %s", mapset);
-
if (print->answer && shell_print->answer)
G_fatal_error(_("Please choose only one print style"));
if (print->answer || shell_print->answer || columns->answer)
- Vect_open_old(&Map, inopt->answer, mapset);
+ Vect_open_old(&Map, inopt->answer, "");
else {
if (Vect_open_update_head(&Map, inopt->answer, G_mapset()) < 1)
G_fatal_error(_("Unable to modify vector map stored in other mapset"));
@@ -140,13 +135,13 @@
num_dblinks = Vect_get_num_dblinks(&Map);
if (num_dblinks <= 0)
G_fatal_error(_("Database connection for map <%s> is not defined in DB file"),
- G_fully_qualified_name(input, mapset));
+ input);
else { /* num_dblinks > 0 */
if (print->answer || shell_print->answer) {
if (!(shell_print->answer)) {
G_message(_("Vector map <%s> is connected by:"),
- G_fully_qualified_name(input, mapset));
+ input);
}
for (i = 0; i < num_dblinks; i++) {
if ((fi = Vect_get_dblink(&Map, i)) == NULL)
Modified: grass/trunk/vector/v.db.select/main.c
===================================================================
--- grass/trunk/vector/v.db.select/main.c 2008-08-29 20:57:26 UTC (rev 33160)
+++ grass/trunk/vector/v.db.select/main.c 2008-08-29 22:27:02 UTC (rev 33161)
@@ -41,7 +41,6 @@
struct field_info *Fi;
int field, ncols, col, more;
struct Map_info Map;
- char *mapset;
char query[1024];
struct ilist *list_lines;
@@ -115,20 +114,14 @@
db_init_string(&value_string);
/* open input vector */
- if ((mapset = G_find_vector2(map_opt->answer, "")) == NULL) {
- G_fatal_error(_("Vector map <%s> not found"), map_opt->answer);
- }
-
- if (!r_flag->answer) {
- Vect_open_old_head(&Map, map_opt->answer, mapset);
- }
+ if (!r_flag->answer)
+ Vect_open_old_head(&Map, map_opt->answer, "");
else {
- if (2 > Vect_open_old(&Map, map_opt->answer, mapset)) {
+ if (2 > Vect_open_old(&Map, map_opt->answer, "")) {
Vect_close(&Map);
G_fatal_error(_("Unable to open vector map <%s> at topology level. "
"Flag '%c' requires topology level."),
- G_fully_qualified_name(map_opt->answer, mapset),
- r_flag->key);
+ map_opt->answer, r_flag->key);
}
}
Modified: grass/trunk/vector/v.distance/main.c
===================================================================
--- grass/trunk/vector/v.distance/main.c 2008-08-29 20:57:26 UTC (rev 33160)
+++ grass/trunk/vector/v.distance/main.c 2008-08-29 22:27:02 UTC (rev 33161)
@@ -74,7 +74,6 @@
int i, j, k;
int print_as_matrix; /* only for all */
int all; /* calculate from each to each within the threshold */
- char *mapset;
struct GModule *module;
struct Option *from_opt, *to_opt, *from_type_opt, *to_type_opt,
*from_field_opt, *to_field_opt;
@@ -294,20 +293,12 @@
G_fatal_error(_("Not enough column names"));
/* Open 'from' vector */
- if ((mapset = G_find_vector2(from_opt->answer, "")) == NULL)
- G_fatal_error(_("Vector map <%s> not found"), from_opt->answer);
-
- if (!print_flag->answer && strcmp(mapset, G_mapset()) != 0)
- G_fatal_error(_("Vector map <%s> is not in user mapset and cannot be updated"),
- from_opt->answer);
-
Vect_set_open_level(2);
- Vect_open_old(&From, from_opt->answer, mapset);
+ Vect_open_old(&From, from_opt->answer, G_mapset());
/* Open 'to' vector */
- mapset = G_find_vector2(to_opt->answer, "");
Vect_set_open_level(2);
- Vect_open_old(&To, to_opt->answer, mapset);
+ Vect_open_old(&To, to_opt->answer, "");
/* Open output vector */
if (out_opt->answer) {
Modified: grass/trunk/vector/v.drape/main.c
===================================================================
--- grass/trunk/vector/v.drape/main.c 2008-08-29 20:57:26 UTC (rev 33160)
+++ grass/trunk/vector/v.drape/main.c 2008-08-29 22:27:02 UTC (rev 33161)
@@ -136,13 +136,8 @@
Vect_check_input_output_name(in_opt->answer, out_opt->answer,
GV_FATAL_EXIT);
- mapset = G_find_vector2(in_opt->answer, "");
- if (!mapset) {
- G_fatal_error(_("Vector map <%s> not found"), in_opt->answer);
- }
+ Vect_open_old(&In, in_opt->answer, "");
- Vect_open_old(&In, in_opt->answer, mapset);
-
/* checks
does the elevation raster cover the entire are of the vector map?
does the current region include the entire input vector map ?
Modified: grass/trunk/vector/v.edit/main.c
===================================================================
--- grass/trunk/vector/v.edit/main.c 2008-08-29 20:57:26 UTC (rev 33160)
+++ grass/trunk/vector/v.edit/main.c 2008-08-29 22:27:02 UTC (rev 33161)
@@ -27,7 +27,6 @@
struct Map_info Map;
struct Map_info **BgMap; /* backgroud vector maps */
int nbgmaps; /* number of registrated background maps */
- char *mapset;
enum mode action_mode;
FILE *ascii;
@@ -104,17 +103,10 @@
}
}
else { /* open selected vector file */
- mapset = G_find_vector2(params.map->answer, G_mapset());
- if (mapset == NULL) {
- G_fatal_error(_("Vector map <%s> not found in the current mapset"),
- params.map->answer);
- }
- else if (action_mode == MODE_ADD) { /* write */
- ret = Vect_open_update(&Map, params.map->answer, mapset);
- }
- else { /* read-only -- select features */
- ret = Vect_open_old(&Map, params.map->answer, mapset);
- }
+ if (action_mode == MODE_ADD) /* write */
+ ret = Vect_open_update(&Map, params.map->answer, G_mapset());
+ else /* read-only -- select features */
+ ret = Vect_open_old(&Map, params.map->answer, G_mapset());
if (ret < 2)
G_fatal_error(_("Unable to open vector map <%s> at topological level %d"),
@@ -126,37 +118,28 @@
/* open backgroud maps */
if (params.bmaps->answer) {
i = 0;
- char *bmap;
while (params.bmaps->answers[i]) {
- bmap = params.bmaps->answers[i];
- mapset = G_find_vector2(bmap, "");
- if (mapset == NULL) {
+ const char *bmap = params.bmaps->answers[i];
+ const char *mapset = G_find_vector2(bmap, "");
+ if (!mapset)
G_fatal_error(_("Vector map <%s> not found"), bmap);
- }
- if (strcmp
- (G_fully_qualified_name
- ((const char *)params.map->answer, (const char *)G_mapset()),
- G_fully_qualified_name((const char *)bmap,
- (const char *)mapset)) == 0) {
+ if (strcmp(
+ G_fully_qualified_name(params.map->answer, G_mapset()),
+ G_fully_qualified_name(bmap, mapset)) == 0) {
G_fatal_error(_("Unable to open vector map <%s> as the backround map. "
"It is given as vector map to be edited."),
bmap);
}
nbgmaps++;
- BgMap =
- (struct Map_info **)G_realloc((void *)BgMap,
- nbgmaps *
- sizeof(struct Map_info *));
+ BgMap = (struct Map_info **)G_realloc(
+ BgMap, nbgmaps * sizeof(struct Map_info *));
BgMap[nbgmaps - 1] =
(struct Map_info *)G_malloc(sizeof(struct Map_info));
- if (Vect_open_old(BgMap[nbgmaps - 1], bmap, mapset) == -1) {
- G_fatal_error(_("Unable to open vector map <%s>"),
- G_fully_qualified_name(bmap, mapset));
- }
- G_verbose_message(_("Background vector map <%s> registered"),
- G_fully_qualified_name(bmap, mapset));
+ if (Vect_open_old(BgMap[nbgmaps - 1], bmap, "") == -1)
+ G_fatal_error(_("Unable to open vector map <%s>"), bmap);
+ G_verbose_message(_("Background vector map <%s> registered"), bmap);
i++;
}
}
Modified: grass/trunk/vector/v.extract/main.c
===================================================================
--- grass/trunk/vector/v.extract/main.c 2008-08-29 20:57:26 UTC (rev 33160)
+++ grass/trunk/vector/v.extract/main.c 2008-08-29 22:27:02 UTC (rev 33161)
@@ -53,7 +53,7 @@
int **ocats, *nocats, nfields, *fields;
int dissolve = 0, x, y, type_only;
char buffr[1024], text[80];
- char *input, *output, *mapset;
+ char *input, *output;
struct GModule *module;
struct Option *inopt, *outopt, *fileopt, *newopt, *typopt, *listopt,
*fieldopt;
@@ -139,12 +139,7 @@
/* set input vector map name and mapset */
input = inopt->answer;
- mapset = G_find_vector2(input, "");
- if (!mapset)
- G_fatal_error(_("Vector map <%s> not found"), input);
-
- G_debug(3, "Mapset = %s", mapset);
/* set output vector map name */
output = outopt->answer;
@@ -162,7 +157,7 @@
/* Do initial read of input file */
Vect_set_open_level(2);
- Vect_open_old(&In, input, mapset);
+ Vect_open_old(&In, input, "");
/* Open output file */
Vect_open_new(&Out, output, Vect_is_3d(&In));
Modified: grass/trunk/vector/v.extrude/main.c
===================================================================
--- grass/trunk/vector/v.extrude/main.c 2008-08-29 20:57:26 UTC (rev 33160)
+++ grass/trunk/vector/v.extrude/main.c 2008-08-29 22:27:02 UTC (rev 33161)
@@ -34,7 +34,6 @@
int main(int argc, char *argv[])
{
struct GModule *module;
- char *mapset;
struct Option *old, *new, *zshift, *height, *elevation, *hcolumn,
*type_opt, *field_opt;
struct Flag *t_flag;
@@ -138,8 +137,6 @@
/* set input vector map name and mapset */
Vect_check_input_output_name(old->answer, new->answer, GV_FATAL_EXIT);
- if ((mapset = G_find_vector2(old->answer, "")) == NULL)
- G_fatal_error(_("Vector map <%s> not found"), old->answer);
/* vector setup */
Points = Vect_new_line_struct();
@@ -149,7 +146,7 @@
Vect_open_new(&Out, new->answer, WITH_Z);
/* opening old vector */
- Vect_open_old(&In, old->answer, mapset);
+ Vect_open_old(&In, old->answer, "");
Vect_hist_copy(&In, &Out);
Vect_hist_command(&Out);
@@ -173,12 +170,8 @@
/* raster setup */
G_get_window(&window);
- /* check for the elev raster, and check for error condition */
- if ((mapset = G_find_cell2(elevation->answer, "")) == NULL)
- G_fatal_error(_("Raster map <%s> not found"), elevation->answer);
-
/* open the elev raster, and check for error condition */
- if ((fdrast = G_open_cell_old(elevation->answer, mapset)) < 0)
+ if ((fdrast = G_open_cell_old(elevation->answer, "")) < 0)
G_fatal_error(_("Unable to open raster map <%s>"),
elevation->answer);
}
@@ -340,7 +333,7 @@
char *comment;
G_asprintf(&comment, "Generated by %s from vector map <%s>",
- G_program_name(), G_fully_qualified_name(old->answer, mapset));
+ G_program_name(), old->answer);
Vect_set_comment(&Out, comment);
G_free(comment);
Modified: grass/trunk/vector/v.generalize/main.c
===================================================================
--- grass/trunk/vector/v.generalize/main.c 2008-08-29 20:57:26 UTC (rev 33160)
+++ grass/trunk/vector/v.generalize/main.c 2008-08-29 22:27:02 UTC (rev 33161)
@@ -46,7 +46,6 @@
static struct line_pnts *Points;
struct line_cats *Cats;
int i, type, iter;
- char *mapset;
struct GModule *module; /* GRASS module for parsing arguments */
struct Option *map_in, *map_out, *thresh_opt, *method_opt,
*look_ahead_opt;
@@ -297,14 +296,10 @@
Vect_check_input_output_name(map_in->answer, map_out->answer,
GV_FATAL_EXIT);
- if ((mapset = G_find_vector2(map_in->answer, "")) == NULL)
- G_fatal_error(_("Vector map <%s> not found"), map_in->answer);
-
Vect_set_open_level(2);
- if (1 > Vect_open_old(&In, map_in->answer, mapset))
- G_fatal_error(_("Unable to open vector map <%s>"),
- G_fully_qualified_name(map_in->answer, mapset));
+ if (Vect_open_old(&In, map_in->answer, "") < 1)
+ G_fatal_error(_("Unable to open vector map <%s>"), map_in->answer);
with_z = Vect_is_3d(&In);
Modified: grass/trunk/vector/v.hull/main.c
===================================================================
--- grass/trunk/vector/v.hull/main.c 2008-08-29 20:57:26 UTC (rev 33160)
+++ grass/trunk/vector/v.hull/main.c 2008-08-29 22:27:02 UTC (rev 33161)
@@ -271,7 +271,6 @@
struct Flag *all, *flat;
struct Cell_head window;
- char *mapset;
char *sitefile;
struct Map_info Map;
@@ -310,15 +309,11 @@
sitefile = input->answer;
- mapset = G_find_vector2(sitefile, "");
- if (mapset == NULL)
- G_fatal_error(_("Vector map <%s> not found"), sitefile);
-
Vect_check_input_output_name(input->answer, output->answer,
GV_FATAL_EXIT);
/* open site file */
- if (Vect_open_old(&Map, sitefile, mapset) < 0)
+ if (Vect_open_old(&Map, sitefile, "") < 0)
G_fatal_error(_("Cannot open vector map <%s>"), sitefile);
/* load site coordinates */
Modified: grass/trunk/vector/v.info/main.c
===================================================================
--- grass/trunk/vector/v.info/main.c 2008-08-29 20:57:26 UTC (rev 33160)
+++ grass/trunk/vector/v.info/main.c 2008-08-29 22:27:02 UTC (rev 33161)
@@ -100,7 +100,7 @@
}
Vect_set_open_level(2);
- Vect_open_old_head(&Map, in_opt->answer, mapset);
+ Vect_open_old_head(&Map, in_opt->answer, "");
with_z = Vect_is_3d(&Map);
v_head = Map.head;
More information about the grass-commit
mailing list