CrudRepository自定义SQL查询中的Postgres几何类型操作错误

时间:2020-03-28 09:08:10

标签: sql spring postgresql postgis

我有两个WGS 84点p1(lonul,latul)的左上点和p2(lonbr,latbr)的右下点,我想看看哪个圆柱与它们定义的矩形相交,所以我对CrudRepository进行了以下查询:

CREATE TABLE protected_area
(
    id            serial not null primary key,
    constraint_id integer not null,
    radius    float not null,
    height      float not null,
    coordinates path not null,
    gtype       geometrytype not null,
    name          varchar(50),
);


@Query("SELECT u FROM ProtectedArea u WHERE u.gtype='Cylinder' AND polygon( box(point(:lonul - (180/pi()) * (u.radius/(6378137*cos(pi()*:lonul/180))), :latul - (180/pi()) * (u.radius/6378137)), point(:lonbr + (180/pi()) * (u.radius/(6378137*cos(pi()*:lonbr/180))),:latbr + (180/pi()) * (u.radius/6378137)))) @> polygon(coordinates)")

似乎运算符@>指示几何是否包含在另一个几何图中

但是我遇到了这个错误

原因:org.hibernate.QueryException:意外的字符:'@'[SELECT u FROM ProtectedArea u在哪里u.gtype ='Cylinder'和多边形( box(point(:lonul-(180 / pi())* (u.radius /(6378137 * cos(pi()*:lonul / 180))),:latul-(180 / pi())* (u.radius / 6378137)),点(:lonbr +(180 / pi())* (u.radius /(6378137 * cos(pi()*:lonbr / 180))),: latbr +(180 / pi())* (u.radius / 6378137))))@>多边形(坐标)]

0 个答案:

没有答案