用我的桌子
CREATE TABLE map.vzla_seg
(
seg_id serial NOT NULL,
link_id bigint,
geom geometry(LineString),
sentido integer,
azimuth integer
)
如果我执行此查询
SELECT ST_GeometryType (geom), COUNT(*)
FROM map.vzla_seg
GROUP BY ST_GeometryType (geom)
ST_GeometryType
返回text
,所以我得到了:
但如果我这样做,我就会收到错误:
SELECT *
FROM map.vzla_seg
WHERE ST_GeometryType (geom) <> 'ST_LineString'
ERROR: Unknown geometry type: 0 - Unknown
********** Error **********
ERROR: Unknown geometry type: 0 - Unknown
SQL state: XX000
那么一个函数如何在GROUP BY
中运行正常但不适用于WHERE
我试图让错误的行来修复它。
答案 0 :(得分:0)
只需从geom
SELECT
即可
SELECT seg_id serial, link_id, -- geom geometry(LineString),
sentido, azimuth,
ST_GeometryType (geom)
FROM map.vzla_seg
WHERE ST_GeometryType (geom) <> 'ST_LineString'
答案 1 :(得分:0)
似乎您的某些几何图形缺少SRID或SRID无效。
使用此
SELECT *
FROM map.vzla_seg
WHERE ST_GeometryType (ST_SetSRID(geom,4326)) <>'ST_LineString'
我用4326作为例子。您应该使用自己的SRID