Open frjonsen opened 9 months ago
I'm totally not an expert on Postgis and WKBWriter
either. I'm happy to improve the codec if someone knowledgeable provides us with some guidance.
Seems the required information cannot be retrieved reliably as per https://github.com/locationtech/jts/issues/654
Bug Report
Versions
Current Behavior
I am using PostGIS, and have a table defined as
geometry(Pointz, 4326)
. I have manually inserted a record in the database, where the value for this column is serialized as01010000A0E6100000C5FEB27BF2B02840BC0512143FBA53400000000000407F40
. I can query this table just fine. For reference, converted to GeoJson the result I get is{ "type": "Point", "coordinates": [ 12.3456, 78.9101, 500 ] }
, which is what I would expected.However, passing this same GeoJson back in, converting to a JTS Point, and trying to insert it, I can an error,
io.r2dbc.postgresql.ExceptionFactory$PostgresqlBadGrammarException: Column has Z dimension but geometry does not
As far as I can tell, this is because the codec appears to be hardcoded for two dimensions rather than actually checking the number of dimensions the Geometry object is holding.
Table schema
Input Code
```sql -- your SQL here; ```Steps to reproduce
Input Code
```java // your code here; ```Expected behavior/code
Insert should not error, and all dimensions should be set
Possible Solution
A naïve solution that works in my case is
but I'm not familiar enough with either PostGIS or JTS to tell if this solution is general for all geometric types, or if it only solves the case of Point and PointZ.
Additional context