在PostGIS中检查孤线(Find isolated lines in PostGIS)

在PostGIS环境中,对于线要素表中的孤线检查及自动纠正过程进行了详细阐述。首先定义孤线为两端点不连接其他线的线段,接着通过函数查找孤线并计算其最接近的纠偏位置。文章分为三个步骤:孤线查找、孤线点定位和新线计算。测试数据展示了线段分布,其中B和D被识别为孤线。
摘要由CSDN通过智能技术生成

场景

在PostGIS中有一张线要素表,需要检查该表中的孤线,并且进行自动纠正的计算。
其中孤线定义为两端端点都不在任何其他线的顶点上。
本文介绍在PostGIS中的线要素点,通过函数计算指定线要素表中的孤线,并计算最接近的纠偏位置。
In PostGIS, there is a table of line features, and it is necessary to check the orphan lines in this table and perform the calculation for automatic correction. Among them, an orphan line is defined as a line whose both end points are not on the vertices of any other lines. This article introduces the line feature points in PostGIS, and through functions, calculates the orphan lines in the specified line feature table and calculates the closest corrected position. The test data situation is as follows. There are six lines, ABCDEM, distributed as follows:

测试数据情况如下,存在ABCDEM六条线,分布如下:
在这里插入图片描述
其中A和M的分布关系如下:
在这里插入图片描述
ABC在相交处的关系如下:
在这里插入图片描述
CDE的关系如下:
在这里插入图片描述
我们可以直观看出B和D属于孤线。

第一步线进行孤线查找

判断待检查的要素表如果不是线类型的,则直接返回:

execute SELECT EXISTS (SELECT POSITION(''Line'' in ST_GEOMETRYTYPE(GEOM)) FROM ' ||targetTb|| ' LIMIT 1) into _ISPOINTTYPE;
	-- 如果类型不是点,则不检查
	if _ISPOINTTYPE = false then 
		return -1;
	end if;

获取自动修复的容差,如果偏差大于该阈值,则不做自动修复的计算

if EXISTS (SELECT ID FROM PUBLIC.sp_ck_settings WHERE ITEMNAME = 'single_line_tolerance_4_autofix') then 
		execute 'SELECT ITEMVAL FROM PUBLIC.sp_ck_settings WHERE ITEMNAME = ''single_line_tolerance_4_autofix'' AND USERNAME = '  
		||  curUserName into _TOLERANCE;
		if _TOLERANCE is null then 
			execute 'SELECT ITEMVAL FROM PUBLIC.sp_ck_settings WHERE ITEMNAME = ''single_line_tolerance_4_autofix'' AND USERNAME = ''system'' ' 
  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

丷丩

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值