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 geom.Geometry.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 ¶
- func Buffer(g geom.Geometry, radius float64, opts ...BufferOption) (geom.Geometry, error)
- func ConcaveHull(g geom.Geometry, concavenessRatio float64, allowHoles bool) (geom.Geometry, error)
- func Contains(a, b geom.Geometry) (bool, error)
- func CoverageIsValid(g geom.Geometry, gapWidth float64) (bool, geom.Geometry, error)
- func CoverageSimplifyVW(g geom.Geometry, tolerance float64, preserveBoundary bool) (geom.Geometry, error)
- func CoverageUnion(g geom.Geometry) (geom.Geometry, error)
- func CoveredBy(a, b geom.Geometry) (bool, error)
- func Covers(a, b geom.Geometry) (bool, error)
- func Crosses(a, b geom.Geometry) (bool, error)
- func Difference(a, b geom.Geometry) (geom.Geometry, error)
- func Disjoint(a, b geom.Geometry) (bool, error)
- func Equals(a, b geom.Geometry) (bool, error)
- func Intersection(a, b geom.Geometry) (geom.Geometry, error)
- func Intersects(a, b geom.Geometry) (bool, error)
- func MakeValid(g geom.Geometry) (geom.Geometry, error)
- func Overlaps(a, b geom.Geometry) (bool, error)
- func Relate(g1, g2 geom.Geometry) (string, error)
- func Simplify(g geom.Geometry, tolerance float64) (geom.Geometry, error)
- func SymmetricDifference(a, b geom.Geometry) (geom.Geometry, error)
- func TopologyPreserveSimplify(g geom.Geometry, tolerance float64) (geom.Geometry, error)
- func Touches(a, b geom.Geometry) (bool, error)
- func UnaryUnion(g geom.Geometry) (geom.Geometry, error)
- func Union(a, b geom.Geometry) (geom.Geometry, error)
- func Within(a, b geom.Geometry) (bool, error)
- type BufferOption
- func BufferEndCapFlat() BufferOption
- func BufferEndCapRound() BufferOption
- func BufferEndCapSquare() BufferOption
- func BufferJoinStyleBevel() BufferOption
- func BufferJoinStyleMitre(mitreLimit float64) BufferOption
- func BufferJoinStyleRound() BufferOption
- func BufferQuadSegments(quadSegments int) BufferOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Buffer ¶
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
ConcaveHull returns a concave hull of the input. A concave hull is generally a geom.Polygon, but could also be a 2-point geom.LineString or a geom.Point in degenerate cases. It will be made of vertices that are a subset of the input vertices. The concavenessRatio parameter controls the concaveness of the hull (a value of 1 will produce convex hulls, and a value of 0 will produce maximally concave hulls). The allowHoles parameter controls whether holes are allowed in the hull.
func Contains ¶
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 CoverageIsValid ¶ added in v0.51.0
CoverageIsValid checks if a coverage (provided as a geom.GeometryCollection) is valid. Coverage validity is indicated by the boolean return value. A valid coverage must have the following properties:
all input geometries are of type geom.Polygon or geom.MultiPolygon,
the interiors of the inputs do not intersect, and
the common boundaries of adjacent [geom.Polygon]s or [geom.MultiPolygon]s have the same set of vertices.
If the coverage is not valid, then the returned geometry shows the invalid edges.
func CoverageSimplifyVW ¶ added in v0.51.0
func CoverageSimplifyVW(g geom.Geometry, tolerance float64, preserveBoundary bool) (geom.Geometry, error)
CoverageSimplifyVW simplifies a polygon coverage, provided as a geom.GeometryCollection of [geom.Polygon]s and/or [geom.MultiPolygon]s. It uses the Visvalingam–Whyatt algorithm and relies on the coverage being valid (see the CoverageIsValid function for details).
It may not check that the input forms a valid coverage, so it's possible that an incorrect result is returned without an error.
The validity of the result is not checked.
func CoverageUnion ¶ added in v0.43.0
The CoverageUnion function is used to union polygonal inputs that form a coverage, provided as a geom.GeometryCollection of [geom.Polygon]s and/or [geom.MultiPolygon]s. This method is much faster than other unioning methods, but it relies on the input being a valid coverage (see the CoverageIsValid function for details).
CoverageUnion may detect that the input is not a coverage and return an error, but this is not guaranteed (causing an invalid result to be returned without an error). It is the responsibility of the caller to ensure that the is valid before using this function.
The validity of the result is not checked.
func CoveredBy ¶
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 ¶
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 ¶
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
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 Equals ¶
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 ¶
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 ¶
Intersects returns true if and only if the geometries share at least one point in common.
func MakeValid ¶ added in v0.35.0
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 ¶
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
Relate returns a 9-character DE9-IM string that describes the relationship between two geometries.
func Simplify ¶ added in v0.12.0
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
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 TopologyPreserveSimplify ¶ added in v0.51.0
TopologyPreserveSimplify creates a simplified version of a geometry using the Douglas-Peucker algorithm. An attempt is made to preserve topological invariants, e.g. ring collapse and intersection.
The validity of the result is not checked.
func Touches ¶
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
UnaryUnion is a single argument version of Union. It is most useful when supplied with a geom.GeometryCollection, resulting in the union of the geom.GeometryCollection's child geometries.
The validity of the result is not checked.
func Union ¶
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 ¶
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.