-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Geometry column type support #147
Comments
For now my workaround is to exclude the real field from the schema and using a virtual field filled with a fragment in the query: query =
from p in Project,
select_merge: %{location: fragment("CAST(Location AS nvarchar(100))")}
Repo.one!(query) or query =
from p in Project,
select_merge: %{location: fragment("Location.STAsText()")}
Repo.one!(query) |
The more I look at it, the more I think it should be just ecto custom type. |
I think the first step should be to make TDS aware of the types so it will not error. Ideally we would have all the types already decoded, maybe in WKT or WKB, to manipulate the values with the appropriate libraries. |
I'm facing another limitation now, I moved all containers on my M1 Mac so I have to use the azure-sql-edge docker image. This will not impact the production system but is not ideal from a dev POV, do you think we can at least find a way to get the binary value from the geography/geometry column? |
We are trying to make plan for binary format support, that should resolve STAsString issue, but if that is the case, Im not sure if you will be able to use other geometry::* functions. Did you try to run other sqlerver image in amd64 emulated mode? |
This is awesome!
Why? You mean with the arm version? I'm less than worried to no be able to use the geometry functions, I don't really need to query the database with geo* functions. What I need is to extract some POINTs from this legacy DB to interact with the data in another new system. The legacy system will go under a total rewrite anyway later this year and we will use Postgres.
No, for now I tried just the arm one and disabled the problematic field, |
Then you will be covered 😄. I will definitely try to figure out workaround for arm issue anyways and make instructions in readme |
@mjaric The big rewrite got postponed so we are stuck with the legacy database, We can do it converting the geometry during the query with Can you help me to get the raw binary from the database? I'm hitting |
Spatial data represents information about the physical location and shape of geometric objects. These objects can be point locations or more complex objects such as countries/regions, roads, or lakes.
SQL Server supports two spatial data types: the geometry data type and the geography data type.
Both data types are implemented as .NET common language runtime (CLR) data types in SQL Server.
Simple types:
Collection types:
Data storage is binary, tho there are function
STAsText
andSTGeomFromText
that can be used to display or parse string representation, The rest of functions can be found hereBinary storage for geography is packed in format:
All SRIDs can be found in
Commonly used is
4326
or WGS 84 (World Geodetic System 1984) coordinate system. It can be identified from first 4 bytes of binary data ( for instance4326
is seen stored in spatial data column as0xE6100000....
in little endianness).The text was updated successfully, but these errors were encountered: