2013-03-07 78 views
0

我在PLPGSQL以下查询:比较操作错误

FOR _t IN EXECUTE 'select distinct_network_point.id AS network_point_id 
      from distinct_network_point, all_points_ordered 
      where road_id='||road_id||' AND distinct_network_point.point = all_points_ordered.point AND all_points_ordered.point != st_setsrid(st_makepoint('||new_point||'),4326) 
      order by st_distance(all_points_ordered.point,st_setsrid(st_makepoint('||new_point||'),4326)) 
      limit 1' 

对于一些它给我以下错误:

enter image description here

如果我用这个<>运营商,它会给我这个比:

enter image description here

任何人都可以解释它的真正含义吗?该查询在sql中正常工作。

+0

我已尝试了,不过谢谢你的建议 – 2013-03-07 22:46:28

+0

我已经更新的问题,以显示错误,当我尝试<>运算符。 @bernie – 2013-03-07 22:48:45

回答

1

由于您正在处理几何类型,因此!=<>运算符均无效。

Instead, please refer to the following list of geometric operators.

在这种情况下,由于要检查两个点是不一样的,我相信你可以使用运营商<->距离之间,并检查您的两点之间的距离大于某种非常小的epsilon价值。

喜欢的东西:

AND all_points_ordered.point <-> st_setsrid(st_makepoint('||new_point||'),4326) > 0.0001 
+0

非常感谢您的建议@michaelfredrickson – 2013-03-07 23:06:38

+1

我认为将它们转换为文本会更好。 'all_points_ordered.point :: text <> st_setsrid(st_makepoint('|| new_point ||'),4326):: text'。它始终工作,可能会更快 – 2013-03-07 23:14:34