geolatte-geom icon indicating copy to clipboard operation
geolatte-geom copied to clipboard

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

Open mpschaeuble opened this issue 7 years ago • 1 comments

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?

mpschaeuble avatar Jan 11 '18 07:01 mpschaeuble

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.

maesenka avatar Jan 31 '18 21:01 maesenka