After spending some time on this and ending up trying various ideas, this ended up being what I thought was the best and simplest solution. Basically, when write_tile_cfg is called, loop through the zones in self.v_["zone_list"] and compare each zone with the active tile coordinates. If any point (lat, lon) in each zone matches, then we append that to a new tile_zones list which is then saved to the tile configuration. For future reference (mostly for myself), here's some more details:
self.v_["zone_list"] is a tk.StringVar and has to be converted to a Python string
The string is then converted to a list so it can be iterated
Convert zone_list to a set for optimization (faster and removes any duplicate coordinates within a zone)
Check if the active coords (longitude + 1 since the active coordinates are based on the SW corner) are in the set
Finally, write the matching zones to the configuration file
Changes:
When write_tile_cfg is called, only save zones for the selected/active tile.
Clean up some cfg_vars descriptions for consistency.
Added feedback (console output) when configuration window buttons (Load Tile Config, Write Tile Config, etc.) are used.
The bottom two are obviously just clean up and personal preference, but I thought it was a simple but helpful change.
This fixes #265.
After spending some time on this and ending up trying various ideas, this ended up being what I thought was the best and simplest solution. Basically, when
write_tile_cfg
is called, loop through the zones inself.v_["zone_list"]
and compare each zone with the active tile coordinates. If any point (lat, lon) in each zone matches, then we append that to a newtile_zones
list which is then saved to the tile configuration. For future reference (mostly for myself), here's some more details:self.v_["zone_list"]
is atk.StringVar
and has to be converted to a Python stringzone_list
to a set for optimization (faster and removes any duplicate coordinates within a zone)Changes:
write_tile_cfg
is called, only save zones for the selected/active tile.cfg_vars
descriptions for consistency.The bottom two are obviously just clean up and personal preference, but I thought it was a simple but helpful change.