#!/bin/sh
############################################################################
#
# MODULE:	v.build.all
# AUTHOR(S):	Radim Blazek
# PURPOSE:	Build all vectors in current mapset
# COPYRIGHT:	(C) 2004 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: Rebuilds topology on all vector maps in the current mapset.
#% keywords: vector
#%End

if test "$GISBASE" = ""; then
    echo "You must be in GRASS GIS to run this program." >&2
    exit 1
fi

# skip parser if no args are given
if [ "$#" -gt 0 ] ; then
  if [ "$1" != "@ARGS_PARSED@" ] ; then
    exec g.parser "$0" "$@"
  fi
fi

eval `g.gisenv`
: ${GISBASE?} ${GISDBASE?} ${LOCATION_NAME?} ${MAPSET?}
LOCATION="$GISDBASE/$LOCATION_NAME/$MAPSET"


for VECT in `g.list type=vect mapset="$MAPSET" | sed 1,2d | grep -v '^-*$'`
do
    g.message "Build topology for vector '${VECT}@${MAPSET}'" 
    CMD="v.build map=${VECT}@${MAPSET}"
    g.message message="$CMD" 
    $CMD
done

exit 0
