您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

Python GeoModel替代方案

5b51 2022/1/14 8:23:22 python 字数 1643 阅读 589 来源 www.jb51.cc/python

我正在为app引擎数据存储寻找替代库,它将执行最近n或盒装地理查询,目前我正在使用GeoModel 0.2并且它运行得非常慢(在某些情况下大于1.5秒).有没有人有什么建议? 谢谢! 我对geomodel有同样的问题. 为了更正,我使用4的分辨率,我使用 python排序和过滤器. SEARCHED_LOCATION = db.GeoPt("48.8566667, 2.3509871") # Lo

概述

谢谢!

SEARCHED_LOCATION = db.GeoPt("48.8566667,2.3509871") # Location of Paris.
DISTANCE = 50000 #Between 10000 and 150000.
MAX_RESULTS = 300

# Resolution '4' is about 150 kilometers i suppose it's a good compromise.                                                                                                                            
bBox = geocell.compute_Box(geocell.compute(SEARCHED_LOCATION,resolution=4))
cell = geocell.best_bBox_search_cells(bBox,geomodel.default_cost_function)

query.filter('location_geocells IN',cell)

# Python filters
def _func(x):
  """Private method used to set the distance of the model to the searched location
  and return this distance.
  """
  x.dist = geomath.distance(SEARCHED_LOCATION,x.location)
  return x.dist

results = sorted(query.fetch(MAX_RESULTS),key=_func) # Order the result by distance
results = [x for x in results if x.dist <= DISTANCE]  # Filter the result

总结

以上是编程之家为你收集整理的Python GeoModel替代方案全部内容,希望文章能够帮你解决Python GeoModel替代方案所遇到的程序开发问题。


如果您也喜欢它,动动您的小指点个赞吧

除非注明,文章均由 laddyq.com 整理发布,欢迎转载。

转载请注明:
链接:http://laddyq.com
来源:laddyq.com
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。


联系我
置顶