Documentation
¶
Overview ¶
Package geom holds geometry objects and functions to operate on them. They can be encoded and decoded by other packages in this repository.
Index ¶
- type Bounds
- func (b *Bounds) Bounds() *Bounds
- func (b *Bounds) Copy() *Bounds
- func (b *Bounds) Empty() bool
- func (b *Bounds) Extend(b2 *Bounds)
- func (b *Bounds) Overlaps(b2 *Bounds) bool
- func (b *Bounds) Similar(g Geom, tolerance float64) bool
- func (b *Bounds) Transform(t proj.Transformer) (Geom, error)
- func (b *Bounds) Within(poly Polygonal) bool
- type Geom
- type GeometryCollection
- type LineString
- type Linear
- type MultiLineString
- func (ml MultiLineString) Bounds() *Bounds
- func (ml MultiLineString) Length() float64
- func (ml MultiLineString) Similar(g Geom, tolerance float64) bool
- func (ml MultiLineString) Simplify(tolerance float64) Geom
- func (ml MultiLineString) Transform(t proj.Transformer) (Geom, error)
- func (ml MultiLineString) Within(p Polygonal) bool
- type MultiPoint
- type MultiPolygon
- func (mp MultiPolygon) Area() float64
- func (mp MultiPolygon) Bounds() *Bounds
- func (mp MultiPolygon) Centroid() Point
- func (mp MultiPolygon) Difference(p2 Polygonal) Polygon
- func (mp MultiPolygon) Intersection(p2 Polygonal) Polygon
- func (mp MultiPolygon) Polygons() []Polygon
- func (mp MultiPolygon) Similar(g Geom, tolerance float64) bool
- func (mp MultiPolygon) Simplify(tolerance float64) Geom
- func (mp MultiPolygon) Transform(t proj.Transformer) (Geom, error)
- func (mp MultiPolygon) Union(p2 Polygonal) Polygon
- func (mp MultiPolygon) XOr(p2 Polygonal) Polygon
- type Point
- type PointLike
- type Polygon
- func (p Polygon) Area() float64
- func (p Polygon) Bounds() *Bounds
- func (p Polygon) Centroid() Point
- func (p Polygon) Difference(p2 Polygonal) Polygon
- func (p Polygon) Intersection(p2 Polygonal) Polygon
- func (p Polygon) Polygons() []Polygon
- func (p Polygon) Similar(g Geom, tolerance float64) bool
- func (p Polygon) Simplify(tolerance float64) Geom
- func (p Polygon) Transform(t proj.Transformer) (Geom, error)
- func (p Polygon) Union(p2 Polygonal) Polygon
- func (p Polygon) XOr(p2 Polygonal) Polygon
- type Polygonal
- type Simplifier
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bounds ¶
type Bounds struct {
Min, Max Point
}
Bounds holds the spatial extent of a geometry.
func NewBoundsPoint ¶
NewBoundsPoint creates a bounds object from a point.
type Geom ¶
type Geom interface { Bounds() *Bounds Similar(Geom, float64) bool Transform(proj.Transformer) (Geom, error) }
Geom is an interface for generic geometry types.
type GeometryCollection ¶
type GeometryCollection []Geom
GeometryCollection is a holder for multiple related geometry objects of arbitrary type.
func (GeometryCollection) Bounds ¶
func (gc GeometryCollection) Bounds() *Bounds
Bounds gives the rectangular extents of the GeometryCollection.
func (GeometryCollection) Similar ¶
func (gc GeometryCollection) Similar(g Geom, tolerance float64) bool
Similar determines whether two geometries collections are similar within tolerance. If gc and g have the same geometries but in a different order, it will return true.
func (GeometryCollection) Transform ¶
func (gc GeometryCollection) Transform(t proj.Transformer) (Geom, error)
Transform shifts the coordinates of gc according to t.
type LineString ¶
type LineString []Point
LineString is a number of points that make up a path or line.
func (LineString) Bounds ¶
func (l LineString) Bounds() *Bounds
Bounds gives the rectangular extents of the LineString.
func (LineString) Similar ¶
func (l LineString) Similar(g Geom, tolerance float64) bool
Similar determines whether two geometries are similar within tolerance. If two lines contain the same points but in different directions it will return false.
func (LineString) Simplify ¶
func (l LineString) Simplify(tolerance float64) Geom
Simplify simplifies l by removing points according to the tolerance parameter, while ensuring that the resulting shape is not self intersecting (but only if the input shape is not self intersecting).
It is based on the algorithm: J. L. G. Pallero, Robust line simplification on the plane. Comput. Geosci. 61, 152–159 (2013).
func (LineString) Transform ¶
func (l LineString) Transform(t proj.Transformer) (Geom, error)
Transform shifts the coordinates of l according to t.
func (LineString) Within ¶
func (l LineString) Within(p Polygonal) bool
Within calculates whether l is completely within p.
type Linear ¶
type Linear interface { Geom Length() float64 //Clip(Polygonal) Linear //Intersection(Linear) MultiPoint Simplify(tolerance float64) Geom Within(Polygonal) bool }
Linear is an interface for types that are linear in nature.
type MultiLineString ¶
type MultiLineString []LineString
MultiLineString is a holder for multiple related LineStrings.
func (MultiLineString) Bounds ¶
func (ml MultiLineString) Bounds() *Bounds
Bounds gives the rectangular extents of the MultiLineString.
func (MultiLineString) Length ¶
func (ml MultiLineString) Length() float64
Length calculates the combined length of the linestrings in ml.
func (MultiLineString) Similar ¶
func (ml MultiLineString) Similar(g Geom, tolerance float64) bool
Similar determines whether two geometries are similar within tolerance. If ml and g have the similar linestrings but in a different order, it will return true.
func (MultiLineString) Simplify ¶
func (ml MultiLineString) Simplify(tolerance float64) Geom
Simplify simplifies ml by removing points according to the tolerance parameter, while ensuring that the resulting shape is not self intersecting (but only if the input shape is not self intersecting).
It is based on the algorithm: J. L. G. Pallero, Robust line simplification on the plane. Comput. Geosci. 61, 152–159 (2013).
func (MultiLineString) Transform ¶
func (ml MultiLineString) Transform(t proj.Transformer) (Geom, error)
Transform shifts the coordinates of ml according to t.
func (MultiLineString) Within ¶
func (ml MultiLineString) Within(p Polygonal) bool
Within calculates whether ml is completely within p.
type MultiPoint ¶
type MultiPoint []Point
MultiPoint is a holder for multiple related points.
func (MultiPoint) Bounds ¶
func (mp MultiPoint) Bounds() *Bounds
Bounds gives the rectangular extents of the MultiPoint.
func (MultiPoint) Similar ¶
func (mp MultiPoint) Similar(g Geom, tolerance float64) bool
Similar determines whether two geometries are similar within tolerance.
func (MultiPoint) Transform ¶
func (mp MultiPoint) Transform(t proj.Transformer) (Geom, error)
Transform shifts the coordinates of mp according to t.
func (MultiPoint) Within ¶
func (mp MultiPoint) Within(poly Polygonal) bool
Within calculates whether all of the points in mp are within poly.
type MultiPolygon ¶
type MultiPolygon []Polygon
MultiPolygon is a holder for multiple related polygons.
func (MultiPolygon) Area ¶
func (mp MultiPolygon) Area() float64
Area returns the combined area of the polygons in p. The function works correctly for polygons with holes, regardless of the winding order of the holes, but may give the wrong result for self-intersecting polygons, or polygons in mp that overlap each other.
func (MultiPolygon) Bounds ¶
func (mp MultiPolygon) Bounds() *Bounds
Bounds gives the rectangular extents of the MultiPolygon.
func (MultiPolygon) Centroid ¶
func (mp MultiPolygon) Centroid() Point
Centroid calculates the centroid of mp, from wikipedia: http://en.wikipedia.org/wiki/Centroid#Centroid_of_polygon. The polygon can have holes, but each ring must be closed (i.e., p[0] == p[n-1], where the ring has n points) and must not be self-intersecting. The algorithm will not check to make sure the holes are actually inside the outer rings.
func (MultiPolygon) Difference ¶
func (mp MultiPolygon) Difference(p2 Polygonal) Polygon
Difference subtracts p2 from mp.
func (MultiPolygon) Intersection ¶
func (mp MultiPolygon) Intersection(p2 Polygonal) Polygon
Intersection returns the area(s) shared by mp and p2.
func (MultiPolygon) Polygons ¶
func (mp MultiPolygon) Polygons() []Polygon
Polygons returns the polygons that make up mp.
func (MultiPolygon) Similar ¶
func (mp MultiPolygon) Similar(g Geom, tolerance float64) bool
Similar determines whether two geometries are similar within tolerance. If ml and g have the similar polygons but in a different order, it will return true.
func (MultiPolygon) Simplify ¶
func (mp MultiPolygon) Simplify(tolerance float64) Geom
Simplify simplifies mp by removing points according to the tolerance parameter, while ensuring that the resulting shape is not self intersecting (but only if the input shape is not self intersecting). Self-intersecting polygons may cause the algorithm to fall into an infinite loop.
It is based on the algorithm: J. L. G. Pallero, Robust line simplification on the plane. Comput. Geosci. 61, 152–159 (2013).
func (MultiPolygon) Transform ¶
func (mp MultiPolygon) Transform(t proj.Transformer) (Geom, error)
Transform shifts the coordinates of mp according to t.
func (MultiPolygon) Union ¶
func (mp MultiPolygon) Union(p2 Polygonal) Polygon
Union returns the combination of mp and p2.
func (MultiPolygon) XOr ¶
func (mp MultiPolygon) XOr(p2 Polygonal) Polygon
XOr returns the area(s) occupied by either mp or p2 but not both.
type Point ¶
type Point struct {
X, Y float64
}
Point is a holder for 2D coordinates X and Y.
type PointLike ¶
type PointLike interface { Geom Points() []Point //On(l Linear, tolerance float64) bool Within(Polygonal) bool }
PointLike is an interface for types that are pointlike in nature.
type Polygon ¶
type Polygon [][]Point
A Polygon is a series of closed rings. The inner rings should be nested inside of the outer ring.
func (Polygon) Area ¶
Area returns the area of p. The function works correctly for polygons with holes, regardless of the winding order of the holes, but will give the wrong result for self-intersecting polygons.
func (Polygon) Centroid ¶
Centroid calculates the centroid of p, from wikipedia: http://en.wikipedia.org/wiki/Centroid#Centroid_of_polygon. The polygon can have holes, but each ring must be closed (i.e., p[0] == p[n-1], where the ring has n points) and must not be self-intersecting. The algorithm will not check to make sure the holes are actually inside the outer rings.
func (Polygon) Difference ¶
Difference subtracts p2 from p.
func (Polygon) Intersection ¶
Intersection returns the area(s) shared by p and p2.
func (Polygon) Similar ¶
Similar determines whether two geometries are similar within tolerance. If p and g have the same points with the same winding direction, but a different starting point, it will return true. If they have the same rings but in a different order, it will return true. If the rings have the same points but different winding directions, it will return false.
func (Polygon) Simplify ¶
Simplify simplifies p by removing points according to the tolerance parameter, while ensuring that the resulting shape is not self intersecting (but only if the input shape is not self intersecting). Self-intersecting polygons may cause the algorithm to fall into an infinite loop.
It is based on the algorithm: J. L. G. Pallero, Robust line simplification on the plane. Comput. Geosci. 61, 152–159 (2013).
func (Polygon) Transform ¶
func (p Polygon) Transform(t proj.Transformer) (Geom, error)
Transform shifts the coordinates of p according to t.
type Polygonal ¶
type Polygonal interface { Geom Polygons() []Polygon Intersection(Polygonal) Polygon Union(Polygonal) Polygon XOr(Polygonal) Polygon Difference(Polygonal) Polygon Area() float64 Simplify(tolerance float64) Geom Centroid() Point }
Polygonal is an interface for types that are polygonal in nature.
type Simplifier ¶
Simplifier is an interface for types that can be simplified.
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
Package carto is a Go language map drawing library
|
Package carto is a Go language map drawing library |
encoding
|
|
osm
Package osm extracts and manipulates OpenStreetMap (OSM) data.
|
Package osm extracts and manipulates OpenStreetMap (OSM) data. |
shp
Package shp decodes and encodes shapefiles to and from geometry objects.
|
Package shp decodes and encodes shapefiles to and from geometry objects. |
index
|
|
rtree
A library for efficiently storing and querying spatial data.
|
A library for efficiently storing and querying spatial data. |
Package op provides implementation of algorithms for geometry operations.
|
Package op provides implementation of algorithms for geometry operations. |
Package route finds the shortest route between two points along a geometrical network (e.g., a road network).
|
Package route finds the shortest route between two points along a geometrical network (e.g., a road network). |