2010-11-21 22:43:57 +00:00
#!/bin/sh
#
# Written by Martin Spott
#
# Copyright (C) 2010 Markus Metz @ GRASS GIS
# Copyright (C) 2010 Martin Spott - Martin (at) flightgear (dot) org
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
#MODE=${1} # Doesn't work in $GRASS_BATCH_JOB
# Create reasonable symlinks pointing to this script to return proper
# $MODE-values for the "case" clause, like 'grass01import.sh_shp'
MODE = ` basename ${ 0 } | cut -f 2 -d \_ `
#
# Self-explaining ....
DEBUG = false
#
# DB-Connection
PGHOST = geoscope.optiputer.net
PGUSER = webuser
PGDATABASE = landcover
2010-11-22 15:29:55 +00:00
PSQL = " psql -tA -h ${ PGHOST } -U ${ PGUSER } -d ${ PGDATABASE } -c "
2010-11-21 22:43:57 +00:00
#
# Note: CORINE Shapefiles are EPSG:3035, Landcover-DB is EPSG:4326, but
# _both_ projections (reference systems) are using square meters as unit for
# area size declarations in GRASS !
# Units for snapping are different in GRASS, though. Whereas EPSG:3035 is
# using meters, EPSG:4326 is using degrees.
#
case ${ MODE } in
shp)
# Local, pre-intersected Shapefiles
DSN = ${ HOME } /live/corine
2010-12-13 19:35:33 +00:00
# PREFIX=nl_
PREFIX = clc00_
2010-11-21 22:43:57 +00:00
SELECTION = ${ DSN } /${ PREFIX } c[ 0-9] [ 0-9] [ 0-9] .shp
SNAP = 1
SPAT = ""
; ;
ldb)
# Landcover-DB
DSN = " PG:host= ${ PGHOST } user= ${ PGUSER } dbname= ${ PGDATABASE } "
2011-01-07 20:26:13 +00:00
# PREFIX=clc_
PREFIX = cs_
# Maybe unsafe because "_" matches any single character in LIKE;
# escape understores.
2011-09-28 11:30:21 +00:00
SELECTION = ` ${ PSQL } " SELECT f_table_name FROM geometry_columns WHERE f_table_name LIKE ' $( echo ${ PREFIX } | sed -e 's/_/\\_/g' ) %' AND type LIKE 'ST_Polygon' ORDER BY f_table_name " `
2011-01-07 20:26:13 +00:00
# SELECTION=`psql -tA -c "\dt" | awk -F\| '{print $2}' | grep \^${PREFIX}`
SNAP = 0.0003 # Fits nicely with VMap0, consider SNAP=0.00001 for accurate data
# SPAT="spatial=2.8,49.8,8.2,54.2" # spatial=-123,37,-121,38 # spatial=3,50,8,54
SPAT = ""
2010-11-21 22:43:57 +00:00
; ;
esac
#
MIN_AREA = 1
# Strip input down to bare GRASS map name
#
Selection ( ) {
for FILE in ${ SELECTION } ; do
basename ${ FILE } | cut -f 1 -d \. | cut -f 2 -d \_
done
}
if [ ${ DEBUG } = "true" ] ; then
echo "PREFIX # GRASSMAP # DSN # LAYER-in-DSN"
fi
# Go
#
for MAP in ` echo $( Selection) ` ; do
LAYER = ${ PREFIX } ${ MAP }
if [ ${ DEBUG } = "true" ] ; then
echo " ${ PREFIX } # ${ MAP } # ${ DSN } # ${ LAYER } "
fi
2011-11-15 17:17:59 +00:00
# v.in.ogr dsn="${DSN}" layer=${LAYER} output=${MAP} snap=${SNAP} min_area=${MIN_AREA} ${SPAT} --verbose
v.in.ogr dsn = " ${ DSN } " layer = ${ LAYER } output = ${ MAP } --verbose
2010-11-21 22:43:57 +00:00
done
# EOF