geos

package
v0.49.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: MIT Imports: 2 Imported by: 1

Documentation

Overview

Package geos provides a cgo wrapper around the GEOS (Geometry Engine, Open Source) library. See https://www.osgeo.org/projects/geos/ for more details.

Its purpose is to provide functionality that has been implemented in GEOS, but is not yet available natively in the simplefeatures library.

Results from functions in this package are returned from GEOS unvalidated and as-is. Users may call the Validate method on results if they wish to check result validity.

The operations in this package ignore Z and M values if they are present.

To use this package, you will need to install the GEOS library.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Buffer

func Buffer(g geom.Geometry, radius float64, opts ...BufferOption) (geom.Geometry, error)

Buffer returns a geometry that contains all points within the given radius of the input geometry.

The validity of the result is not checked.

func ConcaveHull added in v0.48.0

func ConcaveHull(g geom.Geometry, concavenessRatio float64, allowHoles bool) (geom.Geometry, error)

ConcaveHull returns concave hull of input geometry. concavenessRatio - ratio 0 to 1 (0 - max concaveness, 1 - convex hull) allowHoles - true to allow holes inside of polygons.

func Contains

func Contains(a, b geom.Geometry) (bool, error)

Contains returns true if and only if geometry A contains geometry B. Formally, the following two conditions must hold:

1. No points of B lies on the exterior of geometry A. That is, B must only be in the exterior or boundary of A.

2 .At least one point of the interior of B lies on the interior of A. That is, they can't *only* intersect at their boundaries.

func CoverageUnion added in v0.43.0

func CoverageUnion(g geom.Geometry) (geom.Geometry, error)

The CoverageUnion function is used to union polygonal inputs that form a coverage, which are typically provided as a GeometryCollection. This method is much faster than other unioning methods, but there are some constraints that must be met by the inputs to form a valid polygonal coverage. These constraints are:

  1. all input geometries must be polygonal,
  2. the interiors of the inputs must not intersect, and
  3. the common boundaries of adjacent polygons have the same set of vertices in both polygons.

It should be noted that while CoverageUnion may detect constraint violations and return an error, but this is not guaranteed, and an invalid result may be returned without an error. It is the responsibility of the caller to ensure that the constraints are met before using this function.

The validity of the result is not checked.

func CoveredBy

func CoveredBy(a, b geom.Geometry) (bool, error)

CoveredBy returns true if and only if geometry A is covered by geometry B. Formally, the following two conditions must hold:

1. No points of A lies on the exterior of geometry B. That is, A must only be in the exterior or boundary of B.

2. At least one point of A lies on B (either its interior or boundary).

func Covers

func Covers(a, b geom.Geometry) (bool, error)

Covers returns true if and only if geometry A covers geometry B. Formally, the following two conditions must hold:

1. No points of B lies on the exterior of geometry A. That is, B must only be in the exterior or boundary of A.

2. At least one point of B lies on A (either its interior or boundary).

func Crosses

func Crosses(a, b geom.Geometry) (bool, error)

Crosses returns true if and only if geometry A and B cross each other. Formally, the following conditions must hold:

1. The geometries must have some but not all interior points in common.

2. The dimensionality of the intersection must be less than the maximum dimension of the input geometries.

3. The intersection must not equal either of the input geometries.

func Difference added in v0.16.0

func Difference(a, b geom.Geometry) (geom.Geometry, error)

Difference returns the geometry that represents the parts of input geometry A that are not part of input geometry B.

The validity of the result is not checked.

func Disjoint

func Disjoint(a, b geom.Geometry) (bool, error)

Disjoint returns true if and only if the input geometries have no points in common.

func Equals

func Equals(a, b geom.Geometry) (bool, error)

Equals returns true if and only if the input geometries are spatially equal, i.e. they represent exactly the same set of points.

func Intersection

func Intersection(a, b geom.Geometry) (geom.Geometry, error)

Intersection returns a geometry that is the intersection of the input geometries. Formally, the returned geometry will contain a particular point X if and only if X is present in both geometries.

The validity of the result is not checked.

func Intersects

func Intersects(a, b geom.Geometry) (bool, error)

Intersects returns true if and only if the geometries share at least one point in common.

func MakeValid added in v0.35.0

func MakeValid(g geom.Geometry) (geom.Geometry, error)

MakeValid can be used to convert an invalid geometry into a valid geometry. It does this by keeping the original control points and constructing a new geometry that is valid and similar (but not the same as) the original invalid geometry. If the input geometry is valid, then it is returned unaltered.

The validity of the result is not checked.

func Overlaps

func Overlaps(a, b geom.Geometry) (bool, error)

Overlaps returns true if and only if geometry A and B overlap with each other. Formally, the following conditions must hold:

1. The geometries must have the same dimension.

2. The geometries must have some but not all points in common.

3. The intersection of the geometries must have the same dimension as the geometries themselves.

func Relate added in v0.17.0

func Relate(g1, g2 geom.Geometry) (string, error)

Relate returns a 9-character DE9-IM string that describes the relationship between two geometries.

func Simplify added in v0.12.0

func Simplify(g geom.Geometry, tolerance float64) (geom.Geometry, error)

Simplify creates a simplified version of a geometry using the Douglas-Peucker algorithm. Topological invariants may not be maintained, e.g. polygons can collapse into linestrings, and holes in polygons may be lost.

The validity of the result is not checked.

func SymmetricDifference added in v0.16.0

func SymmetricDifference(a, b geom.Geometry) (geom.Geometry, error)

SymmetricDifference returns the geometry that represents the parts of the input geometries that are not part of the other input geometry.

The validity of the result is not checked.

func Touches

func Touches(a, b geom.Geometry) (bool, error)

Touches returns true if and only if the geometries have at least 1 point in common, but their interiors don't intersect.

func UnaryUnion added in v0.43.0

func UnaryUnion(g geom.Geometry) (geom.Geometry, error)

UnaryUnion is a single argument version of Union. It is most useful when supplied with a GeometryCollection, resulting in the union of the GeometryCollection's child geometries.

The validity of the result is not checked.

func Union

func Union(a, b geom.Geometry) (geom.Geometry, error)

Union returns a geometry that is the union of the input geometries. Formally, the returned geometry will contain a particular point X if and only if X is present in either geometry (or both).

The validity of the result is not checked.

func Within

func Within(a, b geom.Geometry) (bool, error)

Within returns true if and only if geometry A is completely within geometry B. Formally, the following two conditions must hold:

1. No points of A lies on the exterior of geometry B. That is, A must only be in the exterior or boundary of B.

2.At least one point of the interior of A lies on the interior of B. That is, they can't *only* intersect at their boundaries.

Types

type BufferOption added in v0.20.0

type BufferOption func(*bufferOptionSet)

BufferOption allows the behaviour of the Buffer operation to be modified.

func BufferEndCapFlat added in v0.20.0

func BufferEndCapFlat() BufferOption

BufferEndCapFlat sets the end cap style to 'flat'. It is 'round' by default.

func BufferEndCapRound added in v0.20.0

func BufferEndCapRound() BufferOption

BufferEndCapRound sets the end cap style to 'round'. It is 'round' by default.

func BufferEndCapSquare added in v0.20.0

func BufferEndCapSquare() BufferOption

BufferEndCapSquare sets the end cap style to 'square'. It is 'round' by default.

func BufferJoinStyleBevel added in v0.20.0

func BufferJoinStyleBevel() BufferOption

BufferJoinStyleBevel sets the join style to 'bevel'. It is 'round' by default.

func BufferJoinStyleMitre added in v0.20.0

func BufferJoinStyleMitre(mitreLimit float64) BufferOption

BufferJoinStyleMitre sets the join style to 'mitre'. It is 'round' by default.

func BufferJoinStyleRound added in v0.20.0

func BufferJoinStyleRound() BufferOption

BufferJoinStyleRound sets the join style to 'round'. It is 'round' by default.

func BufferQuadSegments added in v0.20.0

func BufferQuadSegments(quadSegments int) BufferOption

BufferQuadSegments sets the number of segments used to approximate a quarter circle. It defaults to 8.

Jump to

Keyboard shortcuts

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