geom

package module
v0.0.0-...-8d1fdb3 Latest Latest
Warning

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

Go to latest
Published: May 12, 2016 License: BSD-2-Clause Imports: 3 Imported by: 0

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

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 NewBounds

func NewBounds() *Bounds

NewBounds initializes a new bounds object.

func NewBoundsPoint

func NewBoundsPoint(point Point) *Bounds

NewBoundsPoint creates a bounds object from a point.

func (*Bounds) Bounds

func (b *Bounds) Bounds() *Bounds

Bounds returns b

func (*Bounds) Copy

func (b *Bounds) Copy() *Bounds

Copy returns a copy of b.

func (*Bounds) Empty

func (b *Bounds) Empty() bool

Empty returns true if b does not contain any points.

func (*Bounds) Extend

func (b *Bounds) Extend(b2 *Bounds)

Extend increases the extent of b1 to include b2.

func (*Bounds) Overlaps

func (b *Bounds) Overlaps(b2 *Bounds) bool

Overlaps returns whether b and b2 overlap.

func (*Bounds) Similar

func (b *Bounds) Similar(g Geom, tolerance float64) bool

Similar determines whether two bounds are similar within tolerance.

func (*Bounds) Transform

func (b *Bounds) Transform(t proj.Transformer) (Geom, error)

Transform shifts the coordinates of b according to t.

func (*Bounds) Within

func (b *Bounds) Within(poly Polygonal) bool

Within calculates whether b is within poly.

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) Length

func (l LineString) Length() float64

Length calculates the length of l.

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.

func NewPoint

func NewPoint(x, y float64) *Point

NewPoint returns a new point with coordinates x and y.

func (Point) Bounds

func (p Point) Bounds() *Bounds

Bounds gives the rectangular extents of the Point.

func (Point) Similar

func (p Point) Similar(g Geom, tolerance float64) bool

Similar determines whether two geometries are similar within tolerance.

func (Point) Transform

func (p Point) Transform(t proj.Transformer) (Geom, error)

Transform shifts the coordinates of p according to t.

func (Point) Within

func (p Point) Within(poly Polygonal) bool

Within calculates whether p is within poly.

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

func (p Polygon) Area() float64

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) Bounds

func (p Polygon) Bounds() *Bounds

Bounds gives the rectangular extents of the polygon.

func (Polygon) Centroid

func (p Polygon) Centroid() Point

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

func (p Polygon) Difference(p2 Polygonal) Polygon

Difference subtracts p2 from p.

func (Polygon) Intersection

func (p Polygon) Intersection(p2 Polygonal) Polygon

Intersection returns the area(s) shared by p and p2.

func (Polygon) Polygons

func (p Polygon) Polygons() []Polygon

Polygons returns []{p} to fulfill the Polygonal interface.

func (Polygon) Similar

func (p Polygon) Similar(g Geom, tolerance float64) bool

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

func (p Polygon) Simplify(tolerance float64) Geom

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.

func (Polygon) Union

func (p Polygon) Union(p2 Polygonal) Polygon

Union returns the combination of p and p2.

func (Polygon) XOr

func (p Polygon) XOr(p2 Polygonal) Polygon

XOr returns the area(s) occupied by either p or p2 but not both.

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

type Simplifier interface {
	Simplify(tolerance float64) Geom
}

Simplifier is an interface for types that can be simplified.

Directories

Path Synopsis
Package carto is a Go language map drawing library
Package carto is a Go language map drawing library
encoding
hex
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.
wkb
wkt
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).

Jump to

Keyboard shortcuts

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