如何将几何数据字段显示为文本 [英] How to display geometry datafield as Text

查看:97
本文介绍了如何将几何数据字段显示为文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将DELPHI与ADO和SQL Server 2014一起使用。

I'm using DELPHI with ADO and SQL Server 2014.

在我们的数据库表中,有一个用于显示几何数据的空间列。我们可以向该字段读取和写入数据(更多信息在这里: https://docs.microsoft.com/de-de/sql/relational-databases/spatial/spatial-data-sql-server )。

In our database table there is a spatial column for geometrical data. We can read and write data to this field (more info is here : https://docs.microsoft.com/de-de/sql/relational-databases/spatial/spatial-data-sql-server).

如果我使用TDBGRID组件显示此表,则我的表中该列的内容仅显示(BLOB)。

If I display this table using a TDBGRID component I got only (BLOB) shown for the content of this column in my table.

现在,我想查看此列的内容。是显示该列内容的良好编码吗,例如

Now I want to see the content of this column. Is the any good coding to show the content of this column e.g. in a dbmemo as text.

我知道的唯一解决方案是将字段作为文本读取为字符串并将其放入普通备忘录中,我很期待获得更有效的方法来访问此数据

The only solution I know is to read the field as text into a string and put this to a normal memo, I'm looking forward to get a more efficient method to access this data

推荐答案

您可以查询例如通过使用类似SQL函数的 知名文本 格式 STAsText

You can query e.g. for Well-known text format by using SQL function like STAsText:

SELECT MyColumn.STAsText() FROM MyTable

另一种方法是在 知名二进制 数据流,在客户端将其解析为自己表示为文本(描述了格式)。要获取此类流,您可以使用 STAsBinary 函数:

An alternative would be fetching your data in Well-known binary data stream with parsing it on the client side to represent as text by yourself (the format is described). For fetching such stream you'd use STAsBinary function:

SELECT MyColumn.STAsBinary() FROM MyTable

另一种选择是获取原始 几何 数据,因为它们存储在数据库中(就像您现在所做的那样)并自己解析。 > [MS-SSCLRT] 文档。但是,如果您是我,我会更好地为WKB格式编写解析器,并以WKB格式获取数据,因为它是非常通用的格式,而SQL Server内部格式可能会经常更改。

Yet another option would be fetching raw geometry data as they are stored in database (as you do right now) and parse it by yourself. The format is described in the [MS-SSCLRT] document. But if I were you I would better write parser for the WKB format and fetch data in WKB format because it's quite established universal format, whilst SQL Server internal formats may change frequently.

这篇关于如何将几何数据字段显示为文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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