Oracle - 将 SDO_GEOMETRY 转换为 WKT?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/44832223/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 03:26:12  来源:igfitidea点击:

Oracle - Converting SDO_GEOMETRY to WKT?

oracleoracle-spatial

提问by

I am very new to oracle spatial.

我对 oracle 空间很陌生。

I have a spatial table with one SDO_GEOMETRY column. After inserting POINT data in this table, I want to retrieve data in WKT format.

我有一个带有 SDO_GEOMETRY 列的空间表。在此表中插入 POINT 数据后,我想以 WKT 格式检索数据。

Here is what I did:

这是我所做的:

Inserting data -

插入数据 -

INSERT INTO new_test (name, geom) VALUES (
'Test', 
SDO_GEOMETRY(
             2001,
             4326, 
             SDO_POINT_TYPE(12,14,NULL), 
             NULL, 
             NULL));

Fetching data -

获取数据 -

SELECT NAME, SDO_UTIL.TO_WKTGEOMETRY(GEOM) AS point FROM NEW_TEST;

Output -

输出 -

NAME | POINT
-------------
Test | (null)

Why do I get null here? Shouldn't it display the co-ordinate points?

为什么我在这里得到空值?它不应该显示坐标点吗?

回答by MT0

Too long for a comment - not sure why it doesn't work for you but I cannot replicate your results:

评论太长了 - 不知道为什么它对你不起作用,但我无法复制你的结果:

Oracle Setup:

甲骨文设置

CREATE TABLE new_test ( name varchar2(20), geom SDO_GEOMETRY );

INSERT INTO new_test (name, geom)
VALUES (
  'Test', 
  SDO_GEOMETRY( 2001, 4326, SDO_POINT_TYPE(12,14,NULL), NULL, NULL)
);

Query:

查询

SELECT NAME, SDO_UTIL.TO_WKTGEOMETRY(GEOM) AS point FROM NEW_TEST;

Output:

输出

NAME POINT                                                                          
---- -----------------
Test POINT (12.0 14.0)

回答by Lars

The function SDO_UTIL.TO_WKTGEOMETRYseems not to be available in the Express version(Source- Siva Ravada-Oracle):

该功能SDO_UTIL.TO_WKTGEOMETRY似乎在Express 版本中不可用(来源- Siva Ravada-Oracle):

Oracle Express does not have a Javavm in the database and the WKT conversion routines need this as the feature is implemented as Java stored procedures. So these WKT routines are not supported on the Express edition.

Oracle Express 在数据库中没有 Javavm,WKT 转换例程需要它,因为该功能是作为 Java 存储过程实现的。因此 Express 版本不支持这些 WKT 例程。

You can still build your own WKT like this (for points):

您仍然可以像这样构建自己的 WKT(积分):

SELECT name, 'POINT ('||t.X||' '||t.Y||')' AS point FROM NEW_TEST p, TABLE(SDO_UTIL.GETVERTICES(p.GEOM)) t;