Next / Previous / Contents / NM Tech homepage

6.25. CBCData.genPrimaryRegionCircles()
# - - -   C B C D a t a . g e n P r i m a r y R e g i o n C i r c l e s

    def genPrimaryRegionCircles(self, regionCode):
        '''Generate circles that have the given regionCode first.

This method is only slightly different from Section 6.25, “CBCData.genPrimaryRegionCircles(): it finds only those circles for which the given regionCode is the first listed region. For example, if regionCode is "KY", will find circle “KY-TN-VA: Cumberland Gap”, but not “IN-IL-KY: Posey County”.

In database terms, we need to know if the cir_reg row that relates a region to a circle has a reg_pos (region position) value 0. For example, there are two records for “IN-KY: Evansville”. The first has reg_pos==0 and reg_code=="IN"; the second has reg_pos==1 and reg_code=="KY".
        q = ( self.s.query(self.Circle)
               .order_by('cir_name') )
        for circle in q:
            yield circle