geomfn

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

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

Go to latest
Published: Jun 17, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package geomfn contains functions that are used for geometry-based builtins.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Area

func Area(g *geo.Geometry) (float64, error)

Area returns the area of a given Geometry.

func Azimuth

func Azimuth(a *geo.Geometry, b *geo.Geometry) (*float64, error)

Azimuth returns the azimuth in radians of the segment defined by the given point geometries, where point a is the reference point. The reference direction from which the azimuth is calculated is north, and is positive clockwise. i.e. North = 0; East = π/2; South = π; West = 3π/2. See https://en.wikipedia.org/wiki/Polar_coordinate_system. Returns nil if the two points are the same. Returns an error if any of the two Geometry items are not points.

func Buffer

func Buffer(g *geo.Geometry, params BufferParams, distance float64) (*geo.Geometry, error)

Buffer buffers a given Geometry by the supplied parameters.

func Centroid

func Centroid(g *geo.Geometry) (*geo.Geometry, error)

Centroid returns the Centroid of a given Geometry.

func Contains

func Contains(a *geo.Geometry, b *geo.Geometry) (bool, error)

Contains returns whether geometry A contains geometry B.

func ContainsProperly

func ContainsProperly(a *geo.Geometry, b *geo.Geometry) (bool, error)

ContainsProperly returns whether geometry A properly contains geometry B.

func ConvexHull

func ConvexHull(g *geo.Geometry) (*geo.Geometry, error)

ConvexHull returns the convex hull of a given Geometry.

func CoveredBy

func CoveredBy(a *geo.Geometry, b *geo.Geometry) (bool, error)

CoveredBy returns whether geometry A is covered by geometry B.

func Covers

func Covers(a *geo.Geometry, b *geo.Geometry) (bool, error)

Covers returns whether geometry A covers geometry B.

func Crosses

func Crosses(a *geo.Geometry, b *geo.Geometry) (bool, error)

Crosses returns whether geometry A crosses geometry B.

func DFullyWithin

func DFullyWithin(a *geo.Geometry, b *geo.Geometry, d float64) (bool, error)

DFullyWithin determines whether the maximum distance across every pair of points comprising geometries A and B is within D units.

func DWithin

func DWithin(a *geo.Geometry, b *geo.Geometry, d float64) (bool, error)

DWithin determines if any part of geometry A is within D units of geometry B.

func Equals

func Equals(a *geo.Geometry, b *geo.Geometry) (bool, error)

Equals returns whether geometry A equals geometry B.

func Intersection

func Intersection(a *geo.Geometry, b *geo.Geometry) (*geo.Geometry, error)

Intersection returns the geometries of intersection between A and B.

func Intersects

func Intersects(a *geo.Geometry, b *geo.Geometry) (bool, error)

Intersects returns whether geometry A intersects geometry B.

func Length

func Length(g *geo.Geometry) (float64, error)

Length returns the length of a given Geometry. Note only (MULTI)LINESTRING objects have a length. (MULTI)POLYGON objects should use Perimeter.

func LineInterpolatePoints

func LineInterpolatePoints(g *geo.Geometry, fraction float64, repeat bool) (*geo.Geometry, error)

LineInterpolatePoints returns one or more points along the given LineString which are at an integral multiples of given fraction of LineString's total length. When repeat is set to false, it returns the first point.

func LongestLineString

func LongestLineString(a *geo.Geometry, b *geo.Geometry) (*geo.Geometry, error)

LongestLineString returns the LineString corresponds to maximum distance across every pair of points comprising geometries A and B.

func MakePolygon

func MakePolygon(outer *geo.Geometry, interior ...*geo.Geometry) (*geo.Geometry, error)

MakePolygon creates a Polygon geometry from linestring and optional inner linestrings. Returns errors if geometries are not linestrings.

func MatchesDE9IM

func MatchesDE9IM(relation string, pattern string) (bool, error)

MatchesDE9IM checks whether the given DE-9IM relation matches the DE-91M pattern. Assumes the relation has been computed, and such has no 'T' and '*' characters. See: https://en.wikipedia.org/wiki/DE-9IM.

func MaxDistance

func MaxDistance(a *geo.Geometry, b *geo.Geometry) (float64, error)

MaxDistance returns the maximum distance across every pair of points comprising geometries A and B.

func MinDistance

func MinDistance(a *geo.Geometry, b *geo.Geometry) (float64, error)

MinDistance returns the minimum distance between geometries A and B. This returns a geo.EmptyGeometryError if either A or B is EMPTY.

func Overlaps

func Overlaps(a *geo.Geometry, b *geo.Geometry) (bool, error)

Overlaps returns whether geometry A overlaps geometry B.

func Perimeter

func Perimeter(g *geo.Geometry) (float64, error)

Perimeter returns the perimeter of a given Geometry. Note only (MULTI)POLYGON objects have a perimeter. (MULTI)LineString objects should use Length.

func PointOnSurface

func PointOnSurface(g *geo.Geometry) (*geo.Geometry, error)

PointOnSurface returns the PointOnSurface of a given Geometry.

func Relate

func Relate(a *geo.Geometry, b *geo.Geometry) (string, error)

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

func RelatePattern

func RelatePattern(a *geo.Geometry, b *geo.Geometry, pattern string) (bool, error)

RelatePattern returns whether the DE-9IM relation between A and B matches.

func Segmentize

func Segmentize(g *geo.Geometry, segmentMaxLength float64) (*geo.Geometry, error)

Segmentize return modified Geometry having no segment longer that given maximum segment length. This works by inserting the extra points in such a manner that minimum number of new segments with equal length is created, between given two-points such that each segment has length less than or equal to given maximum segment length.

func ShortestLineString

func ShortestLineString(a *geo.Geometry, b *geo.Geometry) (*geo.Geometry, error)

ShortestLineString returns the LineString corresponds to minimum distance across every pair of points comprising geometries A and B.

func Touches

func Touches(a *geo.Geometry, b *geo.Geometry) (bool, error)

Touches returns whether geometry A touches geometry B.

func Union

func Union(a *geo.Geometry, b *geo.Geometry) (*geo.Geometry, error)

Union returns the geometries of intersection between A and B.

func Within

func Within(a *geo.Geometry, b *geo.Geometry) (bool, error)

Within returns whether geometry A is within geometry B.

Types

type BufferParams

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

BufferParams is a wrapper around the geos.BufferParams.

func MakeDefaultBufferParams

func MakeDefaultBufferParams() BufferParams

MakeDefaultBufferParams returns the default BufferParams/

func ParseBufferParams

func ParseBufferParams(s string, distance float64) (BufferParams, float64, error)

ParseBufferParams parses the given buffer params from a SQL string into the BufferParams form. The string must be of the same format as specified by https://postgis.net/docs/ST_Buffer.html. Returns the BufferParams, as well as the modified distance.

func (BufferParams) WithQuadrantSegments

func (b BufferParams) WithQuadrantSegments(quadrantSegments int) BufferParams

WithQuadrantSegments returns a copy of the BufferParams with the quadrantSegments set.

Jump to

Keyboard shortcuts

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