简体   繁体   English

如何在mysql GIS空间扩展中关闭打开的多边形

[英]How to close an open polygon in mysql GIS spacial extensions

I have a mysql table containing polygons some of which are open and I need to close them. 我有一个包含多边形的mysql表,其中一些是打开的,我需要关闭它们。 Presumably by appending the "StartPoint" to the end of the "Linestring" and rewriting as a polygon. 大概是通过将“ StartPoint”附加到“ Linestring”的末尾并重写为多边形。 Any ideas? 有任何想法吗?

Sure I can grab out and test a polygon to see if its open or closed with 当然,我可以拿出并测试多边形以查看其打开还是关闭状态

SELECT ExteriorRing(SHAPE) into @testshape from tablename where OGR_FID=1; 
SELECT (StartPoint(@testshape)) INTO @SP;
SELECT (EndPoint(@testshape)) INTO @EP;
SELECT @EP=@SP as myIsRing;

ok fine but when it's open I need to append the Startpoint to the end of the line string in order to close the polygon. 好的,但是当它打开时,我需要将起点附加到线串的末尾以关闭多边形。 Is there a way to append that "closure" point and create a closed polygon? 有没有办法添加该“封闭”点并创建一个封闭的多边形?

Might be worth noting that I tried (as per the man page) 可能值得注意的是我尝试过(根据手册页)

SELECT UNION(@testshape,@SP) INTO @newshape;

And got the standard syntax error ERROR 1064 (42000) as though my version didnt accept the UNION function. 并得到了标准语法错误ERROR 1064(42000),好像我的版本不接受UNION函数。

Sorry everyone, Threw a couple more hours at the problem and got the following 抱歉,每个人都花了几个小时解决问题,并得到了以下结果

select polygon(geomfromtext(astext(concat(geomfromtext(astext(@testshape)),(geomfromtext(astext(@SP))))))) INTO @newpoly;

Not exactly clean but it worked and can be tested with: 并非完全干净,但可以使用,并且可以使用以下工具进行测试:

SELECT (StartPoint(EXTERIORRING(@newpoly))) INTO @SP2;
SELECT (EndPoint(EXTERIORRING(@newpoly))) INTO @EP2;
SELECT @EP2=@SP2 as myIsRing;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM