[GRASS-SVN] r39896 - grass/trunk/vector/v.parallel
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Dec 4 11:35:28 EST 2009
Author: martinl
Date: 2009-12-04 11:35:28 -0500 (Fri, 04 Dec 2009)
New Revision: 39896
Modified:
grass/trunk/vector/v.parallel/main.c
Log:
v.parallel: OGR support (read access)
Modified: grass/trunk/vector/v.parallel/main.c
===================================================================
--- grass/trunk/vector/v.parallel/main.c 2009-12-04 16:06:13 UTC (rev 39895)
+++ grass/trunk/vector/v.parallel/main.c 2009-12-04 16:35:28 UTC (rev 39896)
@@ -5,19 +5,21 @@
*
* AUTHOR(S): Radim Blazek
* Upgraded by Rosen Matev (Google Summer of Code 2008)
+ * OGR support by Martin Landa <landa.martin gmail.com>
*
* PURPOSE: Create parallel lines
*
- * COPYRIGHT: (C) 2008 by the GRASS Development Team
+ * COPYRIGHT: (C) 2008-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.
*
**************************************************************/
+
#include <stdlib.h>
#include <math.h>
+
#include <grass/gis.h>
#include <grass/vector.h>
#include <grass/glocale.h>
@@ -25,7 +27,7 @@
int main(int argc, char *argv[])
{
struct GModule *module;
- struct Option *in_opt, *out_opt, *dista_opt;
+ struct Option *in_opt, *layer_opt, *out_opt, *dista_opt;
struct Option *distb_opt, *angle_opt, *side_opt;
struct Option *tol_opt;
struct Flag *round_flag, *buf_flag;
@@ -34,6 +36,7 @@
struct line_cats *Cats;
int line, nlines, inner_count, j;
+ int layer;
double da, db, dalpha, tolerance;
int side;
@@ -45,9 +48,12 @@
module->description = _("Creates parallel line to input vector lines.");
in_opt = G_define_standard_option(G_OPT_V_INPUT);
+
+ layer_opt = G_define_standard_option(G_OPT_V_FIELD_ALL);
+
out_opt = G_define_standard_option(G_OPT_V_OUTPUT);
- /* layer_opt = G_define_standard_option(G_OPT_V_FIELD); */
+
dista_opt = G_define_option();
dista_opt->key = "distance";
dista_opt->type = TYPE_DOUBLE;
@@ -104,7 +110,6 @@
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
- /* layer = atoi ( layer_opt->answer ); */
da = atof(dista_opt->answer);
if (distb_opt->answer)
@@ -130,8 +135,11 @@
side = 0;
Vect_set_open_level(2);
- Vect_open_old(&In, in_opt->answer, "");
+ Vect_open_old2(&In, in_opt->answer, "", layer_opt->answer);
+ layer = Vect_get_field_number(&In, layer_opt->answer);
+
Vect_open_new(&Out, out_opt->answer, 0);
+
Vect_copy_head_data(&In, &Out);
Vect_hist_copy(&In, &Out);
Vect_hist_command(&Out);
@@ -149,6 +157,9 @@
ltype = Vect_read_line(&In, Points, Cats, line);
+ if (layer != -1 && !Vect_cat_get(Cats, layer, NULL))
+ continue;
+
if (ltype & GV_LINES) {
if (!(buf_flag->answer)) {
if (side != 0) {
More information about the grass-commit
mailing list