我想找到近车在距离几何和Spring启动

wfypjpf4  于 2021-07-15  发布在  Java
关注(0)|答案(0)|浏览(161)

我想从这一点找到附近的汽车清单
我有一个存储库接口,我编写了这个查询

@Query(value = "select * from Driver d where ST_DWithin(d.location, ?1, ?2 * 1000.0, false) = true", nativeQuery=true)
  List<Driver> findNearBy(Geometry geometry, Integer km);

但在运行代码时,我看到以下异常:

Caused by: java.sql.SQLSyntaxErrorException: FUNCTION driverservice.ST_DWithin does not exist

这就是所谓的数据库服务和这个查询:

public void test(Double lat,Double lon) {
    final Geometry geometry = wktToGeometry("POINT(" + lat.toString() + " " + lon.toString() + ")");
    if (!geometry.getGeometryType().equals("Point")) {
        throw new RuntimeException("Geometry must be a point. Got a " + geometry.getGeometryType());
    }
    final Point newPoint = geometryFactory.createPoint(new Coordinate(geometry.getCoordinate()));
    newPoint.setSRID(SRID);
    List<Driver> driver = driverRepository.findNearBy(newPoint,3);
    driver.forEach(x->{
        log.debug(x.toString());
    });

}

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题