-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Support mapping (and querying) of geometry collections #30630
Comments
Some thoughts on why someone would want to use
|
See npgsql/efcore.pg#2722 for an example of a user attempting to map Thinking about this some more, there may be a good compromise here... We could allow users to map |
Design decision: don't special case geometry in any way:
|
Requires #30677 to control JSON serialization of spatial types as WKT. |
Blocked on dotnet#30677 for serializing spatial types as WKT in JSON Closes dotnet#30630
@ajcvickers this should be doable not that JsonValueReaderWriter is available on the type mappings, as just another case in #30727. However, we also need CollectionToJsonStringConverter to use it (currently it tries to just do JsonSerializer.Serialize() on the NetTopologySuite object, which fails. I'll revisit this once we wire everything together, should be easy. Note to self: remember that SQL Server OPENWITH with WITH doesn't support geometry; we'll have to rewrite it to OPENWITH without JSON in postprocessing, just like we do when ordering needs to be preserved. The casting to a SQL Server relational geometry value will be introduced there as well. |
Note mini-investigation of geometry and IN/equality: #31912 (comment) |
i wanted to help spur this tangent on by formally mentioning the dreaded geojson featurecollection and the challenging openapi schema (polyglot) of site and vendor specific implementions of ogc spec responses. there is also a nod to the use of jsonb in timescaledb while bearing in mind this consider https://api.weather.gov/zones/forecast/MIZ034. note that the response contains domain and organization specific properties
consider https://api.weather.gc.ca/collections/ahccd-stations/items. note that the response contains domain and organization specific properties
the examples will vary for every endpoint by scientific domain and data collection epoch. one should here formally state that this schema variability is a feature of the wireformat data models of the underlying scientific domains. indeed one (where one = hil +- human) queries the metadata, discovers dimensions and attributes of interest and composes further queries to actually retrieve the data. for instance, the response to this request contains https:$reflike pointers to gridded met forecast datapoints following the link to the gridded data implementations seeking to exploit this dataset might want to apply a tool such as timescaledb to the advertised timeseries atoms once timescaledb is in the mix one quickly checks its support for jsonb and though for performance reasons it's not advised, timeseries functions are available against jsonb one may here assert that
one also here provides evidence that this (consume, mutate and persist gis datasets) has been a pain point for gis developers for a long time mov ax, 'thanks' |
GIS has a concept of a collection of geometry objects; this is represented by NetTopologySuite's GeometryCollection type, which extends Geometry and which we map to the database geometry/geography types (e.g. GeometryCollection in SQL Server). In most databases we also translate some spatial functions.
As part of #29427, we're allowing to map a .NET collection of any supported type to a JSON column in the database; but since collections of spatial objects have a special representation, we're excluding that specifically. Since GeometryCollection already implements
IEnumerable<Geometry>
, we probably don't want to also allow mapping e.g.Geometry[]
. However, most database don't allow unpacking a geometry collection to a queryable table (PG supports this via ST_Dump); this means mappingGeometry[]
to a regular JSON string column in the database does an advantage (queryability) over mapping to a database geometry collection.Note: SQL Server OPENJSON doesn't natively support geometry, i.e. does not allow using
geometry
in its WITH clause. But we can still get WKT out as a string and just wrap it in a function which returns the geometry object.The text was updated successfully, but these errors were encountered: