Documentation
¶
Overview ¶
Package postgis is the template for adding a Postgres extension without touching pg. It covers the PostGIS calls a location feature needs: make a point, measure, filter by radius, order by nearest. Needs CREATE EXTENSION postgis. Everything here is one line over pg's exported constructors, so a new extension package is a copy of this file with the names changed.
Index ¶
- Variables
- func AsGeoJSON(g sqlb.Expr[Geometry]) sqlb.Expr[string]
- func Contains(a, b sqlb.Expr[Geometry]) sqlb.Predicate
- func DWithin(a, b sqlb.Expr[Geometry], d sqlb.Expr[float64]) sqlb.Predicate
- func Distance(a, b sqlb.Expr[Geometry]) sqlb.Expr[float64]
- func DistanceSphere(a, b sqlb.Expr[Geometry]) sqlb.Expr[float64]
- func Intersects(a, b sqlb.Expr[Geometry]) sqlb.Predicate
- func KNN(a, b sqlb.Expr[Geometry]) sqlb.Expr[float64]
- func MakePoint(lon, lat sqlb.Expr[float64], srid int) sqlb.Expr[Geometry]
- type Geometry
Constants ¶
This section is empty.
Variables ¶
var ErrGeometryType = errors.New("postgis: geometry must scan from text")
ErrGeometryType is returned by Scan for a value that is not text.
var Extension = pg.Extension{Name: "postgis"}
Extension is the PostGIS extension this package's constructs need, for pg.CreateExtension(Extension), so a library installs what it uses without spelling its name.
Functions ¶
func Contains ¶
Contains renders ST_Contains(a, b): b lies entirely inside a. The argument order is the reverse of what reads naturally, so name the arguments at the call site.
func DistanceSphere ¶
DistanceSphere renders ST_DistanceSphere(a, b) in metres.
func Intersects ¶
Intersects renders ST_Intersects(a, b): the geometries share any point.
Types ¶
type Geometry ¶
type Geometry string
Geometry is a PostGIS geometry as the server sends it: EWKB hex text, or GeoJSON when selected through AsGeoJSON. The wire form stays opaque here because decoding it is a job for a geometry library, not a query builder.