# When and where will it become daylight / night time on your next # flight? Well, just download the previous day's flight's .kml track # log and compute! # # Usage example: Making a .solar.txt out of a .kml present in the directory: # make FlightAware_UAL872_RCTP_KSFO_20220706.solar.csv # # This Makefile you are reading will compute the mean solar time of # points on a flight, and thus tell you where it will get dark (around # 18:00), or light (around 06:00). Yes, seasons are disregarded, as so # is even latitude. Sorry. # # Author: Dan Jacobson https://www.jidanni.org/ # Copyright: https://www.gnu.org/licenses/gpl.html # Created: 2023-03-22T02:39:40+0000 # Last-Updated: 2023-03-27T05:37:46+0000 # Update #: 118 # https://en.wikipedia.org/wiki/Solar_time#Mean_solar_time S=sqlite3 -bail # https://www.sqlite.org/lang_datefunc.html %.solar.csv:%.sqlite; echo "SELECT Latitude, Longitude, \ strftime('%Y-%m-%dT%H:%M:%S', Time, (Longitude / 15 )||' hours') \ AS 'Mean solar time' FROM t1;"|$S --csv --header $? > $@ %.sqlite:%.csv; echo .import --csv $? t1|$S $@ %.csv:%.kml %.style; TZ= gpsbabel -t -i kml -f $< -x nuketypes,waypoints -o xcsv,style=$*.style -F $@ # https://www.gpsbabel.org/htmldoc-development/style_define.html %.style:; echo $(style)|perl -pwle 's/\s*\@/\n/g;' > $@ style=\ FIELD_DELIMITER COMMA\ @RECORD_DELIMITER NEWLINE\ @PROLOGUE Latitude,Longitude,Time\ @IFIELD LAT_DECIMAL,"","%f"\ @IFIELD LON_DECIMAL,"","%f"\ @IFIELD ISO_TIME,"","%s" # Time shifting to mean solar time would be too much to ask # https://www.gpsbabel.org/htmldoc-development/filter_track.html # to implement for so few users, so we do it ourselves above! # One notices at high latitudes, westbound planes can even "turn back # the hands of time".