Postgres 将 PATH 类型转换为 ARRAY [英] Postgres convert PATH type to ARRAY

查看:69
本文介绍了Postgres 将 PATH 类型转换为 ARRAY的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以将 Postgres PATH 类型转换为 ARRAY 以便对其点进行索引访问?

Is there any way to convert Postgres PATH type to an ARRAY in order to have index access to it's points?

推荐答案

单独使用 PostgreSQL 无法做到这一点 - 您必须编写自己的 C 函数.

There is no way to do that with PostgreSQL alone - you'd have to write your own C function.

使用 PostGIS 扩展,您可以将 path 转换为 geometry 并在那里执行操作:

With the PostGIS extension, you can cast the path to geometry and perform the operation there:

SELECT array_agg(CAST(geom AS point))
FROM st_dumppoints(CAST(some_path AS geometry));

这篇关于Postgres 将 PATH 类型转换为 ARRAY的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆