以下是我要执行的操作的简要摘要:Postgres中有3个表,“ a”和“ b”,每个表都有一个Polygon列,而“ c”有一个Point列。我在这里要做的是获取“ a”,“ b”和“ c”之间的几何形状相交,并在OpenLayers矢量层上显示此类几何形状。
我已经知道如何在OpenLayers中显示字符串中的任何几何形状,但是我在使用PostGIS的ST_Intersection函数时遇到了麻烦,我正在这样做:
SELECT ST_Intersection(a.geom, b.geom) as inter from a, b;
其中a.geom和b.geom都是几何列,并且我收到此错误消息:
NOTICE: TopologyException: found non-noded intersection between 515172 2.14408e+06, 497067 2.13373e+06 and 501321 2.13546e+06, 471202 2.14843e+06 500621 2.13576e+06
ERROR: GEOS Intersection() threw an error!
我也尝试使用ST_AsText将生成的几何图形表示为文本,如下所示:
SELECT ST_AsText(ST_Intersection(a.geom, b.geom)) as inter from a, b;
但它向我发送此错误消息:
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
我不知道自己在做什么错,我只想让Polygons的WKT在OpenLayers上显示它,这就是我从WKT显示几何的方法:
var in_options = {
'internalProjection': new OpenLayers.Projection("EPSG:4326"),
'externalProjection': new OpenLayers.Projection("EPSG:4326")
};
var fea= new OpenLayers.Format.WKT(in_options).read(data); //data is the string with the WKT
vectorLayer.addFeatures([fea]); //this piece of code works great
map.zoomToExtent(bounds);
更新:我尝试下一个:
SELECT ST_Intersection(a.geom, b.geom) as intersect_ab FROM a INNER JOIN b ON
ST_Intersection(a,b) WHERE ST_Overlaps(a.geom, b.geom)
AND ST_isvalid(a.geom)='t' AND ST_isvalid(b.geom)='t';
但我收到下一条错误消息:
ERROR: Function st_intersection(a,b) does not exist.
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
我添加了isvalid来验证是否仅评估了有效的多边形,但是这表明错误在ST_Intersection(a,b)中,a,b和c都具有相同的SRID,所以我真的很困惑,如果我问得太多,但我对PostGIS还是很陌生,所以我希望我不会打扰您。谢谢。
SELECT PostGIS_Full_Version();
回报?