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

22.10. PriIndex._overlapEntry(): Generate one overlap line

cbchistlib.py
# - - -   P r i I n d e x . _ o v e r l a p E n t r y

    def _overlapEntry(self, parent, pct, c):
        '''Format the "Overlaps" entry for a given circle.

          [ (pct is the percentage overlap as a float) and
            (c is a pycbc.Circle) ->
              if c has any efforts within self's year range ->
                parent  +:=  a div of class CLASS_AS_DIV
                    displaying pct, c's name, regions and center,
                    and a list of the years of those efforts
              else -> I ]
        '''

There is no guarantee that any circle was worked in the years we are selecting. Hence, first we build a list of Effort instances for the overlapping circle, and filter out those outside the year range.

cbchistlib.py
        #-- 1
        # [ effList  :=  a list of efforts for circle c whose year
        #       numbers are within self's range ]
        effList = [ effort
                    for effort in c.efforts
                    if ((effort.year_no >= self.firstYear) and
                        (effort.year_no <= self.lastYear)) ]

        #-- 2
        if len(effList) == 0:
            return

        #-- 3
        # [ parent  +:=  a new div of class CLASS_AS_DIV displaying
        #       the overlap percentage
        #   div  :=  that new div ]
        heading = "Overlaps %.1f%%: " % pct
        div = subElement(parent,
                  E.div(CLASS_AS_DIV, heading))
                  
        #-- 4
        # [ div  +:=  (a link to the anchor for c containing the
        #       names of c and a span of class lat-lon
        #       containing c's center coordinates) + (a span of
        #       class year-list displaying effList) ]
        anchor = {'href': ('#'+anchorName(c))}
        refCenter = latLonFormat(c.lat, c.lon)
        refNames = '%s, %s' % (c.cir_name, c.allRegions())
        div.append(
            E.a(anchor, refNames,
                E.span(CLASS_LAT_LON, refCenter)))
        div.append(
            E.span(CLASS_YEAR_LIST, yearBrackets(effList)))