#!/bin/sh
#
############################################################################
#
# MODULE:       v.what.vect
# AUTHOR(S):    Markus Neteler
# PURPOSE:      Uploads attributes at the location of vector points to the table.
# COPYRIGHT:    (C) 2005 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.
#
#############################################################################

#%Module
#%  description: Uploads vector values at positions of vector points to the table
#%  keywords: vector, database, attribute table
#%End

#%option
#% key: vector
#% type: string
#% key_desc: name
#% gisprompt: old,vector,vector
#% description: Vector map with points for which to modify the attribute table
#% required : yes
#%end

#%option
#% key: qvector
#% type: string
#% key_desc: name
#% gisprompt: old,vector,vector
#% description: Vector map to be queried
#% required : yes
#%end

#%option
#% key: layer
#% type: integer
#% description: Layer of the vector for which to modify the attribute table
#% answer: 1
#% required : no
#%end

#%option
#% key: qlayer
#% type: integer
#% description: Layer of the vector to be queried
#% answer: 1
#% required : no
#%end

#%option
#% key: column
#% type: string
#% description: Column to be updated with the query result
#% required : yes
#%end

#%option
#% key: qcolumn
#% type: string
#% description: Column to be queried
#% required : yes
#%end

if  [ -z $GISBASE ] ; then
    echo "You must be in GRASS GIS to run this program."
 exit 1
fi

if [ "$1" != "@ARGS_PARSED@" ] ; then
    exec g.parser "$0" "$@"
fi


v.distance from=$GIS_OPT_VECTOR to=$GIS_OPT_QVECTOR column=$GIS_OPT_COLUMN to_column=$GIS_OPT_QCOLUMN \
           upload=to_attr dmax=0 from_layer=$GIS_OPT_LAYER to_layer=$GIS_OPT_QLAYER

