Spatial Point type support

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
Post Reply
Michael Logutov
Posts: 2
Joined: Thu 07 Aug 2014 05:28

Spatial Point type support

Post by Michael Logutov » Thu 07 Aug 2014 05:31

Hello.
Is there a way to utilize geo spatial support in dotConnect for MySql. Namely POINT data type?

Pinturiccio
Devart Team
Posts: 2420
Joined: Wed 02 Nov 2011 09:44

Re: Spatial Point type support

Post by Pinturiccio » Thu 07 Aug 2014 15:10

dotConnect for MySQL supports spatial data types in ADO.NET only with Well-Known Binary (WKB) Format (as a byte array). For more information, please refer to http://dev.mysql.com/doc/refman/5.1/ja/ ... ormat.html

Entity Framework of versions v5 and v6 support spatial data types. For more information, please refer to http://blog.devart.com/enhanced-entity- ... resql.html

Michael Logutov
Posts: 2
Joined: Thu 07 Aug 2014 05:28

Re: Spatial Point type support

Post by Michael Logutov » Thu 07 Aug 2014 16:41

Thank you.
So, how do I convert lat, lng values into WKB and back?
Is there some kind of OpenGIS .NET library that provides the types serializable in WKB format? Or is there a way to convert System.Device.Location.GeoCoordinate to WKB and back?

Pinturiccio
Devart Team
Posts: 2420
Joined: Wed 02 Nov 2011 09:44

Re: Spatial Point type support

Post by Pinturiccio » Mon 18 Aug 2014 13:58

Michael Logutov wrote:So, how do I convert lat, lng values into WKB and back?
If you use a column of a spatial type, the data in this column is stored as a set of bytes in a binary format. If you perform a SELECT statement for this column, you will get this binary data. After this you may process this binary data in your application. For example, you may create a custom class that accepts this binary data to its constructor, parse it and assign corresponding values for the fields. Then you may work with this class, and after this convert data back to the binary format and store it to the database table.

You can also get the necessary fields with a query using the functions, creating geometry values using WKB. The list of such functions you can find in the MySQL documentation http://dev.mysql.com/doc/refman/4.1/en/ ... tions.html

For example, suppose you have the following table:
SQL script:

Code: Select all

CREATE TABLE semenb.test_point (
  t1 point DEFAULT NULL
);

INSERT INTO semenb.test_point(t1)
VALUES(PointFromText('POINT(1 1)'));
You can use MySQL functions for spatial types to get textual information on the POINT type coordinates. For example, you can use the following query:

Code: Select all

SELECT x(PointFROMWKB(t1)) AS X, y(PointFROMWKB(t1)) AS Y FROM test_point
Michael Logutov wrote:Is there some kind of OpenGIS .NET library that provides the types serializable in WKB format?
dotConnect for MySQL does not provide such a feature. Probably there are .NET libraries that provide the types serializable in WKB format, but this question is beyond the scope of our support.
Michael Logutov wrote:Or is there a way to convert System.Device.Location.GeoCoordinate to WKB and back?
GeoCoordinate class belongs to the System assembly, so please contact the Microsoft support on this question.

Post Reply