【发布时间】:2020-01-27 14:24:13
【问题描述】:
Google Cloud Datastore 的文档详细介绍了 地理点 数据类型 [1]。虽然 Java 库中没有严格对应的类,但有一个 LatLng 类 [2] 似乎是规范的等价物。
虽然我可以很好地存储值,但我可以通过提供一个完全构造的 LatLng 实例来查询 准确 位置,如下所示:
ofy.load().type(Site.class) // Site is a custom class, whose latLng field is a LatLng-type
.filter("latLng", LatLng.of(26.329,127.744))
.first()
.now()
我似乎无法在本地进行 inexact 查询,至少不能在控制台上进行。虽然我可以在 Objectify 中某种做类似的事情:
ofy.load().type(Site.class)
.filter("latLng >", LatLng.of(26.0,127.0))
.filter("latLng <", LatLng.of(90,127.750))
.first()
.now()
我的问题是:数据存储区中是否有对地理空间查询的原生/一流支持?还是这种坐标几何——“hackery”是进行此类搜索/查询的唯一可接受的方式?
[1]https://cloud.google.com/datastore/docs/concepts/entities#geographical_point [2]https://googleapis.dev/java/google-cloud-clients/0.111.0-alpha/com/google/cloud/datastore/LatLng.html
【问题讨论】:
标签: java google-cloud-datastore geospatial objectify