TruckstopDataMaps.py

'''DEFINES TRUCKSTOP DATA MAPS'''

class TransportationMode:
    def __init__(self):
        self.modes = {
            1: {"code": "TL", "definition": "Truck Load", "capacity": "Full"},
            2: {"code": "LTL", "definition": "Less Than Truck Load", "capacity": "Partial"},
            3: {"code": "IM", "definition": "Intermodal", "capacity": "Full"},
            4: {"code": "PTL", "definition": "Partial", "capacity": "Partial"},
            5: {"code": "D", "definition": "Drayage", "capacity": "Full"},
            6: {"code": "PRC", "definition": "Parcel", "capacity": "Partial"},
            7: {"code": "AIR", "definition": "Air", "capacity": "Partial"},
            8: {"code": "W", "definition": "Water", "capacity": "Full"},
            9: {"code": "O", "definition": "Ocean", "capacity": "Full"},
        }

    def get_value(self, identifier, column):
        if identifier in self.modes:
            return self.modes[identifier].get(column)
        
        for mode in self.modes.values():
            if mode.get("code") == identifier or mode.get("definition") == identifier:
                return mode.get(column)
        
        return None
    
class TrailerType:
    def __init__(self):
        self.trailers = {
            1: {"code": "2F", "description": "Two 24 or 28 Foot Flatbeds", "category": "Flat"},
            2: {"code": "ANIM", "description": "Animal Carrier", "category": "Specialized"},
            3: {"code": "AUTO", "description": "Auto Carrier", "category": "Specialized"},
            4: {"code": "B-TR", "description": "B-Train/Supertrain (Canada only)", "category": "Specialized"},
            5: {"code": "BELT", "description": "Conveyor Belt", "category": "Specialized"},
            6: {"code": "BOAT", "description": "Boat Hauling Trailer", "category": "Specialized"},
            7: {"code": "CH", "description": "Convertible Hopper", "category": "Specialized"},
            8: {"code": "CONT", "description": "Container Trailer", "category": "Specialized"},
            9: {"code": "DD", "description": "Double Drop", "category": "Specialized"},
            10: {"code": "DUMP", "description": "Dump Trucks", "category": "Specialized"},
            11: {"code": "ENDP", "description": "End Dump", "category": "Specialized"},
            12: {"code": "F", "description": "Flatbed", "category": "Flat"},
            13: {"code": "FEXT", "description": "Stretch Trailers or Extendable Flatbed", "category": "Flat"},
            14: {"code": "FINT", "description": "Flatbed Intermodal", "category": "Flat"},
            15: {"code": "FO", "description": "Flatbed Over-Dimension Loads", "category": "Flat"},
            16: {"code": "FSD", "description": "Flatbed or Step Deck", "category": "Flat"},
            17: {"code": "FVR", "description": "Flatbed, Van or Reefer", "category": "Van"},
            18: {"code": "FWS", "description": "Flatbed With Sides", "category": "Flat"},
            19: {"code": "HOPP", "description": "Hopper Bottom", "category": "Specialized"},
            20: {"code": "HS", "description": "Hot Shot", "category": "Specialized"},
            21: {"code": "HTU", "description": "Haul and Tow Unit", "category": "Specialized"},
            22: {"code": "LAF", "description": "Landoll Flatbed", "category": "Specialized"},
            23: {"code": "LB", "description": "Lowboy", "category": "Specialized"},
            24: {"code": "LBO", "description": "Lowboy Over-Dimension Loads", "category": "Specialized"},
            25: {"code": "LDOT", "description": "Load-Out are empty trailers you load and haul", "category": "Specialized"},
            26: {"code": "LIVE", "description": "Live Bottom Trailer", "category": "Specialized"},
            27: {"code": "MAXI", "description": "Maxi or Double Flat Trailers", "category": "Specialized"},
            28: {"code": "MBHM", "description": "Mobile Home", "category": "Specialized"},
            29: {"code": "PNEU", "description": "Pneumatic", "category": "Specialized"},
            30: {"code": "PO", "description": "Power Only (Tow-Away)", "category": "Specialized"},
            31: {"code": "R", "description": "Refrigerated (Reefer)", "category": "Refrigerated"},
            32: {"code": "RGN", "description": "Removable Goose Neck & Multi-Axle Heavy Haulers", "category": "Specialized"},
            33: {"code": "RGNE", "description": "RGN Extendable", "category": "Specialized"},
            34: {"code": "RINT", "description": "Refrigerated Intermodal", "category": "Refrigerated"},
            35: {"code": "ROLL", "description": "Roll Top Conestoga", "category": "Refrigerated"},
            36: {"code": "RPD", "description": "Refrigerated Carrier with Plant Decking", "category": "Refrigerated"},
            37: {"code": "SD", "description": "Step Deck", "category": "Flat"},
            38: {"code": "SDL", "description": "Step Deck with Loading Ramps", "category": "Flat"},
            39: {"code": "SDO", "description": "Step Deck Over-Dimension Loads", "category": "Flat"},
            40: {"code": "SPEC", "description": "Unspecified Specialized Trailers", "category": "Specialized"},
            41: {"code": "SV", "description": "Straight Van", "category": "Van"},
            42: {"code": "TANK", "description": "Tanker (Food grade, liquid, bulk, etc.)", "category": "Specialized"},
            43: {"code": "V", "description": "Van", "category": "Van"},
            44: {"code": "V-OT", "description": "Open Top Van", "category": "Van"},
            45: {"code": "VB", "description": "Blanket Wrap Van", "category": "Van"},
            46: {"code": "CV", "description": "Curtain Van", "category": "Van"},
            47: {"code": "VCAR", "description": "Cargo Vans (1 Ton capacity)", "category": "Van"},
            48: {"code": "VF", "description": "Flatbed or Van", "category": "Van"},
            49: {"code": "VINT", "description": "Van Intermodal", "category": "Van"},
            50: {"code": "VIV", "description": "Vented Insulated Van", "category": "Van"},
            51: {"code": "VLG", "description": "Van with Liftgate", "category": "Van"},
            52: {"code": "VM", "description": "Moving Van", "category": "Van"},
            53: {"code": "VR", "description": "Van or Reefer", "category": "Van"},
            54: {"code": "VV", "description": "Vented Van", "category": "Van"},
            55: {"code": "WALK", "description": "Walking Floor", "category": "Specialized"},
            56: {"code": "VVR", "description": "Vented Van or Refrigerated", "category": "Van"},
            57: {"code": "VIVR", "description": "Vented Insulated Van or Refrigerated", "category": "Van"},
            58: {"code": "VA", "description": "Van - Air-Ride", "category": "Van"},
            59: {"code": "FA", "description": "FlatBed - Air-Ride", "category": "Flat"},
            60: {"code": "FV", "description": "Van or Flatbed", "category": "Flat"},
            61: {"code": "FRV", "description": "Flatbed, Van or Reefer", "category": "Flat"},
            62: {"code": "FSDV", "description": "Flatbed, Step Deck or Van", "category": "Flat"},
            63: {"code": "FVVR", "description": "Flatbed, Vented Van or Reefer", "category": "Flat"},
            64: {"code": "VRDD", "description": "Van, Reefer or Double Drop", "category": "Van"},
            65: {"code": "FVV", "description": "Flatbed or Vented Van", "category": "Flat"},
            66: {"code": "SDRG", "description": "Step Deck or Removable Gooseneck", "category": "Specialized"},
            67: {"code": "VFR", "description": "Flatbed, Van or Reefer", "category": "Van"},
            68: {"code": "RVF", "description": "Flatbed, Van or Reefer", "category": "Refrigerated"},
            69: {"code": "RFV", "description": "Flatbed, Van or Reefer", "category": "Refrigerated"},
            70: {"code": "RV", "description": "Van or Reefer", "category": "Refrigerated"},
            71: {"code": "SPV", "description": "Cargo/Small/Sprinter Van", "category": "Specialized"},
            72: {"code": "SDC", "description": "Step Deck Conestoga", "category": "Specialized"},
            73: {"code": "SDE", "description": "Step Deck Extendable", "category": "Specialized"},
            74: {"code": "DA", "description": "Drive Away", "category": "Specialized"},
            75: {"code": "DDE", "description": "Double Drop Extendable", "category": "Specialized"},
            76: {"code": "VRF", "description": "Flatbed, Van or Reefer", "category": "Van"},
            77: {"code": "BEAM", "description": "Beam", "category": "Specialized"},
            78: {"code": "CONG", "description": "Conestoga", "category": "Flat"},
            79: {"code": "BDMP", "description": "Belly Dump", "category": "Specialized"},
        }

    def get_value(self, identifier, column):
        if identifier in self.trailers:
            return self.trailers[identifier].get(column)
        
        for trailer in self.trailers.values():
            if trailer.get("code") == identifier or trailer.get("description") == identifier:
                return trailer.get(column)
        
        return None

class Commodity:
    def __init__(self):
        self.commodities = {
            1: "Advertising Materials/Books/Magazines",
            2: "Aggregate",
            3: "Agricultural Machinery and Implements",
            4: "Air Conditioning Equipment Parts",
            5: "Alcoholic Beverages/Beer Wine/Spirits",
            6: "Aluminum, Plate, Sheet, Coil and Ingots",
            7: "Ammunition, Small Arms, Sporting",
            8: "Apparel, Wearing",
            9: "Appliances, Household, Electric",
            10: "Asphalt Products",
            11: "Auto Parts and Accessories",
            12: "Bagged Goods, Cement, Fertilizer, etc.",
            13: "Batteries, Dry Cell",
            14: "Bolts, Nuts and Screws",
            15: "Cement Bulk or Bags",
            16: "Carpet/Floor Coverings",
            17: "Chemicals (dry) in cases or bags",
            18: "Chemicals (liquid) in metal cans or drums",
            19: "Construction Machinery (new)",
            20: "Contractors Equipment (new)",
            23: "Engines/Motors all types",
            24: "Flammables and Explosives",
            25: "Food Products (non-perishable)",
            26: "Frozen Foods",
            27: "Generators, Home and Farm",
            28: "Grain",
            30: "Household Appliances",
            31: "Insecticides (Not Bagged)",
            32: "Instruments (Electrical/Musical)",
            33: "Instruments (Scientific)",
            34: "Instruments (Surgical)",
            35: "Kraft Paper and Newsprint in Rolls",
            36: "Laboratory Equipment",
            37: "Lamps and Lighting Fixtures",
            38: "Leathers, Finished",
            39: "Lubricants",
            40: "Lumber",
            41: "Machine Parts",
            42: "Machinery Used or Reconditioned",
            43: "Machinery New - All Types",
            44: "Masonry",
            45: "Motorcycles, Boxed/Crated",
            46: "Furniture",
            47: "New Approved General Merchandise",
            48: "Oil Field/Refinery Equipment",
            49: "Oil Refinery Equipment",
            51: "Pumps, Industrial",
            52: "Railroad Equipment and Rolling Stock",
            53: "Refrigeration Equipment",
            54: "Rubber Products",
            55: "Slag",
            56: "Smoking Supplies",
            57: "Steel Pipe",
            58: "Steel Processing Equipment",
            59: "Steel, Plate, Sheet and Coils",
            60: "Tile, Non-Ceramic, Non-Marble",
            61: "Tractors, Supplies and Parts",
            62: "Transformers (Industrial)",
            63: "Used Machines",
            64: "Used Merchandise",
            69: "Cotton and Textiles/Fabric (excluding garments)",
            70: "Sundries (excluding Narcotics or Pharmaceuticals)",
            71: "Hospital Supplies (Excluding and Pharmaceuticals)",
            72: "Fresh Produce",
            75: "General Goods",
            76: "Steel Products",
            77: "Aluminum Products",
            78: "Wood Products",
            79: "Iron Products",
            80: "Copper Products",
            81: "Plastic Products",
            82: "Concrete Products",
            83: "Roofing Products",
            84: "Building Products",
            85: "Siding Products",
            86: "Flooring Products",
            87: "Insulation Products",
            88: "Wallboard",
            89: "Reels",
            90: "Decking Products",
            91: "Paneling Products",
            92: "Foam Products",
            93: "Fencing",
            94: "Brick",
            95: "Pavers",
            96: "Stone",
            97: "Conveyor Systems",
            98: "Hay",
            99: "Crane Mats",
            100: "Clay Products",
            101: "Storage Pods/Containers",
            102: "Mulch",
            103: "Sod",
            104: "Scaffolding",
            105: "Salt",
            106: "Marble",
            107: "Lime",
            108: "Graphite",
            109: "Magnesium",
            110: "Zinc",
        }

    def get_definition(self, id):
        return self.commodities.get(id, None)

    def get_id_by_definition(self, definition):
        return self.reverse_lookup.get(definition, None)

class EquipmentOptions:
    def __init__(self):
        self.codes = {
            1: {"code": "T", "definition": "Tarp"},
            2: {"code": "Z", "definition": "Hazmat"},
            3: {"code": "X", "definition": "Pallet Exchange"},
            5: {"code": "2", "definition": "Team"},
            11: {"code": "!", "definition": "Expedited"},
        }

        # Create reverse lookup dictionaries
        self.code_lookup = {v["code"]: k for k, v in self.codes.items()}
        self.definition_lookup = {v["definition"]: k for k, v in self.codes.items()}

    def get_code_by_id(self, id):
        return self.codes.get(id, {}).get("code", None)

    def get_definition_by_id(self, id):
        return self.codes.get(id, {}).get("definition", None)

    def get_id_by_code(self, code):
        return self.code_lookup.get(code, None)

    def get_id_by_definition(self, definition):
        return self.definition_lookup.get(definition, None)