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


Python Rectangle.max_lat方法代碼示例

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


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

示例1: traverse_to

# 需要導入模塊: from rectangle import Rectangle [as 別名]
# 或者: from rectangle.Rectangle import max_lat [as 別名]
        def traverse_to(level, key):
            page = self.db.get(key)
            min_lat, min_lon, max_lat, max_lon, pickled_ids = page.split(":")
            page_bounds = BBox(
                min_lat=float(min_lat), min_lon=float(min_lon), max_lat=float(max_lat), max_lon=float(max_lon)
            )

            ids = pickle.loads(pickled_ids)

            if level == 0:  # We're at the best leaf, add it
                if node.id in ids:
                    print "Warning: not adding duplicate id to spatial index"
                    return

                    # Get the potentially expanded bounds
                rect = Rectangle()
                rect.node_ids = ids
                rect.min_lat = float(min_lat)
                rect.min_lon = float(min_lon)
                rect.max_lat = float(max_lat)
                rect.max_lon = float(max_lon)
                rect.include(node.lat, node.lon, node.id)

                # Update the record
                self.db.put(key, str(rect))
            else:  # We're at an intermediate node, keep going
                best = None
                for id in ids:
                    page = self.db.get(id)
                    min_lat, min_lon, max_lat, max_lon, pickled_ids = page.split(":")

                    rect = Rectangle()
                    rect.node_ids = pickle.loads(pickled_ids)
                    rect.min_lat = float(min_lat)
                    rect.min_lon = float(min_lon)
                    rect.max_lat = float(max_lat)
                    rect.max_lon = float(max_lon)
                    area_before = rect.area()

                    rect.include(node.lat, node.lon)
                    area_after = rect.area()

                    growth = area_after - area_before
                    if not best or growth < best[1] or (growth == best[1] and area_after < best[2]):
                        best = (id, growth, area_after, rect)

                if best[1] > 1e-8:  # This rectangle needs to grow
                    self.db.put(best[0], str(best[3]))
                traverse_to(level - 1, best[0])
開發者ID:tannewt,項目名稱:menzies,代碼行數:51,代碼來源:berkeley_db_rtree.py


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