Skip to content
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

Using PostGIS Geometry types #5

Open
JindrichPilar opened this issue Mar 16, 2020 · 1 comment
Open

Using PostGIS Geometry types #5

JindrichPilar opened this issue Mar 16, 2020 · 1 comment

Comments

@JindrichPilar
Copy link

When using PostGIS geometry types and storing a record it serializes the Point type incorrectly.
$10::geometry gets as parameter "(50.501899 10.963963)" instead of "Point(50.501899 10.963963)". Insert fails with an error ERROR: invalid input syntax for type point.

Column definition:

gps
    geometry
    not null

Record usage:

val record = dsl.newRecord(Tables.TABLE_WITH_GPS)
record.gps = org.postgis.Point(50.501899, 10.963963)
record.insert() // This throws an error
@zezulka
Copy link

zezulka commented Feb 13, 2022

I was able to reproduce the same behaviour.

The problem most probably stems from incorrect implementation of PostgisGeometryConverter: https://github.com/dmitry-zhuravlev/jooq-postgis-spatial/blob/master/src/main/kotlin/net/dmitry/jooq/postgis/spatial/converter/PostgisGeometryConverter.kt#L25 . In the context of JTSGeometryBinding, this "native" converter works just fine, the problem is when the converter is used in the context of PostgisGeometryBinding.

When I defined my own converter based on PostgisGeometryConverter which uses

PGobject().apply {
   type = "geometry" // passing in the geometry type string is just plain wrong, PGobject type does not expect enum of ["linestring", "point", ...] but ["geometry", "box2d", ...], see https://postgis.net/docs/reference.html#PostGIS_Types
   value = geom.toString() // this converts postgis geometry to an EWKT string
}

instead of

PGobject().apply {
    type = geom.typeString
    value = geom.value
}

all postgis queries seemed to work properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants