当前位置: 首页>>代码示例>>Python>>正文


Python Rectangle.min_lat方法代码示例

本文整理汇总了Python中rectangle.Rectangle.min_lat方法的典型用法代码示例。如果您正苦于以下问题:Python Rectangle.min_lat方法的具体用法?Python Rectangle.min_lat怎么用?Python Rectangle.min_lat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rectangle.Rectangle的用法示例。


在下文中一共展示了Rectangle.min_lat方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: traverse_to

# 需要导入模块: from rectangle import Rectangle [as 别名]
# 或者: from rectangle.Rectangle import min_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.min_lat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。