# - - - P r i I n d e x . h t m l A s
def htmlAs(self, parent):
'''Show other circle names and/or locations
[ parent is an et.Element ->
parent +:= "As" entries for self ]
'''
There are two kinds of “As” entries:
Entries with different names but the same coordinates.
Entries with the same name but different coordinates. There are relatively few of this type.
Because this list may run on for dozens of lines (check Massachusetts in the early days, e.g.), there should be some sensible ordering to the entries. We'll generate all of the name variants in alphabetical order, followed by all the center coordinates variants in ascending order with latitude as the primary key and longitude as the secondary key.
The algorithm is straightforward. Starting with the Effort rows currently referred to the primary circle,
we form a set of 3-tuples (, and sort that.
Note that this list will always include the current name and
center coordinates.
name, lat,
lon)
Then we work through the list twice in order, ignoring the entry for the current primary. The first time through we produce lines for the same-name, different-center cases. The second time we produce lines for the different-name, same-center cases.
#-- 1
# [ variantSet := a set of (name, lat, lon) tuples
# representing the unique combinations of those
# values found in self.effortList ]
variantSet = set()
for effort in self.effortList:
variantSet.add((effort.as_name, effort.as_lat, effort.as_lon))
#-- 2
# [ variantList := variantSet, sorted, as a list ]
variantList = sorted(variantSet)
For the logic that builds an “As” line, see
Section 22.8, “PriIndex._buildAs(): Build an
“As” line”.
#-- 3
# [ parent +:= "As" entries for elements of variantList
# whose names match self.circle.cir_name but whose
# lat or lon differ ]
for name, lat, lon in variantList:
if ( (self.circle.cir_name == name) and
( ( self.circle.lat != lat ) or
( self.circle.lon != lon ) ) ):
self._buildAs(parent, name, lat, lon)
#-- 4
# [ parent +:= "As" entries for elements of variantList
# whose names differ from self.circle.cir_name ]
for name, lat, lon in variantList:
if self.circle.cir_name != name:
self._buildAs(parent, name, lat, lon)