6. 拓扑访问器
6.1. GetEdgeByPoint
GetEdgeByPoint - 找到与给定点相交的边的边id
6.1.1. 概要
integer GetEdgeByPoint(varchar atopology, geometry apoint, float8 tol);
6.1.2. 描述
该函数返回一个整数(id-edge),给定一个拓扑、一个POINT和一个公差。 如果公差为0,则该点必须与边相交。
如果该点没有与边相交,则返回0(零)。
如果使用公差> 0且该点附近有多条边,则抛出异常。
如果公差= 0,函数使用ST_Intersects,否则使用ST_DWithin。
6.1.3. 样例
- 这些例子使用了我们在AddEdge中创建的边
SELECT topology.GetEdgeByPoint('ma_topo',geom, 1) As with1mtol, topology.GetEdgeByPoint('ma_topo',geom,0) As withnotol FROM ST_GeomFromEWKT('SRID=26986;POINT(227622.6 893843)') As geom;
| with1mtol | withnotol |
|---|---|
| 2 | 0 |
SELECT topology.GetEdgeByPoint('ma_topo',geom, 1) As nearnode FROM ST_GeomFromEWKT('SRID=26986;POINT(227591.9 893900.4)') As geom;
-- get error --
ERROR: Two or more edges found
6.2. GetFaceByPoint
GetEdgeByPoint - 找到与给定点相交的边的边id
6.2.1. 概要
integer GetEdgeByPoint(varchar atopology, geometry apoint, float8 tol);
6.2.2. 描述
检索与点相交的面的id。
该函数返回一个整数(id-face),给出一个拓扑、一个POINT和一个容忍度。 如果公差为0,那么这个点必须与面相交。
如果点没有与面相交,返回0(零)。
如果使用公差> 0并且在该点附近有多个面,则抛出异常。
6.2.3. 样例
- 这些例子使用在AddFace中创建的边面
SELECT topology.GetFaceByPoint('ma_topo',geom, 10) As with1mtol, topology.GetFaceByPoint('ma_topo',geom,0) As withnotol FROM ST_GeomFromEWKT('POINT(234604.6 899382.0)') As geom;
| with1mtol | withnotol |
|---|---|
| 1 | 0 |
SELECT topology.GetFaceByPoint('ma_topo',geom, 1) As nearnode FROM ST_GeomFromEWKT('POINT(227591.9 893900.4)') As geom;
-- get error --
ERROR: Two or more faces found
6.3. GetNodeByPoint
GetNodeByPoint -查找一个点位置的节点id
6.3.1. 概要
integer GetNodeByPoint(varchar atopology, geometry point, float8 tol);
6.3.2. 描述
获取一个点位置节点的id
该函数返回一个整数(id-node),给出一个拓扑、一个POINT和一个容差。 如果公差= 0表示正好相交
否则从间隔中检索节点。
如果该点上没有节点,则返回0(零)。
如果使用公差> 0,并且该点附近有多个节点,则会抛出异常。
6.3.3. 样例
- 这些例子使用了我们在AddEdge中创建的边
SELECT topology.GetNodeByPoint('ma_topo',geom, 1) As nearnode FROM ST_GeomFromEWKT('SRID=26986;POINT(227591.9 893900.4)') As geom;
| nearnode |
|---|
| 2 |
SELECT topology.GetNodeByPoint('ma_topo',geom, 1000) As too_much_tolerance FROM ST_GeomFromEWKT('SRID=26986;POINT(227591.9 893900.4)') As geom;
----get error--
ERROR: Two or more nodes found
6.4. GetTopologyID
GetTopologyID -返回拓扑中一个拓扑的id。 给出拓扑名称的拓扑表。
6.4.1. 概要
integer GetTopologyID(varchar toponame);
6.4.2. 描述
返回拓扑中一个拓扑的id。 给出拓扑名称的拓扑表
6.4.3. 样例
SELECT topology.GetTopologyID('ma_topo') As topo_id;
| topo_id |
|---|
| 1 |
6.5. GetTopologySRID
GetTopologySRID — 返回拓扑中某个拓扑的SRID。 给出拓扑名称的拓扑表
6.5.1. 概要
integer GetTopologyID(varchar toponame);
6.5.2. 描述
返回拓扑中拓扑的空间引用id。 给出拓扑名称的拓扑表。
6.5.3. 样例
SELECT topology.GetTopologySRID('ma_topo') As SRID;
| SRID |
|---|
| 4326 |
6.6. GetTopologyName
GetTopologyName — 返回给定拓扑id的拓扑(模式)的名称。
6.6.1. 概要
varchar GetTopologyName(integer topology_id);
6.6.2. 描述
从拓扑返回一个拓扑的拓扑名称(模式)。 给出拓扑的拓扑id的拓扑表。
6.6.3. 样例
SELECT topology.GetTopologyName(1) As topo_name;
| topo_name |
|---|
| ma_topo |
6.7. ST_GetFaceEdges
ST_GetFaceEdges - 返回一组绑定面的有序边。
6.7.1. 概要
getfaceedges_returntype ST_GetFaceEdges(varchar atopology, integer aface);
6.7.2. 描述
返回一组被绑定面的有序边。 每个输出都包含一个序列和边id。 序号从值1开始。
每个环边的枚举从标识符最小的边开始。 边的顺序遵循左手规则(边界面在每个有向边的左边)。
6.7.3. 样例
- 返回边界面1
SELECT (topology.ST_GetFaceEdges('tt', 1)).*;
| sequence | edge |
|---|---|
| 1 | -4 |
| 2 | 5 |
| 3 | 7 |
| 4 | -6 |
| 5 | 1 |
| 6 | 2 |
| 7 | 3 |
-- 返回序列,边id
-- 以及边界面1的几何形状
-- 如果你只需要geom和seq,可以使用ST_GetFaceGeometry
SELECT t.seq, t.edge, geom FROM topology.ST_GetFaceEdges('tt',1) As t(seq,edge)
INNER JOIN tt.edge AS e ON abs(t.edge) = e.edge_id;
6.8. ST_GetFaceGeometry
ST_GetFaceGeometry -返回给定拓扑中具有指定面id的多边形。
6.8.1. 概要
geometry ST_GetFaceGeometry(varchar atopology, integer aface);
6.8.2. 描述
返回给定拓扑中具有指定面id的多边形。 从构成脸的边缘构建多边形。
6.8.3. 样例
- 返回用AddFace添加的多边形的wkt
SELECT ST_AsText(topology.ST_GetFaceGeometry('ma_topo', 1)) As facegeomwkt;
| facegeomwkt |
|---|
| POLYGON((234776.9 899563.7,234896.5 899456.7,234914 899436.4,234946.6 899356.9,234872.5 899328.7,234891 899285.4,234992.5 899145,234890.6 899069,234755.2 899255.4,234612.7 899379.4,234776.9 899563.7)) |
6.9. GetRingEdges
GetRingEdges -返回沿给定边边遍历时遇到的有符号边标识符的有序集合。
6.9.1. 概要
getfaceedges_returntype GetRingEdges(varchar atopology, integer aring, integer max_edges=null);
6.9.2. 描述
返回沿给定边边遍历时遇到的带符号边标识符的有序集合。 每个输出由一个序列和一个带符号的边缘id组成。 序号从值1开始。
如果你传递一个正的边id,步行从对应边的左侧开始,并遵循边的方向。 如果你传递一个负的边id,行走从它的右边开始,然后向后走。
如果max_edges不为空,则该函数只返回这些记录。 这意味着在处理可能无效的拓扑时,这是一个安全参数。
6.10. GetNodeEdges
GetNodeEdges - 返回与给定节点相关的边缘的有序集合。
6.10.1. 概要
getfaceedges_returntype GetNodeEdges(varchar atopology, integer anode);
6.10.2. 描述
返回与给定节点相关的边缘的有序集合。 每个输出由一个序列和一个带符号的边缘id组成。 序号从值1开始。 一条正边从给定的节点开始。 一条负边结束到给定的节点。 关闭的边将出现两次(用两个符号)。 按顺时针方向从北向开始。
该函数计算顺序,而不是从元数据派生,因此可用来构建边缘环链接。
