Next / Previous / Contents / NM Tech homepage

6.9. The cir_reg table

This table is the intermediate table in the many-to-many relation between circles and regions.

pycbc.py
    cir_reg_table = schema.Table('cir_reg', meta,
        schema.Column('lat',       types.CHAR(4)),
        schema.Column('lon',       types.CHAR(5)),
        schema.Column('reg_pos',   types.SMALLINT, nullable=False),
        schema.Column('reg_code',  types.CHAR(2),
            schema.ForeignKey("regions.reg_code", name="cir_reg_reg_x")),
        schema.PrimaryKeyConstraint('lat', 'lon', 'reg_pos'),
        schema.ForeignKeyConstraint(('lat', 'lon'),
             ('circles.lat', 'circles.lon')))

    class CirReg(object):
        def __init__(self, lat, lon, reg_pos, reg_code):
            self.lat = lat
            self.lon = lon
            self.reg_pos = reg_pos
            self.reg_code = reg_code
        def __repr__(self):
            return ( "<CirReg(%sn %sw [%d] %s)>" %
                     (self.lat, self.lon, self.reg_pos, self.reg_code) )