|
@@ -4,13 +4,14 @@
|
|
* MODULE: v.out.svg
|
|
* MODULE: v.out.svg
|
|
* AUTHOR(S): Original author Klaus Foerster
|
|
* AUTHOR(S): Original author Klaus Foerster
|
|
* Klaus Foerster - klaus.foerster@uibk.ac.at
|
|
* Klaus Foerster - klaus.foerster@uibk.ac.at
|
|
|
|
+ * OGR support by Martin Landa <landa.martin gmail.com> (2009)
|
|
* PURPOSE: Export GRASS vector map to SVG with custom
|
|
* PURPOSE: Export GRASS vector map to SVG with custom
|
|
* coordinate-precision and optional attributes
|
|
* 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 @@ int main(int argc, char *argv[])
|
|
|
|
|
|
/* parse command-line */
|
|
/* parse command-line */
|
|
module = G_define_module();
|
|
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(_("vector"));
|
|
G_add_keyword(_("export"));
|
|
G_add_keyword(_("export"));
|
|
|
|
|
|
in_opt = G_define_standard_option(G_OPT_V_INPUT);
|
|
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 = G_define_standard_option(G_OPT_F_OUTPUT);
|
|
out_opt->description = _("Name for SVG output file");
|
|
out_opt->description = _("Name for SVG output file");
|
|
|
|
|
|
@@ -95,15 +98,12 @@ int main(int argc, char *argv[])
|
|
prec_opt->multiple = NO;
|
|
prec_opt->multiple = NO;
|
|
prec_opt->description = _("Coordinate precision");
|
|
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->key = "attribute";
|
|
- attr_opt->type = TYPE_STRING;
|
|
|
|
attr_opt->required = NO;
|
|
attr_opt->required = NO;
|
|
attr_opt->multiple = YES;
|
|
attr_opt->multiple = YES;
|
|
attr_opt->description = _("Attribute(s) to include in output SVG");
|
|
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))
|
|
if (G_parser(argc, argv))
|
|
exit(EXIT_FAILURE);
|
|
exit(EXIT_FAILURE);
|
|
|
|
|
|
@@ -119,12 +119,12 @@ int main(int argc, char *argv[])
|
|
G_fatal_error(_("Precision must not be higher than 15"));
|
|
G_fatal_error(_("Precision must not be higher than 15"));
|
|
}
|
|
}
|
|
|
|
|
|
- /* parse field number */
|
|
|
|
- field = atoi(field_opt->answer);
|
|
|
|
-
|
|
|
|
/* open input vector */
|
|
/* open input vector */
|
|
Vect_set_open_level(2);
|
|
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 */
|
|
/* open db-driver to attribs */
|
|
db_init_string(&dbstring);
|
|
db_init_string(&dbstring);
|
|
@@ -183,7 +183,7 @@ int main(int argc, char *argv[])
|
|
|
|
|
|
/* open output SVG-file and print SVG-header with viewBox and Namenspaces */
|
|
/* open output SVG-file and print SVG-header with viewBox and Namenspaces */
|
|
if ((fpsvg = fopen(out_opt->answer, "w")) == NULL) {
|
|
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\" ",
|
|
fprintf(fpsvg, "<svg xmlns=\"%s\" xmlns:xlink=\"%s\" xmlns:gg=\"%s\" ",
|
|
@@ -250,6 +250,8 @@ int main(int argc, char *argv[])
|
|
for (i = 1; i <= Vect_get_num_primitives(&In, GV_POINTS); i++) {
|
|
for (i = 1; i <= Vect_get_num_primitives(&In, GV_POINTS); i++) {
|
|
G_percent(i, Vect_get_num_primitives(&In, GV_POINTS), 10);
|
|
G_percent(i, Vect_get_num_primitives(&In, GV_POINTS), 10);
|
|
Vect_read_line(&In, Points, Cats, i);
|
|
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++) {
|
|
for (j = 0; j < Points->n_points; j++) {
|
|
fprintf(fpsvg, " <circle ");
|
|
fprintf(fpsvg, " <circle ");
|
|
if (Cats->n_cats > 0) {
|
|
if (Cats->n_cats > 0) {
|
|
@@ -306,6 +308,8 @@ int main(int argc, char *argv[])
|
|
/* close SVG-file */
|
|
/* close SVG-file */
|
|
fclose(fpsvg);
|
|
fclose(fpsvg);
|
|
|
|
|
|
|
|
+ G_done_msg(" ");
|
|
|
|
+
|
|
exit(EXIT_SUCCESS);
|
|
exit(EXIT_SUCCESS);
|
|
}
|
|
}
|
|
|
|
|