Next / Previous / Contents / TCC Help System / NM Tech homepage

22.7. PriIndex.htmlAs(): Generate primary “As” entries
# - - -   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:

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 (name, lat, lon), and sort that. Note that this list will always include the current name and center coordinates.

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 but whose
        #       lat or lon differ ]
        for name, lat, lon in variantList:
            if ( ( == name) and
                 ( ( != lat ) or
                   ( != lon ) ) ):
                self._buildAs(parent, name, lat, lon)

        #-- 4
        # [ parent  +:=  "As" entries for elements of variantList
        #       whose names differ from ]
        for name, lat, lon in variantList:
            if != name:
                self._buildAs(parent, name, lat, lon)