twpayne / go-geos

Package geos provides an interface to GEOS.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

geos.Geom does not implement the Scanner and Valuer interfaces

xiaoming-master opened this issue · comments

geos.Geom does not implement the Scanner and Valuer interfaces, and some errors will occur when I use some orm frameworks (such as gorm) to operate geos.Geom objects.
[error] invalid field found for struct main.Waypoint's field Geom: define a valid foreign key for relations or implement the Valuer/Scanner interface

I found that geometry.Geometry has implemented these interfaces.

Exactly.

There is also pgx-geos if you're using the pgx database driver.

I use go-shapefile to read data of geom.T type from the shapefile, then convert this data to wkb format, and then convert the wkb format data to geometry.Geometry. Is there a simple way to achieve this?

You can use go-geobabel to convert between Go geometry formats, but your current approach of round-tripping via WKB is reasonable.