加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

Python GeoModel替代方案

发布时间:2020-12-16 23:40:12 所属栏目:Python 来源:网络整理
导读:我正在为app引擎数据存储寻找替代库,它将执行最近n或盒装地理查询,目前我正在使用GeoModel 0.2并且它运行得非常慢(在某些情况下大于1.5秒).有没有人有什么建议? 谢谢! 解决方法 我对geomodel有同样的问题. 为了更正,我使用4的分辨率,我使用 python排序和过
我正在为app引擎数据存储寻找替代库,它将执行最近n或盒装地理查询,目前我正在使用GeoModel 0.2并且它运行得非常慢(在某些情况下大于1.5秒).有没有人有什么建议?

谢谢!

解决方法

我对geomodel有同样的问题.
为了更正,我使用4的分辨率,我使用 python排序和过滤器.
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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读