本文整理匯總了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])