Documentation ¶
Index ¶
- Constants
- Variables
- func Equal(g1, g2 Geometry) bool
- type Bound
- func (b Bound) Bottom() float64
- func (b Bound) Bound() Bound
- func (b Bound) Center() Point
- func (b Bound) Contains(point Point) bool
- func (b Bound) Dimensions() int
- func (b Bound) Equal(c Bound) bool
- func (b Bound) Extend(point Point) Bound
- func (b Bound) GeoJSONType() string
- func (b Bound) Intersects(bound Bound) bool
- func (b Bound) IsEmpty() bool
- func (b Bound) IsZero() bool
- func (b Bound) Left() float64
- func (b Bound) LeftTop() Point
- func (b Bound) Pad(d float64) Bound
- func (b Bound) Right() float64
- func (b Bound) RightBottom() Point
- func (b Bound) ToPolygon() Polygon
- func (b Bound) ToRing() Ring
- func (b Bound) Top() float64
- func (b Bound) Union(other Bound) Bound
- type Collection
- type DistanceFunc
- type Geometry
- type LineString
- type MultiLineString
- type MultiPoint
- type MultiPolygon
- type Orientation
- type Point
- type Pointer
- type Polygon
- type Projection
- type Ring
- type Simplifier
Constants ¶
const EarthRadius = 6378137.0 // meters
EarthRadius is the radius of the earth in meters. It is used in geo distance calculations. To keep things consistent, this value matches WGS84 Web Mercator (EPSG:3857).
Variables ¶
var AllGeometries = []Geometry{ nil, Point{}, MultiPoint{}, LineString{}, MultiLineString{}, Ring{}, Polygon{}, MultiPolygon{}, Bound{}, Collection{}, MultiPoint(nil), LineString(nil), MultiLineString(nil), Ring(nil), Polygon(nil), MultiPolygon(nil), Collection(nil), Collection{Collection{Point{}}}, }
AllGeometries lists all possible types and values that a geometry interface can be. It should be used only for testing to verify functions that accept a Geometry will work in all cases.
var DefaultRoundingFactor = 1e6 // 6 decimal places
DefaultRoundingFactor is the default rounding factor used by the Round func.
Functions ¶
Types ¶
type Bound ¶
type Bound struct {
Min, Max Point
}
A Bound represents a closed box or rectangle. To create a bound with two points you can do something like:
orb.MultiPoint{p1, p2}.Bound()
func (Bound) Contains ¶
Contains determines if the point is within the bound. Points on the boundary are considered within.
func (Bound) Dimensions ¶
Dimensions returns 2 because a Bound is a 2d object.
func (Bound) GeoJSONType ¶
GeoJSONType returns the GeoJSON type for the object.
func (Bound) Intersects ¶
Intersects determines if two bounds intersect. Returns true if they are touching.
func (Bound) IsEmpty ¶
IsEmpty returns true if it contains zero area or if it's in some malformed negative state where the left point is larger than the right. This can be caused by padding too much negative.
func (Bound) RightBottom ¶
RightBottom return the lower right point of the bound.
type Collection ¶
type Collection []Geometry
A Collection is a collection of geometries that is also a Geometry.
func (Collection) Bound ¶
func (c Collection) Bound() Bound
Bound returns the bounding box of all the Geometries combined.
func (Collection) Clone ¶
func (c Collection) Clone() Collection
Clone returns a deep copy of the collection.
func (Collection) Dimensions ¶
func (c Collection) Dimensions() int
Dimensions returns the max of the dimensions of the collection.
func (Collection) Equal ¶
func (c Collection) Equal(collection Collection) bool
Equal compares two collections. Returns true if lengths are the same and all the sub geometries are the same and in the same order.
func (Collection) GeoJSONType ¶
func (c Collection) GeoJSONType() string
GeoJSONType returns the geometry collection type.
type DistanceFunc ¶
A DistanceFunc is a function that computes the distance between two points.
type Geometry ¶
type Geometry interface { GeoJSONType() string Dimensions() int // e.g. 0d, 1d, 2d Bound() Bound // contains filtered or unexported methods }
Geometry is an interface that represents the shared attributes of a geometry.
type LineString ¶
type LineString []Point
LineString represents a set of points to be thought of as a polyline.
func (LineString) Bound ¶
func (ls LineString) Bound() Bound
Bound returns a rect around the line string. Uses rectangular coordinates.
func (LineString) Clone ¶
func (ls LineString) Clone() LineString
Clone returns a new copy of the line string.
func (LineString) Dimensions ¶
func (ls LineString) Dimensions() int
Dimensions returns 1 because a LineString is a 1d object.
func (LineString) Equal ¶
func (ls LineString) Equal(lineString LineString) bool
Equal compares two line strings. Returns true if lengths are the same and all points are Equal.
func (LineString) GeoJSONType ¶
func (ls LineString) GeoJSONType() string
GeoJSONType returns the GeoJSON type for the object.
func (LineString) Reverse ¶
func (ls LineString) Reverse()
Reverse will reverse the line string. This is done inplace, ie. it modifies the original data.
type MultiLineString ¶
type MultiLineString []LineString
MultiLineString is a set of polylines.
func (MultiLineString) Bound ¶
func (mls MultiLineString) Bound() Bound
Bound returns a bound around all the line strings.
func (MultiLineString) Clone ¶
func (mls MultiLineString) Clone() MultiLineString
Clone returns a new deep copy of the multi line string.
func (MultiLineString) Dimensions ¶
func (mls MultiLineString) Dimensions() int
Dimensions returns 1 because a MultiLineString is a 2d object.
func (MultiLineString) Equal ¶
func (mls MultiLineString) Equal(multiLineString MultiLineString) bool
Equal compares two multi line strings. Returns true if lengths are the same and all points are Equal.
func (MultiLineString) GeoJSONType ¶
func (mls MultiLineString) GeoJSONType() string
GeoJSONType returns the GeoJSON type for the object.
type MultiPoint ¶
type MultiPoint []Point
A MultiPoint represents a set of points in the 2D Eucledian or Cartesian plane.
func (MultiPoint) Bound ¶
func (mp MultiPoint) Bound() Bound
Bound returns a bound around the points. Uses rectangular coordinates.
func (MultiPoint) Clone ¶
func (mp MultiPoint) Clone() MultiPoint
Clone returns a new copy of the points.
func (MultiPoint) Dimensions ¶
func (mp MultiPoint) Dimensions() int
Dimensions returns 0 because a MultiPoint is a 0d object.
func (MultiPoint) Equal ¶
func (mp MultiPoint) Equal(multiPoint MultiPoint) bool
Equal compares two MultiPoint objects. Returns true if lengths are the same and all points are Equal, and in the same order.
func (MultiPoint) GeoJSONType ¶
func (mp MultiPoint) GeoJSONType() string
GeoJSONType returns the GeoJSON type for the object.
type MultiPolygon ¶
type MultiPolygon []Polygon
MultiPolygon is a set of polygons.
func (MultiPolygon) Bound ¶
func (mp MultiPolygon) Bound() Bound
Bound returns a bound around the multi-polygon.
func (MultiPolygon) Clone ¶
func (mp MultiPolygon) Clone() MultiPolygon
Clone returns a new deep copy of the multi-polygon.
func (MultiPolygon) Dimensions ¶
func (mp MultiPolygon) Dimensions() int
Dimensions returns 2 because a MultiPolygon is a 2d object.
func (MultiPolygon) Equal ¶
func (mp MultiPolygon) Equal(multiPolygon MultiPolygon) bool
Equal compares two multi-polygons.
func (MultiPolygon) GeoJSONType ¶
func (mp MultiPolygon) GeoJSONType() string
GeoJSONType returns the GeoJSON type for the object.
type Orientation ¶
type Orientation int8
Orientation defines the order of the points in a polygon or closed ring.
const ( // CCW stands for Counter Clock Wise CCW Orientation = 1 // CW stands for Clock Wise CW Orientation = -1 )
Constants to define orientation. They follow the right hand rule for orientation.
type Point ¶
type Point [2]float64
A Point is a Lon/Lat 2d point.
func (Point) Dimensions ¶
Dimensions returns 0 because a point is a 0d object.
func (Point) GeoJSONType ¶
GeoJSONType returns the GeoJSON type for the object.
type Pointer ¶
type Pointer interface {
Point() Point
}
Pointer is something that can be represented by a point.
type Polygon ¶
type Polygon []Ring
Polygon is a closed area. The first LineString is the outer ring. The others are the holes. Each LineString is expected to be closed ie. the first point matches the last.
func (Polygon) Clone ¶
Clone returns a new deep copy of the polygon. All of the rings are also cloned.
func (Polygon) Dimensions ¶
Dimensions returns 2 because a Polygon is a 2d object.
func (Polygon) Equal ¶
Equal compares two polygons. Returns true if lengths are the same and all points are Equal.
func (Polygon) GeoJSONType ¶
GeoJSONType returns the GeoJSON type for the object.
type Projection ¶
A Projection a function that moves a point from one space to another.
type Ring ¶
type Ring LineString
Ring represents a set of ring on the earth.
func (Ring) Closed ¶
Closed will return true if the ring is a real ring. ie. 4+ points and the first and last points match. NOTE: this will not check for self-intersection.
func (Ring) Dimensions ¶
Dimensions returns 2 because a Ring is a 2d object.
func (Ring) Equal ¶
Equal compares two rings. Returns true if lengths are the same and all points are Equal.
func (Ring) GeoJSONType ¶
GeoJSONType returns the GeoJSON type for the object.
func (Ring) Orientation ¶
func (r Ring) Orientation() Orientation
Orientation returns 1 if the the ring is in couter-clockwise order, return -1 if the ring is the clockwise order and 0 if the ring is degenerate and had no area.
type Simplifier ¶
type Simplifier interface { Simplify(g Geometry) Geometry LineString(ls LineString) LineString MultiLineString(mls MultiLineString) MultiLineString Ring(r Ring) Ring Polygon(p Polygon) Polygon MultiPolygon(mp MultiPolygon) MultiPolygon Collection(c Collection) Collection }
A Simplifier is something that can simplify geometry.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package clip is a library for clipping geometry to a bounding box.
|
Package clip is a library for clipping geometry to a bounding box. |
smartclip
Package smartclip performs a more advanced clipping algorithm so it can deal with correctly oriented open rings and polygon.
|
Package smartclip performs a more advanced clipping algorithm so it can deal with correctly oriented open rings and polygon. |
encoding
|
|
mvt/vectortile
Package vectortile is a generated protocol buffer package.
|
Package vectortile is a generated protocol buffer package. |
wkb
Package wkb is for decoding ESRI's Well Known Binary (WKB) format sepcification at http://edndoc.esri.com/arcsde/9.1/general_topics/wkb_representation.htm
|
Package wkb is for decoding ESRI's Well Known Binary (WKB) format sepcification at http://edndoc.esri.com/arcsde/9.1/general_topics/wkb_representation.htm |
Package geo computes properties on geometries assuming they are lon/lat data.
|
Package geo computes properties on geometries assuming they are lon/lat data. |
Package geojson is a library for encoding and decoding GeoJSON into Go structs using the geometries in the orb package.
|
Package geojson is a library for encoding and decoding GeoJSON into Go structs using the geometries in the orb package. |
internal
|
|
Package maptile defines a Tile type and methods to work with web map projected tile data.
|
Package maptile defines a Tile type and methods to work with web map projected tile data. |
tilecover
Package tilecover computes the covering set of tiles for an orb.Geometry.
|
Package tilecover computes the covering set of tiles for an orb.Geometry. |
Package planar computes properties on geometries assuming they are in 2d euclidean space.
|
Package planar computes properties on geometries assuming they are in 2d euclidean space. |
Package project defines projections to and from Mercator and WGS84 along with helpers to apply them to orb geometry types.
|
Package project defines projections to and from Mercator and WGS84 along with helpers to apply them to orb geometry types. |
Package quadtree implements a quadtree using rectangular partitions.
|
Package quadtree implements a quadtree using rectangular partitions. |
Package resample has a couple functions for resampling line geometry into more or less evenly spaces points.
|
Package resample has a couple functions for resampling line geometry into more or less evenly spaces points. |
Package simplify implements several reducing/simplifying functions for `orb.Geometry` types.
|
Package simplify implements several reducing/simplifying functions for `orb.Geometry` types. |