# Experimental code to plot city names.

proc new_city {city lat long} {
   global city_coords
   set city_coords($city) [list $lat $long]
}


proc addcity {city} {
   global user_cities
   lappend user_cities $city
}


# rmcities clears the map of city names
proc rmcities {} {
   global cities_loaded
   .c delete withtag cityname
   set cities_loaded 0
}

# TODO:
# * Use airport codes for unique identifiers for each city name plotted.
# * In add/remove cities code, make it a set of radiobuttons for each
#   city name:  left ( )   right ( ) Z do not plot (*)
#   When the radiobuttons change value, the city name is plotted/removed
#   accordingly.
#
# plotcity plots the city name at the specified lat/long (if on map)
proc plotcity {name lat long} {
   global color loadsat

   if {$loadsat == 0} {
      set fill gray
      set font {Times 12}
   } else {
      set fill red
      set font {Times 12 bold}
   }

   if {![valid_coords $lat $long]} { return }
   set y [set_latt $lat]
   set x [set_long $long]
   set item [.c create text $x $y -text "* $name" -anchor w \
                           -fill $fill -font $font]
   addtags $item cityname
}


# plot_user_cities plots the selected list of city names

proc plot_user_cities {} {
   global user_cities city_coords install_dir cities_loaded

   # start with a clean chart/empty variables
   rmcities
   set user_cities [list]

   # Now load what the user has asked for
   set cities_loaded 1
   source $install_dir/tracker/config_citydefs.tcl
   source $install_dir/tracker/config_user_citylist.tcl

   foreach city $user_cities {
      foreach {lat long} $city_coords($city) { break }
      plotcity $city $lat $long
   }
}


