Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display geometry datafield as Text

Tags:

delphi

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

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://learn.microsoft.com/de-de/sql/relational-databases/spatial/spatial-data-sql-server).

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

like image 520
user9044066 Avatar asked Oct 14 '25 03:10

user9044066


1 Answers

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

SELECT MyColumn.STAsText() FROM MyTable

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

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.

like image 174
Victoria Avatar answered Oct 17 '25 13:10

Victoria