-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
Problem
Currently, CrateDB's GEO_SHAPE types cannot be directly marshalled to/from .NET GeoJSON types when using Npgsql. While GEO_POINT works well with NpgsqlPoint, GeoJSON geometry types require manual string serialization.
Current Behavior
The InsertGeoJsonTyped() method in by-language/csharp-npgsql/DemoTypes.cs attempts to use NpgsqlDbType.Geometry but fails with:
System.NotSupportedException: The NpgsqlDbType 'Geometry' isn't present in your
database. You may need to install an extension or upgrade to a newer version.
Workaround: The InsertGeoJsonString() method manually serializes GeoJSON objects (Point, Polygon, etc.) to JSON strings using JsonConvert.SerializeObject() and passes them as NpgsqlDbType.Json.
Desired Behavior
Enable fluent marshalling similar to PostgreSQL with PostGIS, where GeoJSON types can be directly used:
- Use Npgsql's PostGIS/GeoJSON Type Plugin
- Directly pass .NET GeoJSON.Net types (Point, Polygon, etc.) as parameters
- Directly read GeoJSON types from query results without manual deserialization
Technical Details
- CrateDB communicates
GEO_SHAPEas string types (WKT or GeoJSON format) - The PostGIS/GeoJSON plugin expects the database to identify as PostGIS
- CrateDB does not currently identify itself as PostGIS (see review discussion)
Related
- PR Npgsql: Use
NpgsqlPoint.NET type for marshallingGEO_POINTtypes. Explore communicating and marshalling GeoJSON types. #782: Initial exploration of Npgsql geospatial type support - Comment: Npgsql: Use
NpgsqlPoint.NET type for marshallingGEO_POINTtypes. Explore communicating and marshalling GeoJSON types. #782 (comment) - Npgsql issue: The NpgsqlDbType 'Geometry' isn't present in your database. npgsql/npgsql#2411
Tasks
- Investigate why
NpgsqlDbType.Geometryis not recognized by CrateDB - Determine if CrateDB can/should identify as PostGIS for geometry type compatibility
- Explore alternative approaches to enable direct GeoJSON type marshalling
- Consider supporting direct conversion to Npgsql geometry types (
NpgsqlLSeg,NpgsqlBox,NpgsqlPath,NpgsqlPolygon,NpgsqlCircle)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels