Python GeoModel 替代方案

标签 python google-app-engine google-cloud-datastore gis geohashing

我正在为 App Engine 数据存储寻找一个替代库,它将执行 nearest-n 或盒装地理查询,目前我使用的是 GeoModel 0.2,它运行得非常慢(在某些情况下 > 1.5s)。有人有什么建议吗?

谢谢!

最佳答案

我对地理模型有同样的问题。 为了更正它,我使用了 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

关于Python GeoModel 替代方案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3993862/

相关文章:

来自外部文件的 Javascript 未加载

python - 如何在 python 中解析字符串?

python - Pandas :根据其他多级列对最里面的列进行分组排序

google-app-engine - 在 GWT/Java 的 SuggestBox 中建议地址

java - 数据存储索引异常,尽管我已经为其定义了索引

python - 发送到使用 contextlib.contextmanager 定义的上下文管理器

java - 有没有任何指南展示如何在 Eclipse 中使用 appengine 和 Maven 有效构建应用程序?

python - 如何在 Google App Engine 数据存储中存储正则表达式?

java - 使用 Google Cloud Dataflow 的 Java API for Datastore 将属性设置为 null?

python - ndb 数据存储查询游标和索引问题