Search code examples
.netmysqlsubsonicgeospatialspatial

Using MySQL GeoSpatial data types in .NET


I'm looking for information on how to use MySQL geometry types in .NET. I'm using Sub-sonic for ORM and don't really need to support much more than MySQL's POINT type.

The MySQL .NET connector seems to return point data as a byte[] array in the OpenGIS WKB format.

  • What libraries are recommended for working with this WKB format?

  • Alternatively, since I only need support for Point, examples on converting WKB to/from a .NET type would probably suffice.

  • Assuming I can find (or build) a class that can handle the Point data type, how much trouble am I going to have getting Sub-sonic (v3) to work with it?


Solution

  • Check out the OpenSource GeoAPI.Net - http://geoapi.codeplex.com

    This has .NET classes for all geometry types and a number of tools to convert to these from other types such as WKB. Look at the sourcecode for version 2.11a src > GeoAPI > IO > WellKnownBinary. There are readers / writers / parsers etc.

    GeoAPI.Net is used in a number of projects such as http://sharpmap.codeplex.com which have more complex spatial operations using the GeoAPI.Net types. http://code.google.com/p/nettopologysuite/ also uses thse classes so you will have a wide range of powerful operations to use on the classes if needed.

    I know nothing about Sub-sonic, but as the Point classes / interface are fairly standard .NET I don't see why this sould cause any problems. You can always have a look at the source online to check.