Exemplo n.º 1
0
def QUALIN(lookuptype, name):
    common_rule = [{
        'instruction':
        LC('LOWACC21'),
        'rules': (
            # QUAPOS only has values 1 to 11. QUAPOS not in 1, 10, 11 is
            # equivalent to the below rules
            MSCompare('QUAPOS', '1', MSCompare.OP.GT)
            & MSCompare('QUAPOS', '10', MSCompare.OP.LT))
    }]

    if name == 'COALNE':
        return common_rule + [{
            'instruction': LS('SOLD', 1, 'CSTLN'),
            'rules': MSNoRules()
        }]
    else:
        return common_rule + [
            {
                'instruction':
                [LS('SOLD', 3, 'CHMGF'),
                 LS('SOLD', 1, 'CSTLN')],
                'rules': MSCompare('CONRAD', '1')
            },
            {
                # CONRAD missing and CONRAD != 1 both lead here
                'instruction': LS('SOLD', 1, 'CSTLN'),
                'rules': MSNoRules()
            }
        ]
Exemplo n.º 2
0
def OBSTRN_point(name):
    common_rule = [{
        'rules': MSCompare('VALSOU', '30', MSCompare.OP.GT),
        'instruction': SY('DANGER02')
    }]

    if name == 'UWTROC':
        return common_rule + [{
            'rules': (MSHasValue('VALSOU')
                      & (MSCompare('WATLEV', '4') | MSCompare('WATLEV', '5'))),
            'instruction':
            SY('UWTROC04')
        }, {
            'rules': MSHasValue('VALSOU'),
            'instruction': SY('DANGER01')
        }, {
            'rules': MSCompare('WATLEV', '3'),
            'instruction': SY('UWTROC03')
        }, {
            'rules': MSNoRules(),
            'instruction': SY('UWTROC04')
        }]

    else:
        return common_rule + [
            {
                'rules': MSHasValue('VALSOU') & MSCompare('CATOBS', '6'),
                'instruction': SY('DANGER01')
            }, {
                'rules':
                (MSHasValue('VALSOU')
                 & (MSCompare('WATLEV', '1') | MSCompare('WATLEV', '2'))),
                'instruction':
                SY('OBSTRN11')
            }, {
                'rules':
                (MSHasValue('VALSOU')
                 & (MSCompare('WATLEV', '4') | MSCompare('WATLEV', '5'))),
                'instruction':
                SY('DANGER03')
            }, {
                'rules': MSHasValue('VALSOU'),
                'instruction': SY('DANGER01')
            }, {
                'rules': MSCompare('CATOBS', '6'),
                'instruction': SY('OBSTRN01')
            }, {
                'rules': MSCompare('WATLEV', '1') | MSCompare('WATLEV', '2'),
                'instruction': SY('OBSTRN11')
            }, {
                'rules': MSCompare('WATLEV', '4') | MSCompare('WATLEV', '5'),
                'instruction': SY('OBSTRN03')
            }, {
                'rules': MSNoRules(),
                'instruction': SY('OBSTRN01')
            }
        ]
Exemplo n.º 3
0
def WRECKS_other(lookup_type, name):
    # TODO: add rules for background
    return [{
        'rules': (MSCompare('QUAPOS', '1', MSCompare.OP.GT)
                  & MSCompare('QUAPOS', '10', MSCompare.OP.LT)),
        'instruction':
        LC('LOWACC41')
    }, {
        'rules': MSCompare('VALSOU', '30', MSCompare.OP.GT),
        'instruction': LS('DASH', 2, 'CHBLK')
    }, {
        'rules': MSHasValue('VALSOU'),
        'instruction': LS('DOTT', 2, 'CHBLK')
    }, {
        'rules': MSCompare('WATLEV', '1') | MSCompare('WATLEV', '2'),
        'instruction': [LS('SOLD', 2, 'CSTLN'),
                        AC('CHBRN')]
    }, {
        'rules': MSCompare('WATLEV', '4'),
        'instruction': [LS('DASH', 2, 'CSTLN'),
                        AC('DEPIT')]
    }, {
        'rules': MSCompare('WATLEV', '3') | MSCompare('WATLEV', '5'),
        'instruction': [LS('DOTT', 2, 'CSTLN'),
                        AC('DEPVS')]
    }, {
        'rules': MSNoRules(),
        'instruction': [LS('DOTT', 2, 'CSTLN'),
                        AC('DEPVS')]
    }]
Exemplo n.º 4
0
def DEPARE(lookup_type, name):

    # These values are normally passed by the mariner
    # safety_contour = 10
    # shallow_contour = 20
    # deep_contour = 30

    # Basic implementation of DEPARE constructed symbol.
    # We are missing all the line and fill symbology
    return [{
        'instruction': AC('DEPIT'),
        'rules': MSCompare('DRVAL2', '0', MSCompare.OP.LE),
    }, {
        'instruction': AC('DEPVS'),
        'rules': MSCompare('DRVAL2', '10', MSCompare.OP.LT),
    }, {
        'instruction': AC('DEPMS'),
        'rules': MSCompare('DRVAL2', '20', MSCompare.OP.LT),
    }, {
        'instruction': AC('DEPMD'),
        'rules': MSCompare('DRVAL2', '30', MSCompare.OP.LT),
    }, {
        'instruction': AC('DEPDW'),
        'rules': MSNoRules(),
    }]
Exemplo n.º 5
0
def WRECKS_Point(lookup_type, name):
    return [{
        'rules': MSCompare('VALSOU', '30', MSCompare.OP.GT),
        'instruction': SY('DANGER02')
    }, {
        'rules': MSHasValue('VALSOU'),
        'instruction': SY('DANGER01')
    }, {
        'rules': MSCompare('CATWRK', '1') & MSCompare('WATLEV', '3'),
        'instruction': SY('WRECKS04')
    }, {
        'rules': MSCompare('CATWRK', '2') & MSCompare('WATLEV', '3'),
        'instruction': SY('WRECKS05')
    }, {
        'rules': (MSCompare('CATWRK', '4')
                  | MSCompare('CATWRK', '5')
                  | MSCompare('WATLEV', '1')
                  | MSCompare('WATLEV', '2')
                  | MSCompare('WATLEV', '3')
                  | MSCompare('WATLEV', '4')),
        'instruction':
        SY('WRECKS01')
    }, {
        'rules': MSNoRules(),
        'instruction': SY('WRECKS05')
    }]
Exemplo n.º 6
0
def RESTRN(lookup_type, name):
    includes = MSStrCompare.includes

    return [{
        'rules':
        (includes('RESTRN', 7, 8, 14)
         & includes('RESTRN', 1, 2, 3, 4, 5, 13, 16, 17, 23, 24, 25, 26, 27)),
        'instruction':
        SY('ENTRES61'),
    }, {
        'rules': (includes('RESTRN', 7, 8, 14)
                  & includes('RESTRN', 9, 10, 11, 12, 15, 18, 19, 20, 21, 22)),
        'instruction':
        SY('ENTRES71'),
    }, {
        'rules': includes('RESTRN', 7, 8, 14),
        'instruction': SY('ENTRES51'),
    }, {
        'rules':
        (includes('RESTRN', 1, 2)
         & includes('RESTRN', 3, 4, 5, 6, 13, 16, 17, 23, 24, 25, 26, 27)),
        'instruction':
        SY('ACHRES61'),
    }, {
        'rules': (includes('RESTRN', 1, 2)
                  & includes('RESTRN', 9, 10, 11, 12, 15, 18, 19, 20, 21, 22)),
        'instruction':
        SY('ACHRES71'),
    }, {
        'rules': includes('RESTRN', 1, 2),
        'instruction': SY('ACHRES51'),
    }, {
        'rules': (includes('RESTRN', 3, 4, 5, 6, 24)
                  & includes('RESTRN', 13, 16, 17, 23, 25, 26, 27)),
        'instruction':
        SY('FHSRES61')
    }, {
        'rules': (includes('RESTRN', 3, 4, 5, 6, 24)
                  & includes('RESTRN', 9, 10, 11, 12, 15, 18, 19, 20, 21, 22)),
        'instruction':
        SY('FHSRES71'),
    }, {
        'rules': includes('RESTRN', 3, 4, 5, 6, 24),
        'instruction': SY('FHSRES51'),
    }, {
        'rules': (includes('RESTRN', 13, 16, 17, 23, 25, 26, 27)
                  & includes('RESTRN', 9, 10, 11, 12, 15, 18, 19, 20, 21, 22)),
        'instruction':
        SY('CTYARE71'),
    }, {
        'rules': includes('RESTRN', 13, 16, 17, 23, 25, 26, 27),
        'instruction': SY('CTYARE51'),
    }, {
        'rules': includes('RESTRN', 9, 10, 11, 12, 15, 18, 19, 20, 21, 22),
        'instruction': SY('INFARE51'),
    }, {
        'rules': MSNoRules(),
        'instruction': SY('RSRDEF51'),
    }]
Exemplo n.º 7
0
def RESARE_no_continuation():
    return LookupCollection([
        Lookup(rules=MSStrCompare.includes('RESTRN', 9, 10, 11, 12, 15, 18, 19,
                                           20, 21, 22),
               instruction=SY('INFARE51')),
        Lookup(rules=MSNoRules(), instruction=SY('RSRDEF51'))
    ]) @ LookupCollection([
        Lookup(instruction=LS('DASH', 2, 'CHMGD'), table='Plain'),
        Lookup(instruction=LC('CTYARE51'), table='Symbolized')
    ])
Exemplo n.º 8
0
def DEPCNT(lookup_type, name):
    return [{
        'rules': (MSCompare('QUAPOS', '1', MSCompare.OP.GT)
                  & MSCompare('QUAPOS', '10', MSCompare.OP.LT)),
        'instruction':
        LS('DASH', 1, 'DEPCN'),
    }, {
        'rules': MSNoRules(),
        'instruction': LS('SOLD', 1, 'DEPCN'),
    }]
Exemplo n.º 9
0
def SYMINS(lookup_type, name):
    instructions = {
        'Point': SY('NEWOBJ01'),
        'Line': LC('NEWOBJ01'),
        'Area': [SY('NEWOBJ01'), LS('DASH', 2, 'CHMGD')],
    }

    return [{
        'rules': MSNoRules(),
        'instruction': instructions[lookup_type],
    }]
Exemplo n.º 10
0
def OBSTRN_line(name):
    return [
        {
            'rules': MSCompare('VALSOU', '30', MSCompare.OP.GT),
            'instruction': LS('DASH', 2, 'CHBLK')
        },
        {
            # VALSOU missing and <= SAFETY_DEPTH both lead here
            'rules': MSNoRules(),
            'instruction': LS('DOTT', 2, 'CHBLK')
        }
    ]
Exemplo n.º 11
0
def LEGLIN(lookup_type, name):
    plnspd = TE("'%d kt'", 'plnspd', 3, 2, 2, '15110', 0, 0, 'CHBLK', 50)

    return [{
        'rules': MSCompare('select', '1') & MSHasValue('plnspd'),
        'instruction': [LC('PLNRTE03'), SY('PLNSPD03'), plnspd],
    }, {
        'rules': MSCompare('select', '1'),
        'instruction': LC('PLNRTE03'),
    }, {
        'rules': MSHasValue('plnspd'),
        'instruction': [LS('DOTT', 2, 'APLRT'),
                        SY('PLNSPD04'), plnspd],
    }, {
        'rules': MSNoRules(),
        'instruction': LS('DOTT', 2, 'APLRT'),
    }]
Exemplo n.º 12
0
def TOPMAR(lookup_type, name):
    if os.environ.get('TOPMAR_FLOAT'):
        sy_getter = itemgetter(0)
    else:
        sy_getter = itemgetter(1)

    return [{
        'instruction': SY(sy),
        'rules': MSCompare('TOPSHP', shp)
    } for shp, floating, rigid in topshp_to_sy
            for sy in [sy_getter([floating, rigid])]
            ] + [{
                'instruction': SY(sy_getter(('TMARDEF2', 'TMARDEF1'))),
                'rules': MSHasValue('TOPSHP')
            }, {
                'instruction': SY('QUESMRK1'),
                'rules': MSNoRules(),
            }]
Exemplo n.º 13
0
def SOUNDG(lookup_type, name):
    return [{
        'instruction':
        _MS('''
        LABEL
            TEXT (round([DEPTH]+(-0.5),1))
            TYPE TRUETYPE
            FONT sc
            COLOR {color[CHGRD].rgb}
            # COLOR 136 152 139
            SIZE 8
            ANTIALIAS TRUE
            FORCE TRUE
        END

        LABEL
            EXPRESSION ([DEPTH] > 10 AND [DEPTH] < 31)
            TEXT ( [DEPTH] * 10 % 10)
            OFFSET 8 4
            TYPE TRUETYPE
            FONT sc
            COLOR {color[CHGRD].rgb}
            # COLOR 136 152 139
            SIZE 7
            ANTIALIAS TRUE
            FORCE TRUE
        END

        LABEL
            EXPRESSION ([DEPTH] < 10)
            TEXT ( [DEPTH] * 10 % 10)
            OFFSET 5 4
            TYPE TRUETYPE
            FONT sc
            COLOR {color[CHGRD].rgb}
            # COLOR 136 152 139
            SIZE 6
            ANTIALIAS TRUE
            FORCE TRUE
        END
    '''),
        'rules':
        MSNoRules()
    }]
Exemplo n.º 14
0
def lookups_from_cs(detail, lookup_type, name):

    function_name = detail[:6]
    function = globals().get(function_name)

    if function:
        lookups = function(lookup_type, name)
    else:
        warnings.warn('Symproc not implemented: {}'.format(function_name),
                      NotImplementedWarning)

        # Return default lookup; leave CS as is, maybe CS in instruction.py can
        # make something useful
        lookups = [{
            'instruction': CS(detail),
            'rules': MSNoRules(),
        }]

    return LookupCollection(lookups, id='-CS({})'.format(detail))
Exemplo n.º 15
0
def OBSTRN_area(name):
    return [{
        'rules': MSCompare('VALSOU', '30', MSCompare.OP.GT),
        'instruction': LS('DASH', 2, 'CHGRD')
    }, {
        'rules': MSHasValue('VALSOU'),
        'instruction': LS('DOTT', 2, 'CHBLK')
    }, {
        'rules': MSCompare('CATOBS', '6'),
        'instruction': [AP('FOULAR01'), LS('DOTT', 2, 'CHBLK')]
    }, {
        'rules': MSCompare('WATLEV', '1') | MSCompare('WATLEV', '2'),
        'instruction': [AC('CHBRN'), LS('SOLD', 2, 'CSTLN')]
    }, {
        'rules': MSCompare('WATLEV', '4'),
        'instruction': [AC('DEPIT'), LS('DASH', 2, 'CSTLN')]
    }, {
        'rules': MSNoRules(),
        'instruction': [AC('DEPVS'), LS('DOTT', 2, 'CHBLK')]
    }]
Exemplo n.º 16
0
def SLCONS(lookup_type, name):
    return [
        {
            'instruction':
            SY('LOWACC01'),
            'rules': (
                # QUAPOS only has values 1 to 11. QUAPOS not in 1, 10, 11 is
                # equivalent to the below rules
                MSCompare('QUAPOS', '1', MSCompare.OP.GT)
                & MSCompare('QUAPOS', '10', MSCompare.OP.LT))
        },
        {
            'instruction':
            LC('LOWACC21'),
            'rules': (
                # QUAPOS only has values 1 to 11. QUAPOS not in 1, 10, 11 is
                # equivalent to the below rules
                MSCompare('QUAPOS', '1', MSCompare.OP.GT)
                & MSCompare('QUAPOS', '10', MSCompare.OP.LT))
        },
        {
            'instruction': LS('DASH', 1, 'CSTLN'),
            'rules': MSCompare('CONDTN', '1') | MSCompare('CONDTN', '2')
        },
        {
            'instruction':
            LS('SOLD', 4, 'CSTLN'),
            'rules': (MSCompare('CATSLC', '6')
                      | MSCompare('CATSLC', '15')
                      | MSCompare('CATSLC', '16'))
        },
        {
            'instruction': LS('DASH', 2, 'CSTLN'),
            'rules': MSCompare('WATLEV', '3') | MSCompare('WATLEV', '4')
        },
        {
            'instruction': LS('SOLD', 2, 'CSTLN'),
            'rules': MSNoRules()
        }
    ]
Exemplo n.º 17
0
def OWNSHP(lookuptype, name):
    return [{'rules': MSNoRules(), 'instruction': SY('OWNSHP01')}]
Exemplo n.º 18
0
def DATCVR(lookup_type, name):
    return [{
        'instruction': LC('HODATA01'),
        'rules': MSNoRules(),
    }]