spring - 在 Spring Data ArangoDB 中使用地理空间查询时出现内存不足异常

标签 spring gis geospatial arangodb

我正在使用 spring-boot 2.0.0 和 arangodb-spring-data 2.0.3,我正在学习 here 中的地理空间查询教程。用我自己的数据结构。

@Data
@NoArgsConstructor
@Document(value = "hospital")
public class Hospital {
    @Id
    private String id;
    private String name;
    private String phone;
    private String address;
    @GeoIndexed
    private double[] location;

    public Hospital(String name, String phone, String address, double[] location) {
        super();
        this.name = name;
        this.phone = phone;
        this.address = address;
        this.location = location;
    }
}

@Repository
public interface HospitalRepository extends ArangoRepository<Hospital> {
    GeoResults<Hospital> findByLocationWithin(Point location, Distance distance);
}

@Test
public void geoSpatialTest() throws IOException {
    populateDb();
    Point point = new Point(-7.2895286, 112.7731704);
    Distance distance = new Distance(2, Metrics.KILOMETERS);
    GeoResults<Hospital> results = repository.findByLocationWithin(point, distance);
    results.getContent().forEach(System.out::println);
}

如果我调用 findByLocationWithin() 方法,它只会抛出内存异常。

com.arangodb.ArangoDBException: Response: 500, Error: 3 - AQL: out of memory (exception location: /var/lib/otherjenkins/workspace/RELEASE__BuildPackages/arangod/MMFiles/MMFilesGeoIndex.cpp:151) (while executing) (exception location: /var/lib/otherjenkins/workspace/RELEASE__BuildPackages/arangod/RestHandler/RestCursorHandler.cpp:135)

我想做的是到距离小于 X 公里的附近医院。我可以通过在 ArangoDB 中使用这个查询来实现这一点。

FOR hospital IN WITHIN(hospital, -7.2895286, 112.7731704, 2000)
RETURN hospital

arangodb-spring-data 是否以某种方式损坏了?我需要为此自定义 @Query 吗?

最佳答案

您必须切换 Point 的值才能在您的 Java 应用程序中执行与在 AQL 查询中相同的操作。

Point point = new Point(112.7731704, -7.2895286);

ArangoDB Spring数据假定Point的第一个参数是经度,第二个是纬度。

错误 AQL: out of memory 发生是因为在 ArangoDB 地理索引中检查经度在 -180 和 180 之间,纬度在 -90 和 90 之间。错误消息非常具有误导性,但已经有一个 PR on github解决这个问题。

关于spring - 在 Spring Data ArangoDB 中使用地理空间查询时出现内存不足异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49691991/

相关文章:

java - JMS ActiveMQ 队列已经存在

python - 在计算地球上各点之间的距离时,为什么我的 Haversine 与 Geodesic 计算结果不同?

r - ggplot2 的 fortify 函数出错

snowflake-cloud-data-platform - 如何在 Snowflake 中将 MultiPoint 转换为 LineString?

c# - 彼此靠近的 Lat、Long 簇

geolocation - 哪个地理服务(如果有)可以根据城市名称返回市中心的经纬度和城市半径?

java - spring 表单标签具有默认值

java - 创建 bean entityManagerFactory 时出错,NoSuchMethodError : javax/persistence/Table. 索引

java - Spring是否用java配置中的现有bean替换方法调用?

python - 如何使用 Folium 绘制成对的起点和终点地理空间点之间的路线?