In my region table I have a geometry column geom that could be of different types : polygon, multipolygon
I try to use the wkb.Scanner with a orb.Geometry var but it fails, when I use a orb.Polygon it's ok.
Is it possible to scan a column as orb.Geometry or should we provide the right type. And then how to handle multi type columns ?
(I'm pretty new to go programming)
my code :
func (q *RegionQueries) GetRegion(code string) (models.Region, error) {
region := models.Region{}
query := `SELECT code, label, label_uc, ST_AsBinary(geom) FROM region WHERE code = $1`
var geom orb.Geometry
// var geom orb.Polygon // ok
s := wkb.Scanner(&geom)
q.QueryRow(
context.Background(),
query,
code,
).Scan(®ion.Code, ®ion.Label, ®ion.LabelUC, s)
if s.Valid {
region.Geom = s.Geometry
} else {
region.Geom = nil
}
// ...
}
Hi,
In my
region
table I have a geometry columngeom
that could be of different types : polygon, multipolygon I try to use thewkb.Scanner
with aorb.Geometry
var but it fails, when I use aorb.Polygon
it's ok. Is it possible to scan a column asorb.Geometry
or should we provide the right type. And then how to handle multi type columns ?(I'm pretty new to go programming)
my code :