/** * Main driver for heatmap program. * * @author CPSC 223 Staff and you */ // see the header file for suggestions on how the suggested functions behave // (but this and heatmap.c are in Optional, so you can do whatever you want // or need to do with any of this code -- that goes for track.c as well) #include "heatmap.h" #include #include #include #include #include "track.h" #include "trackpoint.h" #include "location.h" int main(int argc, char **argv) { command_line args; if (!validate_command_line(argc, argv, &args)) { fprintf(stderr, "%s: invalid parameter\n", argv[0]); return 1; } track *trk = track_create(); if (trk == NULL) { fprintf(stderr, "%s: could not create track\n", argv[0]); return 1; } if (!read_input(stdin, trk)) { track_destroy(trk); return 1; } // print the heatmap if (!show_heatmap(stdout, trk, &args)) { track_destroy(trk); return 1; } track_destroy(trk); return 0; } bool validate_command_line(int argc, char **argv, command_line *args) { // TO DO: set the fields of the struct args points to according to // the contents of the command line, checking for validity along the // way return true; } bool read_input(FILE *in, track *trk) { // THIS WORKS FOR VALID INPUTS WITH ONLY ONE SEGMENT // TO DO: checking for blank lines that separate segments and making sure // no crashes or infinite loops on invalid input double lat; double lon; long time; while (fscanf(in, "%lf %lf %ld", &lat, &lon, &time) == 3) { // create point and add to track trackpoint *pt = trackpoint_create(lat, lon, time); if (pt == NULL) { fprintf(stderr, "could not create point %f %f %ld\n", lat, lon, time); return false; } track_add_point(trk, pt); // track made its own copy, so we destroy ours trackpoint_destroy(pt); } return true; } bool show_heatmap(FILE *out, const track *trk, const command_line *args) { // TO DO: ask the track for a heatmap and print it! return true; }