README

Godoc

geom

Geometry interfaces to help drive interoperability within the Go geospatial community. This package focuses on 2D geometries.

Dependencies

Dependencies are managed through go mod with the execption of one package:

Expand ▾ Collapse ▴

Documentation

Overview

Package geom describes geometry interfaces.

Index

Constants

const (
	// PrecisionLevelBigFloat is the precision of big floats, rounding if over
	PrecisionLevelBigFloat = 20
)

Variables

var EmptyPoint = Point{nan, nan}

EmptyPoint describes an empty 2D point object.


var ErrInvalidLineString = errors.New("geom: invalid LineString")

ErrInvalidLineString is thrown when a LineString is malformed


var ErrInvalidLineStringM = errors.New("geom: invalid LineStringM")

ErrInvalidLineStringM is thrown when a LineStringM is malformed


var ErrInvalidLineStringMS = errors.New("geom: invalid LineStringMS")

ErrInvalidLineStringMS is thrown when a LineStringMS is malformed


var ErrInvalidLineStringS = errors.New("geom: invalid LineStringS")

ErrInvalidLineStringS is thrown when a LineStringS is malformed


var ErrInvalidLineStringZ = errors.New("geom: invalid LineStringZ")

ErrInvalidLineStringZ is thrown when a LineStringZ is malformed


var ErrInvalidLineStringZM = errors.New("geom: invalid LineStringZM")

ErrInvalidLineStringZM is thrown when a LineStringZM is malformed


var ErrInvalidLineStringZMS = errors.New("geom: invalid LineStringZMS")

ErrInvalidLineStringZMS is thrown when a LineStringZMS is malformed


var ErrInvalidLineStringZS = errors.New("geom: invalid LineStringZS")

ErrInvalidLineStringZS is thrown when a LineStringZS is malformed


var ErrInvalidLinearRing = errors.New("geom: invalid LinearRing")

ErrInvalidLinearRing is thrown when a LinearRing is malformed


var ErrInvalidPolygon = errors.New("geom: invalid Polygon")

ErrInvalidPolygon is thrown when a Polygon is malformed


var ErrNilCollection = errors.New("geom: nil collection")

ErrNilCollection is thrown when a collection is nil but shouldn't be


var ErrNilLineString = errors.New("geom: nil LineString")

ErrNilLineString is thrown when a LineString is nil but shouldn't be


var ErrNilLineStringM = errors.New("geom: nil LineStringM")

ErrNilLineStringM is thrown when a LineStringM is nil but shouldn't be


var ErrNilLineStringMS = errors.New("geom: nil LineStringMS")

ErrNilLineStringMS is thrown when a LineStringS is nil but shouldn't be


var ErrNilLineStringS = errors.New("geom: nil LineStringS")

ErrNilLineStringS is thrown when a LineStringS is nil but shouldn't be


var ErrNilLineStringZ = errors.New("geom: nil LineStringZ")

ErrNilLineStringZ is thrown when a LineStringZ is nil but shouldn't be


var ErrNilLineStringZM = errors.New("geom: nil LineStringZM")

ErrNilLineStringZM is thrown when a LineStringZM is nil but shouldn't be


var ErrNilLineStringZMS = errors.New("geom: nil LineStringZMS")

ErrNilLineStringZMS is thrown when a LineStringZMS is nil but shouldn't be


var ErrNilLineStringZS = errors.New("geom: nil LineStringZS")

ErrNilLineStringZS is thrown when a LineStringS is nil but shouldn't be


var ErrNilMultiLineString = errors.New("geom: nil MultiLineString")

ErrNilMultiLineString is thrown when MultiLineString is nil but shouldn't be


var ErrNilMultiPoint = errors.New("geom: nil MultiPoint")

ErrNilMultiPoint is thrown when a MultiPoint is nil but shouldn't be


var ErrNilMultiPointM = errors.New("geom: nil MultiPointM")

ErrNilMultiPointM is thrown when a MultiPointM is nil but shouldn't be


var ErrNilMultiPointMS = errors.New("geom: nil MultiPointMS")

ErrNilMultiPointMS is thrown when a MultiPointMS is nil but shouldn't be


var ErrNilMultiPointS = errors.New("geom: nil MultiPointS")

ErrNilMultiPointS is thrown when a MultiPointS is nil but shouldn't be


var ErrNilMultiPointZ = errors.New("geom: nil MultiPointZ")

ErrNilMultiPointZ is thrown when a MultiPointZ is nil but shouldn't be


var ErrNilMultiPointZM = errors.New("geom: nil MultiPointZM")

ErrNilMultiPointZM is thrown when a MultiPointZM is nil but shouldn't be


var ErrNilMultiPointZMS = errors.New("geom: nil MultiPointZMS")

ErrNilMultiPointZMS is thrown when a MultiPointZMS is nil but shouldn't be


var ErrNilMultiPointZS = errors.New("geom: nil MultiPointZS")

ErrNilMultiPointZS is thrown when a MultiPointZS is nil but shouldn't be


var ErrNilMultiPolygon = errors.New("geom: nil MultiPolygon")

ErrNilMultiPolygon is thrown when a MultiPolygon is nul but shouldn't be


var ErrNilPoint = errors.New("geom: nil Point")

ErrNilPoint is thrown when a point is null but shouldn't be


var ErrNilPointM = errors.New("geom: nil PointM")

ErrNilPointM is thrown when a point is null but shouldn't be


var ErrNilPointMS = errors.New("geom: nil PointMS")

ErrNilPointMS is thrown when a point is null but shouldn't be


var ErrNilPointS = errors.New("geom: nil PointS")

ErrNilPointS is thrown when a point is null but shouldn't be


var ErrNilPointZ = errors.New("geom: nil PointZ")

ErrNilPointZ is thrown when a point is null but shouldn't be


var ErrNilPointZM = errors.New("geom: nil PointZM")

ErrNilPointZM is thrown when a point is null but shouldn't be


var ErrNilPointZMS = errors.New("geom: nil PointZMS")

ErrNilPointZMS is thrown when a point is null but shouldn't be


var ErrNilPointZS = errors.New("geom: nil PointZS")

ErrNilPointZS is thrown when a point is null but shouldn't be


var ErrNilPolygon = errors.New("geom: nil Polygon")

ErrNilPolygon is thrown when a polygon is nil but shouldn't be


var ErrPointsAreCoLinear = errors.New("given points are colinear")

ErrPointsAreCoLinear is thrown when points are colinear but that is unexpected


Functions

func IsColinear

func IsColinear(a, b, c [2]float64) bool

IsColinear returns weather the a,b,c are colinear to each other

func IsEmpty

func IsEmpty(geo Geometry) bool

IsEmpty returns if the geometry represents an empty geometry

func RoundToPrec

func RoundToPrec(v float64, prec int) float64

RoundToPrec will round the given value to the precision value. The precision value should be a power of 10.

Types

type Circle

type Circle struct {
	Center [2]float64
	Radius float64
}

Circle is a point (float tuple) and a radius

func CircleFromPoints

func CircleFromPoints(a, b, c [2]float64) (Circle, error)

CircleFromPoints returns the circle from by the given points, or an error if the points are colinear. REF: Formula used gotten from http://mathforum.org/library/drmath/view/55233.html

func (Circle) AsLineString

func (c Circle) AsLineString(k uint) LineString

func (Circle) AsPoints

func (c Circle) AsPoints(k uint) []Point

func (Circle) AsSegments

func (c Circle) AsSegments(k uint) []Line

AsSegments takes the number of segments that should be returned to describe the circle. a value less then 3 will use the default value of 30.

func (Circle) ContainsPoint

func (c Circle) ContainsPoint(pt [2]float64) bool

ContainsPoint will check to see if the point is in the circle.

type ClockwiseFunc

type ClockwiseFunc func(...[2]float64) bool

ClockwiseFunc returns weather the set of points should be considered clockwise or counterclockwise. The last point is not the same as the first point, and the function should connect these points as needed.

type Collection

type Collection []Geometry

Collection is a collection of one or more geometries.

func (Collection) Geometries

func (c Collection) Geometries() []Geometry

Geometries returns the slice of Geometries

func (*Collection) SetGeometries

func (c *Collection) SetGeometries(input []Geometry) (err error)

SetGeometries modifies the array of 2D coordinates

type CollectionSetter

type CollectionSetter interface {
	Collectioner
	SetGeometries([]Geometry) error
}

CollectionSetter is a mutable Collectioner.

type Collectioner

type Collectioner interface {
	Geometry
	Geometries() []Geometry
}

Collectioner is a collections of different geometries.

type ErrUnknownGeometry

type ErrUnknownGeometry struct {
	Geom Geometry
}

ErrUnknownGeometry represents an objects that is not a known geom geometry.

func (ErrUnknownGeometry) Error

func (e ErrUnknownGeometry) Error() string

type Extent

type Extent [4]float64

Extent represents the minx, miny, maxx and maxy A nil extent represents the whole universe.

func NewExtent

func NewExtent(points ...[2]float64) *Extent

NewExtent returns an Extent for the provided points; in following format [4]float64{ MinX, MinY, MaxX, MaxY }

func NewExtentFromGeometry

func NewExtentFromGeometry(g Geometry) (*Extent, error)

NewExtentFromGeometry tries to create an extent based on the geometry

func NewExtentFromPoints

func NewExtentFromPoints(points ...Point) *Extent

NewExtentFromPoints returns an Extent for the provided points; in following format [4]float64{ MinX, MinY, MaxX, MaxY }

func (*Extent) Add

func (e *Extent) Add(extent MinMaxer)

Add will expand the extent to contain the given extent.

func (*Extent) AddGeometry

func (e *Extent) AddGeometry(g Geometry) error

AddGeometry expands the specified envelop to contain g.

func (*Extent) AddPointers

func (e *Extent) AddPointers(pts ...Pointer)

AddPointers will expand the Extent if a point is outside it

func (*Extent) AddPoints

func (e *Extent) AddPoints(points ...[2]float64)

AddPoints will expand the extent to contain the given points.

func (*Extent) Area

func (e *Extent) Area() float64

Area returns the area of the extent, if the extent is nil, it will return 0

func (*Extent) AsPolygon

func (e *Extent) AsPolygon() Polygon

AsPolygon will return the extent as a Polygon

func (*Extent) Clone

func (e *Extent) Clone() *Extent

Clone returns a new Extent with contents copied.

func (*Extent) Contains

func (e *Extent) Contains(ne MinMaxer) bool

Contains will return whether the given extent is inside of the extent.

func (*Extent) ContainsGeom

func (e *Extent) ContainsGeom(g Geometry) (bool, error)

ContainsGeom will return weather the given geometry is completely inside of the extent.

func (*Extent) ContainsLine

func (e *Extent) ContainsLine(l [2][2]float64) bool

ContainsLine will return weather the given line completely inside of the extent.

func (*Extent) ContainsPoint

func (e *Extent) ContainsPoint(pt [2]float64) bool

ContainsPoint will return whether the given point is inside of the extent.

func (*Extent) Edges

func (e *Extent) Edges(cwfn ClockwiseFunc) [][2][2]float64

Edges returns the clockwise order of the edges that make up the extent.

func (*Extent) ExpandBy

func (e *Extent) ExpandBy(s float64) *Extent

ExpandBy will expand extent by the given factor.

func (*Extent) Extent

func (e *Extent) Extent() [4]float64

Extent returns back the min and max of the Extent

func (*Extent) Intersect

func (e *Extent) Intersect(ne *Extent) (*Extent, bool)

Intersect will return a new extent that is the intersect of the two extents.

+-------------------------+
|                         |
|       A      +----------+------+
|              |//////////|      |
|              |/// C ////|      |
|              |//////////|      |
+--------------+----------+      |
               |             B   |
               +-----------------+

For example the for the above Box A intersects Box B at the area surround by C.

If the Boxes don't intersect does will be false, otherwise ibb will be the intersect.

func (*Extent) IsUniverse

func (e *Extent) IsUniverse() bool

IsUniverse returns weather the extent contains the universe. This is true if the clip box is nil or the x,y values are max values.

func (*Extent) Max

func (e *Extent) Max() [2]float64

Max returns the (MaxX, MaxY) values

func (*Extent) MaxX

func (e *Extent) MaxX() float64

MaxX is the larger of the x values.

func (*Extent) MaxY

func (e *Extent) MaxY() float64

MaxY is the larger of the y values.

func (*Extent) Min

func (e *Extent) Min() [2]float64

Min returns the (MinX, MinY) values

func (*Extent) MinX

func (e *Extent) MinX() float64

MinX is the smaller of the x values.

func (*Extent) MinY

func (e *Extent) MinY() float64

MinY is the smaller of the y values.

func (*Extent) ScaleBy

func (e *Extent) ScaleBy(s float64) *Extent

ScaleBy will scale the points in the extent by the given scale factor.

func (*Extent) Vertices

func (e *Extent) Vertices() [][2]float64

Vertices return the vertices of the Bounding Box. The vertices are ordered in the following maner. (minx,miny), (maxx,miny), (maxx,maxy), (minx,maxy)

func (*Extent) XSpan

func (e *Extent) XSpan() float64

XSpan is the distance of the Extent in X or inf TODO (gdey): look at how to have this function take into account the dpi.

func (*Extent) YSpan

func (e *Extent) YSpan() float64

YSpan is the distance of the Extent in Y or Inf

type Extenter

type Extenter interface {
	Extent() (extent [4]float64)
}

Extenter represents an interface that returns a boundbox.

type Geometry

type Geometry interface{}

Geometry is an object with a spatial reference. if a method accepts a Geometry type it's only expected to support the geom types in this package

func ApplyToPoints

func ApplyToPoints(geometry Geometry, f func(coords ...float64) ([]float64, error)) (Geometry, error)

ApplyToPoints applys the given function to each point in the geometry and any sub geometries, return a new transformed geometry.

func Clone

func Clone(geometry Geometry) (Geometry, error)

Clone returns a deep clone of the Geometry.

type Line

type Line [2][2]float64

Line has exactly two points

func ExtractLines

func ExtractLines(g Geometry) (lines []Line, err error)

ExtractLines extracts all linear components from a geometry (line segements). If the geometry contains no line segements (e.g. empty geometry or point), then an empty array will be returned.

Duplicate lines will not be removed.

func (Line) ContainsPoint

func (l Line) ContainsPoint(pt [2]float64) bool

ContainsPoint checks to see if the given pont lines on the linesegment. (Incliding the end points.)

func (Line) ContainsPointBigFloat

func (l Line) ContainsPointBigFloat(pt [2]*big.Float) bool

ContainsPointBigFloat checks to see if the given point lies on the line segment. (Including the endpoints.)

func (Line) IsHorizontal

func (l Line) IsHorizontal() bool

IsHorizontal returns true if the `x` elements of the points that make the line (l) are equal.

func (Line) IsVertical

func (l Line) IsVertical() bool

IsVertical returns true if the `y` elements of the points that make up the line (l) are equal.

func (Line) LengthSquared

func (l Line) LengthSquared() float64

LengthSqured returns the length of the segment squared

func (Line) Point1

func (l Line) Point1() *Point

Point1 returns a new copy of the first point in the line.

func (Line) Point2

func (l Line) Point2() *Point

Point2 returns a new copy of the second point in the line.

func (Line) Vertices

func (l Line) Vertices() [][2]float64

type LineString

type LineString [][2]float64

LineString is a basic line type which is made up of two or more points that don't interacted.

func (LineString) AsSegments

func (ls LineString) AsSegments() (segs []Line, err error)

AsSegments returns the line string as a slice of lines.

func (LineString) IsRing

func (ls LineString) IsRing() bool

IsRing returns true if the first and last vertices are the same

func (*LineString) SetVertices

func (ls *LineString) SetVertices(input [][2]float64) (err error)

SetVertices modifies the array of 2D coordinates

func (LineString) Vertices

func (ls LineString) Vertices() [][2]float64

Vertices returns a slice of XY values

type LineStringM

type LineStringM [][3]float64

LineString is a basic line type which is made up of two or more points that don't interacted.

func (LineStringM) LineString

func (lsm LineStringM) LineString() LineString

Get the simple 2D linestring

func (*LineStringM) SetVertices

func (lsm *LineStringM) SetVertices(input [][3]float64) (err error)

SetVertices modifies the array of 2D+1 coordinates

func (LineStringM) Vertices

func (lsm LineStringM) Vertices() [][3]float64

Vertices returns a slice of XYM values

type LineStringMS

type LineStringMS struct {
	Srid uint32
	Lsm  LineStringM
}

LineStringMS is a basic line type which is made up of two or more points that don't interacted.

func (LineStringMS) LineStringM

func (lsms LineStringMS) LineStringM() LineStringM

Get the simple 2D + 1 linestring

func (*LineStringMS) SetSRID

func (lsms *LineStringMS) SetSRID(srid uint32, lsm LineStringM) (err error)

SetVertices modifies the struct containing the SRID int and the array of 2D + 1 coordinates

func (LineStringMS) Vertices

func (lsms LineStringMS) Vertices() struct {
	Srid uint32
	Lsm  LineStringM
}

Vertices returns a slice of referenced XYM values

type LineStringMSSetter

type LineStringMSSetter interface {
	LineStringMSer
	SetSRID(srid uint32, lsm LineStringM) error
}

LineStringMSSetter is a mutable LineStringMSer.

type LineStringMSer

type LineStringMSer interface {
	Geometry
	Vertices() struct {
		Srid uint32
		Lsm  LineStringM
	}
}

LineStringMSer is a line of two or more M points + SRID.

type LineStringMSetter

type LineStringMSetter interface {
	LineStringMer
	SetVertices([][3]float64) error
}

LineStringMSetter is a mutable LineStringMer.

type LineStringMer

type LineStringMer interface {
	Geometry
	Vertices() [][3]float64
}

LineStringMer is a line of two or more M points.

type LineStringS

type LineStringS struct {
	Srid uint32
	Ls   LineString
}

LineString is a basic line type which is made up of two or more points that don't interacted.

func (LineStringS) LineString

func (lss LineStringS) LineString() LineString

Get the simple 2D linestring

func (*LineStringS) SetSRID

func (lss *LineStringS) SetSRID(srid uint32, ls LineString) (err error)

SetVertices modifies the struct containing the SRID int and the array of 2D coordinates

func (LineStringS) Vertices

func (lss LineStringS) Vertices() struct {
	Srid uint32
	Ls   LineString
}

Vertices returns a slice of referenced XY values

type LineStringSSetter

type LineStringSSetter interface {
	LineStringSer
	SetSRID(srid uint32, ls LineString) error
}

LineStringSSetter is a mutable LineStringSer.

type LineStringSer

type LineStringSer interface {
	Geometry
	Vertices() struct {
		Srid uint32
		Ls   LineString
	}
}

LineStringSer is a line of two or more points + SRID.

type LineStringSetter

type LineStringSetter interface {
	LineStringer
	SetVertices([][2]float64) error
}

LineStringSetter is a mutable LineStringer.

type LineStringZ

type LineStringZ [][3]float64

LineString is a basic line type which is made up of two or more points that don't interacted.

func (LineStringZ) LineString

func (lsz LineStringZ) LineString() LineString

Get the simple 2D linestring

func (*LineStringZ) SetVertices

func (lsz *LineStringZ) SetVertices(input [][3]float64) (err error)

SetVertices modifies the array of 3D coordinates

func (LineStringZ) Vertices

func (lsz LineStringZ) Vertices() [][3]float64

Vertices returns a slice of XYM values

type LineStringZM

type LineStringZM [][4]float64

LineString is a basic line type which is made up of two or more points that don't interacted.

func (LineStringZM) LineString

func (lszm LineStringZM) LineString() LineString

Get the simple 2D linestring

func (*LineStringZM) SetVertices

func (lszm *LineStringZM) SetVertices(input [][4]float64) (err error)

SetVertices modifies the array of 3D + 1 coordinates

func (LineStringZM) Vertices

func (lszm LineStringZM) Vertices() [][4]float64

Vertices returns a slice of XYM values

type LineStringZMS

type LineStringZMS struct {
	Srid uint32
	Lszm LineStringZM
}

LineStringZMS is a basic line type which is made up of two or more points that don't interacted.

func (LineStringZMS) LineStringZM

func (lszms LineStringZMS) LineStringZM() LineStringZM

Get the simple 3D + 1 linestring

func (*LineStringZMS) SetSRID

func (lszms *LineStringZMS) SetSRID(srid uint32, lszm LineStringZM) (err error)

SetVertices modifies the struct containing the SRID int and the array of 3D + 1 coordinates

func (LineStringZMS) Vertices

func (lszms LineStringZMS) Vertices() struct {
	Srid uint32
	Lszm LineStringZM
}

Vertices returns a slice of referenced XYZM values

type LineStringZMSSetter

type LineStringZMSSetter interface {
	LineStringZMSer
	SetSRID(srid uint32, lszm LineStringZM) error
}

LineStringZMSSetter is a mutable LineStringZMSer.

type LineStringZMSer

type LineStringZMSer interface {
	Geometry
	Vertices() struct {
		Srid uint32
		Lszm LineStringZM
	}
}

LineStringZMSer is a line of two or more ZM points + SRID.

type LineStringZMSetter

type LineStringZMSetter interface {
	LineStringZMer
	SetVertices([][4]float64) error
}

LineStringZMSetter is a mutable LineStringZMer.

type LineStringZMer

type LineStringZMer interface {
	Geometry
	Vertices() [][4]float64
}

LineStringZMer is a line of two or more ZM points.

type LineStringZS

type LineStringZS struct {
	Srid uint32
	Lsz  LineStringZ
}

LineStringZS is a basic line type which is made up of two or more points that don't interacted.

func (LineStringZS) LineStringZ

func (lszs LineStringZS) LineStringZ() LineStringZ

Get the simple 3D linestring

func (*LineStringZS) SetSRID

func (lszs *LineStringZS) SetSRID(srid uint32, lsz LineStringZ) (err error)

SetVertices modifies the struct containing the SRID int and the array of 3D coordinates

func (LineStringZS) Vertices

func (lszs LineStringZS) Vertices() struct {
	Srid uint32
	Lsz  LineStringZ
}

Vertices returns a slice of referenced XYM values

type LineStringZSSetter

type LineStringZSSetter interface {
	LineStringZSer
	SetSRID(srid uint32, lsz LineStringZ) error
}

LineStringZSSetter is a mutable LineStringZSer.

type LineStringZSer

type LineStringZSer interface {
	Geometry
	Vertices() struct {
		Srid uint32
		Lsz  LineStringZ
	}
}

LineStringZSer is a line of two or more Z points + SRID.

type LineStringZSetter

type LineStringZSetter interface {
	LineStringZer
	SetVertices([][3]float64) error
}

LineStringZSetter is a mutable LineStringZer.

type LineStringZer

type LineStringZer interface {
	Geometry
	Vertices() [][3]float64
}

LineStringZer is a line of two or more Z points.

type LineStringer

type LineStringer interface {
	Geometry
	Vertices() [][2]float64
}

LineStringer is a line of two or more points.

type MinMaxer

type MinMaxer interface {
	MinX() float64
	MinY() float64
	MaxX() float64
	MaxY() float64
}

MinMaxer is a wrapper for an Extent that gets min/max of the extent

type MultiLineString

type MultiLineString [][][2]float64

MultiLineString is a geometry with multiple LineStrings.

func (MultiLineString) AsSegments

func (mls MultiLineString) AsSegments() (segs [][]Line, err error)

AsSegments returns the multi lines string as a set of lines.

func (MultiLineString) LineStrings

func (mls MultiLineString) LineStrings() [][][2]float64

LineStrings returns the coordinates for the linestrings

func (*MultiLineString) SetLineStrings

func (mls *MultiLineString) SetLineStrings(input [][][2]float64) (err error)

SetLineStrings modifies the array of 2D coordinates

type MultiLineStringSetter

type MultiLineStringSetter interface {
	MultiLineStringer
	SetLineStrings([][][2]float64) error
}

MultiLineStringSetter is a mutable MultiLineStringer.

type MultiLineStringer

type MultiLineStringer interface {
	Geometry
	LineStrings() [][][2]float64
}

MultiLineStringer is a geometry with multiple LineStrings.

type MultiPoint

type MultiPoint [][2]float64

MultiPoint is a geometry with multiple points.

func (MultiPoint) Points

func (mp MultiPoint) Points() [][2]float64

Points returns the coordinates for the points

func (*MultiPoint) SetPoints

func (mp *MultiPoint) SetPoints(input [][2]float64) (err error)

SetPoints modifies the array of 2D coordinates

type MultiPointM

type MultiPointM [][3]float64

MultiPointM is a geometry with multiple 2+1D points.

func (MultiPointM) MultiPoint

func (mpm MultiPointM) MultiPoint() MultiPoint

Get the simple 2D multipoint

func (MultiPointM) Points

func (mpm MultiPointM) Points() [][3]float64

Points returns the coordinates for the 2+1D points

func (*MultiPointM) SetPoints

func (mpm *MultiPointM) SetPoints(input [][3]float64) (err error)

SetPoints modifies the array of 2+1D coordinates

type MultiPointMS

type MultiPointMS struct {
	Srid uint32
	Mpm  MultiPointM
}

MultiPointMS is a geometry with multiple, referenced 2+1D points.

func (MultiPointMS) MultiPointM

func (mpms MultiPointMS) MultiPointM() MultiPointM

Get the simple 3D multipoint

func (MultiPointMS) Points

func (mpms MultiPointMS) Points() struct {
	Srid uint32
	Mpm  MultiPointM
}

Points returns the coordinates for the 3D points

func (*MultiPointMS) SetSRID

func (mpms *MultiPointMS) SetSRID(srid uint32, mpm MultiPointM) (err error)

SetSRID modifies the struct containing the SRID int and the array of 3D coordinates

type MultiPointMSSetter

type MultiPointMSSetter interface {
	MultiPointMSer
	SetSRID(srid uint32, mpz MultiPointM) error
}

MultiPointMSSetter is a mutable MultiPointMSer.

type MultiPointMSer

type MultiPointMSer interface {
	Geometry
	Points() struct {
		Srid uint32
		Mpm  MultiPointM
	}
}

MultiPointMSer is a MultiPointM + SRID.

type MultiPointMSetter

type MultiPointMSetter interface {
	MultiPointMer
	SetPoints([][3]float64) error
}

MultiPointMSetter is a mutable MultiPointer.

type MultiPointMer

type MultiPointMer interface {
	Geometry
	Points() [][3]float64
}

MultiPointMer is a geometry with multiple 2+1D points.

type MultiPointS

type MultiPointS struct {
	Srid uint32
	Mp   MultiPoint
}

MultiPointS is a geometry with multiple, referenced 2D points.

func (MultiPointS) MultiPoint

func (mps MultiPointS) MultiPoint() MultiPoint

Get the simple 2D multipoint

func (MultiPointS) Points

func (mps MultiPointS) Points() struct {
	Srid uint32
	Mp   MultiPoint
}

Points returns the coordinates for the 2D points

func (*MultiPointS) SetSRID

func (mps *MultiPointS) SetSRID(srid uint32, mp MultiPoint) (err error)

SetSRID modifies the struct containing the SRID int and the array of 2D coordinates

type MultiPointSSetter

type MultiPointSSetter interface {
	MultiPointSer
	SetSRID(srid uint32, mp MultiPoint) error
}

MultiPointSSetter is a mutable MultiPointSer.

type MultiPointSer

type MultiPointSer interface {
	Geometry
	Points() struct {
		Srid uint32
		Mp   MultiPoint
	}
}

MultiPointSer is a MultiPoint + SRID.

type MultiPointSetter

type MultiPointSetter interface {
	MultiPointer
	SetPoints([][2]float64) error
}

MultiPointSetter is a mutable MultiPointer.

type MultiPointZ

type MultiPointZ [][3]float64

MultiPointZ is a geometry with multiple 3D points.

func (MultiPointZ) MultiPoint

func (mpz MultiPointZ) MultiPoint() MultiPoint

Get the simple 2D multipoint

func (MultiPointZ) Points

func (mpz MultiPointZ) Points() [][3]float64

Points returns the coordinates for the 3D points

func (*MultiPointZ) SetPoints

func (mpz *MultiPointZ) SetPoints(input [][3]float64) (err error)

SetPoints modifies the array of 3D coordinates

type MultiPointZM

type MultiPointZM [][4]float64

MultiPointZM is a geometry with multiple 3+1D points.

func (MultiPointZM) MultiPoint

func (mpzm MultiPointZM) MultiPoint() MultiPoint

Get the simple 2D multipoint

func (MultiPointZM) Points

func (mpzm MultiPointZM) Points() [][4]float64

Points returns the coordinates for the 3+1D points

func (*MultiPointZM) SetPoints

func (mpzm *MultiPointZM) SetPoints(input [][4]float64) (err error)

SetPoints modifies the array of 3+1D coordinates

type MultiPointZMS

type MultiPointZMS struct {
	Srid uint32
	Mpzm MultiPointZM
}

MultiPointZMS is a geometry with multiple, referenced 3+1D points.

func (MultiPointZMS) MultiPointZM

func (mpzms MultiPointZMS) MultiPointZM() MultiPointZM

Get the simple 3D multipoint

func (MultiPointZMS) Points

func (mpzms MultiPointZMS) Points() struct {
	Srid uint32
	Mpzm MultiPointZM
}

Points returns the coordinates for the 3+1D points

func (*MultiPointZMS) SetSRID

func (mpzms *MultiPointZMS) SetSRID(srid uint32, mpzm MultiPointZM) (err error)

SetSRID modifies the struct containing the SRID int and the array of 3+1D coordinates

type MultiPointZMSSetter

type MultiPointZMSSetter interface {
	MultiPointZMSer
	SetSRID(srid uint32, mpzm MultiPointZM) error
}

MultiPointZMSSetter is a mutable MultiPointZMSer.

type MultiPointZMSer

type MultiPointZMSer interface {
	Geometry
	Points() struct {
		Srid uint32
		Mpzm MultiPointZM
	}
}

MultiPointZMSer is a MultiPointZM + SRID.

type MultiPointZMSetter

type MultiPointZMSetter interface {
	MultiPointZMer
	SetPoints([][4]float64) error
}

MultiPointZMSetter is a mutable MultiPointer.

type MultiPointZMer

type MultiPointZMer interface {
	Geometry
	Points() [][4]float64
}

MultiPointZMer is a geometry with multiple 3+1D points.

type MultiPointZS

type MultiPointZS struct {
	Srid uint32
	Mpz  MultiPointZ
}

MultiPointZS is a geometry with multiple, referenced 3D points.

func (MultiPointZS) MultiPointZ

func (mps MultiPointZS) MultiPointZ() MultiPointZ

Get the simple 3D multipoint

func (MultiPointZS) Points

func (mpzs MultiPointZS) Points() struct {
	Srid uint32
	Mpz  MultiPointZ
}

Points returns the coordinates for the 3D points

func (*MultiPointZS) SetSRID

func (mpzs *MultiPointZS) SetSRID(srid uint32, mpz MultiPointZ) (err error)

SetSRID modifies the struct containing the SRID int and the array of 3D coordinates

type MultiPointZSSetter

type MultiPointZSSetter interface {
	MultiPointZSer
	SetSRID(srid uint32, mpz MultiPointZ) error
}

MultiPointZSSetter is a mutable MultiPointZSer.

type MultiPointZSer

type MultiPointZSer interface {
	Geometry
	Points() struct {
		Srid uint32
		Mpz  MultiPointZ
	}
}

MultiPointZSer is a MultiPointZ + SRID.

type MultiPointZSetter

type MultiPointZSetter interface {
	MultiPointZer
	SetPoints([][3]float64) error
}

MultiPointZSetter is a mutable MultiPointer.

type MultiPointZer

type MultiPointZer interface {
	Geometry
	Points() [][3]float64
}

MultiPointZer is a geometry with multiple 3D points.

type MultiPointer

type MultiPointer interface {
	Geometry
	Points() [][2]float64
}

MultiPointer is a geometry with multiple points.

type MultiPolygon

type MultiPolygon [][][][2]float64

MultiPolygon is a geometry of multiple polygons.

func (MultiPolygon) AsSegments

func (mp MultiPolygon) AsSegments() (segs [][][]Line, err error)

AsSegments return a set of []Line

func (MultiPolygon) Polygons

func (mp MultiPolygon) Polygons() [][][][2]float64

Polygons returns the array of polygons.

func (*MultiPolygon) SetPolygons

func (mp *MultiPolygon) SetPolygons(input [][][][2]float64) (err error)

SetPolygons modifies the array of 2D coordinates

type MultiPolygonSetter

type MultiPolygonSetter interface {
	MultiPolygoner
	SetPolygons([][][][2]float64) error
}

MultiPolygonSetter is a mutable MultiPolygoner.

type MultiPolygoner

type MultiPolygoner interface {
	Geometry
	Polygons() [][][][2]float64
}

MultiPolygoner is a geometry of multiple polygons.

type Point

type Point [2]float64

Point describes a simple 2D point

func GetCoordinates

func GetCoordinates(g Geometry) (pts []Point, err error)

GetCoordinates return a list of points that make up a geometry. This makes no attempt to remove duplicate points.

func (Point) Area

func (p Point) Area() float64

Area of a point is always 0

func (Point) CrossProduct

func (p Point) CrossProduct(pt Point) float64

CrossProduct will return the cross product of the p and pt.

func (Point) Magnitude

func (p Point) Magnitude() float64

Magnitude of the point is the size of the point

func (Point) MaxX

func (p Point) MaxX() float64

MaxX is the same as X

func (Point) MaxY

func (p Point) MaxY() float64

MaxY is the same as y

func (Point) MinX

func (p Point) MinX() float64

MinX is the same as X

func (Point) MinY

func (p Point) MinY() float64

MinY is the same as y

func (Point) Multiply

func (p Point) Multiply(pt Point) Point

Multiply will return a new point that is the multiplication of pt and p

func (*Point) SetXY

func (p *Point) SetXY(xy [2]float64) (err error)

SetXY sets a pair of coordinates

func (Point) Subtract

func (p Point) Subtract(pt Point) Point

Subtract will return a new point that is the subtraction of pt from p

func (Point) WithinCircle

func (p Point) WithinCircle(a, b, c Point) bool

WithinCircle indicates weather the point p is contained the the circle defined by a,b,c REF: See Guibas and Stolf (1985) p.107

func (Point) X

func (p Point) X() float64

X is the x coordinate of a point in the projection

func (Point) XY

func (p Point) XY() [2]float64

XY returns an array of 2D coordinates

func (Point) Y

func (p Point) Y() float64

Y is the y coordinate of a point in the projection

type PointM

type PointM [3]float64

Point describes a simple 2D+1D point

func (PointM) M

func (p PointM) M() float64

M returns the metric related to the 2D point

func (*PointM) SetXYM

func (p *PointM) SetXYM(xym [3]float64) (err error)

SetXYM sets the three coordinates

func (PointM) XY

func (p PointM) XY() [2]float64

XY returns an array of 2D coordinates

func (PointM) XYM

func (p PointM) XYM() [3]float64

XYM returns an array of 2D+1D coordinates

type PointMS

type PointMS struct {
	Srid uint32
	Xym  PointM
}

Point describes a simple 3D point with SRID

func (PointMS) S

func (p PointMS) S() uint32

S returns the srid as uint32

func (*PointMS) SetXYMS

func (p *PointMS) SetXYMS(srid uint32, xym PointM) (err error)

SetXYMS sets the XYM coordinates and the SRID

func (PointMS) XYM

func (p PointMS) XYM() PointM

XYM returns 3D+1D point

func (PointMS) XYMS

func (p PointMS) XYMS() struct {
	Srid uint32
	Xym  PointM
}

XYMS returns the struct itself

type PointMSSetter

type PointMSSetter interface {
	PointMSer
	SetXYMS(srid uint32, xym PointM) error
}

PointMSSetter is a mutable PointMer

type PointMSer

type PointMSer interface {
	Geometry
	XYMS() struct {
		Srid uint32
		Xym  PointM
	}
}

PointMSer is a 2D+1D point + SRID

type PointMSetter

type PointMSetter interface {
	PointMer
	SetXYM([3]float64) error
}

PointMSetter is a mutable PointMer

type PointMer

type PointMer interface {
	Geometry
	XYM() [3]float64
}

PointMer is a 2D+1D point.

type PointS

type PointS struct {
	Srid uint32
	Xy   Point
}

Point describes a simple 2D point with SRID

func (PointS) S

func (p PointS) S() uint32

S returns the srid as uint32

func (*PointS) SetXYS

func (p *PointS) SetXYS(srid uint32, xy Point) (err error)

SetXYS sets the XY coordinates and the SRID

func (PointS) XY

func (p PointS) XY() Point

XY returns 2D point

func (PointS) XYS

func (p PointS) XYS() struct {
	Srid uint32
	Xy   Point
}

XYS returns the struct itself

type PointSSetter

type PointSSetter interface {
	PointSer
	SetXYS(srid uint32, xy Point) error
}

PointSSetter is a mutable PointSer

type PointSer

type PointSer interface {
	Geometry
	XYS() struct {
		Srid uint32
		Xy   Point
	}
}

PointSer is a 2D point + SRID

type PointSetter

type PointSetter interface {
	Pointer
	SetXY([2]float64) error
}

PointSetter is a mutable Pointer.

type PointZ

type PointZ [3]float64

Point describes a simple 3D point

func (PointZ) Magnitude

func (p PointZ) Magnitude() float64

Magnitude of the point is the size of the point

func (*PointZ) SetXYZ

func (p *PointZ) SetXYZ(xyz [3]float64) (err error)

SetXYZ sets the three coordinates

func (PointZ) XY

func (p PointZ) XY() [2]float64

XY returns an array of 2D coordinates

func (PointZ) XYZ

func (p PointZ) XYZ() [3]float64

XYZ returns an array of 3D coordinates

type PointZM

type PointZM [4]float64

Point describes a simple 3D+1D point

func (PointZM) M

func (p PointZM) M() float64

M returns the metric related to the 2D point

func (*PointZM) SetXYZM

func (p *PointZM) SetXYZM(xyzm [4]float64) (err error)

SetXYZM sets the three coordinates

func (PointZM) XYZ

func (p PointZM) XYZ() [3]float64

XYZ returns an array of 3D coordinates

func (PointZM) XYZM

func (p PointZM) XYZM() [4]float64

XYZM returns an array of 3D+1D coordinates

type PointZMS

type PointZMS struct {
	Srid uint32
	Xyzm PointZM
}

Point describes a simple 3D+1D point with SRID

func (PointZMS) S

func (p PointZMS) S() uint32

S returns the srid as uint32

func (*PointZMS) SetXYZMS

func (p *PointZMS) SetXYZMS(srid uint32, xyzm PointZM) (err error)

SetXYZMS sets the XYZM coordinates and the SRID

func (PointZMS) XYZM

func (p PointZMS) XYZM() PointZM

XYZM returns 3D+1D point

func (PointZMS) XYZMS

func (p PointZMS) XYZMS() struct {
	Srid uint32
	Xyzm PointZM
}

XYZMS returns the struct itself

type PointZMSSetter

type PointZMSSetter interface {
	PointZMSer
	SetXYZMS(srid uint32, xyzm PointZM) error
}

PointZMSSetter is a mutable PointZMer

type PointZMSer

type PointZMSer interface {
	Geometry
	XYZMS() struct {
		Srid uint32
		Xyzm PointZM
	}
}

PointZMSer is a 3D+1D point + SRID

type PointZMSetter

type PointZMSetter interface {
	PointZMer
	SetXYZM([4]float64) error
}

PointZMSetter is a mutable PointZMer

type PointZMer

type PointZMer interface {
	Geometry
	XYZM() [4]float64
}

PointZMer is a 3D+1D point.

type PointZS

type PointZS struct {
	Srid uint32
	Xyz  PointZ
}

Point describes a simple 3D point with SRID

func (PointZS) S

func (p PointZS) S() uint32

S returns the srid as uint32

func (*PointZS) SetXYZS

func (p *PointZS) SetXYZS(srid uint32, xyz PointZ) (err error)

SetXYZS sets the XYZ coordinates and the SRID

func (PointZS) XYZ

func (p PointZS) XYZ() PointZ

XYZ returns 3D point

func (PointZS) XYZS

func (p PointZS) XYZS() struct {
	Srid uint32
	Xyz  PointZ
}

XYZS returns the struct itself

type PointZSSetter

type PointZSSetter interface {
	PointZSer
	SetXYZS(srid uint32, xyz PointZ) error
}

PointZSSetter is a mutable PointZSer

type PointZSer

type PointZSer interface {
	Geometry
	XYZS() struct {
		Srid uint32
		Xyz  PointZ
	}
}

PointZSer is a 3D point + SRID

type PointZSetter

type PointZSetter interface {
	PointZer
	SetXYZ([3]float64) error
}

PointZSetter is a mutable PointZer

type PointZer

type PointZer interface {
	Geometry
	XYZ() [3]float64
}

PointZer is a 3D point.

type Pointer

type Pointer interface {
	Geometry
	XY() [2]float64
}

Pointer is a point with two dimensions.

type Polygon

type Polygon [][][2]float64

Polygon is a geometry consisting of multiple closed LineStrings. There must be only one exterior LineString with a clockwise winding order. There may be one or more interior LineStrings with a counterclockwise winding orders. The last point in the linear ring will not match the first point.

func (Polygon) AsSegments

func (p Polygon) AsSegments() (segs [][]Line, err error)

AsSegments returns the polygon as a slice of lines. This will make no attempt to only add unique segments.

func (Polygon) LinearRings

func (p Polygon) LinearRings() [][][2]float64

LinearRings returns the coordinates of the linear rings

func (*Polygon) SetLinearRings

func (p *Polygon) SetLinearRings(input [][][2]float64) (err error)

SetLinearRings modifies the array of 2D coordinates

type PolygonSetter

type PolygonSetter interface {
	Polygoner
	SetLinearRings([][][2]float64) error
}

PolygonSetter is a mutable Polygoner.

type Polygoner

type Polygoner interface {
	Geometry
	LinearRings() [][][2]float64
}

Polygoner is a geometry consisting of multiple Linear Rings. There must be only one exterior LineString with a clockwise winding order. There may be one or more interior LineStrings with a counterclockwise winding orders. It is assumed that the last point is connected to the first point, and the first point is NOT duplicated at the end.

type Triangle

type Triangle [3][2]float64

Triangle is a array representation of a geometry triangle.

func NewTriangleContaining

func NewTriangleContaining(pts ...Point) Triangle

NewTriangleContaining returns a triangle that is large enough to contain the given points

func NewTriangleContainingPoints

func NewTriangleContainingPoints(pts ...[2]float64) Triangle

func NewTriangleForExtent

func NewTriangleForExtent(ext *Extent, buff float64) (Triangle, error)

func NewTriangleFromPolygon

func NewTriangleFromPolygon(py [][][2]float64) Triangle

NewTriangleFromPolygon takes the first three points from the outer ring of a polygon to create a triangle.

func (Triangle) Area

func (t Triangle) Area() float64

Area reaturns twice the area of the oriented triangle (a,b,c), i.e. the area is positive if the triangle is oriented counterclockwise.

func (Triangle) Center

func (t Triangle) Center() (pt [2]float64)

Center returns a point at the center of the triangle.

func (Triangle) LinearRings

func (t Triangle) LinearRings() [][][2]float64

LinearRings returns the coordinates of the linear rings

func (Triangle) ThirdPoint

func (t Triangle) ThirdPoint(p1, p2 [2]float64) [2]float64

ThirdPoint takes 2 points and checks which point is the 3rd in the Triangle

Directories

Path Synopsis
cmd
cmp
encoding
encoding/geojson
encoding/gpkg
encoding/gpkg/examples
encoding/mvt Package mvt is used to encode MVT tiles In short, a `Tile`s has `Layer`s, which have `Feauture`s.
encoding/mvt/vector_tile go:generate protoc "--go_out=." "vector_tile.proto" Package vectorTile is a generated protocol buffer package.
encoding/wkb Package wkb is for decoding ESRI's Well Known Binary (WKB) format for OGC geometry (WKBGeometry) sepcification at http://edndoc.esri.com/arcsde/9.1/general_topics/wkb_representation.htm There are a few types supported by the specification.
encoding/wkb/internal/consts
encoding/wkb/internal/decode
encoding/wkb/internal/encode
encoding/wkb/internal/tcase
encoding/wkb/internal/tcase/symbol
encoding/wkb/internal/tcase/token
encoding/wkt
encoding/wkt/internal/cmd/fuzz
encoding/wkt/internal/cmd/fuzz/fuzz Package fuzz provides primitives to generate random geom geometry types.
encoding/wkt/internal/symbol
encoding/wkt/internal/token
internal/debugger Package debugger provides a way for us to capture partial geometries during geometry processing.
internal/debugger/recorder
internal/debugger/recorder/gpkg
internal/parsing
internal/rtreego Package rtreego is a library for efficiently storing and querying spatial data.
internal/test/must
planar
planar/clip
planar/coord
planar/coord/utm Package utm provides the ability to work with UTM coordinates References: https://stevedutch.net/FieldMethods/UTMSystem.htm https://gisgeography.com/central-meridian/
planar/index/kdtree kdtree is a two dimensional kd-tree implementation
planar/intersect
planar/makevalid
planar/makevalid/hitmap
planar/makevalid/walker
planar/simplify
planar/triangulate
planar/triangulate/delaunay
planar/triangulate/delaunay/quadedge Package quadedge describes a quadedge object used to build up the triangulation A quadedge is made up of four directional edges DO ^* || O*----++---->D L D<----++----*O R || *V OD O represents the Origin D represents the Destination
planar/triangulate/delaunay/subdivision
planar/triangulate/delaunay/subdivision/internal/phenix
planar/triangulate/delaunay/subdivision/pseudopolygon
planar/triangulate/delaunay/subdivision/testingtables
slippy
spherical
testing/must Package must provides helpers to decode wkt geometries to be used in tests
winding Package winding provides primitives for determining the winding order of a set of points