#
# Plik: ge_douglas.py, wywolanie:
#
#  > python "C:\GRASS\ge_douglas" --input="streams" --output="dg_streams" --method="douglas" --threshold="0.1"
#
#
import getopt
import sys
import os
import grass.script as grass


def main(argv):


    try:  
        opt, args = getopt.getopt(argv, "hi:o:m:t:a:", ["help", "input=", "output=", "method=", "threshold=", "angle_thresh="])

    except:
        usage()
        sys.exit(2)

   
    inputs = ''
    outputs = ''
    methods = ''
    thresholds = ''
    angle_threshs=''


    
    #Loop through all the option / argument pairs and perform any actions associated with them.

    for o, a in opt:
        if o in ("-h", "--help"):
            usage()
            sys.exit()
        elif o in ("-i", "--input"):
            inputs = a
        elif o in ("-o", "--output"):
            outputs = a
        elif o in ("-m", "--method"):
            methods= a
        elif o in ("-t", "--threshold"):
            thresholds = a
        elif o in ("-a", "--angle_thresh"):
            angle_threshs = a
        else:
            assert False, "unhandled option"

        print inputs
        print outputs
        print methods
        print thresholds
     
        grass.parse_command('v.generalize', input = inputs, output = outputs, method = methods, threshold=thresholds)

        grass.parse_command('v.build', map = outputs)


    #Print the usage for this program
def usage():
        usage = "-h --help Prints this"
        print usage

if __name__ == "__main__":
        main(sys.argv[1:])

        # [1:] slices off the first argument which is the name of the program
