File: main.c

package info (click to toggle)
grass 6.0.2-6
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 40,044 kB
  • ctags: 31,303
  • sloc: ansic: 321,125; tcl: 25,676; sh: 11,176; cpp: 10,098; makefile: 5,025; fortran: 1,846; yacc: 493; lex: 462; perl: 133; sed: 1
file content (96 lines) | stat: -rw-r--r-- 2,831 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/***************************************************************
 *
 * MODULE:       v.net
 * 
 * AUTHOR(S):    Radim Blazek
 *               
 * PURPOSE:      Network maintenance
 *               
 * COPYRIGHT:    (C) 2001 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.
 *
 **************************************************************/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "gis.h"
#include "Vect.h"
#include "proto.h"

int main (int argc, char **argv)
{
    struct GModule *module;
    struct Option *input;
    struct Option *output;
    struct Option *action;
    struct Option *afield_opt, *nfield_opt;
    int    afield, nfield;

    /*  Initialize the GIS calls */
    G_gisinit(argv[0]) ;

    module = G_define_module();
    module->description = "Network maintenance.";

    /* Define the options */
    input = G_define_option ();
    input->key = "input";
    input->type = TYPE_STRING;
    input->required = YES;
    input->multiple = NO;
    input->gisprompt = "old,vector,vector";
    input->description = "Input vector map";

    output = G_define_option ();
    output->key = "output";
    output->type = TYPE_STRING;
    output->required = NO;
    output->multiple = NO;
    output->gisprompt = "new,vector,vector";
    output->description = "Output vector map";

    action = G_define_option ();
    action->key = "operation";
    action->type = TYPE_STRING;
    action->required = NO;
    action->multiple = NO;
    action->answer = "nodes";
    action->options = "nodes,report";
    action->description = "Operation to be performed\n"
	    "\t\tnodes - new point is placed on each node (line end) if doesn't exist\n"
	    "\t\treport - print to standard output: line_category start_point_category end_point_category";

    afield_opt = G_define_standard_option(G_OPT_V_FIELD);
    afield_opt->key = "alayer";
    afield_opt->answer = "1";
    afield_opt->description = "Arc layer";

    nfield_opt = G_define_standard_option(G_OPT_V_FIELD);
    nfield_opt->key = "nlayer";
    nfield_opt->answer = "2";
    nfield_opt->description = "Node layer";    
  
    if (G_parser(argc, argv))
        exit (-1);
  
    afield = atoi (afield_opt->answer);
    nfield = atoi (nfield_opt->answer);
    
    if ( action->answer[0] == 'n' ) { /* nodes */
	Vect_check_input_output_name ( input->answer, output->answer, GV_FATAL_EXIT );
	
        if ( output->answer == NULL ) 
	    G_fatal_error("Output vector map must be specified");

        nodes ( input->answer, output->answer);
    }

    if ( action->answer[0] == 'r' ) /* report */
      report ( input->answer, afield, nfield);

  return (0);
}