Esempio n. 1
0
    def delete_postal_code(self, fields_map: Dict):
        Session = sessionmaker(bind=self.engine)
        session = Session()
        accessor = PostalCodeAccessor(session)

        pri_map = {x: fields_map[x] for x in self.pri_keys if x in fields_map}
        accessor.delete(pri_map)

        session.close()
Esempio n. 2
0
    def get_postal_code(self, filter_map: Dict):
        Session = sessionmaker(bind=self.engine)
        session = Session()
        accessor = PostalCodeAccessor(session)

        postal_code = accessor.read(filter_map)

        session.close()

        return postal_code
Esempio n. 3
0
    def insert_postal_code(self, fields_map: Dict):
        Session = sessionmaker(bind=self.engine)
        session = Session()
        accessor = PostalCodeAccessor(session)

        new_postal_code = PostalCode()
        for k, v in fields_map.items():
            setattr(new_postal_code, k, v)
        accessor.create(new_postal_code)

        session.close()
Esempio n. 4
0
    def get_land_use_from_location(self, location_key: LocationKey):
        Session = sessionmaker(bind=self.engine)
        session = Session()
        accessor = PostalCodeAccessor(session)

        postal_code = accessor.read({
            "block": location_key.block,
            "road": location_key.road,
            "postal_code": location_key.postal_code
        })

        session.close()

        return postal_code[0]["land_use_type"]
Esempio n. 5
0
    def get_coordinates(self, location_key: LocationKey):
        Session = sessionmaker(bind=self.engine)
        session = Session()
        accessor = PostalCodeAccessor(session)

        postal_code = accessor.read({
            "block": location_key.block,
            "road": location_key.road,
            "postal_code": location_key.postal_code
        })

        session.close()

        return postal_code[0]["latitude"], postal_code[0]["longitude"]
Esempio n. 6
0
    def is_shophouse(self, location_key: LocationKey):
        Session = sessionmaker(bind=self.engine)
        session = Session()
        accessor = PostalCodeAccessor(session)

        postal_code = accessor.read({
            "block": location_key.block,
            "road": location_key.road,
            "postal_code": location_key.postal_code
        })

        session.close()

        if postal_code and postal_code[0]["property_type"] == 'Shophouses':
            return True
        else:
            return False