#!/bin/sh
#
# $Id: get-NWSdata,v 1.9 2007/02/16 19:48:55 we7u Exp $
#
# Script to retrieve NWS data files. 
#
# Originally written 2006/03/07 by Steven, WM5Z, and Curt, WE7U.
#
# Copyright (C) 2000-2007  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., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, 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.weather.gov/geodata/>


FILE1="z_18oc06"  # NWSM Libraries: Public Zone Boundaries
FILE2="w_16mr06"  # NWSM Libraries: County Warning Area Boundaries
FILE3="mz30nv06"  # NWSM Libraries: Coastal and Offshore Marine Zones
FILE4="oz15de04"  # NWSM Libraries: Coastal and Offshore Marine Zones
FILE5="hz28au04"  # NWSM Libraries: Coastal and Offshore Marine Zones
FILE6="c_16mr06"  # County Libraries: AWIPS Counties
FILE7="fz24my06"  # NWSM Libraries: Fire Weather Zone Boundaries


cd /usr/local/share/xastir/Counties


# 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.
#
#
if [ -e $FILE1.shp ]
  then
    echo "Already have $FILE1 shapefile, skipping..."
  else
    # Remove possible older copies
    rm -f z_*.shx z_*.shp z_*.dbf z_*.prj z_*.zip 2>&1 >/dev/null
    wget http://www.weather.gov/geodata/catalog/wsom/data/$FILE1.zip
    unzip z_*.zip
    rm *.zip
fi


if [ -e $FILE2.shp ]
  then
    echo "Already have $FILE2 shapefile, skipping..."
  else
    # Remove possible older copies
    rm -f w_*.shx w_*.shp w_*.dbf w_*.prj w_*.zip 2>&1 >/dev/null
    wget http://www.weather.gov/geodata/catalog/wsom/data/$FILE2.zip
    unzip w_*.zip
    rm *.zip
fi


if [ -e $FILE3.shp ]
  then
    echo "Already have $FILE3 shapefile, skipping..."
  else
    # Remove possible older copies
    rm -f mz_*.shx mz_*.shp mz_*.dbf mz_*.prj mz_*.zip 2>&1 >/dev/null
    wget http://www.weather.gov/geodata/catalog/wsom/data/$FILE3.zip
    unzip mz*.zip
    rm *.zip
fi


if [ -e $FILE4.shp ]
  then
    echo "Already have $FILE4 shapefile, skipping..."
  else
    # Remove possible older copies
    rm -f oz_*.shx oz_*.shp oz_*.dbf oz_*.prj oz_*.zip 2>&1 >/dev/null
    wget http://www.weather.gov/geodata/catalog/wsom/data/$FILE4.zip
    unzip oz*.zip
    rm *.zip
fi


if [ -e $FILE5.shp ]
  then
    echo "Already have $FILE5 shapefile, skipping..."
  else
    # Remove possible older copies
    rm -f hz_*.shx hz_*.shp hz_*.dbf hz_*.prj hz_*.zip 2>&1 >/dev/null
    wget http://www.weather.gov/geodata/catalog/wsom/data/$FILE5.zip
    unzip hz*.zip
    rm *.zip
fi


if [ -e $FILE6.shp ]
  then
    echo "Already have $FILE6 shapefile, skipping..."
  else
    # Remove possible older copies
    rm -f c_*.shx c_*.shp c_*.dbf c_*.prj c_*.zip 2>&1 >/dev/null
    wget http://www.weather.gov/geodata/catalog/county/data/$FILE6.zip
    unzip c_*.zip
    rm *.zip
fi


if [ -e $FILE7.shp ]
  then
    echo "Already have $FILE7 shapefile, skipping..."
  else
    # Remove possible older copies
    rm -f fz_*.shx fz_*.shp fz_*.dbf fz_*.prj fz_*.zip 2>&1 >/dev/null
    wget http://www.weather.gov/geodata/catalog/wsom/data/$FILE7.zip
    unzip fz*.zip
    rm *.zip
fi


