當前位置: 首頁>>代碼示例>>Python>>正文


Python Catalog.update方法代碼示例

本文整理匯總了Python中catalog.Catalog.update方法的典型用法代碼示例。如果您正苦於以下問題:Python Catalog.update方法的具體用法?Python Catalog.update怎麽用?Python Catalog.update使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在catalog.Catalog的用法示例。


在下文中一共展示了Catalog.update方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from catalog import Catalog [as 別名]
# 或者: from catalog.Catalog import update [as 別名]
class Area:
    image_url = IMAGE_URL
    buffer = 10
    save_attrs = ["code", "area_type", "attrs", "image_path", "center", "extent", "image_extent", "width", "height"]

    def __init__(self, code="", area_type=1, epsilon=5, media_path="", with_log=True, catalog="",
                 coord_out="EPSG:3857", center_only=False, with_proxy=False):
        self.with_log = with_log
        self.area_type = area_type
        self.media_path = media_path
        self.image_url = ""
        self.xy = []  # [[[area1], [hole1], [holeN]], [[area2]]]
        self.image_xy_corner = []  # cartesian coord from image, for draw plot
        self.width = 0
        self.height = 0
        self.image_path = ""
        self.extent = {}
        self.image_extent = {}
        self.center = {'x': None, 'y': None}
        self.center_only = center_only
        self.attrs = {}
        self.epsilon = epsilon
        self.code = code
        self.code_id = ""
        self.file_name = self.code[:].replace(":", "_")
        self.with_proxy = with_proxy

        self.coord_out = coord_out

        t = string.Template(SEARCH_URL)
        self.search_url = t.substitute({"area_type": area_type})
        t = string.Template(FEATURE_INFO_URL)
        self.feature_info_url = t.substitute({"area_type": area_type})
        
        if not self.media_path:
            # self.media_path = os.path.dirname(os.path.realpath(__file__))
            self.media_path = os.getcwd()
        if not os.path.isdir(self.media_path):
            os.makedirs(self.media_path)
        if catalog:
            self.catalog = Catalog(catalog)
            restore = self.catalog.find(self.code)
            if restore:
                self.restore(restore)
                self.log("%s - restored from %s" % (self.code, catalog))
                return
        if not code:
            return

        feature_info = self.download_feature_info()
        if feature_info:
            geometry = self.get_geometry()
            if catalog and geometry:
                self.catalog.update(self)
                self.catalog.close()
        else:
            self.log("Nothing found")


    def restore(self, restore):
        for a in self.save_attrs:
            setattr(self, a, restore[a])
        if self.coord_out:
            setattr(self, "coord_out", self.coord_out)
        setattr(self, "code_id", self.code)
        self.get_geometry()
        self.file_name = self.code.replace(":", "_")

    def get_coord(self):
        if self.xy:
            return self.xy
        center = self.get_center_xy()
        if center:
            return center
        return []

    def get_attrs(self):
        return self.attrs

    def _get_attrs_to_geojson(self):
        if self.attrs:
            for a in self.attrs:
                attr = self.attrs[a]
                if isinstance(attr, basestring):
                    try:
                        attr = attr.encode('utf-8').strip()
                        self.attrs[a] = attr
                    except:
                        pass
        return self.attrs

    def to_geojson_poly(self, with_attrs=False, dumps=True):
        return self.to_geojson("polygon", with_attrs, dumps)

    def to_geojson_center(self, with_attrs=False, dumps=True):
        current_center_status = self.center_only
        self.center_only = True
        to_return = self.to_geojson("point", with_attrs, dumps)
        self.center_only = current_center_status
        return to_return
#.........這裏部分代碼省略.........
開發者ID:rendrom,項目名稱:rosreestr2coord,代碼行數:103,代碼來源:parser.py


注:本文中的catalog.Catalog.update方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。