#!/bin/sh

# 
# Compiles the kml files (one per time step) into a single geojson file 
# with an associated time field. All features in the same kml file get
# the same time value in the output. 
#
if [[ $# -ne 2 ]] ; then
        echo Usage $0 date timezone_offset
        exit 0
fi
curdate=$1
tz=$2

for hour in `seq 12 20` ; do 
	curtime=${curdate}T${hour}:00${tz}
	echo $curtime
	select_stmt="SELECT '$curtime' as time from \"Wind Speed\""
	echo $select_stmt
	ogr2ogr -f GeoJSON -sql "$select_stmt" -append wrf_${curdate}.geojson wrf_${hour}00.kml

done
