php - 将几何线连接在一起的 PostGIS 函数?

标签 php function postgresql postgis

(注意:the_geom 是一个几何值(类型:LINESTRING),在这种情况下,我将它们随机化以提高可读性)

gid | kstart  | kend    | ctrl_sec_no | the_geom | the_sum_geom
626 | 238     | 239     | 120802      | 123456   | NULL
638 | 249     | 250     | 120802      | 234567   | NULL
4037| 239     | 249     | 120802      | 345678   | NULL

【实战说明】不介意者略过

I would like to do 'this' (a set of queries from my past question, link located on the end of this post) for every row in Table B (aka. land_inventory). These two tables are related by 'ctrl_sec_no' (aka. control section number of a road) which means :: in ONE ctrl_sec_no -- 120802 (in fact, it is a road which is equivalent to 3 geometry LINESTRINGs (the_geom) connected together, from kstart 238 (start at kilometre of 238) to kend 250)

[PostGIS 问题]

问题是如何将这 3 行 {aka gid(626,638,4037) from the table} 连接在一起,并通过使用 PostGIS 函数(无论如何)产生“the_sum_geom”(最初为 NULL)。之后我们将使用这个 'the_sum_geom' 找到这个几何 LINESTRING 上的点

(How calculate things from many tables by using a few queries?)。

最佳答案

您要找的函数是ST_Union ,您需要将其与聚合形式一起使用:

update mytable set the_sum_geom = 
ST_LineMerge( ( select ST_Union(the_geom) from mytable where ctrl_sec_no  = 120802 ) )
where ctrl_sec_no = 120802;

ST_LineMerge您可以从 Multiline 转换为 LineString 但有一个警告,如果不能合并多行,它将返回多行而不进行任何修改。查看ST_LineMerge文档以了解 ST_LineMerge 可以做什么或不能做什么。

关于php - 将几何线连接在一起的 PostGIS 函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9213026/

相关文章:

php - 处理大格式输入中的 "Kill"

php - Zend Framework 2 - ZFCUser 模块安装

c - 使用指针在递归函数中创建一个计数器?

sql - 如何通过 Node 和 pg 导入 PostgreSQL 数据库转储

java - 如何使用flyway创建数据库?

php - 如何在 PHP 单元测试中模拟在构造函数中调用的方法?

php - Ajax GET 传递了错误的数据

c++ - 如何在 main() 完成后调用 C++ 函数

python - 如何在函数中使用局部变量并返回它?

node.js - 在 postgreSQL 中使用测试数据库更好地测试 Express 路由