[GRASS-SVN] r39885 - grass/trunk/vector/v.out.svg
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Dec 3 15:15:47 EST 2009
Author: martinl
Date: 2009-12-03 15:15:46 -0500 (Thu, 03 Dec 2009)
New Revision: 39885
Modified:
grass/trunk/vector/v.out.svg/main.c
Log:
v.out.svg: OGR support (read access)
Modified: grass/trunk/vector/v.out.svg/main.c
===================================================================
--- grass/trunk/vector/v.out.svg/main.c 2009-12-03 20:05:07 UTC (rev 39884)
+++ grass/trunk/vector/v.out.svg/main.c 2009-12-03 20:15:46 UTC (rev 39885)
@@ -4,13 +4,14 @@
* MODULE: v.out.svg
* AUTHOR(S): Original author Klaus Foerster
* Klaus Foerster - klaus.foerster at uibk.ac.at
+ * OGR support by Martin Landa <landa.martin gmail.com> (2009)
* PURPOSE: Export GRASS vector map to SVG with custom
* coordinate-precision and optional attributes
- * COPYRIGHT: (C) 2006 by the GRASS Development Team
+ * COPYRIGHT: (C) 2006-2009 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.
+ * This program is free software under the GNU General
+ * Public License (>=v2). Read the file COPYING that
+ * comes with GRASS for details.
*
*****************************************************************************/
@@ -68,12 +69,14 @@
/* parse command-line */
module = G_define_module();
- module->description = _("Exports a GRASS vector map to SVG.");
+ module->description = _("Exports a vector map to SVG file.");
G_add_keyword(_("vector"));
G_add_keyword(_("export"));
in_opt = G_define_standard_option(G_OPT_V_INPUT);
+ field_opt = G_define_standard_option(G_OPT_V_FIELD);
+
out_opt = G_define_standard_option(G_OPT_F_OUTPUT);
out_opt->description = _("Name for SVG output file");
@@ -95,15 +98,12 @@
prec_opt->multiple = NO;
prec_opt->description = _("Coordinate precision");
- attr_opt = G_define_option();
+ attr_opt = G_define_standard_option(G_OPT_DB_COLUMNS);
attr_opt->key = "attribute";
- attr_opt->type = TYPE_STRING;
attr_opt->required = NO;
attr_opt->multiple = YES;
attr_opt->description = _("Attribute(s) to include in output SVG");
-
- field_opt = G_define_standard_option(G_OPT_V_FIELD);
-
+
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
@@ -119,13 +119,13 @@
G_fatal_error(_("Precision must not be higher than 15"));
}
- /* parse field number */
- field = atoi(field_opt->answer);
-
/* open input vector */
Vect_set_open_level(2);
- Vect_open_old(&In, in_opt->answer, "");
+ Vect_open_old2(&In, in_opt->answer, "", field_opt->answer);
+ /* parse field number */
+ field = Vect_get_field_number(&In, field_opt->answer);
+
/* open db-driver to attribs */
db_init_string(&dbstring);
@@ -183,7 +183,7 @@
/* open output SVG-file and print SVG-header with viewBox and Namenspaces */
if ((fpsvg = fopen(out_opt->answer, "w")) == NULL) {
- G_fatal_error(_("Unable to open SVG file <%s>"), out_opt->answer);
+ G_fatal_error(_("Unable to create SVG file <%s>"), out_opt->answer);
}
fprintf(fpsvg, "<svg xmlns=\"%s\" xmlns:xlink=\"%s\" xmlns:gg=\"%s\" ",
@@ -250,6 +250,8 @@
for (i = 1; i <= Vect_get_num_primitives(&In, GV_POINTS); i++) {
G_percent(i, Vect_get_num_primitives(&In, GV_POINTS), 10);
Vect_read_line(&In, Points, Cats, i);
+ if (field > 0 && !Vect_cat_get(Cats, field, NULL))
+ continue;
for (j = 0; j < Points->n_points; j++) {
fprintf(fpsvg, " <circle ");
if (Cats->n_cats > 0) {
@@ -306,6 +308,8 @@
/* close SVG-file */
fclose(fpsvg);
+ G_done_msg(" ");
+
exit(EXIT_SUCCESS);
}
More information about the grass-commit
mailing list