geos

package
v0.0.0-...-1b6ad0c Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2020 License: Apache-2.0 Imports: 8 Imported by: 3

Documentation

Overview

Package geos is a wrapper around the spatial data types between the geo package and the GEOS C library. The GEOS library is dynamically loaded at init time. Operations will error if the GEOS library was not found.

Index

Constants

View Source
const (
	BufferParamsJoinStyleRound = 1
	BufferParamsJoinStyleMitre = 2
	BufferParamsJoinStyleBevel = 3
)

These should be kept in sync with the geos_c.h.in corresponding enum definition.

View Source
const (
	BufferParamsEndCapStyleRound  = 1
	BufferParamsEndCapStyleFlat   = 2
	BufferParamsEndCapStyleSquare = 3
)

These should be kept in sync with the geos_c.h.in corresponding enum definition.

Variables

This section is empty.

Functions

func Area

func Area(ewkb geopb.EWKB) (float64, error)

Area returns the area of an EWKB.

func Buffer

func Buffer(ewkb geopb.EWKB, params BufferParams, distance float64) (geopb.EWKB, error)

Buffer buffers the given geometry by the given distance and params.

func Centroid

func Centroid(ewkb geopb.EWKB) (geopb.EWKB, error)

Centroid returns the centroid of an EWKB.

func ClipEWKBByRect

func ClipEWKBByRect(
	ewkb geopb.EWKB, xMin float64, yMin float64, xMax float64, yMax float64,
) (geopb.EWKB, error)

ClipEWKBByRect clips a EWKB to the specified rectangle.

func Contains

func Contains(a geopb.EWKB, b geopb.EWKB) (bool, error)

Contains returns whether the EWKB provided by A contains the EWKB provided by B.

func ConvexHull

func ConvexHull(ewkb geopb.EWKB) (geopb.EWKB, error)

ConvexHull returns an EWKB which returns the convex hull of the given EWKB.

func CoveredBy

func CoveredBy(a geopb.EWKB, b geopb.EWKB) (bool, error)

CoveredBy returns whether the EWKB provided by A is covered by the EWKB provided by B.

func Covers

func Covers(a geopb.EWKB, b geopb.EWKB) (bool, error)

Covers returns whether the EWKB provided by A covers the EWKB provided by B.

func Crosses

func Crosses(a geopb.EWKB, b geopb.EWKB) (bool, error)

Crosses returns whether the EWKB provided by A crosses the EWKB provided by B.

func EnsureInit

func EnsureInit(
	errDisplay EnsureInitErrorDisplay, flagLibraryDirectoryValue string,
) (string, error)

EnsureInit attempts to start GEOS if it has not been opened already and returns the location if found, and an error if the CR_GEOS is not valid.

func Equals

func Equals(a geopb.EWKB, b geopb.EWKB) (bool, error)

Equals returns whether the EWKB provided by A equals the EWKB provided by B.

func InterpolateLine

func InterpolateLine(ewkb geopb.EWKB, distance float64) (geopb.EWKB, error)

InterpolateLine returns the point along the given LineString which is at a given distance from starting point. Note: For distance less than 0 it returns start point similarly for distance greater LineString's length. InterpolateLine also works with (Multi)LineString. However, the result is not appropriate as it combines all the LineString present in (MULTI)LineString, considering all the corner points of LineString overlaps each other.

func Intersection

func Intersection(a geopb.EWKB, b geopb.EWKB) (geopb.EWKB, error)

Intersection returns an EWKB which contains the geometries of intersection between A and B.

func Intersects

func Intersects(a geopb.EWKB, b geopb.EWKB) (bool, error)

Intersects returns whether the EWKB provided by A intersects the EWKB provided by B.

func Length

func Length(ewkb geopb.EWKB) (float64, error)

Length returns the length of an EWKB.

func MinDistance

func MinDistance(a geopb.EWKB, b geopb.EWKB) (float64, error)

MinDistance returns the minimum distance between two EWKBs.

func Overlaps

func Overlaps(a geopb.EWKB, b geopb.EWKB) (bool, error)

Overlaps returns whether the EWKB provided by A overlaps the EWKB provided by B.

func PointOnSurface

func PointOnSurface(ewkb geopb.EWKB) (geopb.EWKB, error)

PointOnSurface returns an EWKB with a point that is on the surface of the given EWKB.

func Relate

func Relate(a geopb.EWKB, b geopb.EWKB) (string, error)

Relate returns the DE-9IM relation between A and B.

func RelatePattern

func RelatePattern(a geopb.EWKB, b geopb.EWKB, pattern string) (bool, error)

RelatePattern whether A and B have a DE-9IM relation matching the given pattern.

func Touches

func Touches(a geopb.EWKB, b geopb.EWKB) (bool, error)

Touches returns whether the EWKB provided by A touches the EWKB provided by B.

func Union

func Union(a geopb.EWKB, b geopb.EWKB) (geopb.EWKB, error)

Union returns an EWKB which is a union of shapes A and B.

func WKTToEWKB

func WKTToEWKB(wkt geopb.WKT, srid geopb.SRID) (geopb.EWKB, error)

WKTToEWKB parses a WKT into WKB using the GEOS library.

func Within

func Within(a geopb.EWKB, b geopb.EWKB) (bool, error)

Within returns whether the EWKB provided by A is within the EWKB provided by B.

Types

type BufferParams

type BufferParams struct {
	JoinStyle        BufferParamsJoinStyle
	EndCapStyle      BufferParamsEndCapStyle
	SingleSided      bool
	QuadrantSegments int
	MitreLimit       float64
}

BufferParams are parameters to provide into the GEOS buffer function.

type BufferParamsEndCapStyle

type BufferParamsEndCapStyle int

BufferParamsEndCapStyle maps to the GEOSBufCapStyles enum in geos_c.h.in.

type BufferParamsJoinStyle

type BufferParamsJoinStyle int

BufferParamsJoinStyle maps to the GEOSBufJoinStyles enum in geos_c.h.in.

type EnsureInitErrorDisplay

type EnsureInitErrorDisplay int

EnsureInitErrorDisplay is used to control the error message displayed by EnsureInit.

const (
	// EnsureInitErrorDisplayPrivate displays the full error message, including
	// path info. It is intended for log messages.
	EnsureInitErrorDisplayPrivate EnsureInitErrorDisplay = iota
	// EnsureInitErrorDisplayPublic displays a redacted error message, excluding
	// path info. It is intended for errors to display for the client.
	EnsureInitErrorDisplayPublic
)

type Error

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

A Error wraps an error returned from a GEOS operation.

func (*Error) Error

func (err *Error) Error() string

Error implements the error interface.

Jump to

Keyboard shortcuts

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