[GRASS-SVN] r44630 - in grass/trunk: . include include/vect lib/gis
lib/vector/Vlib vector/v.external.out
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Dec 19 15:23:06 EST 2010
Author: martinl
Date: 2010-12-19 12:23:06 -0800 (Sun, 19 Dec 2010)
New Revision: 44630
Modified:
grass/trunk/grasslib.dox
grass/trunk/include/gisdefs.h
grass/trunk/include/vect/dig_structs.h
grass/trunk/include/vector.h
grass/trunk/lib/gis/overwrite.c
grass/trunk/lib/gis/parser.c
grass/trunk/lib/vector/Vlib/build.c
grass/trunk/lib/vector/Vlib/close.c
grass/trunk/lib/vector/Vlib/close_ogr.c
grass/trunk/lib/vector/Vlib/open.c
grass/trunk/lib/vector/Vlib/open_ogr.c
grass/trunk/lib/vector/Vlib/write_ogr.c
grass/trunk/vector/v.external.out/args.c
grass/trunk/vector/v.external.out/link.c
grass/trunk/vector/v.external.out/local_proto.h
grass/trunk/vector/v.external.out/main.c
grass/trunk/vector/v.external.out/status.c
Log:
vectlib: very initial direct OGR write support (v.external.out)
Modified: grass/trunk/grasslib.dox
===================================================================
--- grass/trunk/grasslib.dox 2010-12-19 19:30:30 UTC (rev 44629)
+++ grass/trunk/grasslib.dox 2010-12-19 20:23:06 UTC (rev 44630)
@@ -58,7 +58,6 @@
-->
\image html "grass7_arch.png" "GRASS 7 Architecture"
-<p>
<b>PLEASE UPDATE FOR GRASS 7</b>
\section corelibs Principal library
Modified: grass/trunk/include/gisdefs.h
===================================================================
--- grass/trunk/include/gisdefs.h 2010-12-19 19:30:30 UTC (rev 44629)
+++ grass/trunk/include/gisdefs.h 2010-12-19 20:23:06 UTC (rev 44630)
@@ -468,6 +468,7 @@
char *G_recreate_command(void);
void G_add_keyword(const char *);
void G_set_keywords(const char *);
+int G_get_overwrite();
/* paths.c */
int G_mkdir(const char *);
Modified: grass/trunk/include/vect/dig_structs.h
===================================================================
--- grass/trunk/include/vect/dig_structs.h 2010-12-19 19:30:30 UTC (rev 44629)
+++ grass/trunk/include/vect/dig_structs.h 2010-12-19 20:23:06 UTC (rev 44630)
@@ -163,16 +163,19 @@
/*! \brief Non-native format info (OGR)
- \todo Structure size should not change depending on compilation I think, do it better
-*/
+ \todo Structure size should not change depending on compilation I
+think, do it better */
struct Format_info_ogr
{
+ char *driver_name; /* OGR driver name */
char *dsn; /* OGR datasource name */
char *layer_name; /* OGR layer name */
#ifdef HAVE_OGR
+ OGRSFDriverH driver; /* pointer to OGRDriver */
OGRDataSourceH ds; /* pointer to OGRDataSourceH */
OGRLayerH layer; /* pointer to OGRLayerH */
#else
+ void *driver;
void *ds;
void *layer;
#endif
@@ -193,11 +196,11 @@
int feature_cache_id; /* id of feature read in feature_cache */
/* Array where OGR feature/part info is stored for each line in
- * GRASS. This is not used for GV_CENTROID. Because one feature
+ * GRASS. This is not used for GV_CENTROID. Because one feature
* may contain more elements (geometry collection also
* recursively), offset for one line may be stored in more
- * records. First record is FID, next records are part indexes if
- * necessary. Example: 5. ring in 3. polygon in 7. feature
+ * records. First record is FID, next records are part indexes if
+ * necessary. Example: 5. ring in 3. polygon in 7. feature
* (multipolygon) of geometry collection which has FID = 123 123
* (feature 123: geometry colletion) 6 (7. feature in geometry
* collection: multiPolygon) 2 (3. polygon) 4 (5. ring in the
Modified: grass/trunk/include/vector.h
===================================================================
--- grass/trunk/include/vector.h 2010-12-19 19:30:30 UTC (rev 44629)
+++ grass/trunk/include/vector.h 2010-12-19 20:23:06 UTC (rev 44630)
@@ -455,6 +455,7 @@
int V1_open_old_ogr(struct Map_info *, int);
int V2_open_old_ogr(struct Map_info *);
int V1_open_new_nat(struct Map_info *, const char *, int);
+int V1_open_new_ogr(struct Map_info *, const char *, int);
int V1_rewind_nat(struct Map_info *);
int V1_rewind_ogr(struct Map_info *);
int V2_rewind_nat(struct Map_info *);
Modified: grass/trunk/lib/gis/overwrite.c
===================================================================
--- grass/trunk/lib/gis/overwrite.c 2010-12-19 19:30:30 UTC (rev 44629)
+++ grass/trunk/lib/gis/overwrite.c 2010-12-19 20:23:06 UTC (rev 44630)
@@ -1,24 +1,21 @@
-
-/**
- * \file overwrite.c
+/*!
+ * \file lib/gis/overwrite.c
*
* \brief GIS Library - Check for overwrite.
*
- * (C) 2001-2008 by the GRASS Development Team
+ * (C) 2001-2008, 2010 by the GRASS Development Team
*
* This program is free software under the GNU General Public License
* (>=v2). Read the file COPYING that comes with GRASS for details.
*
* \author GRASS GIS Development Team, Martin Landa <landa.martin gmail.com>
- *
- * \date 2007-2008
*/
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
-/**
+/*!
* \brief Check for overwrite mode
*
* Check variables OVERWRITE, GRASS_OVERWRITE and '--o' flag.
@@ -27,8 +24,8 @@
* we can switch out the check and do it
* in the module after the parser.
*
- * \param[in] argc number of arguments
- * \param[in] argv array of arguments
+ * \param argc number of arguments
+ * \param argv array of arguments
*
* \return 1 if overwrite
* \return 0 if not overwrite
Modified: grass/trunk/lib/gis/parser.c
===================================================================
--- grass/trunk/lib/gis/parser.c 2010-12-19 19:30:30 UTC (rev 44629)
+++ grass/trunk/lib/gis/parser.c 2010-12-19 20:23:06 UTC (rev 44630)
@@ -758,7 +758,17 @@
fflush(fd);
}
+/*!
+ \Get overwrite value
+ \return 1 overwrite enabled
+ \return 0 overwrite disabled
+*/
+int G_get_overwrite()
+{
+ return st->overwrite;
+}
+
void define_keywords(void)
{
st->n_keys = 0;
@@ -1304,6 +1314,11 @@
if(G_find_file(element, opt->answers[i], G_mapset()))
found = TRUE;
}
+
+ if (found && strcmp(element, "vector") == 0 &&
+ G_find_file("", "OGR", G_mapset()))
+ found = FALSE;
+
if (found) { /* found */
if (!st->overwrite && !over) {
if (G_info_format() != G_INFO_FORMAT_GUI) {
Modified: grass/trunk/lib/vector/Vlib/build.c
===================================================================
--- grass/trunk/lib/vector/Vlib/build.c 2010-12-19 19:30:30 UTC (rev 44629)
+++ grass/trunk/lib/vector/Vlib/build.c 2010-12-19 20:23:06 UTC (rev 44630)
@@ -119,7 +119,8 @@
/* If topology is already build (map on level2), set level to 1 so that lines will
* be read by V1_read_ (all lines) */
Map->level = 1; /* may be not needed, because V1_read is used directly by Vect_build_ */
- Map->support_updated = 1;
+ if (Map->format != GV_FORMAT_OGR_DIRECT)
+ Map->support_updated = 1;
if (Map->plus.Spidx_built == 0)
Vect_open_sidx(Map, 2);
Modified: grass/trunk/lib/vector/Vlib/close.c
===================================================================
--- grass/trunk/lib/vector/Vlib/close.c 2010-12-19 19:30:30 UTC (rev 44629)
+++ grass/trunk/lib/vector/Vlib/close.c 2010-12-19 20:23:06 UTC (rev 44630)
@@ -57,7 +57,7 @@
/*!
\brief Close vector map
- \param Map pointer to Map_info
+ \param Map pointer to Map_info (vector map to close)
\return 0 on success
\return non-zero on error
@@ -146,6 +146,10 @@
Map->name = NULL;
G_free((void *)Map->mapset);
Map->mapset = NULL;
+ G_free((void *)Map->location);
+ Map->location = NULL;
+ G_free((void *)Map->gisdbase);
+ Map->gisdbase = NULL;
Map->open = VECT_CLOSED_CODE;
Modified: grass/trunk/lib/vector/Vlib/close_ogr.c
===================================================================
--- grass/trunk/lib/vector/Vlib/close_ogr.c 2010-12-19 19:30:30 UTC (rev 44629)
+++ grass/trunk/lib/vector/Vlib/close_ogr.c 2010-12-19 20:23:06 UTC (rev 44630)
@@ -37,14 +37,17 @@
if (!VECT_OPEN(Map))
return -1;
- if (Map->mode == GV_MODE_WRITE || Map->mode == GV_MODE_RW)
+ if (Map->format != GV_FORMAT_OGR_DIRECT &&
+ (Map->mode == GV_MODE_WRITE || Map->mode == GV_MODE_RW))
Vect__write_head(Map);
if (Map->fInfo.ogr.feature_cache)
OGR_F_Destroy(Map->fInfo.ogr.feature_cache);
+ if (Map->fInfo.ogr.driver)
+ OGR_DS_Destroy(Map->fInfo.ogr.driver);
OGR_DS_Destroy(Map->fInfo.ogr.ds);
-
+
for (i = 0; i < Map->fInfo.ogr.lines_alloc; i++) {
Vect_destroy_line_struct(Map->fInfo.ogr.lines[i]);
}
@@ -52,6 +55,7 @@
G_free(Map->fInfo.ogr.lines);
G_free(Map->fInfo.ogr.lines_types);
+ G_free(Map->fInfo.ogr.driver_name);
G_free(Map->fInfo.ogr.dsn);
G_free(Map->fInfo.ogr.layer_name);
Modified: grass/trunk/lib/vector/Vlib/open.c
===================================================================
--- grass/trunk/lib/vector/Vlib/open.c 2010-12-19 19:30:30 UTC (rev 44629)
+++ grass/trunk/lib/vector/Vlib/open.c 2010-12-19 20:23:06 UTC (rev 44630)
@@ -28,7 +28,7 @@
#include <grass/glocale.h>
/*
- \brief Number of available levels
+ \brief Number of levels - without and with topology
*/
#define MAX_OPEN_LEVEL 2
@@ -37,6 +37,11 @@
return 0;
}
+static int open_new_dummy()
+{
+ return 0;
+}
+
#ifndef HAVE_OGR
static int format()
{
@@ -63,6 +68,22 @@
#endif
};
+static int (*Open_new_array[][2]) () = {
+ {
+ open_new_dummy, V1_open_new_nat}
+#ifdef HAVE_OGR
+ , {
+ open_new_dummy, V1_open_new_ogr}
+ , {
+ open_new_dummy, V1_open_new_ogr}
+#else
+ , {
+ open_new_dummy, format}
+ , {
+ open_new_dummy, format}
+#endif
+};
+
static void fatal_error(int ferror, char *errmsg)
{
switch (ferror) {
@@ -669,6 +690,8 @@
char xname[GNAME_MAX], xmapset[GMAPSET_MAX];
G_debug(2, "Vect_open_new(): name = %s", name);
+
+ G_zero(Map, sizeof(struct Map_info));
/* init header */
Vect__init_head(Map);
@@ -690,49 +713,78 @@
if (Vect_legal_filename(name) < 0) {
sprintf(errmsg, _("Vector map name is not SQL compliant"));
fatal_error(ferror, errmsg);
- return (-1);
+ return -1;
}
- /* Check if map already exists */
- if (G_find_vector2(name, G_mapset()) != NULL) {
- G_warning(_("Vector map <%s> already exists and will be overwritten"),
- name);
+ /* determine output format native or ogr */
+ if (G_find_file2("", "OGR", G_mapset())) {
+ /* OGR */
+ FILE *fp;
+ struct Key_Value *key_val;
+ const char *p;
- ret = Vect_delete(name);
- if (ret == -1) {
- sprintf(errmsg, _("Unable to delete vector map <%s>"), name);
+ Map->format = GV_FORMAT_OGR_DIRECT;
+ fp = G_fopen_old("", "OGR", G_mapset());
+ if (!fp) {
+ sprintf(errmsg, _("Unable to open OGR file"));
fatal_error(ferror, errmsg);
- return (-1);
}
+ key_val = G_fread_key_value(fp);
+ fclose(fp);
+
+ p = G_find_key_value("format", key_val);
+ if (p)
+ Map->fInfo.ogr.driver_name = G_store(p);
+ p = G_find_key_value("dsn", key_val);
+ if (p)
+ Map->fInfo.ogr.dsn = G_store(p);
+ Map->fInfo.ogr.layer_name = G_store(name);
}
+ else {
+ /* native */
+ Map->format = GV_FORMAT_NATIVE;
- Map->name = G_store(name);
- Map->mapset = G_store(G_mapset());
+ /* check if map already exists */
+ if (G_find_vector2(name, G_mapset()) != NULL) {
+ G_warning(_("Vector map <%s> already exists and will be overwritten"),
+ name);
+
+ ret = Vect_delete(name);
+ if (ret == -1) {
+ sprintf(errmsg, _("Unable to delete vector map <%s>"), name);
+ fatal_error(ferror, errmsg);
+ return -1;
+ }
+ }
+ }
+
+ Map->name = G_store(name);
+ Map->mapset = G_store(G_mapset());
Map->location = G_store(G_location());
Map->gisdbase = G_store(G_gisdbase());
-
- Map->format = GV_FORMAT_NATIVE;
-
+
/* set 2D/3D */
Map->plus.spidx_with_z = Map->plus.with_z = Map->head.with_z = (with_z != 0);
- if (V1_open_new_nat(Map, name, with_z) < 0) {
+ if ((*Open_new_array[Map->format][1]) (Map, name, with_z) < 0) {
sprintf(errmsg, _("Unable to create vector map <%s>"),
Vect_get_full_name(Map));
fatal_error(ferror, errmsg);
- return (-1);
+ return -1;
}
- /* Open history file */
- sprintf(buf, "%s/%s", GV_DIRECTORY, Map->name);
- Map->hist_fp = G_fopen_new(buf, GV_HIST_ELEMENT);
- if (Map->hist_fp == NULL) {
- sprintf(errmsg, _("Unable to open history file of vector map <%s>"),
- Vect_get_full_name(Map));
- fatal_error(ferror, errmsg);
- return (-1);
+ if (Map->format == GV_FORMAT_NATIVE) {
+ /* Open history file */
+ sprintf(buf, "%s/%s", GV_DIRECTORY, Map->name);
+ Map->hist_fp = G_fopen_new(buf, GV_HIST_ELEMENT);
+ if (Map->hist_fp == NULL) {
+ sprintf(errmsg, _("Unable to open history file of vector map <%s>"),
+ Vect_get_full_name(Map));
+ fatal_error(ferror, errmsg);
+ return -1;
+ }
}
-
+
Open_level = 0;
/* initialize topo */
Modified: grass/trunk/lib/vector/Vlib/open_ogr.c
===================================================================
--- grass/trunk/lib/vector/Vlib/open_ogr.c 2010-12-19 19:30:30 UTC (rev 44629)
+++ grass/trunk/lib/vector/Vlib/open_ogr.c 2010-12-19 20:23:06 UTC (rev 44630)
@@ -5,9 +5,7 @@
Higher level functions for reading/writing/manipulating vectors.
- \todo Implement V1_open_new_ogr()
-
- (C) 2001-2009 by the GRASS Development Team
+ (C) 2001-2010 by the GRASS Development Team
This program is free software under the GNU General Public License
(>=v2). Read the file COPYING that comes with GRASS for details.
@@ -29,6 +27,7 @@
#ifdef HAVE_OGR
#include <ogr_api.h>
+#include <cpl_string.h>
/*!
\brief Open existing OGR layer (level 1 - without feature index file)
@@ -201,4 +200,81 @@
return 0;
}
+/*!
+ \brief Create new OGR layer in given OGR datasource (level 1)
+
+ \param[out] Map pointer to Map_info structure
+ \param name name of OGR layer to create
+ \param with_z 2D or 3D (unused?)
+
+ \return 0 success
+ \return -1 error
+*/
+int V1_open_new_ogr(struct Map_info *Map, const char *name, int with_z)
+{
+ OGRSFDriverH Ogr_driver;
+ OGRDataSourceH Ogr_ds;
+ OGRLayerH Ogr_layer;
+
+ int i;
+ char **Ogr_layer_options;
+
+ Ogr_layer_options = NULL;
+
+ OGRRegisterAll();
+
+ Ogr_driver = OGRGetDriverByName(Map->fInfo.ogr.driver_name);
+ if (!Ogr_driver) {
+ G_warning(_("Unable to get OGR driver <%s>"), Map->fInfo.ogr.driver_name);
+ return -1;
+ }
+ Map->fInfo.ogr.driver = Ogr_driver;
+
+ /* TODO: creation options */
+ Ogr_ds = OGR_Dr_CreateDataSource(Ogr_driver, Map->fInfo.ogr.dsn, NULL);
+ if (!Ogr_ds) {
+ G_warning(_("Unable to create OGR data source '%s'"),
+ Map->fInfo.ogr.dsn);
+ return -1;
+ }
+ Map->fInfo.ogr.ds = Ogr_ds;
+
+ Ogr_layer = OGR_DS_GetLayerByName(Ogr_ds, Map->fInfo.ogr.layer_name);
+ if (Ogr_layer) {
+ for (i = 0; i < OGR_DS_GetLayerCount(Ogr_ds); i++) {
+ if (OGR_DS_GetLayer(Ogr_ds, i) == Ogr_layer) {
+ if (G_get_overwrite()) {
+ G_warning(_("OGR layer <%s> already exists and will be overwritten"),
+ Map->fInfo.ogr.layer_name);
+
+ if (OGR_DS_DeleteLayer(Ogr_ds, i) != OGRERR_NONE) {
+ G_warning(_("Unable to delete OGR layer <%s>"),
+ Map->fInfo.ogr.layer_name);
+ return -1;
+ }
+ }
+ else {
+ G_fatal_error(_("OGR layer <%s> already exists in datasource '%s'"),
+ Map->fInfo.ogr.layer_name, Map->fInfo.ogr.dsn);
+ }
+ break;
+ }
+ }
+ }
+
+ /* create new OGR layer */
+ /* TODO: spatial reference */
+ /* Ogr_layer_options = CSLSetNameValue(Ogr_layer_options, "OVERWRITE", "YES"); */
+ Ogr_layer = OGR_DS_CreateLayer(Ogr_ds, Map->fInfo.ogr.layer_name,
+ NULL, wkbPoint, Ogr_layer_options);
+ CSLDestroy(Ogr_layer_options);
+ if (!Ogr_layer) {
+ G_warning(_("Unable to create OGR layer <%s> in '%s'"),
+ Map->fInfo.ogr.layer_name, Map->fInfo.ogr.dsn);
+ return -1;
+ }
+ Map->fInfo.ogr.layer = Ogr_layer;
+
+ return 0;
+}
#endif
Modified: grass/trunk/lib/vector/Vlib/write_ogr.c
===================================================================
--- grass/trunk/lib/vector/Vlib/write_ogr.c 2010-12-19 19:30:30 UTC (rev 44629)
+++ grass/trunk/lib/vector/Vlib/write_ogr.c 2010-12-19 20:23:06 UTC (rev 44630)
@@ -43,7 +43,7 @@
}
/*!
- \brief Writes feature on level 1
+ \brief Writes feature on level 1 (OGR interface)
\param Map pointer to Map_info structure
\param type feature type
@@ -60,15 +60,19 @@
struct field_info *Fi;
- OGRGeometryH Ogr_geometry;
- OGRFeatureH Ogr_feature;
- OGRFeatureDefnH Ogr_featuredefn;
-
+ OGRGeometryH Ogr_geometry;
+ OGRFeatureH Ogr_feature;
+ OGRFeatureDefnH Ogr_featuredefn;
+ OGRwkbGeometryType Ogr_geom_type;
+
if (!Map->fInfo.ogr.layer) {
G_warning(_("OGR layer not defined"));
return -1;
}
+ Ogr_featuredefn = OGR_L_GetLayerDefn(Map->fInfo.ogr.layer);
+ Ogr_geom_type = OGR_FD_GetGeomType(Ogr_featuredefn);
+
/* determine matching OGR feature geometry type */
/* NOTE: centroids are not supported in OGR,
* pseudotopo holds virtual centroids */
@@ -76,16 +80,30 @@
* pseudotopo treats polygons as boundaries */
if (type & (GV_POINT | GV_KERNEL)) {
+ if (Ogr_geom_type != wkbPoint &&
+ Ogr_geom_type != wkbPoint25D) {
+ G_warning(_("Feature is not a point. Skipping."));
+ return -1;
+ }
Ogr_geometry = OGR_G_CreateGeometry(wkbPoint);
}
else if (type & GV_LINE) {
+ if (Ogr_geom_type != wkbLineString &&
+ Ogr_geom_type != wkbLineString25D) {
+ G_warning(_("Feature is not a line Skipping."));
+ return -1;
+ }
Ogr_geometry = OGR_G_CreateGeometry(wkbLineString);
}
else if (type & GV_FACE) {
+ if (Ogr_geom_type != wkbPolygon25D) {
+ G_warning(_("Feature is not a face. Skipping."));
+ return -1;
+ }
Ogr_geometry = OGR_G_CreateGeometry(wkbPolygon25D);
}
else {
- G_warning("V1_write_line_ogr(): %s (%d)", _("Unsupported feature type"), type);
+ G_warning(_("Unsupported feature type (%d)"), type);
return -1;
}
@@ -98,31 +116,21 @@
G_debug(4, " n_points = %d", points->n_points);
- Ogr_featuredefn = OGR_L_GetLayerDefn(Map->fInfo.ogr.layer);
-
/* create feature & set geometry */
Ogr_feature = OGR_F_Create(Ogr_featuredefn);
OGR_F_SetGeometry(Ogr_feature, Ogr_geometry);
/* write attributes */
- if (cats->n_cats > 0) {
+ Fi = Vect_get_field(Map, cats->field[0]);
+ if (Fi && cats->n_cats > 0) {
cat = cats->cat[0];
if (cats->n_cats > 1) {
G_warning(_("Feature has more categories, using "
"category %d (from layer %d)"),
cat, cats->field[0]);
}
-
- Fi = Vect_get_field(Map, cats->field[0]);
- if (!Fi) {
- G_fatal_error(_("Database connection not defined for layer %d"),
- cats->field[0]);
- }
write_attributes(cat, Fi, Map->fInfo.ogr.layer, Ogr_feature);
}
- else { /* no attributes */
- G_warning(_("Feature has no categories"));
- }
/* write feature into layer */
ret = OGR_L_CreateFeature(Map->fInfo.ogr.layer, Ogr_feature);
@@ -277,17 +285,14 @@
*/
int V2_delete_line_ogr(struct Map_info *Map, off_t line)
{
- int ret, i, side, type, first, next_line, area;
+ int ret, i, type, first;
struct P_line *Line;
- struct P_area *Area;
struct Plus_head *plus;
- struct bound_box box, abox;
- int adjacent[4], n_adjacent;
static struct line_cats *Cats = NULL;
G_debug(3, "V2_delete_line_nat(), line = %d", (int) line);
- type = first = n_adjacent = 0;
+ type = first = 0;
Line = NULL;
plus = &(Map->plus);
Modified: grass/trunk/vector/v.external.out/args.c
===================================================================
--- grass/trunk/vector/v.external.out/args.c 2010-12-19 19:30:30 UTC (rev 44629)
+++ grass/trunk/vector/v.external.out/args.c 2010-12-19 20:23:06 UTC (rev 44630)
@@ -8,19 +8,12 @@
void parse_args(int argc, char **argv,
struct _options *options, struct _flags *flags)
{
- options->dir = G_define_option();
- options->dir->key = "directory";
- options->dir->description = _("Name of output directory");
- options->dir->required = YES;
- options->dir->type = TYPE_STRING;
- options->dir->key_desc = "path";
+ options->dsn = G_define_option();
+ options->dsn->key = "dsn";
+ options->dsn->description = _("Name for output OGR datasource");
+ options->dsn->required = YES;
+ options->dsn->type = TYPE_STRING;
- options->ext = G_define_option();
- options->ext->key = "extension";
- options->ext->description = _("Extension for output files");
- options->ext->required = NO;
- options->ext->type = TYPE_STRING;
-
options->format = G_define_option();
options->format->key = "format";
options->format->description = _("Format of output files");
@@ -44,7 +37,7 @@
flags->r = G_define_flag();
flags->r->key = 'r';
- flags->r->description = _("Cease using OGR and revert to native output");
+ flags->r->description = _("Cease using OGR, revert to native output and exit");
flags->r->suppress_required = YES;
flags->p = G_define_flag();
Modified: grass/trunk/vector/v.external.out/link.c
===================================================================
--- grass/trunk/vector/v.external.out/link.c 2010-12-19 19:30:30 UTC (rev 44629)
+++ grass/trunk/vector/v.external.out/link.c 2010-12-19 20:23:06 UTC (rev 44630)
@@ -4,7 +4,7 @@
#include <grass/gis.h>
#include <grass/glocale.h>
-void make_link(const char *dir, const char *ext,
+void make_link(const char *dsn,
const char *format, char **options)
{
struct Key_Value *key_val = G_create_key_value();
@@ -32,17 +32,8 @@
*p++ = '\0';
}
- if (ext && ext[0] != '.') {
- char *p;
-
- G_asprintf(&p, ".%s", ext);
- ext = p;
- }
-
- if (dir)
- G_set_key_value("directory", dir, key_val);
- if (ext)
- G_set_key_value("extension", ext, key_val);
+ if (dsn)
+ G_set_key_value("dsn", dsn, key_val);
if (format)
G_set_key_value("format", format, key_val);
if (opt_str)
Modified: grass/trunk/vector/v.external.out/local_proto.h
===================================================================
--- grass/trunk/vector/v.external.out/local_proto.h 2010-12-19 19:30:30 UTC (rev 44629)
+++ grass/trunk/vector/v.external.out/local_proto.h 2010-12-19 20:23:06 UTC (rev 44630)
@@ -2,7 +2,7 @@
#define V_EXTERNAL_OUT_LOCAL_PROTO_H
struct _options {
- struct Option *dir, *ext, *format, *opts;
+ struct Option *dsn, *format, *opts;
};
struct _flags {
@@ -17,7 +17,7 @@
void check_format(const char *);
/* link.c */
-void make_link(const char *, const char *,
+void make_link(const char *,
const char *, char **);
/* list.c */
Modified: grass/trunk/vector/v.external.out/main.c
===================================================================
--- grass/trunk/vector/v.external.out/main.c 2010-12-19 19:30:30 UTC (rev 44629)
+++ grass/trunk/vector/v.external.out/main.c 2010-12-19 20:23:06 UTC (rev 44630)
@@ -43,11 +43,6 @@
parse_args(argc, argv, &options, &flags);
- if (flags.p->answer) {
- print_status();
- exit(EXIT_SUCCESS);
- }
-
if (flags.f->answer) {
list_formats();
exit(EXIT_SUCCESS);
@@ -61,8 +56,13 @@
if (options.format->answer)
check_format(options.format->answer);
- make_link(options.dir->answer, options.ext->answer,
- options.format->answer, options.opts->answers);
+ if (options.dsn->answer)
+ make_link(options.dsn->answer,
+ options.format->answer, options.opts->answers);
+
+ if (flags.p->answer) {
+ print_status();
+ }
exit(EXIT_SUCCESS);
}
Modified: grass/trunk/vector/v.external.out/status.c
===================================================================
--- grass/trunk/vector/v.external.out/status.c 2010-12-19 19:30:30 UTC (rev 44629)
+++ grass/trunk/vector/v.external.out/status.c 2010-12-19 20:23:06 UTC (rev 44630)
@@ -20,13 +20,10 @@
key_val = G_fread_key_value(fp);
fclose(fp);
- p = G_find_key_value("directory", key_val);
- fprintf(stdout, _("directory: %s\n"),
+ p = G_find_key_value("dsn", key_val);
+ fprintf(stdout, _("dsn: %s\n"),
p ? p : _("not set (default 'ogr')"));
- p = G_find_key_value("extension", key_val);
- fprintf(stdout, _("extension: %s\n"), p ? p : _("<none>"));
-
p = G_find_key_value("format", key_val);
fprintf(stdout, _("format: %s\n"),
p ? p : _("not set (default ESRI_Shapefile)"));
More information about the grass-commit
mailing list