GeoLatte / geolatte-geom

A geometry model that conforms to the OGC Simple Features for SQL specification.
Other
134 stars 63 forks source link

SQL Server: Lat/Lon ordering is wrong when doing encoding/decoding #58

Open mpschaeuble opened 6 years ago

mpschaeuble commented 6 years ago

I wasn't able to serialize a WGS84 point (Geometries.mkPoint(new G2D(longitude, latitude), CoordinateReferenceSystems.WGS84);) such that the SQL server database accepted its byte representation to write the result into a geography typed column.

According to the SQL Server documentation ("Microsoft SQL Server CLR Types Serialization Formats", section "GEOGRAPHY POINT Structure"), latitude must be serialized before longitude. However, the G2D ordering is reversed. As a fix, I changed the ordering in SqlServerGeometry.setCoordinate(...) and SqlServerGeometry.readPoints(...)

Can someone approve that this is a bug?

maesenka commented 6 years ago

That is not really a bug. The current MSSqlServer Encoders/Decoders are designed to work with Geometries, not Geographies.

Now that geolatte-geom Geometries contain coordinate system information, we are ready to take into account the difference between Geometry and Geography structures.

This is something I'm definitely willing to do, as soon as I find the time.