question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[QUESTION] Same values being returned by STAsBinary and serialize

See original GitHub issue

Question

My understanding is that sql server uses CLR data types for representing Spatial types internally, and the method STAsBinary would convert the object to a WKB format.

The difference between these two formats is clear when I query an actual DB:

DECLARE @g geometry;
SET @g = (geometry::STGeomFromText('LINESTRING( -122.360 47.656, -122.343 47.656)', 0))
select @g as CLR, @g.STAsBinary() as WKB

But the JDBC driver seems to return the same exact values whether I use STAsBinary() or serialize(). Is this intentional? I was under the impression that WKB formats needed to follow the protocol described here.

Relevant Issues and Pull Requests

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
peterbaecommented, Mar 6, 2020

I think the STAsBinary() should return the same value as SQL Server (I thought it returned a WKB format), but from what I’m seeing, it’s currently returning the CLR format of the datatype. We will make a fix for this in the near future, so that the STAsBinary() returns the WKB format as the javadoc indicates.

0reactions
humada05commented, Mar 6, 2020

Sounds good, thanks for the update! I’ll go ahead and create an issue for this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

geography and the entity framework - MSDN - Microsoft
Another problem I have with the binary approach is that the STBinary method just ditches the Z and M values of the SqlGeography...
Read more >
SQL Server geography result format - Stack Overflow
You can create such value in C# like this (reference Microsoft.SqlServer. ... Serialize().Value; var hexString = "0x" + BitConverter.
Read more >
Serialize and Deserialize a Binary Tree - GeeksforGeeks
Serialization is to store the tree in a file so that it can be later restored. The structure of the tree must be...
Read more >
SQLCreator only reading geometry column ... - FME Community
I'm using an SQL Creator to return data from three tables (Microsoft SQL Server), one of which contains a geometry column.
Read more >
Exporting Spatial Data From SQL Server to ESRI Shapefile
The problem seems to be that, even though we're only returning ... the shapegeom value directly, use the STAsBinary() method in the SQL ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found