geos

package module
v0.22.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 3, 2026 License: MIT Imports: 10 Imported by: 31

README ΒΆ

go-geos

PkgGoDev

Package go-geos provides an interface to GEOS.

Install

$ go get github.com/twpayne/go-geos

You must also install the GEOS development headers and libraries. These are typically in the package libgeos-dev on Debian-like systems, geos-devel on RedHat-like systems, and geos in Homebrew.

Features

  • Fluent Go API.

  • Low-level Context, CoordSeq, Geom, PrepGeom, and STRtree types provide access to all GEOS methods.

  • High-level geometry.Geometry type implements all GEOS functionality and many standard Go interfaces:

    • database/sql/driver.Valuer and database/sql.Scanner (WKB) for PostGIS database integration.
    • encoding/json.Marshaler and encoding/json.Unmarshaler (GeoJSON).
    • encoding/xml.Marshaler (KML).
    • encoding.BinaryMarshaler and encoding.BinaryUnmarshaler (WKB).
    • encoding.TextMarshaler and encoding.TextUnmarshaler (WKT).
    • encoding/gob.GobEncoder and encoding/gob.GobDecoder (GOB).

    See the PostGIS example for a demonstration of the use of these interfaces.

  • Concurrency-safe. go-geos uses GEOS's threadsafe *_r functions under the hood, with locking to ensure safety, even when used across multiple goroutines. For best performance, use one geos.Context per goroutine.

  • Caching of geometry properties to avoid cgo overhead.

  • Optimized GeoJSON encoder.

  • Automatic cleanup of GEOS objects.

Memory management

go-geos objects live mostly on the C heap. go-geos sets cleanup functions on the objects it creates that free the associated C memory. However, the C heap is not visible to the Go runtime. The can result in significant memory pressure as memory is consumed by large, un-freed geometries, of which the Go runtime is unaware.

Ownership

Returned sub-geometries (e.g. polygon rings or geometries in a collection) and coordinate sequences are owned by the geometry and will keep the geometry alive with a reference to it. Collections take ownership of all their geometries: directly if the geometry is unowned, or via cloning for an already-owned geometry.

Errors, exceptions, and panics

go-geos uses the stable GEOS C bindings. These bindings catch exceptions from the underlying C++ code and convert them to an integer return code. For normal geometry operations, go-geos panics whenever it encounters a GEOS return code indicating an error, rather than returning an error. Such panics will not occur if go-geos is used correctly. Panics will occur for invalid API calls, out-of-bounds access, or operations on invalid geometries. This behavior is similar to slice access in Go (out-of-bounds accesses panic) and keeps the API fluent. When parsing data, errors are expected so an error is returned.

Comparison with github.com/twpayne/go-geom

github.com/twpayne/go-geom is a pure Go library providing similar functionality to go-geos. The major differences are:

  • go-geos uses GEOS, which is an extremely mature library with a rich feature set.
  • go-geos uses cgo, with all the disadvantages that that entails, notably expensive function call overhead, more complex memory management and trickier cross-compilation.
  • go-geom uses a cache-friendly coordinate layout which is generally faster than GEOS for many operations.

go-geos is a good fit if your program is short-lived (meaning you can ignore memory management), or you require the battle-tested geometry functions provided by GEOS and are willing to handle memory management manually. go-geom is recommended for long-running processes with less stringent geometry function requirements.

GEOS version compatibility

go-geos is tested to work with the versions of GEOS tested on CI. See here.

Calling functions unsupported by the underlying GEOS library will result in a panic. Users can use VersionCompare to be sure that a function exists.

Contributing

Please check CONTRIBUTING.md for instructions before you open a pull-request!

License

MIT

Documentation ΒΆ

Overview ΒΆ

Package geos provides an interface to GEOS. See https://trac.osgeo.org/geos/.

Index ΒΆ

Examples ΒΆ

Constants ΒΆ

View Source
const (
	VersionMajor = C.GEOS_VERSION_MAJOR
	VersionMinor = C.GEOS_VERSION_MINOR
	VersionPatch = C.GEOS_VERSION_PATCH
)

Version.

Variables ΒΆ

View Source
var DefaultContext = NewContext()

DefaultContext is the default context.

Functions ΒΆ

func VersionCompare ΒΆ added in v0.15.0

func VersionCompare(major, minor, patch int) int

VersionCompare returns a negative number if the GEOS version is less than the given major.minor.patch version, zero if it is equal, or a positive number otherwise.

Types ΒΆ

type Box2D ΒΆ added in v0.17.0

type Box2D struct {
	MinX float64
	MinY float64
	MaxX float64
	MaxY float64
}

A Box2D is a two-dimensional bounds.

func NewBox2D ΒΆ added in v0.17.0

func NewBox2D(minX, minY, maxX, maxY float64) *Box2D

NewBox2D returns a new bounds.

func NewBox2DEmpty ΒΆ added in v0.17.0

func NewBox2DEmpty() *Box2D

NewBox2DEmpty returns a new empty bounds.

func (*Box2D) Contains ΒΆ added in v0.17.0

func (b *Box2D) Contains(other *Box2D) bool

Contains returns true if b contains other.

func (*Box2D) ContainsPoint ΒΆ added in v0.17.0

func (b *Box2D) ContainsPoint(x, y float64) bool

ContainsPoint returns true if b contains the point at x, y.

func (*Box2D) ContextGeom ΒΆ added in v0.17.0

func (b *Box2D) ContextGeom(context *Context) *Geom

ContextGeom returns b as a Geom.

func (*Box2D) Equals ΒΆ added in v0.17.0

func (b *Box2D) Equals(other *Box2D) bool

Equals returns true if b equals other.

func (*Box2D) Geom ΒΆ added in v0.17.0

func (b *Box2D) Geom() *Geom

Geom returns b as a Geom.

func (*Box2D) Height ΒΆ added in v0.17.0

func (b *Box2D) Height() float64

Height returns the height of b.

func (*Box2D) Intersects ΒΆ added in v0.17.0

func (b *Box2D) Intersects(other *Box2D) bool

Intersects returns true if b intersects other.

func (*Box2D) IsEmpty ΒΆ added in v0.17.0

func (b *Box2D) IsEmpty() bool

IsEmpty returns true if b is empty.

func (*Box2D) IsPoint ΒΆ added in v0.17.0

func (b *Box2D) IsPoint() bool

IsPoint returns true if b is a point.

func (*Box2D) String ΒΆ added in v0.17.0

func (b *Box2D) String() string

func (*Box2D) Width ΒΆ added in v0.17.0

func (b *Box2D) Width() float64

Width returns the width of b.

type Box3D ΒΆ added in v0.18.0

type Box3D struct {
	MinX float64
	MinY float64
	MinZ float64
	MaxX float64
	MaxY float64
	MaxZ float64
}

A Box3D is a three-dimensional bounds.

func NewBox3D ΒΆ added in v0.18.0

func NewBox3D(minX, minY, minZ, maxX, maxY, maxZ float64) *Box3D

NewBox3D returns a new bounds.

func NewBox3DEmpty ΒΆ added in v0.18.0

func NewBox3DEmpty() *Box3D

NewBox3DEmpty returns a new empty bounds.

func (*Box3D) String ΒΆ added in v0.18.0

func (b *Box3D) String() string

type BufCapStyle ΒΆ added in v0.7.0

type BufCapStyle int
const (
	BufCapStyleRound  BufCapStyle = C.GEOSBUF_CAP_ROUND
	BufCapStyleFlat   BufCapStyle = C.GEOSBUF_CAP_FLAT
	BufCapStyleSquare BufCapStyle = C.GEOSBUF_CAP_SQUARE
)

Buffer cap styles.

type BufJoinStyle ΒΆ added in v0.7.0

type BufJoinStyle int
const (
	BufJoinStyleRound BufJoinStyle = C.GEOSBUF_JOIN_ROUND
	BufJoinStyleMitre BufJoinStyle = C.GEOSBUF_JOIN_MITRE
	BufJoinStyleBevel BufJoinStyle = C.GEOSBUF_JOIN_BEVEL
)

Buffer join styles.

type BufParams ΒΆ added in v0.20.2

type BufParams struct {
	// contains filtered or unexported fields
}

A BufParams contains parameters for BufferWithParams.

func (*BufParams) SetEndCapStyle ΒΆ added in v0.20.2

func (p *BufParams) SetEndCapStyle(style BufCapStyle) *BufParams

SetEndCapStyle sets p's end cap style.

func (*BufParams) SetJoinStyle ΒΆ added in v0.20.2

func (p *BufParams) SetJoinStyle(style BufJoinStyle) *BufParams

SetJoinStyle sets p's join style.

func (*BufParams) SetMitreLimit ΒΆ added in v0.20.2

func (p *BufParams) SetMitreLimit(mitreLimit float64) *BufParams

SetMitreLimit sets p's mitre limit.

func (*BufParams) SetQuadrantSegments ΒΆ added in v0.20.2

func (p *BufParams) SetQuadrantSegments(quadSegs int) *BufParams

SetQuadrantSegments sets the number of segments to stroke each quadrant of circular arcs.

func (*BufParams) SetSingleSided ΒΆ added in v0.20.2

func (p *BufParams) SetSingleSided(singleSided bool) *BufParams

SetSingleSided sets whether the computed buffer should be single sided.

type Context ΒΆ

type Context struct {
	// contains filtered or unexported fields
}

A Context is a context.

func NewContext ΒΆ

func NewContext() *Context

NewContext returns a new Context.

func (*Context) Clone ΒΆ

func (c *Context) Clone(g *Geom) *Geom

Clone clones g into c.

func (*Context) NewBufParams ΒΆ added in v0.20.2

func (c *Context) NewBufParams() *BufParams

NewBufParams returns a new BufParams.

func (*Context) NewCollection ΒΆ

func (c *Context) NewCollection(typeID TypeID, geoms []*Geom) *Geom

NewCollection returns a new collection which owns all the supplied geometries; either directly if they were un-owned, or via clones if they were owned already.

func (*Context) NewCoordSeq ΒΆ

func (c *Context) NewCoordSeq(size, dims int) *CoordSeq

NewCoordSeq returns a new CoordSeq.

func (*Context) NewCoordSeqFromCoords ΒΆ

func (c *Context) NewCoordSeqFromCoords(coords [][]float64) *CoordSeq

NewCoordSeqFromCoords returns a new CoordSeq populated with coords.

func (*Context) NewEmptyCollection ΒΆ

func (c *Context) NewEmptyCollection(typeID TypeID) *Geom

NewEmptyCollection returns a new empty collection.

func (*Context) NewEmptyLineString ΒΆ

func (c *Context) NewEmptyLineString() *Geom

NewEmptyLineString returns a new empty line string.

func (*Context) NewEmptyPoint ΒΆ

func (c *Context) NewEmptyPoint() *Geom

NewEmptyPoint returns a new empty point.

func (*Context) NewEmptyPolygon ΒΆ

func (c *Context) NewEmptyPolygon() *Geom

NewEmptyPolygon returns a new empty polygon.

func (*Context) NewGeoJSONReader ΒΆ added in v0.20.2

func (c *Context) NewGeoJSONReader() *GeoJSONReader

NewGeoJSONReader returns a new GeoJSONReader.

func (*Context) NewGeoJSONWriter ΒΆ added in v0.20.2

func (c *Context) NewGeoJSONWriter() *GeoJSONWriter

NewGeoJSONWriter returns a new GeoJSONWriter.

func (*Context) NewGeomFromBounds ΒΆ

func (c *Context) NewGeomFromBounds(minX, minY, maxX, maxY float64) *Geom

NewGeomFromBounds returns a new polygon constructed from bounds.

func (*Context) NewGeomFromGeoJSON ΒΆ added in v0.4.0

func (c *Context) NewGeomFromGeoJSON(geoJSON string) (*Geom, error)

NewGeomFromGeoJSON returns a new geometry in JSON format from json.

func (*Context) NewGeomFromWKB ΒΆ

func (c *Context) NewGeomFromWKB(wkb []byte) (*Geom, error)

NewGeomFromWKB parses a geometry in WKB format from wkb.

func (*Context) NewGeomFromWKT ΒΆ

func (c *Context) NewGeomFromWKT(wkt string) (*Geom, error)

NewGeomFromWKT parses a geometry in WKT format from wkt.

func (*Context) NewLineString ΒΆ

func (c *Context) NewLineString(coords [][]float64) *Geom

NewLineString returns a new line string populated with coords.

func (*Context) NewLinearRing ΒΆ

func (c *Context) NewLinearRing(coords [][]float64) *Geom

NewLinearRing returns a new linear ring populated with coords.

func (*Context) NewPoint ΒΆ

func (c *Context) NewPoint(coord []float64) *Geom

NewPoint returns a new point populated with coord.

func (*Context) NewPointFromXY ΒΆ added in v0.13.0

func (c *Context) NewPointFromXY(x, y float64) *Geom

NewPointFromXY returns a new point with a x and y.

func (*Context) NewPoints ΒΆ added in v0.3.0

func (c *Context) NewPoints(coords [][]float64) []*Geom

NewPoints returns a new slice of points populated from coords.

func (*Context) NewPolygon ΒΆ

func (c *Context) NewPolygon(coordss [][][]float64) *Geom

NewPolygon returns a new polygon populated with coordss.

func (*Context) NewSTRtree ΒΆ added in v0.12.0

func (c *Context) NewSTRtree(nodeCapacity int) *STRtree

NewSTRtree returns a new STRtree.

func (*Context) NewWKBReader ΒΆ added in v0.20.2

func (c *Context) NewWKBReader() *WKBReader

NewWKBReader returns a new WKBReader.

func (*Context) NewWKBWriter ΒΆ added in v0.20.2

func (c *Context) NewWKBWriter(options ...WKBWriterOption) *WKBWriter

NewWKBWriter returns a new WKBWriter with the given options.

func (*Context) NewWKTReader ΒΆ added in v0.20.2

func (c *Context) NewWKTReader() *WKTReader

NewWKTReader returns a new WKTReader.

func (*Context) NewWKTWriter ΒΆ added in v0.20.2

func (c *Context) NewWKTWriter() *WKTWriter

NewWKTWriter returns a new WKTWriter.

func (*Context) OrientationIndex ΒΆ added in v0.13.0

func (c *Context) OrientationIndex(ax, ay, bx, by, px, py float64) int

OrientationIndex returns the orientation index from A to B and then to P.

func (*Context) Polygonize ΒΆ added in v0.9.0

func (c *Context) Polygonize(geoms []*Geom) *Geom

Polygonize returns a set of geometries which contains linework that represents the edges of a planar graph.

func (*Context) PolygonizeValid ΒΆ added in v0.9.0

func (c *Context) PolygonizeValid(geoms []*Geom) *Geom

PolygonizeValid returns a set of polygons which contains linework that represents the edges of a planar graph.

func (*Context) RelatePatternMatch ΒΆ added in v0.12.0

func (c *Context) RelatePatternMatch(mat, pat string) bool

RelatePatternMatch returns if two DE9IM patterns are consistent.

func (*Context) SegmentIntersection ΒΆ added in v0.12.0

func (c *Context) SegmentIntersection(ax0, ay0, ax1, ay1, bx0, by0, bx1, by1 float64) (x, y float64, intersection bool)

SegmentIntersection returns the coordinate where two lines intersect.

type CoordSeq ΒΆ

type CoordSeq struct {
	// contains filtered or unexported fields
}

A CoordSeq is a coordinate sequence.

func NewCoordSeq ΒΆ

func NewCoordSeq(size, dims int) *CoordSeq

NewCoordSeq returns a new CoordSeq.

func NewCoordSeqFromCoords ΒΆ

func NewCoordSeqFromCoords(coords [][]float64) *CoordSeq

NewCoordSeqFromCoords returns a new CoordSeq populated with coords.

func (*CoordSeq) Clone ΒΆ

func (s *CoordSeq) Clone() *CoordSeq

Clone returns a clone of s.

func (*CoordSeq) Dimensions ΒΆ

func (s *CoordSeq) Dimensions() int

Dimensions returns the dimensions of s.

func (*CoordSeq) IsCCW ΒΆ added in v0.10.0

func (s *CoordSeq) IsCCW() bool

IsCCW returns if s is counter-clockwise.

func (*CoordSeq) Ordinate ΒΆ

func (s *CoordSeq) Ordinate(idx, dim int) float64

Ordinate returns the idx-th dim coordinate of s.

func (*CoordSeq) SetOrdinate ΒΆ

func (s *CoordSeq) SetOrdinate(idx, dim int, val float64)

SetOrdinate sets the idx-th dim coordinate of s to val.

func (*CoordSeq) SetX ΒΆ

func (s *CoordSeq) SetX(idx int, val float64)

SetX sets the idx-th X coordinate of s to val.

func (*CoordSeq) SetY ΒΆ

func (s *CoordSeq) SetY(idx int, val float64)

SetY sets the idx-th Y coordinate of s to val.

func (*CoordSeq) SetZ ΒΆ

func (s *CoordSeq) SetZ(idx int, val float64)

SetZ sets the idx-th Z coordinate of s to val.

func (*CoordSeq) Size ΒΆ

func (s *CoordSeq) Size() int

Size returns the size of s.

func (*CoordSeq) ToCoords ΒΆ

func (s *CoordSeq) ToCoords() [][]float64

ToCoords returns s as a [][]float64.

func (*CoordSeq) X ΒΆ

func (s *CoordSeq) X(idx int) float64

X returns the idx-th X coordinate of s.

func (*CoordSeq) Y ΒΆ

func (s *CoordSeq) Y(idx int) float64

Y returns the idx-th Y coordinate of s.

func (*CoordSeq) Z ΒΆ

func (s *CoordSeq) Z(idx int) float64

Z returns the idx-th Z coordinate of s.

type Error ΒΆ

type Error string

An Error is an error returned by GEOS.

func (Error) Error ΒΆ

func (e Error) Error() string

type GeoJSONReader ΒΆ added in v0.20.2

type GeoJSONReader struct {
	// contains filtered or unexported fields
}

A GeoJSONReader reads GeoJSON.

func (*GeoJSONReader) ReadGeometry ΒΆ added in v0.20.2

func (r *GeoJSONReader) ReadGeometry(geoJSON string) (*Geom, error)

ReadGeometry reads a geometry from geoJSON.

type GeoJSONWriter ΒΆ added in v0.20.2

type GeoJSONWriter struct {
	// contains filtered or unexported fields
}

A GeoJSONWriter writes geometries as GeoJSON.

func (*GeoJSONWriter) WriteGeometry ΒΆ added in v0.20.2

func (w *GeoJSONWriter) WriteGeometry(g *Geom, indent int) string

WriteGeometry returns the GeoJSON representation of g.

type Geom ΒΆ

type Geom struct {
	// contains filtered or unexported fields
}

A Geom is a geometry.

func Clone ΒΆ

func Clone(g *Geom) *Geom

Clone clones g into c.

func NewCollection ΒΆ

func NewCollection(typeID TypeID, geoms []*Geom) *Geom

NewCollection returns a new collection.

func NewEmptyCollection ΒΆ

func NewEmptyCollection(typeID TypeID) *Geom

NewEmptyCollection returns a new empty collection.

func NewEmptyLineString ΒΆ

func NewEmptyLineString() *Geom

NewEmptyLineString returns a new empty line string.

func NewEmptyPoint ΒΆ

func NewEmptyPoint() *Geom

NewEmptyPoint returns a new empty point.

func NewEmptyPolygon ΒΆ

func NewEmptyPolygon() *Geom

NewEmptyPolygon returns a new empty polygon.

func NewGeomFromBounds ΒΆ

func NewGeomFromBounds(minX, minY, maxX, maxY float64) *Geom

NewGeomFromBounds returns a new polygon populated with bounds.

func NewGeomFromGeoJSON ΒΆ added in v0.4.0

func NewGeomFromGeoJSON(geoJSON string) (*Geom, error)

NewGeomFromGeoJSON parses a geometry in GeoJSON format from GeoJSON.

func NewGeomFromWKB ΒΆ

func NewGeomFromWKB(wkb []byte) (*Geom, error)

NewGeomFromWKB parses a geometry in WKB format from wkb.

func NewGeomFromWKT ΒΆ

func NewGeomFromWKT(wkt string) (*Geom, error)

NewGeomFromWKT parses a geometry in WKT format from wkt.

func NewLineString ΒΆ

func NewLineString(coords [][]float64) *Geom

NewLineString returns a new line string populated with coords.

func NewLinearRing ΒΆ

func NewLinearRing(coords [][]float64) *Geom

NewLinearRing returns a new linear ring populated with coords.

func NewPoint ΒΆ

func NewPoint(coord []float64) *Geom

NewPoint returns a new point populated with coord.

func NewPointFromXY ΒΆ added in v0.13.0

func NewPointFromXY(x, y float64) *Geom

NewPointFromXY returns a new point with x and y.

func NewPolygon ΒΆ

func NewPolygon(coordss [][][]float64) *Geom

NewPolygon returns a new polygon populated with coordss.

func Polygonize ΒΆ added in v0.9.0

func Polygonize(geoms []*Geom) *Geom

Polygonize returns a set of geometries which contains linework that represents the edges of a planar graph.

func PolygonizeValid ΒΆ added in v0.9.0

func PolygonizeValid(geoms []*Geom) *Geom

PolygonizeValid returns a set of polygons which contains linework that represents the edges of a planar graph.

func (*Geom) Area ΒΆ added in v0.4.0

func (g *Geom) Area() float64

Area returns g's area.

func (*Geom) Boundary ΒΆ added in v0.13.0

func (g *Geom) Boundary() *Geom

Boundary returns the boundary of g.

func (*Geom) Bounds ΒΆ

func (g *Geom) Bounds() *Box2D

Bounds returns g's bounds.

func (*Geom) Buffer ΒΆ added in v0.4.0

func (g *Geom) Buffer(width float64, quadsegs int) *Geom

Buffer returns g with the given buffer.

func (*Geom) BufferWithParams ΒΆ added in v0.17.0

func (g *Geom) BufferWithParams(bufParams *BufParams, width float64) *Geom

BufferWithParams returns g buffered with bufParams.

func (*Geom) BufferWithStyle ΒΆ added in v0.7.0

func (g *Geom) BufferWithStyle(width float64, quadsegs int, endCapStyle BufCapStyle, joinStyle BufJoinStyle, mitreLimit float64) *Geom

BufferWithStyle returns a buffer using the provided style parameters.

func (*Geom) BuildArea ΒΆ added in v0.10.0

func (g *Geom) BuildArea() *Geom

BuildArea returns the polygonization using all the linework, assuming that rings contained within rings are empty holes, rather than extra PolygonHoleSimplify.

func (*Geom) Centroid ΒΆ added in v0.13.0

func (g *Geom) Centroid() *Geom

Centroid returns a point at the center of mass of g.

func (*Geom) ClipByBox2D ΒΆ added in v0.17.0

func (g *Geom) ClipByBox2D(box2d *Box2D) *Geom

ClipByBox2D clips g by box2d.

func (*Geom) ClipByRect ΒΆ added in v0.10.0

func (g *Geom) ClipByRect(minX float64, minY float64, maxX float64, maxY float64) *Geom

ClipByRect returns g clipped to a rectangular polygon.

func (*Geom) Clone ΒΆ

func (g *Geom) Clone() *Geom

Clone returns a clone of g.

func (*Geom) ConcaveHull ΒΆ added in v0.7.0

func (g *Geom) ConcaveHull(ratio float64, allowHoles uint) *Geom

ConcaveHull returns the concave hull of g.

func (*Geom) ConcaveHullByLength ΒΆ added in v0.14.0

func (g *Geom) ConcaveHullByLength(ratio float64, allowHoles uint) *Geom

ConcaveHullByLength returns the concave hull of g.

func (*Geom) ConstrainedDelaunayTriangulation ΒΆ added in v0.13.0

func (g *Geom) ConstrainedDelaunayTriangulation() *Geom

ConstrainedDelaunayTriangulation returns the constrained Delaunay triangulation of the vertices of the g.

func (*Geom) Contains ΒΆ

func (g *Geom) Contains(other *Geom) bool

Contains returns true if g contains other.

func (*Geom) ConvexHull ΒΆ

func (g *Geom) ConvexHull() *Geom

ConvexHull returns g's convex hull.

func (*Geom) CoordSeq ΒΆ

func (g *Geom) CoordSeq() *CoordSeq

CoordSeq returns g's coordinate sequence. The returned CoordSeq is owned by g and will keep it alive.

func (*Geom) CoverageUnion ΒΆ added in v0.10.0

func (g *Geom) CoverageUnion() *Geom

CoverageUnion returns the union of g for polygonal inputs that are correctly noded and do not overlap.

func (*Geom) CoveredBy ΒΆ

func (g *Geom) CoveredBy(other *Geom) bool

CoveredBy returns true if g is covered by other.

func (*Geom) Covers ΒΆ

func (g *Geom) Covers(other *Geom) bool

Covers returns true if g covers other.

func (*Geom) Crosses ΒΆ

func (g *Geom) Crosses(other *Geom) bool

Crosses returns true if g crosses other.

func (*Geom) Densify ΒΆ added in v0.4.0

func (g *Geom) Densify(tolerance float64) *Geom

Densify returns g densified with the given tolerance.

func (*Geom) Difference ΒΆ added in v0.6.0

func (g *Geom) Difference(other *Geom) *Geom

Difference returns the difference between g and other.

func (*Geom) DifferencePrec ΒΆ added in v0.6.0

func (g *Geom) DifferencePrec(other *Geom, gridSize float64) *Geom

DifferencePrec returns the difference between g and other.

func (*Geom) Disjoint ΒΆ

func (g *Geom) Disjoint(other *Geom) bool

Disjoint returns true if g is disjoint from other.

func (*Geom) DisjointSubsetUnion ΒΆ added in v0.20.1

func (g *Geom) DisjointSubsetUnion() *Geom

DisjointSubsetUnion returns the union of all components of a single geometry (optimized for inputs that can be divided into subsets that do not intersect).

func (*Geom) Distance ΒΆ added in v0.3.0

func (g *Geom) Distance(other *Geom) float64

Distance returns the distance between the closes points on g and other.

func (*Geom) DistanceIndexed ΒΆ added in v0.5.0

func (g *Geom) DistanceIndexed(other *Geom) float64

DistanceIndexed returns the distance between g and other, using the indexed facet distance.

func (*Geom) DistanceWithin ΒΆ added in v0.5.0

func (g *Geom) DistanceWithin(other *Geom, dist float64) bool

DistanceWithin returns whether the distance between g and other is within the given dist.

func (*Geom) EndPoint ΒΆ added in v0.13.0

func (g *Geom) EndPoint() *Geom

EndPoint returns the last point of a LineString.

func (*Geom) Envelope ΒΆ

func (g *Geom) Envelope() *Geom

Envelope returns the envelope of g.

func (*Geom) Equals ΒΆ

func (g *Geom) Equals(other *Geom) bool

Equals returns true if g equals other.

func (*Geom) EqualsExact ΒΆ

func (g *Geom) EqualsExact(other *Geom, tolerance float64) bool

EqualsExact returns true if g equals other exactly.

func (*Geom) ExteriorRing ΒΆ

func (g *Geom) ExteriorRing() *Geom

ExteriorRing returns the exterior ring. The returned geometry is a sub-geometry of g and will keep it alive.

func (*Geom) FrechetDistance ΒΆ added in v0.5.0

func (g *Geom) FrechetDistance(other *Geom) float64

FrechetDistance returns the FrΓ©chet distance between g and other.

func (*Geom) FrechetDistanceDensify ΒΆ added in v0.5.0

func (g *Geom) FrechetDistanceDensify(other *Geom, densifyFrac float64) float64

FrechetDistanceDensify returns the FrΓ©chet distance between g and other.

func (*Geom) Geometry ΒΆ

func (g *Geom) Geometry(n int) *Geom

Geometry returns the nth geometry of g. The returned geometry is a sub-geometry of g and will keep it alive.

func (*Geom) HasZ ΒΆ added in v0.10.0

func (g *Geom) HasZ() bool

HasZ returns if g has Z coordinates.

func (*Geom) HausdorffDistance ΒΆ added in v0.5.0

func (g *Geom) HausdorffDistance(other *Geom) float64

HausdorffDistance returns the Hausdorff distance between g and other.

func (*Geom) HausdorffDistanceDensify ΒΆ added in v0.5.0

func (g *Geom) HausdorffDistanceDensify(other *Geom, densifyFrac float64) float64

HausdorffDistanceDensify returns the Hausdorff distance between g and other.

func (*Geom) InteriorRing ΒΆ

func (g *Geom) InteriorRing(n int) *Geom

InteriorRing returns the nth interior ring. The returned geometry is a sub-geometry of g and will keep it alive.

func (*Geom) Interpolate ΒΆ added in v0.7.0

func (g *Geom) Interpolate(d float64) *Geom

Interpolate returns a point distance d from the start of g, which must be a linestring.

func (*Geom) InterpolateNormalized ΒΆ added in v0.7.0

func (g *Geom) InterpolateNormalized(proportion float64) *Geom

InterpolateNormalized returns the point that is at proportion from the start.

func (*Geom) Intersection ΒΆ

func (g *Geom) Intersection(other *Geom) *Geom

Intersection returns the intersection of g and other.

func (*Geom) IntersectionPrec ΒΆ added in v0.7.0

func (g *Geom) IntersectionPrec(other *Geom, gridSize float64) *Geom

IntersectionPrec returns the intersection of g and other.

func (*Geom) Intersects ΒΆ

func (g *Geom) Intersects(other *Geom) bool

Intersects returns true if g intersects other.

func (*Geom) IsClosed ΒΆ

func (g *Geom) IsClosed() bool

IsClosed returns true if g is closed.

func (*Geom) IsEmpty ΒΆ

func (g *Geom) IsEmpty() bool

IsEmpty returns true if g is empty.

func (*Geom) IsRing ΒΆ

func (g *Geom) IsRing() bool

IsRing returns true if g is a ring.

func (*Geom) IsSimple ΒΆ

func (g *Geom) IsSimple() bool

IsSimple returns true if g is simple.

func (*Geom) IsValid ΒΆ

func (g *Geom) IsValid() bool

IsValid returns true if g is valid.

func (*Geom) IsValidReason ΒΆ

func (g *Geom) IsValidReason() string

IsValidReason returns the reason that g is invalid.

func (*Geom) LargestEmptyCircle ΒΆ added in v0.13.0

func (g *Geom) LargestEmptyCircle(other *Geom, tolerance float64) *Geom

LargestEmptyCircle returns the largest empty circle for g, up to a specified tolerance.

func (*Geom) Length ΒΆ added in v0.4.0

func (g *Geom) Length() float64

Length returns g's length.

func (*Geom) LineMerge ΒΆ added in v0.13.0

func (g *Geom) LineMerge() *Geom

LineMerge returns a set of fully noded LineStrings, removing any cardinality 2 nodes in the linework.

func (*Geom) MakeValid ΒΆ added in v0.8.0

func (g *Geom) MakeValid() *Geom

MakeValid repairs an invalid geometry, returning a valid output.

func (*Geom) MakeValidWithParams ΒΆ added in v0.14.0

func (g *Geom) MakeValidWithParams(method MakeValidMethod, collapse MakeValidCollapsed) *Geom

MakeValidWithParams returns a new valid geometry using the MakeValidMethods and MakeValidCollapsed parameters.

func (*Geom) MaximumInscribedCircle ΒΆ added in v0.7.0

func (g *Geom) MaximumInscribedCircle(tolerance float64) *Geom

MaximumInscribedCircle returns the maximum inscribed circle of g up to the the given tolerance.

func (*Geom) MinimumClearance ΒΆ added in v0.13.0

func (g *Geom) MinimumClearance() float64

MinimumClearance returns the minimum clearance of g.

func (*Geom) MinimumClearanceLine ΒΆ added in v0.13.0

func (g *Geom) MinimumClearanceLine() *Geom

MinimumClearanceLine returns a LineString whose endpoints define the minimum clearance of g.

func (*Geom) MinimumRotatedRectangle ΒΆ added in v0.7.0

func (g *Geom) MinimumRotatedRectangle() *Geom

MinimumRotatedRectangle returns the minimum rotated rectangle enclosing g.

func (*Geom) MinimumWidth ΒΆ added in v0.4.0

func (g *Geom) MinimumWidth() *Geom

MinimumWidth returns a linestring geometry which represents the minimum diameter of g.

func (*Geom) NearestPoints ΒΆ added in v0.3.0

func (g *Geom) NearestPoints(other *Geom) [][]float64

NearestPoints returns the nearest coordinates of g and other. If the nearest coordinates do not exist (e.g., when either geom is empty), it returns nil.

func (*Geom) Node ΒΆ added in v0.10.0

func (g *Geom) Node() *Geom

Node returns a new geometry in which no lines cross each other, and all touching occurs at endpoints.

func (*Geom) Normalize ΒΆ added in v0.10.0

func (g *Geom) Normalize() *Geom

func (*Geom) NumCoordinates ΒΆ added in v0.13.0

func (g *Geom) NumCoordinates() int

NumCoordinates returns the number of coordinates in g.

func (*Geom) NumGeometries ΒΆ

func (g *Geom) NumGeometries() int

NumGeometries returns the number of geometries in g.

func (*Geom) NumInteriorRings ΒΆ

func (g *Geom) NumInteriorRings() int

NumInteriorRings returns the number of interior rings in g.

func (*Geom) NumPoints ΒΆ

func (g *Geom) NumPoints() int

NumPoints returns the number of points in g.

func (*Geom) OffsetCurve ΒΆ added in v0.7.0

func (g *Geom) OffsetCurve(width float64, quadsegs int, joinStyle BufJoinStyle, mitreLimit float64) *Geom

OffsetCurve returns the offset curve line(s) of g.

func (*Geom) Overlaps ΒΆ

func (g *Geom) Overlaps(other *Geom) bool

Overlaps returns true if g overlaps other.

func (*Geom) Point ΒΆ

func (g *Geom) Point(n int) *Geom

Point returns the g's nth point.

func (*Geom) PointOnSurface ΒΆ added in v0.13.0

func (g *Geom) PointOnSurface() *Geom

PointOnSurface returns a point that is inside the boundary of a polygonal geometry.

func (*Geom) PolygonizeFull ΒΆ added in v0.9.0

func (g *Geom) PolygonizeFull() (geom, cuts, dangles, invalidRings *Geom)

PolygonizeFull returns a set of geometries which contains linework that represents the edge of a planar graph.

func (*Geom) Precision ΒΆ added in v0.10.0

func (g *Geom) Precision() float64

Precision returns g's precision.

func (*Geom) Prepare ΒΆ

func (g *Geom) Prepare() *PrepGeom

Prepare prepares g.

func (*Geom) Project ΒΆ added in v0.11.0

func (g *Geom) Project(other *Geom) float64

Project returns the distance of other(a point) projected onto g(a line) from the start of the line.

func (*Geom) ProjectNormalized ΒΆ added in v0.11.0

func (g *Geom) ProjectNormalized(other *Geom) float64

ProjectNormalized returns the proportional distance of other(a point) projected onto g(a line) from the start of the line. For example, a point that projects to the middle of a line would be return 0.5.

func (*Geom) Relate ΒΆ added in v0.12.0

func (g *Geom) Relate(other *Geom) string

Relate returns the DE9IM pattern for g and other.

func (*Geom) RelateBoundaryNodeRule ΒΆ added in v0.12.0

func (g *Geom) RelateBoundaryNodeRule(other *Geom, bnr RelateBoundaryNodeRule) string

RelateBoundaryNodeRule returns the DE9IM pattern for g and other.

func (*Geom) RelatePattern ΒΆ added in v0.12.0

func (g *Geom) RelatePattern(other *Geom, pat string) bool

RelatePattern returns if the DE9IM pattern for g and other matches pat.

func (*Geom) ReleaseCollection ΒΆ added in v0.22.0

func (g *Geom) ReleaseCollection() []*Geom

ReleaseCollection removes and returns all the geometries from the collection g.

func (*Geom) Reverse ΒΆ added in v0.12.0

func (g *Geom) Reverse() *Geom

Reverse returns g with sequence orders reversed.

func (*Geom) SRID ΒΆ

func (g *Geom) SRID() int

SRID returns g's SRID.

func (*Geom) SetPrecision ΒΆ added in v0.8.0

func (g *Geom) SetPrecision(gridSize float64, flags PrecisionRule) *Geom

SetPrecision changes the coordinate precision of g.

func (*Geom) SetSRID ΒΆ

func (g *Geom) SetSRID(srid int) *Geom

SetSRID sets g's SRID to srid.

func (*Geom) SetUserData ΒΆ added in v0.10.0

func (g *Geom) SetUserData(userdata uintptr) *Geom

SetUserData sets g's userdata and returns g.

func (*Geom) SharedPaths ΒΆ added in v0.10.0

func (g *Geom) SharedPaths(other *Geom) *Geom

SharedPaths returns the paths shared between g and other, which must be lineal geometries.

func (*Geom) Simplify ΒΆ added in v0.8.0

func (g *Geom) Simplify(tolerance float64) *Geom

Simplify returns a simplified geometry.

func (*Geom) Snap ΒΆ added in v0.13.0

func (g *Geom) Snap(other *Geom, tolerance float64) *Geom

Snap returns a geometry with the vertices and segments of g snapped to other within the given tolerance.

func (*Geom) StartPoint ΒΆ added in v0.13.0

func (g *Geom) StartPoint() *Geom

StartPoint returns the first point of a LineString.

func (*Geom) String ΒΆ

func (g *Geom) String() string

String returns g in WKT format.

func (*Geom) SymDifference ΒΆ added in v0.7.0

func (g *Geom) SymDifference(other *Geom) *Geom

SymDifference returns the symmetric difference between g and other.

func (*Geom) SymDifferencePrec ΒΆ added in v0.10.0

func (g *Geom) SymDifferencePrec(other *Geom, gridSize float64) *Geom

SymDifferencePrec returns the symmetric difference between g and other.

func (*Geom) ToEWKBWithSRID ΒΆ added in v0.16.0

func (g *Geom) ToEWKBWithSRID() []byte

ToEWKBWithSRID returns g in Extended WKB format with its SRID.

func (*Geom) ToGeoJSON ΒΆ added in v0.4.0

func (g *Geom) ToGeoJSON(indent int) string

ToGeoJSON returns g in GeoJSON format.

func (*Geom) ToWKB ΒΆ

func (g *Geom) ToWKB() []byte

ToWKB returns g in WKB format.

func (*Geom) ToWKT ΒΆ

func (g *Geom) ToWKT() string

ToWKT returns g in WKT format.

func (*Geom) TopologyPreserveSimplify ΒΆ added in v0.8.0

func (g *Geom) TopologyPreserveSimplify(tolerance float64) *Geom

TopologyPreserveSimplify returns a simplified geometry preserving topology.

func (*Geom) Touches ΒΆ

func (g *Geom) Touches(other *Geom) bool

Touches returns true if g touches other.

func (*Geom) Type ΒΆ

func (g *Geom) Type() string

Type returns g's type.

func (*Geom) TypeID ΒΆ

func (g *Geom) TypeID() TypeID

TypeID returns g's geometry type id.

func (*Geom) UnaryUnion ΒΆ added in v0.4.0

func (g *Geom) UnaryUnion() *Geom

UnaryUnion returns the union of all components of a single geometry.

func (*Geom) UnaryUnionPrec ΒΆ added in v0.10.0

func (g *Geom) UnaryUnionPrec(gridSize float64) *Geom

UnaryUnionPrec returns the union of all components of a single geometry.

func (*Geom) Union ΒΆ added in v0.10.0

func (g *Geom) Union(other *Geom) *Geom

Union returns the union of g and other.

func (*Geom) UnionPrec ΒΆ added in v0.10.0

func (g *Geom) UnionPrec(other *Geom, gridSize float64) *Geom

UnionPrec returns the union of g and other.

func (*Geom) UserData ΒΆ added in v0.10.0

func (g *Geom) UserData() uintptr

UserData returns g's userdata.

func (*Geom) VoronoiDiagram ΒΆ added in v0.21.0

func (g *Geom) VoronoiDiagram(env *Geom, tolerance float64, flags VoronoiDiagramFlag) *Geom

VoronoiDiagram returns the Voronoi diagram of the vertices of g.

func (*Geom) Within ΒΆ

func (g *Geom) Within(other *Geom) bool

Within returns true if g is within other.

func (*Geom) X ΒΆ

func (g *Geom) X() float64

X returns g's X coordinate.

func (*Geom) Y ΒΆ

func (g *Geom) Y() float64

Y returns g's Y coordinate.

type MakeValidCollapsed ΒΆ added in v0.14.0

type MakeValidCollapsed int
const (
	MakeValidDiscardCollapsed MakeValidCollapsed = 0
	MakeValidKeepCollapsed    MakeValidCollapsed = C.GEOS_PREC_KEEP_COLLAPSED
)

MakeValidMethods.

type MakeValidMethod ΒΆ added in v0.14.0

type MakeValidMethod int
const (
	MakeValidLinework  MakeValidMethod = C.GEOS_MAKE_VALID_LINEWORK
	MakeValidStructure MakeValidMethod = C.GEOS_MAKE_VALID_STRUCTURE
)

MakeValidMethods.

type PrecisionRule ΒΆ added in v0.8.0

type PrecisionRule int
const (
	PrecisionRuleNone          PrecisionRule = 0
	PrecisionRuleValidOutput   PrecisionRule = C.GEOS_PREC_VALID_OUTPUT
	PrecisionRuleNoTopo        PrecisionRule = C.GEOS_PREC_NO_TOPO
	PrecisionRulePointwise     PrecisionRule = C.GEOS_PREC_NO_TOPO
	PrecisionRuleKeepCollapsed PrecisionRule = C.GEOS_PREC_KEEP_COLLAPSED
)

Precision rules.

type PrepGeom ΒΆ

type PrepGeom struct {
	// contains filtered or unexported fields
}

A PrepGeom is a prepared geometry.

Example ΒΆ
package main

import (
	"fmt"

	"github.com/twpayne/go-geos"
)

func main() {
	geom, err := geos.NewGeomFromWKT("POLYGON ((189 115, 200 170, 130 170, 35 242, 156 215, 210 290, 274 256, 360 190, 267 215, 300 50, 200 60, 189 115))")
	if err != nil {
		panic(err)
	}
	prepGeom := geom.Prepare()
	point := geos.NewPointFromXY(190, 200)
	if prepGeom.Intersects(point) {
		fmt.Println("intersects")
	}
}
Output:
intersects

func (*PrepGeom) Contains ΒΆ

func (pg *PrepGeom) Contains(g *Geom) bool

Contains returns if pg contains g.

func (*PrepGeom) ContainsProperly ΒΆ

func (pg *PrepGeom) ContainsProperly(g *Geom) bool

ContainsProperly returns if pg contains g properly.

func (*PrepGeom) ContainsXY ΒΆ added in v0.19.0

func (pg *PrepGeom) ContainsXY(x, y float64) bool

ContainsXY returns if pg contains the point (x, y).

func (*PrepGeom) CoveredBy ΒΆ

func (pg *PrepGeom) CoveredBy(g *Geom) bool

CoveredBy returns if pg is covered by g.

func (*PrepGeom) Covers ΒΆ

func (pg *PrepGeom) Covers(g *Geom) bool

Covers returns if pg covers g.

func (*PrepGeom) Crosses ΒΆ

func (pg *PrepGeom) Crosses(g *Geom) bool

Crosses returns if pg crosses g.

func (*PrepGeom) Disjoint ΒΆ

func (pg *PrepGeom) Disjoint(g *Geom) bool

Disjoint returns if pg is disjoint from g.

func (*PrepGeom) DistanceWithin ΒΆ added in v0.19.0

func (pg *PrepGeom) DistanceWithin(g *Geom, dist float64) bool

DistanceWithin returns if pg is within dist g.

func (*PrepGeom) Intersects ΒΆ

func (pg *PrepGeom) Intersects(g *Geom) bool

Intersects returns if pg contains g.

func (*PrepGeom) IntersectsXY ΒΆ added in v0.19.0

func (pg *PrepGeom) IntersectsXY(x, y float64) bool

IntersectsXY returns if pg intersects the point at (x, y).

func (*PrepGeom) NearestPoints ΒΆ added in v0.19.0

func (pg *PrepGeom) NearestPoints(g *Geom) *CoordSeq

NearestPoints returns if pg overlaps g.

func (*PrepGeom) Overlaps ΒΆ

func (pg *PrepGeom) Overlaps(g *Geom) bool

Overlaps returns if pg overlaps g.

func (*PrepGeom) Touches ΒΆ

func (pg *PrepGeom) Touches(g *Geom) bool

Touches returns if pg contains g.

func (*PrepGeom) Within ΒΆ

func (pg *PrepGeom) Within(g *Geom) bool

Within returns if pg is within g.

type RelateBoundaryNodeRule ΒΆ added in v0.12.0

type RelateBoundaryNodeRule int

A RelateBoundaryNodeRule is a relate boundary node rule.

const (
	RelateBoundaryNodeRuleMod2                RelateBoundaryNodeRule = C.GEOSRELATE_BNR_MOD2
	RelateBoundaryNodeRuleOGC                 RelateBoundaryNodeRule = C.GEOSRELATE_BNR_OGC
	RelateBoundaryNodeRuleEndpoint            RelateBoundaryNodeRule = C.GEOSRELATE_BNR_ENDPOINT
	RelateBoundaryNodeRuleMultivalentEndpoint RelateBoundaryNodeRule = C.GEOSRELATE_BNR_MULTIVALENT_ENDPOINT
	RelateBoundaryNodeRuleMonovalentEndpoint  RelateBoundaryNodeRule = C.GEOSRELATE_BNR_MONOVALENT_ENDPOINT
)

Boundary node rules.

type STRtree ΒΆ added in v0.12.0

type STRtree struct {
	// contains filtered or unexported fields
}

An STRtree is an R-tree spatial index structure for two dimensional data.

WARNING The Go bindings to STRtree are currently broken. Do not use them.

func NewSTRtree ΒΆ added in v0.20.2

func NewSTRtree(nodeCapacity int) *STRtree

NewSTRtree returns a new STRtree with the given number of entries per node.

func (*STRtree) Insert ΒΆ added in v0.12.0

func (t *STRtree) Insert(g *Geom, value any) error

Insert inserts value with geometry g.

func (*STRtree) Iterate ΒΆ added in v0.12.0

func (t *STRtree) Iterate(callback func(any))

Iterate calls f for every value in the t.

func (*STRtree) Nearest ΒΆ added in v0.12.0

func (t *STRtree) Nearest(geom *Geom) *Geom

Nearest returns the nearest geometry to geom in t.

WARNING Nearest is currently broken and always panics with a segmentation fault.

func (*STRtree) NearestGeneric ΒΆ added in v0.20.2

func (t *STRtree) NearestGeneric(value any, valueEnvelope *Geom, distanceFunc func(any, any) float64) any

NearestGeneric returns the nearest value to value.

WARNING NearestGeneric is currently broken and always panics with a segmentation fault.

func (*STRtree) Query ΒΆ added in v0.12.0

func (t *STRtree) Query(g *Geom, callback func(any))

Query calls f with each value that intersects g.

func (*STRtree) Remove ΒΆ added in v0.12.0

func (t *STRtree) Remove(g *Geom, value any) bool

Remove removes value with geometry g from t.

type TypeID ΒΆ added in v0.7.0

type TypeID int

A TypeID is a geometry type id.

const (
	TypeIDPoint              TypeID = C.GEOS_POINT
	TypeIDLineString         TypeID = C.GEOS_LINESTRING
	TypeIDLinearRing         TypeID = C.GEOS_LINEARRING
	TypeIDPolygon            TypeID = C.GEOS_POLYGON
	TypeIDMultiPoint         TypeID = C.GEOS_MULTIPOINT
	TypeIDMultiLineString    TypeID = C.GEOS_MULTILINESTRING
	TypeIDMultiPolygon       TypeID = C.GEOS_MULTIPOLYGON
	TypeIDGeometryCollection TypeID = C.GEOS_GEOMETRYCOLLECTION
)

Geometry type ids.

type VoronoiDiagramFlag ΒΆ added in v0.21.0

type VoronoiDiagramFlag int
const (
	VoronoiDiagramFlagOnlyEdges     VoronoiDiagramFlag = C.GEOS_VORONOI_ONLY_EDGES
	VoronoiDiagramFlagPreserveOrder VoronoiDiagramFlag = C.GEOS_VORONOI_PRESERVE_ORDER
)

Voronoi diagram flags.

type WKBFlavor ΒΆ added in v0.20.2

type WKBFlavor int

A WKBFlavor is a flavor of WKB.

const (
	WKBFlavorExtended WKBFlavor = C.GEOS_WKB_EXTENDED
	WKBFlavorISO      WKBFlavor = C.GEOS_WKB_ISO
)

WKB flavors.

type WKBReader ΒΆ added in v0.20.2

type WKBReader struct {
	// contains filtered or unexported fields
}

A WKBReader reads geometries from WKB (Well Known Binary).

func (*WKBReader) Read ΒΆ added in v0.20.2

func (r *WKBReader) Read(wkb []byte) (*Geom, error)

Read reads a geometry from wkb.

type WKBWriter ΒΆ added in v0.20.2

type WKBWriter struct {
	// contains filtered or unexported fields
}

A WKBWriter writes geometries as WKB (Well Known Binary).

func (*WKBWriter) Write ΒΆ added in v0.20.2

func (w *WKBWriter) Write(g *Geom) []byte

Write returns the WKB representation of g.

type WKBWriterOption ΒΆ added in v0.20.2

type WKBWriterOption func(*WKBWriter)

A WKBWriterOption sets an option on a WKBWriter.

func WithWKBWriterFlavor ΒΆ added in v0.20.2

func WithWKBWriterFlavor(flavor WKBFlavor) WKBWriterOption

WithWKBWriterFlavor sets the WKB flavor.

func WithWKBWriterIncludeSRID ΒΆ added in v0.20.2

func WithWKBWriterIncludeSRID(includeSRID bool) WKBWriterOption

WithWKBWriterIncludeSRID sets whether to include the SRID.

type WKTReader ΒΆ added in v0.20.2

type WKTReader struct {
	// contains filtered or unexported fields
}

A WKTReader reads geometries from WKT (Well Known Text).

func (*WKTReader) Read ΒΆ added in v0.20.2

func (r *WKTReader) Read(wkt string) (*Geom, error)

Read reads a geometry from wkt.

type WKTWriter ΒΆ added in v0.20.2

type WKTWriter struct {
	// contains filtered or unexported fields
}

A WKTWriter writes geometries in WKT (Well Known Text).

func (*WKTWriter) Write ΒΆ added in v0.20.2

func (w *WKTWriter) Write(g *Geom) string

Write returns the WKT representation of g.

Directories ΒΆ

Path Synopsis
examples module
Package geojson implements GEOS-backed GeoJSON.
Package geojson implements GEOS-backed GeoJSON.
Package geometry provides a GEOS-backed geometry type.
Package geometry provides a GEOS-backed geometry type.
internal
cmds/execute-template command
execute-template executes a Go template with data.
execute-template executes a Go template with data.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL