1
|
#!/bin/sh -e
|
2
|
|
3
|
|
4
|
###############################################################################
|
5
|
# '$RCSfile$'
|
6
|
# Authors: Matt Jones, Chad Berkley, Jivka Bojilova
|
7
|
# Copyright: 2000 Regents of the University of California and the
|
8
|
# National Center for Ecological Analysis and Synthesis
|
9
|
# For Details: http://www.nceas.ucsb.edu/
|
10
|
#
|
11
|
# '$Author: harris $'
|
12
|
# '$Date: 2005-09-07 14:03:08 -0700 (Wed, 07 Sep 2005) $'
|
13
|
# '$Revision: 2563 $'
|
14
|
#
|
15
|
# Build file for the Ant cross-platform build system for metacat
|
16
|
# See http://jakarta.apache.org for details on Ant
|
17
|
#
|
18
|
# usage: ant [compile|jar|install|jdoc]
|
19
|
#
|
20
|
# This program is free software; you can redistribute it and/or modify
|
21
|
# it under the terms of the GNU General Public License as published by
|
22
|
# the Free Software Foundation; either version 2 of the License, or
|
23
|
# (at your option) any later version.
|
24
|
#
|
25
|
# This program is distributed in the hope that it will be useful,
|
26
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
27
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
28
|
# GNU General Public License for more details.
|
29
|
#
|
30
|
# You should have received a copy of the GNU General Public License
|
31
|
# along with this program; if not, write to the Free Software
|
32
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
33
|
###############################################################################
|
34
|
|
35
|
## script to create a shapefile from metacat, and to be run nightly as a cronjob
|
36
|
|
37
|
|
38
|
################### JUDITHS'S SETTINGS #########################################
|
39
|
#METACAT_URL=http://metacat.nceas.ucsb.edu/knb/servlet/metacat
|
40
|
METACAT_URL=http://127.0.0.1:8080/knp/servlet/metacat
|
41
|
METACAT_LOGIN=yeah
|
42
|
METACAT_PASSWD=right
|
43
|
|
44
|
TMP_DIR=/tmp
|
45
|
|
46
|
METACAT_SHAPEFILE_RESOURCES=/usr/local/devtools/shapefile/metacat/
|
47
|
#METACAT_SHAPEFILE_RESOURCES=/home/harris/development/private/src/cpp/shapefile/metacat/
|
48
|
|
49
|
PERL_BIN=/usr/bin/perl
|
50
|
|
51
|
POINTS_GEOCOORD=metacat_points_geocoord.txt
|
52
|
POINTS_UTM=metacat_points_utm.txt
|
53
|
|
54
|
SHAPEFILE_GEOCOORD=metacat_points_geocoord
|
55
|
SHAPEFILE_UTM=metacat_points_utm
|
56
|
|
57
|
#DIST_DIR=/home/harris/development/private/src/cpp/shapefile/metacat/data
|
58
|
DIST_DIR=/var/www/html/mapserver/kruger/data/
|
59
|
#############################################################################
|
60
|
|
61
|
|
62
|
|
63
|
################### JOHN'S SETTINGS #########################################
|
64
|
#METACAT_URL=http://dhcp84.nceas.ucsb.edu:8080/knp/servlet/metacat
|
65
|
###METACAT_URL=http://metacat.nceas.ucsb.edu/knb/servlet/metacat
|
66
|
|
67
|
#TMP_DIR=/tmp
|
68
|
|
69
|
#METACAT_SHAPEFILE_RESOURCES=/home/harris/development/private/src/cpp/shapefile/metacat/
|
70
|
|
71
|
#PERL_BIN=/usr/bin/perl
|
72
|
|
73
|
#POINTS_GEOCOORD=metacat_points_geocoord.txt
|
74
|
#POINTS_UTM=metacat_points_utm.txt
|
75
|
|
76
|
#SHAPEFILE_GEOCOORD=metacat_points_geocoord
|
77
|
#SHAPEFILE_UTM=metacat_points_utm
|
78
|
|
79
|
#DIST_DIR=/home/harris/development/private/src/cpp/shapefile/metacat/data
|
80
|
#############################################################################
|
81
|
|
82
|
|
83
|
## 1] get the counding coordinates from metacat
|
84
|
$METACAT_SHAPEFILE_RESOURCES/get_eml.pl $METACAT_URL $METACAT_LOGIN $METACAT_PASSWD > $TMP_DIR/$POINTS_GEOCOORD
|
85
|
echo "THE DATA RETRIEVED FROM METACAT START ON THE FOLLOWING LINE"
|
86
|
echo "THE DATA RETRIEVED FROM METACAT START ON THE FOLLOWING LINE"
|
87
|
echo "THE DATA RETRIEVED FROM METACAT START ON THE FOLLOWING LINE"
|
88
|
echo "THE DATA RETRIEVED FROM METACAT START ON THE FOLLOWING LINE"
|
89
|
cat $TMP_DIR/$POINTS_GEOCOORD
|
90
|
echo "THE DATA RETRIEVED FROM METACAT START ON THE FOLLOWING LINE"
|
91
|
echo "THE DATA RETRIEVED FROM METACAT START ON THE FOLLOWING LINE"
|
92
|
echo "THE DATA RETRIEVED FROM METACAT START ON THE FOLLOWING LINE"
|
93
|
echo "THE DATA RETRIEVED FROM METACAT START ON THE FOLLOWING LINE"
|
94
|
|
95
|
|
96
|
## 2] create the shapefile [this will be in geocoordinates]
|
97
|
$METACAT_SHAPEFILE_RESOURCES/metacat_shapefile $TMP_DIR/$POINTS_GEOCOORD $TMP_DIR/$SHAPEFILE_GEOCOORD
|
98
|
|
99
|
## 3] convert the data to utm
|
100
|
|
101
|
# delete the file if it exists
|
102
|
if test -f $TMP_DIR/$POINTS_UTM; then
|
103
|
rm $TMP_DIR/$POINTS_UTM
|
104
|
fi
|
105
|
|
106
|
cat $TMP_DIR/$POINTS_GEOCOORD | while read line
|
107
|
do
|
108
|
ID=`echo $line | awk '{print $1}'`
|
109
|
LAT=`echo $line | awk '{print $3}'`
|
110
|
LONG=`echo $line | awk '{print $2}'`
|
111
|
URL=`echo $line | awk '{print $4}'`
|
112
|
|
113
|
|
114
|
## the utm x,y's are switched here
|
115
|
UTM=`$METACAT_SHAPEFILE_RESOURCES/coords/ll2utm $LAT $LONG | awk '{print $1, $2}'`
|
116
|
Y=`echo $UTM | awk '{print $1}'`
|
117
|
X=`echo $UTM | awk '{print $2}'`
|
118
|
|
119
|
if test ! -d $X; then
|
120
|
echo $ID $X $Y $URL >> $TMP_DIR/$POINTS_UTM
|
121
|
fi
|
122
|
done
|
123
|
|
124
|
## 4] make a second shapefile -- this time in utm
|
125
|
$METACAT_SHAPEFILE_RESOURCES/metacat_shapefile $TMP_DIR/$POINTS_UTM $TMP_DIR/$SHAPEFILE_UTM
|
126
|
|
127
|
|
128
|
## 5] distribute the shapefiles
|
129
|
cp $TMP_DIR/$SHAPEFILE_GEOCOORD* $DIST_DIR
|
130
|
cp $TMP_DIR/$SHAPEFILE_UTM* $DIST_DIR
|
131
|
|
132
|
|
133
|
## clean up
|
134
|
rm core*
|
135
|
|
136
|
|