File: get-NWSdata.in

package info (click to toggle)
xastir 2.2.4-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 22,860 kB
  • sloc: ansic: 126,160; perl: 7,792; makefile: 448; sh: 228; sql: 102
file content (136 lines) | stat: -rwxr-xr-x 4,490 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/bin/sh
#
# Script to retrieve NWS data files. 
#
# Run this from the INSTALLED location of the script, i.e.
#    /usr/local/share/xastir/scripts
# or /usr/share/xastir/scripts
#
#
# Originally written 2006/03/07 by Steven, WM5Z, and Curt, WE7U.
#
# Copyright (C) 2000-2026 The Xastir Group
#
# 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.
#
# See README.MAPS for a bit more information on the program.
#
#
# NOTE:  Run this script as root.
#
# MAINTAINERS:  Go here to find out what the latest versions are:
# <http://www.nws.noaa.gov/geodata/>
# <http://www.weather.gov/gis/AWIPSShapefiles>



# Please only have ONE of each variable listed here!  Note that the "Valid
# Date" listed on the NWS web pages is the date at which the Shapefile
# should START to be used.  Don't just blindly put the newest filename
# here if that start-date hasn't arrived yet!
#
FILE1="w_03mr26"    # GREEN: NWSM Library: County Warning Area Boundaries
FILE2="z_03mr26"    # GREEN: NWSM Library: Public Forecast Zone Boundaries
FILE3="mz03mr26"    # GREEN: NWSM Library: Coastal and Offshore Marine Zones
FILE4="oz03mr26"   # GREEN: NWSM Library: Coastal and Offshore Marine Zones
FILE5="hz20fe25"    # GREEN: NWSM Library: Coastal and Offshore Marine Zones
FILE6="fz03mr26"    # GREEN: NWSM Library: Fire Weather Zone Boundaries
FILE7="c_03mr26"    # RED: Counties, States, Provinces: U.S. Counties

prefix=@prefix@

cd ${prefix}/share/xastir/Counties || exit 1


# Remove any old zip files hanging around in this directory
#
rm -f *.zip 2>&1 >/dev/null


# Fetch new copies, unzip into place, delete archive.
#
#
DIR=WSOM
for d in $FILE1 $FILE2 $FILE3 $FILE4 $FILE5 $FILE6; do
  if [ -e $d.shp ]; then
    echo "Already have $d shapefile, skipping..."
  else
    # Remove possible older copies
    cut=`echo $d|cut -c1-2 -`
    rm -f $cut*.shx $cut*.shp $cut*.dbf $cut*.prj $cut*.zip 2>&1 >/dev/null
    wget https://www.weather.gov/source/gis/Shapefiles/$DIR/$d.zip
    unzip $d.zip
    rm -f *.zip
  fi
done

DIR=County
for d in $FILE7; do
  if [ -e $d.shp ]; then
    echo "Already have $d shapefile, skipping..."
  else
    # Remove possible older copies
    cut=`echo $d|cut -c1-2 -`
    rm -f $cut*.shx $cut*.shp $cut*.dbf $cut*.prj $cut*.zip 2>&1 >/dev/null
    wget https://www.weather.gov/source/gis/Shapefiles/$DIR/$d.zip
    unzip $d.zip
    rm -f *.zip
  fi
done

####################
# After download/install of map files above, run commands such as these:
#
#   cd /usr/local/share/xastir; testdbfawk -D config -d Counties/mz11au16.dbf 2>&1 | head -5
#   cd /usr/local/share/xastir; testdbfawk -D config -d Counties/w_11au16.dbf 2>&1 | head -5
#
# to determine whether there's dbfawk support for each of the NWS files. NWS
# changes the signature on their files often so we need to create a new
# dbfawk for each in xastir/config, test it, then add it into the
# Makefile.am file there and commit, then do another "make install" to put
# the dbfawk's into place.
# Fixed the issue where there's an 'a' or 'b' after the filename root. NWS likes
# to do that, but have non-a/b files extracted from the zip, which made the below
# tests fail.
####################
#

exitcode=0

for d in $FILE1 $FILE2 $FILE3 $FILE4 $FILE5 $FILE6 $FILE7; do

  e=`echo $d | sed -e's/\(.*[0-9]\)[a-f]$/\1/'`

  if [ -e $e.dbf ]; then
    echo
    echo $e.dbf
    # Run in a separate shell so we don't mess up the current directory for the -e test above
    result=`cd ${prefix}/share/xastir; ${prefix}/bin/testdbfawk -D config -d Counties/$e.dbf 2>&1 | head -3 | tail -1`
    echo $result
    if [ "$result" = "No matching dbfawk signature found" ]; then
        echo "Fix dbfawk for $e!"
        exitcode=1
    fi
  fi
done
echo

if [ $exitcode -eq 1 ] ; then
    echo "One or more dbfawk files is out of date.  Fix the problem."
fi

exit $exitcode