#!/bin/sh
#
# Compare the RoadMap map directory content with the Tiger directory content
# to point out counties that have not yet been translated (or for which the
# translation failed).
#

usage()
{
   echo "usage: rdmcompare <tiger-path> [maps=<map-directory-path>]" >&2
   echo "  Used to check the translation of tiger data." >&2
   exit 1
}


MAPSDIR=/usr/share/roadmap

STARTDIR=`pwd`
TIGERDIR=$1
test -d "$TIGERDIR" || usage
shift

case $1 in
   maps=*) MAPSDIR=`expr $1 : 'maps=\(.*\)'`
           shift
           ;;
esac


check_one_county() {

   base=`basename $1`
   fips=`expr substr $base 4 5`

   if [ ! -e $MAPSDIR/usc$fips.rdm ] ; then
       echo "usc$fips.rdm was not generated"
       echo "## usc$fips.rdm was not generated" >> $STARTDIR/buildmap_errors.log
   fi
}


cd $TIGERDIR

for i in tgr*.zip
do
   if [ -e $i ] ; then
      check_one_county $i
   fi
done

for i in TGR*.ZIP
do
   if [ -e $i ] ; then
      check_one_county $i
   fi
done

