geom

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2020 License: MIT Imports: 13 Imported by: 17

Documentation

Index

Constants

This section is empty.

Variables

View Source
var IgnoreOrder = EqualsExactOption(
	func(s *equalsExactOptionSet) {
		s.ignoreOrder = true
	},
)

IgnoreOrder modifies the behaviour of the EqualsExact method by ignoring ordering that doesn't have a material impact on geometries.

For Points, there is no ordering, so this option does nothing.

For curves (Line, LineString, and LinearRing), the direction of the curve (start to end or end to start) is ignored. For curves that are rings (i.e. are simple and closed), the location of the start and end point of the ring is also ignored.

For polygons the ordering between any interior rings is ignored, as is the ordering inside the rings themselves.

For collections (MultiPoint, MultiLineString, MultiPolygon, and GeometryCollection), the ordering of constituent elements in the collection are ignored.

Functions

func DisableAllValidations

func DisableAllValidations(o *ctorOptionSet)

DisableAllValidations causes geometry constructors to skip all validations. This allows invalid geometries to be loaded, but also has several implications for using the resultant geometries:

  1. If the geometry is invalid, then any geometric calculations resulting from the geometry may be invalid.
  1. If the geometry is invalid, then invoking geometric calculations may cause a panic or infinite loop.

This option should be used with caution. It is most useful when invalid geometries need to be loaded, but no geometric calculations will be performed.

Types

type BitSet added in v0.10.0

type BitSet struct {
	// contains filtered or unexported fields
}

BitSet is a set data structure that holds a mapping from non-negative integers to boolean values (bits). The zero value is the BitSet with all bits set to false.

func (*BitSet) Clone added in v0.10.0

func (b *BitSet) Clone() BitSet

Clone makes a deep copy of the BitSet.

func (*BitSet) Get added in v0.10.0

func (b *BitSet) Get(i int) bool

Get gets the bit as position i. It panics if i is negative. Get returns false for bits that haven't been explicitly set.

func (*BitSet) Set added in v0.10.0

func (b *BitSet) Set(i int, newVal bool)

Set sets the bit in position i to a new value.

type ConstructorOption

type ConstructorOption func(o *ctorOptionSet)

ConstructorOption allows the behaviour of Geometry constructor functions to be modified.

type Coordinates

type Coordinates struct {
	// XY represents the XY position of the point location.
	XY

	// Z represents the height of the location. Its value is zero
	// for non-3D coordinate types.
	Z float64

	// M represents a user defined measure associated with the
	// location. Its value is zero for non-measure coordinate
	// types.
	M float64

	// Type indicates the coordinates type, and therefore whether
	// or not Z and M are populated.
	Type CoordinatesType
}

Coordinates represents a point location.

type CoordinatesType added in v0.10.0

type CoordinatesType byte

CoordinatesType controls the dimensionality and type of data used to encode a point location. At minimum, a point location is defined by X and Y coordinates. It may optionally include a Z value, representing height. It may also optionally include an M value, traditionally representing an arbitrary user defined measurement associated with each point location.

const (
	// DimXY coordinates only contain X and Y values.
	DimXY CoordinatesType = 0b00

	// DimXYZ coordiantes contain X, Y, and Z (height) values.
	DimXYZ CoordinatesType = 0b01

	// DimXYM coordiantes contain X, Y, and M (measure) values.
	DimXYM CoordinatesType = 0b10

	// DimXYZM coordiantes contain X, Y, Z (height), and M (measure) values.
	DimXYZM CoordinatesType = 0b11
)

func (CoordinatesType) Dimension added in v0.10.0

func (t CoordinatesType) Dimension() int

Dimension returns the number of float64 coordinates required to encode a point location using the CoordinatesType.

func (CoordinatesType) Is3D added in v0.10.0

func (t CoordinatesType) Is3D() bool

Is3D returns true if and only if the CoordinatesType includes a Z (3D) value.

func (CoordinatesType) IsMeasured added in v0.10.0

func (t CoordinatesType) IsMeasured() bool

IsMeasured returns true if and only if the Coordinates type includes an M (measure) value.

func (CoordinatesType) String added in v0.10.0

func (t CoordinatesType) String() string

String gives a string representation of a CoordinatesType.

type Envelope

type Envelope struct {
	// contains filtered or unexported fields
}

Envelope is an axis-aligned rectangle (also known as an Axis Aligned Bounding Box or Minimum Bounding Rectangle). It usually represents a 2D area with non-zero width and height, but can also represent degenerate cases where the width or height (or both) are zero.

func EnvelopeFromGeoms

func EnvelopeFromGeoms(geoms ...Geometry) (Envelope, bool)

EnvelopeFromGeoms returns the smallest envelope that contains all points contained by the provided geometries, provided that at least one non-empty geometry is given. If no non-empty geometries are given, then the returned flag is set to false.

func NewEnvelope

func NewEnvelope(first XY, others ...XY) Envelope

NewEnvelope returns the smallest envelope that contains all provided points.

func (Envelope) Area

func (e Envelope) Area() float64

Area returns the area covered by the envelope.

func (Envelope) AsGeometry

func (e Envelope) AsGeometry() Geometry

AsGeometry returns the envelope as a Geometry. In the regular case where the envelope covers some area, then a Polygon geometry is returned. In degenerate cases where the envelope only covers a line or a point, a Line or Point geometry is returned.

func (Envelope) Center

func (e Envelope) Center() XY

Center returns the center point of the envelope.

func (Envelope) Contains

func (e Envelope) Contains(p XY) bool

Contains returns true iff this envelope contains the given point.

func (Envelope) Covers

func (e Envelope) Covers(o Envelope) bool

Covers returns true iff and only if this envelope entirely covers another envelope (i.e. every point in the other envelope is contained within this envelope).

func (Envelope) Distance

func (e Envelope) Distance(o Envelope) float64

Distance calculates the stortest distance between this envelope and another envelope. If the envelopes intersect with each other, then the returned distance is 0.

func (Envelope) ExpandBy

func (e Envelope) ExpandBy(x, y float64) (Envelope, bool)

ExpandBy calculates a new version of this envelope that is expanded in the x and y dimensions. Both the minimum and maximum points in the envelope are expanded by the supplied x and y amounts. Positive values increase the size of the envelope and negative amounts decrease the size of the envelope. If a decrease in envelope size would result in an invalid envelope (where min is greater than max), then false is returned and no envelope is calculated.

func (Envelope) ExpandToIncludeEnvelope

func (e Envelope) ExpandToIncludeEnvelope(other Envelope) Envelope

ExpandToIncludeEnvelope returns the smallest envelope that contains all of the points in this envelope and another envelope.

func (Envelope) ExtendToIncludePoint

func (e Envelope) ExtendToIncludePoint(point XY) Envelope

ExtendToIncludePoint returns the smallest envelope that contains all of the points in this envelope along with the provided point.

func (Envelope) Height

func (e Envelope) Height() float64

Height returns the difference between the maximum and minimum X coordinates of the envelope.

func (Envelope) Intersects

func (e Envelope) Intersects(o Envelope) bool

Intersects returns true iff this envelope has any points in common with another envelope.

func (Envelope) Max

func (e Envelope) Max() XY

Max returns the point in the envelope with the maximum X and Y values.

func (Envelope) Min

func (e Envelope) Min() XY

Min returns the point in the envelope with the minimum X and Y values.

func (Envelope) Width

func (e Envelope) Width() float64

Width returns the difference between the maximum and minimum X coordinates of the envelope.

type EqualsExactOption

type EqualsExactOption func(s *equalsExactOptionSet)

EqualsExactOption allows the behaviour of the EqualsExact method in the Geometry interface to be modified.

func ToleranceXY added in v0.10.0

func ToleranceXY(within float64) EqualsExactOption

ToleranceXY modifies the behaviour of the EqualsExact method by allowing two geometry control points be be considered equal if their XY coordinates are within the given euclidean distance of each other.

type GeoJSONFeature

type GeoJSONFeature struct {
	// Geometry is the geometry that is associated with the Feature.
	Geometry Geometry

	// ID is an identifier to refer to the feature. If an identifier isn't
	// applicable, ID can be left as nil. If it's set, then its value should
	// marshal into a JSON string or number (this is not enforced).
	ID interface{}

	// Properties are free-form properties that are associated with the
	// feature. If there are no properties associated with the feature, then it
	// can either be left as nil.
	Properties map[string]interface{}
}

GeoJSONFeature represents a Geometry with associated free-form properties. GeoJSONFeature values have a one to one correspondence with GeoJSON Features.

func (GeoJSONFeature) MarshalJSON

func (f GeoJSONFeature) MarshalJSON() ([]byte, error)

MarshalJSON implements the encoding/json Marshaler interface by marshalling into a GeoJSON FeatureCollection object.

func (*GeoJSONFeature) UnmarshalJSON

func (f *GeoJSONFeature) UnmarshalJSON(p []byte) error

UnmarshalJSON implements the encoding/json Unmarshaler interface by unmarshalling a GeoJSON Feature Collection object.

type GeoJSONFeatureCollection

type GeoJSONFeatureCollection []GeoJSONFeature

GeoJSONFeatureCollection is a collection of GeoJSONFeatures. GeoJSONFeatureCollection values have a one to one correspondence with GeoJSON FeatureCollections.

func (GeoJSONFeatureCollection) MarshalJSON

func (c GeoJSONFeatureCollection) MarshalJSON() ([]byte, error)

MarshalJSON implements the encoding/json Marshaler interface by marshalling into a GeoJSON FeatureCollection object.

func (*GeoJSONFeatureCollection) UnmarshalJSON

func (c *GeoJSONFeatureCollection) UnmarshalJSON(p []byte) error

UnmarshalJSON implements the encoding/json Unmarshaler interface by unmarshalling a GeoJSON FeatureCollection object.

type Geometry

type Geometry struct {
	// contains filtered or unexported fields
}

Geometry is a single geometry of any type. It's zero value is valid and is an empty GeometryCollection. It is immutable after creation.

func UnmarshalGeoJSON

func UnmarshalGeoJSON(input []byte, opts ...ConstructorOption) (Geometry, error)

UnmarshalGeoJSON unmarshals a geometry that is encoded as a GeoJSON Geometry Object.

func UnmarshalWKB

func UnmarshalWKB(r io.Reader, opts ...ConstructorOption) (Geometry, error)

UnmarshalWKB reads the Well Known Binary (WKB), and returns the corresponding Geometry.

func UnmarshalWKT

func UnmarshalWKT(r io.Reader, opts ...ConstructorOption) (Geometry, error)

UnmarshalWKT parses a Well Known Text (WKT), and returns the corresponding Geometry.

func (Geometry) AppendWKT

func (g Geometry) AppendWKT(dst []byte) []byte

AppendWKT appends the WKT (Well Known Text) representation of this geometry to the input byte slice.

func (Geometry) Area added in v0.4.0

func (g Geometry) Area() float64

Area gives the area of the Polygon or MultiPolygon or GeometryCollection. If the Geometry is none of those types, then 0 is returned.

func (Geometry) AsBinary

func (g Geometry) AsBinary(w io.Writer) error

AsBinary writes the WKB (Well Known Binary) representation of the geometry to the writer.

func (Geometry) AsGeometryCollection added in v0.4.0

func (g Geometry) AsGeometryCollection() GeometryCollection

AsGeometryCollection returns the geometry as a GeometryCollection. It panics if the geometry is not a GeometryCollection.

func (Geometry) AsLine added in v0.4.0

func (g Geometry) AsLine() Line

AsLine returns the geometry as a Line. It panics if the geometry is not a Line.

func (Geometry) AsLineString added in v0.4.0

func (g Geometry) AsLineString() LineString

AsLineString returns the geometry as a LineString. It panics if the geometry is not a LineString.

func (Geometry) AsMultiLineString added in v0.4.0

func (g Geometry) AsMultiLineString() MultiLineString

AsMultiLineString returns the geometry as a MultiLineString. It panics if the geometry is not a MultiLineString.

func (Geometry) AsMultiPoint added in v0.4.0

func (g Geometry) AsMultiPoint() MultiPoint

AsMultiPoint returns the geometry as a MultiPoint. It panics if the geometry is not a MultiPoint.

func (Geometry) AsMultiPolygon added in v0.4.0

func (g Geometry) AsMultiPolygon() MultiPolygon

AsMultiPolygon returns the geometry as a MultiPolygon. It panics if the Geometry is not a MultiPolygon.

func (Geometry) AsPoint added in v0.4.0

func (g Geometry) AsPoint() Point

AsPoint returns the geometry as a Point. It panics if the geometry is not a Point.

func (Geometry) AsPolygon added in v0.4.0

func (g Geometry) AsPolygon() Polygon

AsPolygon returns the geometry as a Polygon. It panics if the geometry is not a Polygon.

func (Geometry) AsText

func (g Geometry) AsText() string

AsText returns the WKT (Well Known Text) representation of this geometry.

func (Geometry) Boundary

func (g Geometry) Boundary() Geometry

Boundary returns the Geometry representing the spatial limit of this geometry. The precise definition is dependant on the concrete geometry type (see the documentation of each concrete Geometry's Boundary method for details).

func (Geometry) Centroid added in v0.4.0

func (g Geometry) Centroid() Point

Centroid returns the geometry's centroid Point. If the Geometry is empty, then an empty Point is returned.

func (Geometry) ConvexHull

func (g Geometry) ConvexHull() Geometry

ConvexHull returns the geometry representing the smallest convex geometry that contains this geometry.

func (Geometry) CoordinatesType added in v0.10.0

func (g Geometry) CoordinatesType() CoordinatesType

CoordinatesType returns the CoordinatesType used to represent points making up the geometry.

func (Geometry) Dimension

func (g Geometry) Dimension() int

Dimension returns the dimension of the Geometry. This is 0 for Points and MultiPoints, 1 for LineStrings and MultiLineStrings, and 2 for Polygons and MultiPolygons (regardless of whether or not they are empty). For GeometryCollections it is the maximum dimension over the collection (or 0 if the collection is the empty collection).

func (Geometry) Envelope

func (g Geometry) Envelope() (Envelope, bool)

Envelope returns the axis aligned bounding box that most tightly surrounds the geometry. Envelopes are not defined for empty geometries, in which case the returned flag will be false.

func (Geometry) EqualsExact

func (g Geometry) EqualsExact(other Geometry, opts ...EqualsExactOption) bool

EqualsExact checks if this geometry is equal to another geometry from a structural pointwise equality perspective. Geometries that are structurally equal are defined by exactly same control points in the same order. Note that even if two geometries are spatially equal (i.e. represent the same point set), they may not be defined by exactly the same way. Ordering differences and numeric tolerances can be accounted for using options.

func (Geometry) Force2D added in v0.10.0

func (g Geometry) Force2D() Geometry

Force2D returns a copy of the geometry with Z and M values removed.

func (Geometry) ForceCoordinatesType added in v0.10.0

func (g Geometry) ForceCoordinatesType(newCType CoordinatesType) Geometry

ForceCoordinatesType returns a new Geometry with a different CoordinatesType. If a dimension is added, then new values are populated with 0.

func (Geometry) Intersection

func (g Geometry) Intersection(other Geometry) (Geometry, error)

Intersection calculates the of this geometry and another, i.e. the portion of the two geometries that are shared. It is not implemented for all geometry pairs, and returns an error for those cases.

func (Geometry) Intersects

func (g Geometry) Intersects(other Geometry) bool

Intersects return true if and only if this geometry intersects with the other, i.e. they shared at least one common point.

func (Geometry) IsEmpty

func (g Geometry) IsEmpty() bool

IsEmpty returns true if this geometry is empty. Collection types are empty if they have zero elements or only contain empty elements.

func (Geometry) IsGeometryCollection added in v0.4.0

func (g Geometry) IsGeometryCollection() bool

IsGeometryCollection return true iff the Geometry is a GeometryCollection geometry.

func (Geometry) IsLine added in v0.4.0

func (g Geometry) IsLine() bool

IsLine return true iff the Geometry is a Line geometry.

func (Geometry) IsLineString added in v0.4.0

func (g Geometry) IsLineString() bool

IsLineString return true iff the Geometry is a LineString geometry.

func (Geometry) IsMultiLineString added in v0.4.0

func (g Geometry) IsMultiLineString() bool

IsMultiLineString return true iff the Geometry is a MultiLineString geometry.

func (Geometry) IsMultiPoint added in v0.4.0

func (g Geometry) IsMultiPoint() bool

IsMultiPoint return true iff the Geometry is a MultiPoint geometry.

func (Geometry) IsMultiPolygon added in v0.4.0

func (g Geometry) IsMultiPolygon() bool

IsMultiPolygon return true iff the Geometry is a MultiPolygon geometry.

func (Geometry) IsPoint added in v0.4.0

func (g Geometry) IsPoint() bool

IsPoint return true iff the Geometry is a Point geometry.

func (Geometry) IsPolygon added in v0.4.0

func (g Geometry) IsPolygon() bool

IsPolygon return true iff the Geometry is a Polygon geometry.

func (Geometry) IsSimple added in v0.4.0

func (g Geometry) IsSimple() (isSimple bool, wellDefined bool)

IsSimple calculates whether or not the geometry contains any anomalous geometric points such as self intersection or self tangency. For details about the precise definition for each type of geometry, see the IsSimple method documentation on that type. It is not defined for GeometryCollections, in which case false is returned.

func (Geometry) IsValid

func (g Geometry) IsValid() bool

IsValid returns if the current geometry is valid. It is useful to use when validation is disabled at constructing, for example, json.Unmarshal

func (Geometry) Length added in v0.4.0

func (g Geometry) Length() float64

Length gives the length of a Line, LineString, or MultiLineString or the sum of the lengths of the components of a GeometryCollection. Other Geometries are defined to return a length of zero.

func (Geometry) MarshalJSON added in v0.4.0

func (g Geometry) MarshalJSON() ([]byte, error)

MarshalJSON implements the encoding/json.Marshaller interface by encoding this geometry as a GeoJSON geometry object.

func (Geometry) Reverse added in v0.6.0

func (g Geometry) Reverse() Geometry

Reverse returns a new geometry containing coordinates listed in reverse order. Multi component geometries do not reverse the order of their components, but merely reverse each component's coordinates in place.

func (*Geometry) Scan added in v0.4.0

func (g *Geometry) Scan(src interface{}) error

Scan implements the database/sql.Scanner interface by parsing the src value as WKB (Well Known Binary).

It constructs the resultant geometry with no ConstructionOptions. If ConstructionOptions are needed, then the value should be scanned into a byte slice and then UnmarshalWKB called manually (passing in the ConstructionOptions as desired).

func (Geometry) TransformXY

func (g Geometry) TransformXY(fn func(XY) XY, opts ...ConstructorOption) (Geometry, error)

TransformXY transforms this Geometry into another geometry according the mapping provided by the XY function. Some classes of mappings (such as affine transformations) will preserve the validity this Geometry in the transformed Geometry, in which case no error will be returned. Other types of transformations may result in a validation error if their mapping results in an invalid Geometry.

func (Geometry) Type added in v0.9.0

func (g Geometry) Type() string

Type returns a string representation of the geometry's type.

func (*Geometry) UnmarshalJSON added in v0.4.0

func (g *Geometry) UnmarshalJSON(p []byte) error

UnmarshalJSON implements the encoding/json.Unmarshaller interface by parsing the JSON stream as GeoJSON geometry object.

It constructs the resultant geometry with no ConstructionOptions. If ConstructionOptions are needed, then the value should be unmarshalled into a json.RawMessage value and then UnmarshalJSON called manually (passing in the ConstructionOptions as desired).

func (Geometry) Value added in v0.4.0

func (g Geometry) Value() (driver.Value, error)

Value implements the database/sql/driver.Valuer interface by returning the WKB (Well Known Binary) representation of this Geometry.

type GeometryCollection

type GeometryCollection struct {
	// contains filtered or unexported fields
}

GeometryCollection is a non-homogeneous collection of geometries. Its zero value is the empty GeometryCollection (i.e. a collection of zero geometries).

func NewGeometryCollection

func NewGeometryCollection(geoms []Geometry, opts ...ConstructorOption) GeometryCollection

NewGeometryCollection creates a collection of geometries. The coordinates type of the GeometryCollection is the lowest common coordinates type of its child geometries.

func (GeometryCollection) AppendWKT

func (c GeometryCollection) AppendWKT(dst []byte) []byte

AppendWKT appends the WKT (Well Known Text) representation of this geometry to the input byte slice.

func (GeometryCollection) Area added in v0.6.0

func (c GeometryCollection) Area() float64

Area in the case of a GeometryCollection is the sum of the areas of its parts.

func (GeometryCollection) AsBinary

func (c GeometryCollection) AsBinary(w io.Writer) error

AsBinary writes the WKB (Well Known Binary) representation of the geometry to the writer.

func (GeometryCollection) AsGeometry added in v0.4.0

func (c GeometryCollection) AsGeometry() Geometry

AsGeometry converts this GeometryCollection into a Geometry.

func (GeometryCollection) AsText

func (c GeometryCollection) AsText() string

AsText returns the WKT (Well Known Text) representation of this geometry.

func (GeometryCollection) Boundary

Boundary returns the spatial boundary of this GeometryCollection. This is the GeometryCollection containing the boundaries of each child geometry.

func (GeometryCollection) Centroid added in v0.8.0

func (c GeometryCollection) Centroid() Point

Centroid of a GeometryCollection is the centroid of its parts' centroids.

func (GeometryCollection) ConvexHull

func (c GeometryCollection) ConvexHull() Geometry

ConvexHull returns the geometry representing the smallest convex geometry that contains this geometry.

func (GeometryCollection) CoordinatesType added in v0.10.0

func (c GeometryCollection) CoordinatesType() CoordinatesType

CoordinatesType returns the CoordinatesType used to represent points making up the geometry.

func (GeometryCollection) Dimension

func (c GeometryCollection) Dimension() int

Dimension returns the maximum dimension over the collection, or 0 if the collection is the empty collection. Points and MultiPoints have dimension 0, LineStrings and MultiLineStrings have dimension 1, and Polygons and MultiPolygons have dimension 2.

func (GeometryCollection) Envelope

func (c GeometryCollection) Envelope() (Envelope, bool)

Envelope returns the Envelope that most tightly surrounds the geometry. If the geometry is empty, then false is returned.

func (GeometryCollection) EqualsExact

func (c GeometryCollection) EqualsExact(other Geometry, opts ...EqualsExactOption) bool

EqualsExact checks if this GeometryCollection is exactly equal to another GeometryCollection.

func (GeometryCollection) Force2D added in v0.10.0

Force2D returns a copy of the GeometryCollection with Z and M values removed.

func (GeometryCollection) ForceCoordinatesType added in v0.10.0

func (c GeometryCollection) ForceCoordinatesType(newCType CoordinatesType) GeometryCollection

ForceCoordinatesType returns a new GeometryCollection with a different CoordinatesType. If a dimension is added, then new values are populated with 0.

func (GeometryCollection) GeometryN

func (c GeometryCollection) GeometryN(n int) Geometry

GeometryN gives the nth (zero based) Geometry in the GeometryCollection.

func (GeometryCollection) Intersection

func (c GeometryCollection) Intersection(g Geometry) (Geometry, error)

Intersection calculates the intersection between this geometry and another (i.e. the overlap between the two geometries). It is not implemented for all geometry pairs, and returns an error for those cases.

func (GeometryCollection) Intersects

func (c GeometryCollection) Intersects(g Geometry) bool

Intersects return true if and only if this geometry intersects with the other, i.e. they shared at least one common point.

func (GeometryCollection) IsEmpty

func (c GeometryCollection) IsEmpty() bool

IsEmpty return true if and only if this GeometryCollection doesn't contain any elements, or only contains empty elements.

func (GeometryCollection) IsValid

func (c GeometryCollection) IsValid() bool

IsValid checks if this GeometryCollection is valid. However, there is no constraints on it, so this function always returns true

func (GeometryCollection) Length added in v0.8.0

func (c GeometryCollection) Length() float64

Length of a GeometryCollection is the sum of the lengths of its parts.

func (GeometryCollection) MarshalJSON

func (c GeometryCollection) MarshalJSON() ([]byte, error)

MarshalJSON implements the encoding/json.Marshaller interface by encoding this geometry as a GeoJSON geometry object.

func (GeometryCollection) NumGeometries

func (c GeometryCollection) NumGeometries() int

NumGeometries gives the number of Geomety elements is the GeometryCollection.

func (GeometryCollection) Reverse added in v0.6.0

Reverse in the case of GeometryCollection reverses each component and also returns them in the original order.

func (GeometryCollection) TransformXY

func (c GeometryCollection) TransformXY(fn func(XY) XY, opts ...ConstructorOption) (GeometryCollection, error)

TransformXY transforms this GeometryCollection into another GeometryCollection according to fn.

func (GeometryCollection) Type added in v0.9.0

func (c GeometryCollection) Type() string

Type return type string for GeometryCollection

func (GeometryCollection) Value

func (c GeometryCollection) Value() (driver.Value, error)

Value implements the database/sql/driver.Valuer interface by returning the WKB (Well Known Binary) representation of this Geometry.

type Line

type Line struct {
	// contains filtered or unexported fields
}

Line is a linear geometry that represents a single line segment between two points that have distinct XY values. It is immutable after creation.

func NewLine added in v0.10.0

func NewLine(a, b Coordinates, opts ...ConstructorOption) (Line, error)

NewLine creates a line segment given the Coordinates of its two endpoints. An error is returned if the XY values of the coordinates are not distinct.

func NewLineFromXY added in v0.10.0

func NewLineFromXY(a, b XY, opts ...ConstructorOption) (Line, error)

NewLineFromXY creates a line segment given the XYs of its two endpoints. An error is returned if the XY values are not distinct.

func (Line) AppendWKT

func (n Line) AppendWKT(dst []byte) []byte

AppendWKT appends the WKT (Well Known Text) representation of this geometry to the input byte slice.

func (Line) AsBinary

func (n Line) AsBinary(w io.Writer) error

AsBinary writes the WKB (Well Known Binary) representation of the geometry to the writer.

func (Line) AsGeometry added in v0.4.0

func (n Line) AsGeometry() Geometry

AsGeometry converts this Line into a Geometry.

func (Line) AsLineString added in v0.2.0

func (n Line) AsLineString() LineString

AsLineString is a helper function that converts this Line into a LineString.

func (Line) AsText

func (n Line) AsText() string

AsText returns the WKT (Well Known Text) representation of this geometry.

func (Line) Boundary

func (n Line) Boundary() MultiPoint

Boundary returns the spatial boundary of this Line. This is the MultiPoint collection containing the two endpoints of the Line.

func (Line) Centroid added in v0.8.0

func (n Line) Centroid() Point

Centroid retruns the centroid of this Line, which is always its midpoint.

func (Line) ConvexHull

func (n Line) ConvexHull() Geometry

ConvexHull returns the geometry representing the smallest convex geometry that contains this geometry.

func (Line) Coordinates

func (n Line) Coordinates() Sequence

Coordinates returns the coordinates of the start and end point of the Line.

func (Line) CoordinatesType added in v0.10.0

func (n Line) CoordinatesType() CoordinatesType

CoordinatesType returns the CoordinatesType used to represent points making up the geometry.

func (Line) EndPoint

func (n Line) EndPoint() Coordinates

EndPoint gives the coordinates of the second (last) control point of the line.

func (Line) Envelope

func (n Line) Envelope() Envelope

Envelope returns the Envelope that most tightly surrounds the Line.

func (Line) EqualsExact

func (n Line) EqualsExact(other Geometry, opts ...EqualsExactOption) bool

EqualsExact checks if this Line is exactly equal to another curve.

func (Line) ForceCoordinatesType added in v0.10.0

func (n Line) ForceCoordinatesType(newCType CoordinatesType) Line

ForceCoordinatesType returns a new Line with a different CoordinatesType. If a dimension is added, then new values are populated with 0.

func (Line) Intersection

func (n Line) Intersection(g Geometry) (Geometry, error)

Intersection calculates the of this geometry and another, i.e. the portion of the two geometries that are shared. It is not implemented for all geometry pairs, and returns an error for those cases.

func (Line) Intersects

func (n Line) Intersects(g Geometry) bool

Intersects return true if and only if this geometry intersects with the other, i.e. they shared at least one common point.

func (Line) IsSimple

func (n Line) IsSimple() bool

IsSimple returns true if this geometry contains no anomalous geometry points, such as self intersection or self tangency. Lines are always simple, so this method always returns true.

func (Line) IsValid

func (n Line) IsValid() bool

IsValid checks if this Line is valid

func (Line) Length

func (n Line) Length() float64

Length gives the length of the line.

func (Line) MarshalJSON

func (n Line) MarshalJSON() ([]byte, error)

MarshalJSON implements the encoding/json.Marshaller interface by encoding this geometry as a GeoJSON geometry object.

func (Line) NumPoints

func (n Line) NumPoints() int

NumPoints always returns 2.

func (Line) PointN

func (n Line) PointN(i int) Coordinates

PointN returns the coordinates of the first point when i is 0, and the second point when i is 1. It panics if i is any other value.

func (Line) Reverse added in v0.6.0

func (n Line) Reverse() Line

Reverse in the case of Line outputs the coordinates in reverse order.

func (Line) StartPoint

func (n Line) StartPoint() Coordinates

StartPoint gives the coordinates of the first control point of the line.

func (Line) TransformXY

func (n Line) TransformXY(fn func(XY) XY, opts ...ConstructorOption) (Line, error)

TransformXY transforms this Line into another Line according to fn.

func (Line) Type added in v0.9.0

func (n Line) Type() string

Type return type string for Line

func (Line) Value

func (n Line) Value() (driver.Value, error)

Value implements the database/sql/driver.Valuer interface by returning the WKB (Well Known Binary) representation of this Geometry.

type LineString

type LineString struct {
	// contains filtered or unexported fields
}

LineString is a linear geometry defined by linear interpolation between a finite set of points. Its zero value is the empty line string. It is immutable after creation.

A LineString must consist of either zero points (i.e. it is the empty line string), or it must have at least 2 points with distinct XY values.

func NewLineString added in v0.10.0

func NewLineString(seq Sequence, opts ...ConstructorOption) (LineString, error)

NewLineString creates a new LineString from a Sequence of points. The sequence must contain exactly 0 points, or at least 2 points with distinct XY values (otherwise an error is returned).

func (LineString) AppendWKT

func (s LineString) AppendWKT(dst []byte) []byte

AppendWKT appends the WKT (Well Known Text) representation of this geometry to the input byte slice.

func (LineString) AsBinary

func (s LineString) AsBinary(w io.Writer) error

AsBinary writes the WKB (Well Known Binary) representation of the geometry to the writer.

func (LineString) AsGeometry added in v0.4.0

func (s LineString) AsGeometry() Geometry

AsGeometry converts this LineString into a Geometry.

func (LineString) AsMultiLineString added in v0.2.0

func (s LineString) AsMultiLineString() MultiLineString

AsMultiLineString is a convenience function that converts this LineString into a MultiLineString.

func (LineString) AsText

func (s LineString) AsText() string

AsText returns the WKT (Well Known Text) representation of this geometry.

func (LineString) Boundary

func (s LineString) Boundary() MultiPoint

Boundary returns the spatial boundary of this LineString. For closed LineStrings (i.e. LineStrings where the start and end points have the same XY value), this is the empty MultiPoint. For non-closed LineStrings, this is the MultiPoint containing the two endpoints of the LineString.

func (LineString) Centroid added in v0.8.0

func (s LineString) Centroid() Point

Centroid gives the centroid of the coordinates of the line string.

func (LineString) ConvexHull

func (s LineString) ConvexHull() Geometry

ConvexHull returns the geometry representing the smallest convex geometry that contains this geometry.

func (LineString) Coordinates

func (s LineString) Coordinates() Sequence

Coordinates returns the coordinates of each point along the LineString.

func (LineString) CoordinatesType added in v0.10.0

func (s LineString) CoordinatesType() CoordinatesType

CoordinatesType returns the CoordinatesType used to represent points making up the geometry.

func (LineString) EndPoint

func (s LineString) EndPoint() Point

EndPoint gives the last point of the LineString. If the LineString is empty then it returns the empty Point.

func (LineString) Envelope

func (s LineString) Envelope() (Envelope, bool)

Envelope returns the Envelope that most tightly surrounds the geometry. If the geometry is empty, then false is returned.

func (LineString) EqualsExact

func (s LineString) EqualsExact(other Geometry, opts ...EqualsExactOption) bool

EqualsExact checks if this LineString is exactly equal to another curve.

func (LineString) Force2D added in v0.10.0

func (s LineString) Force2D() LineString

Force2D returns a copy of the LineString with Z and M values removed.

func (LineString) ForceCoordinatesType added in v0.10.0

func (s LineString) ForceCoordinatesType(newCType CoordinatesType) LineString

ForceCoordinatesType returns a new LineString with a different CoordinatesType. If a dimension is added, then new values are populated with 0.

func (LineString) Intersection

func (s LineString) Intersection(g Geometry) (Geometry, error)

Intersection calculates the of this geometry and another, i.e. the portion of the two geometries that are shared. It is not implemented for all geometry pairs, and returns an error for those cases.

func (LineString) Intersects

func (s LineString) Intersects(g Geometry) bool

Intersects return true if and only if this geometry intersects with the other, i.e. they shared at least one common point.

func (LineString) IsClosed

func (s LineString) IsClosed() bool

IsClosed returns true if and only if this LineString is not empty and its start and end points are coincident.

func (LineString) IsEmpty

func (s LineString) IsEmpty() bool

IsEmpty returns true if and only if this LineString is the empty LineString. The empty LineString is defined by a zero length coordinates sequence.

func (LineString) IsRing

func (s LineString) IsRing() bool

IsRing returns true iff this LineString is both simple and closed (i.e. is a linear ring).

func (LineString) IsSimple

func (s LineString) IsSimple() bool

IsSimple returns true if this geometry contains no anomalous geometry points, such as self intersection or self tangency. LineStrings are simple if and only if the curve defined by the LineString doesn't pass through the same point twice (with the except of the two endpoints being coincident).

func (LineString) IsValid

func (s LineString) IsValid() bool

IsValid checks if this LineString is valid

func (LineString) Length

func (s LineString) Length() float64

Length gives the length of the line string.

func (LineString) MarshalJSON

func (s LineString) MarshalJSON() ([]byte, error)

MarshalJSON implements the encoding/json.Marshaller interface by encoding this geometry as a GeoJSON geometry object.

func (LineString) Reverse added in v0.6.0

func (s LineString) Reverse() LineString

Reverse in the case of LineString outputs the coordinates in reverse order.

func (LineString) StartPoint

func (s LineString) StartPoint() Point

StartPoint gives the first point of the LineString. If the LineString is empty then it returns the empty Point.

func (LineString) TransformXY

func (s LineString) TransformXY(fn func(XY) XY, opts ...ConstructorOption) (LineString, error)

TransformXY transforms this LineString into another LineString according to fn.

func (LineString) Type added in v0.9.0

func (s LineString) Type() string

Type return type string for LineString

func (LineString) Value

func (s LineString) Value() (driver.Value, error)

Value implements the database/sql/driver.Valuer interface by returning the WKB (Well Known Binary) representation of this Geometry.

type MultiLineString

type MultiLineString struct {
	// contains filtered or unexported fields
}

MultiLineString is a linear geometry that consists of a collection of LineStrings. It's zero value is the empty MultiLineString (i.e. the collection of zero LineStrings) of 2D coordinate type. It is immutable after creation.

func NewMultiLineStringFromLineStrings added in v0.10.0

func NewMultiLineStringFromLineStrings(lines []LineString, opts ...ConstructorOption) MultiLineString

NewMultiLineStringFromLineStrings creates a MultiLineString from its constituent LineStrings. The coordinates type of the MultiLineString is the lowest common coordinates type of its LineStrings.

func (MultiLineString) AppendWKT

func (m MultiLineString) AppendWKT(dst []byte) []byte

AppendWKT appends the WKT (Well Known Text) representation of this geometry to the input byte slice.

func (MultiLineString) AsBinary

func (m MultiLineString) AsBinary(w io.Writer) error

AsBinary writes the WKB (Well Known Binary) representation of the geometry to the writer.

func (MultiLineString) AsGeometry added in v0.4.0

func (m MultiLineString) AsGeometry() Geometry

AsGeometry converts this MultiLineString into a Geometry.

func (MultiLineString) AsText

func (m MultiLineString) AsText() string

AsText returns the WKT (Well Known Text) representation of this geometry.

func (MultiLineString) Boundary

func (m MultiLineString) Boundary() MultiPoint

Boundary returns the spatial boundary of this MultiLineString. This is calculated using the "mod 2 rule". The rule states that a Point is included as part of the boundary if and only if it appears on the boundry of an odd number of members in the collection.

func (MultiLineString) Centroid added in v0.8.0

func (m MultiLineString) Centroid() Point

Centroid gives the centroid of the coordinates of the multi line string.

func (MultiLineString) ConvexHull

func (m MultiLineString) ConvexHull() Geometry

ConvexHull returns the geometry representing the smallest convex geometry that contains this geometry.

func (MultiLineString) Coordinates

func (m MultiLineString) Coordinates() []Sequence

Coordinates returns the coordinates of each constintuent LineString in the MultiLineString.

func (MultiLineString) CoordinatesType added in v0.10.0

func (m MultiLineString) CoordinatesType() CoordinatesType

CoordinatesType returns the CoordinatesType used to represent points making up the geometry.

func (MultiLineString) Envelope

func (m MultiLineString) Envelope() (Envelope, bool)

Envelope returns the Envelope that most tightly surrounds the geometry. If the geometry is empty, then false is returned.

func (MultiLineString) EqualsExact

func (m MultiLineString) EqualsExact(other Geometry, opts ...EqualsExactOption) bool

EqualsExact checks if this MultiLineString is exactly equal to another MultiLineString.

func (MultiLineString) Force2D added in v0.10.0

func (m MultiLineString) Force2D() MultiLineString

Force2D returns a copy of the MultiLineString with Z and M values removed.

func (MultiLineString) ForceCoordinatesType added in v0.10.0

func (m MultiLineString) ForceCoordinatesType(newCType CoordinatesType) MultiLineString

ForceCoordinatesType returns a new MultiLineString with a different CoordinatesType. If a dimension is added, then new values are populated with 0.

func (MultiLineString) Intersection

func (m MultiLineString) Intersection(g Geometry) (Geometry, error)

Intersection calculates the of this geometry and another, i.e. the portion of the two geometries that are shared. It is not implemented for all geometry pairs, and returns an error for those cases.

func (MultiLineString) Intersects

func (m MultiLineString) Intersects(g Geometry) bool

Intersects return true if and only if this geometry intersects with the other, i.e. they shared at least one common point.

func (MultiLineString) IsEmpty

func (m MultiLineString) IsEmpty() bool

IsEmpty return true if and only if this MultiLineString doesn't contain any LineStrings, or only contains empty LineStrings.

func (MultiLineString) IsSimple

func (m MultiLineString) IsSimple() bool

IsSimple returns true if this geometry contains no anomalous geometry points, such as self intersection or self tangency. A MultiLineString is simple if and only if the following conditions hold:

1. Each element (a LineString) is simple.

2. The intersection between any two distinct elements occurs at points that are on the boundaries of both elements.

func (MultiLineString) IsValid

func (m MultiLineString) IsValid() bool

IsValid checks if this MultiLineString is valid

func (MultiLineString) Length

func (m MultiLineString) Length() float64

Length gives the sum of the lengths of the constituent members of the multi line string.

func (MultiLineString) LineStringN

func (m MultiLineString) LineStringN(n int) LineString

LineStringN gives the nth (zero indexed) LineString element.

func (MultiLineString) MarshalJSON

func (m MultiLineString) MarshalJSON() ([]byte, error)

MarshalJSON implements the encoding/json.Marshaller interface by encoding this geometry as a GeoJSON geometry object.

func (MultiLineString) NumLineStrings

func (m MultiLineString) NumLineStrings() int

NumLineStrings gives the number of LineString elements in the MultiLineString.

func (MultiLineString) Reverse added in v0.6.0

func (m MultiLineString) Reverse() MultiLineString

Reverse in the case of MultiLineString outputs each component line string in their original order, each individually reversed.

func (MultiLineString) TransformXY

func (m MultiLineString) TransformXY(fn func(XY) XY, opts ...ConstructorOption) (MultiLineString, error)

TransformXY transforms this MultiLineString into another MultiLineString according to fn.

func (MultiLineString) Type added in v0.9.0

func (m MultiLineString) Type() string

Type return type string for MultiLineString

func (MultiLineString) Value

func (m MultiLineString) Value() (driver.Value, error)

Value implements the database/sql/driver.Valuer interface by returning the WKB (Well Known Binary) representation of this Geometry.

type MultiPoint

type MultiPoint struct {
	// contains filtered or unexported fields
}

MultiPoint is a 0-dimensional geometry that is a collection of points. Its zero value is the empty MultiPoint (i.e. a collection of zero points) with 2D coordinates type. It is immutable after creation.

func NewMultiPoint

func NewMultiPoint(seq Sequence, opts ...ConstructorOption) MultiPoint

NewMultiPoint creates a new MultiPoint from a sequence of Coordinates.

func NewMultiPointFromPoints added in v0.10.0

func NewMultiPointFromPoints(pts []Point, opts ...ConstructorOption) MultiPoint

NewMultiPointFromPoints creates a MultiPoint from a list of Points. The coordinate type of the MultiPoint is the lowest common coordinates type of its Points.

func NewMultiPointWithEmptyMask added in v0.10.0

func NewMultiPointWithEmptyMask(seq Sequence, empty BitSet, opts ...ConstructorOption) MultiPoint

NewMultiPointWithEmptyMask creates a new MultiPoint from a sequence of coordinates. If there are any positions set in the BitSet, then these are used to indicate that the corresponding point in the sequence is an empty point.

func (MultiPoint) AppendWKT

func (m MultiPoint) AppendWKT(dst []byte) []byte

AppendWKT appends the WKT (Well Known Text) representation of this geometry to the input byte slice.

func (MultiPoint) AsBinary

func (m MultiPoint) AsBinary(w io.Writer) error

AsBinary writes the WKB (Well Known Binary) representation of the geometry to the writer.

func (MultiPoint) AsGeometry added in v0.4.0

func (m MultiPoint) AsGeometry() Geometry

AsGeometry converts this MultiPoint into a Geometry.

func (MultiPoint) AsText

func (m MultiPoint) AsText() string

AsText returns the WKT (Well Known Text) representation of this geometry.

func (MultiPoint) Boundary

func (m MultiPoint) Boundary() GeometryCollection

Boundary returns the spatial boundary for this MultiPoint, which is always the empty set. This is represented by the empty GeometryCollection.

func (MultiPoint) Centroid added in v0.8.0

func (m MultiPoint) Centroid() Point

Centroid gives the centroid of the coordinates of the MultiPoint.

func (MultiPoint) ConvexHull

func (m MultiPoint) ConvexHull() Geometry

ConvexHull returns the geometry representing the smallest convex geometry that contains this geometry.

func (MultiPoint) Coordinates

func (m MultiPoint) Coordinates() (seq Sequence, empty BitSet)

Coordinates returns the coordinates of the points represented by the MultiPoint. If a point has its corresponding bit set to true in the BitSet, then that point is empty.

func (MultiPoint) CoordinatesType added in v0.10.0

func (m MultiPoint) CoordinatesType() CoordinatesType

CoordinatesType returns the CoordinatesType used to represent points making up the geometry.

func (MultiPoint) Envelope

func (m MultiPoint) Envelope() (Envelope, bool)

Envelope returns the Envelope that most tightly surrounds the geometry. If the geometry is empty, then false is returned.

func (MultiPoint) EqualsExact

func (m MultiPoint) EqualsExact(other Geometry, opts ...EqualsExactOption) bool

EqualsExact checks if this MultiPoint is exactly equal to another MultiPoint.

func (MultiPoint) Force2D added in v0.10.0

func (m MultiPoint) Force2D() MultiPoint

Force2D returns a copy of the MultiPoint with Z and M values removed.

func (MultiPoint) ForceCoordinatesType added in v0.10.0

func (m MultiPoint) ForceCoordinatesType(newCType CoordinatesType) MultiPoint

ForceCoordinatesType returns a new MultiPoint with a different CoordinatesType. If a dimension is added, then new values are populated with 0.

func (MultiPoint) Intersection

func (m MultiPoint) Intersection(g Geometry) (Geometry, error)

Intersection calculates the of this geometry and another, i.e. the portion of the two geometries that are shared. It is not implemented for all geometry pairs, and returns an error for those cases.

func (MultiPoint) Intersects

func (m MultiPoint) Intersects(g Geometry) bool

Intersects return true if and only if this geometry intersects with the other, i.e. they shared at least one common point.

func (MultiPoint) IsEmpty

func (m MultiPoint) IsEmpty() bool

IsEmpty return true if and only if this MultiPoint doesn't contain any Points, or only contains empty Points.

func (MultiPoint) IsSimple

func (m MultiPoint) IsSimple() bool

IsSimple returns true if this geometry contains no anomalous geometry points, such as self intersection or self tangency. MultiPoints are simple if and only if no two of its points have equal XY coordinates.

func (MultiPoint) IsValid

func (m MultiPoint) IsValid() bool

IsValid checks if this MultiPoint is valid. However, there is no way to indicate whether or not MultiPoint is valid, so this function always returns true

func (MultiPoint) MarshalJSON

func (m MultiPoint) MarshalJSON() ([]byte, error)

MarshalJSON implements the encoding/json.Marshaller interface by encoding this geometry as a GeoJSON geometry object.

func (MultiPoint) NumPoints

func (m MultiPoint) NumPoints() int

NumPoints gives the number of element points making up the MultiPoint.

func (MultiPoint) PointN

func (m MultiPoint) PointN(n int) Point

PointN gives the nth (zero indexed) Point.

func (MultiPoint) Reverse added in v0.6.0

func (m MultiPoint) Reverse() MultiPoint

Reverse in the case of MultiPoint outputs each component point in their original order.

func (MultiPoint) TransformXY

func (m MultiPoint) TransformXY(fn func(XY) XY, opts ...ConstructorOption) (MultiPoint, error)

TransformXY transforms this MultiPoint into another MultiPoint according to fn.

func (MultiPoint) Type added in v0.9.0

func (m MultiPoint) Type() string

Type return type string for MultiPoint

func (MultiPoint) Value

func (m MultiPoint) Value() (driver.Value, error)

Value implements the database/sql/driver.Valuer interface by returning the WKB (Well Known Binary) representation of this Geometry.

type MultiPolygon

type MultiPolygon struct {
	// contains filtered or unexported fields
}

MultiPolygon is a planar surface geometry that consists of a collection of Polygons. The zero value is the empty MultiPolygon (i.e. the collection of zero Polygons). It is immutable after creation.

For a MultiPolygon to be valid, the following assertions must hold:

1. It must be made up of zero or more valid Polygons (any of which may be empty).

2. The interiors of any two polygons must not intersect.

3. The boundaries of any two polygons may touch only at a finite number of points.

func NewMultiPolygonFromPolygons added in v0.10.0

func NewMultiPolygonFromPolygons(polys []Polygon, opts ...ConstructorOption) (MultiPolygon, error)

NewMultiPolygonFromPolygons creates a MultiPolygon from its constituent Polygons. It gives an error if any of the MultiPolygon assertions are not maintained. The coordinates type of the MultiPolygon is the lowest common coordinates type its Polygons.

func (MultiPolygon) AppendWKT

func (m MultiPolygon) AppendWKT(dst []byte) []byte

AppendWKT appends the WKT (Well Known Text) representation of this geometry to the input byte slice.

func (MultiPolygon) Area

func (m MultiPolygon) Area() float64

Area in the case of a MultiPolygon is the sum of the areas of its polygons.

func (MultiPolygon) AsBinary

func (m MultiPolygon) AsBinary(w io.Writer) error

AsBinary writes the WKB (Well Known Binary) representation of the geometry to the writer.

func (MultiPolygon) AsGeometry added in v0.4.0

func (m MultiPolygon) AsGeometry() Geometry

AsGeometry converts this MultiPolygon into a Geometry.

func (MultiPolygon) AsText

func (m MultiPolygon) AsText() string

AsText returns the WKT (Well Known Text) representation of this geometry.

func (MultiPolygon) Boundary

func (m MultiPolygon) Boundary() MultiLineString

Boundary returns the spatial boundary of this MultiPolygon. This is the MultiLineString containing the boundaries of the MultiPolygon's elements.

func (MultiPolygon) Centroid

func (m MultiPolygon) Centroid() Point

Centroid returns the multi polygon's centroid point. It returns the empty Point if the multi polygon is empty.

func (MultiPolygon) ConvexHull

func (m MultiPolygon) ConvexHull() Geometry

ConvexHull returns the geometry representing the smallest convex geometry that contains this geometry.

func (MultiPolygon) Coordinates

func (m MultiPolygon) Coordinates() [][]Sequence

Coordinates returns the coordinates of each constituent Polygon of the MultiPolygon.

func (MultiPolygon) CoordinatesType added in v0.10.0

func (m MultiPolygon) CoordinatesType() CoordinatesType

CoordinatesType returns the CoordinatesType used to represent points making up the geometry.

func (MultiPolygon) Envelope

func (m MultiPolygon) Envelope() (Envelope, bool)

Envelope returns the Envelope that most tightly surrounds the geometry. If the geometry is empty, then false is returned.

func (MultiPolygon) EqualsExact

func (m MultiPolygon) EqualsExact(other Geometry, opts ...EqualsExactOption) bool

EqualsExact checks if this MultiPolygon is exactly equal to another MultiPolygon.

func (MultiPolygon) Force2D added in v0.10.0

func (m MultiPolygon) Force2D() MultiPolygon

Force2D returns a copy of the MultiPolygon with Z and M values removed.

func (MultiPolygon) ForceCoordinatesType added in v0.10.0

func (m MultiPolygon) ForceCoordinatesType(newCType CoordinatesType) MultiPolygon

ForceCoordinatesType returns a new MultiPolygon with a different CoordinatesType. If a dimension is added, then new values are populated with 0.

func (MultiPolygon) Intersection

func (m MultiPolygon) Intersection(g Geometry) (Geometry, error)

Intersection calculates the of this geometry and another, i.e. the portion of the two geometries that are shared. It is not implemented for all geometry pairs, and returns an error for those cases.

func (MultiPolygon) Intersects

func (m MultiPolygon) Intersects(g Geometry) bool

Intersects return true if and only if this geometry intersects with the other, i.e. they shared at least one common point.

func (MultiPolygon) IsEmpty

func (m MultiPolygon) IsEmpty() bool

IsEmpty return true if and only if this MultiPolygon doesn't contain any Polygons, or only contains empty Polygons.

func (MultiPolygon) IsSimple

func (m MultiPolygon) IsSimple() bool

IsSimple returns true if this geometry contains no anomalous geometry points, such as self intersection or self tangency. Because MultiPolygons are always simple, this method always returns true.

func (MultiPolygon) IsValid

func (m MultiPolygon) IsValid() bool

IsValid checks if this MultiPolygon is valid

func (MultiPolygon) MarshalJSON

func (m MultiPolygon) MarshalJSON() ([]byte, error)

MarshalJSON implements the encoding/json.Marshaller interface by encoding this geometry as a GeoJSON geometry object.

func (MultiPolygon) NumPolygons

func (m MultiPolygon) NumPolygons() int

NumPolygons gives the number of Polygon elements in the MultiPolygon.

func (MultiPolygon) PolygonN

func (m MultiPolygon) PolygonN(n int) Polygon

PolygonN gives the nth (zero based) Polygon element.

func (MultiPolygon) Reverse added in v0.6.0

func (m MultiPolygon) Reverse() MultiPolygon

Reverse in the case of MultiPolygon outputs the component polygons in their original order, each individually reversed.

func (MultiPolygon) SignedArea added in v0.6.0

func (m MultiPolygon) SignedArea() float64

SignedArea returns the sum of the signed areas of the constituent polygons.

func (MultiPolygon) TransformXY

func (m MultiPolygon) TransformXY(fn func(XY) XY, opts ...ConstructorOption) (MultiPolygon, error)

TransformXY transforms this MultiPolygon into another MultiPolygon according to fn.

func (MultiPolygon) Type added in v0.9.0

func (m MultiPolygon) Type() string

Type return type string for MultiPolygon

func (MultiPolygon) Value

func (m MultiPolygon) Value() (driver.Value, error)

Value implements the database/sql/driver.Valuer interface by returning the WKB (Well Known Binary) representation of this Geometry.

type NullGeometry added in v0.8.0

type NullGeometry struct {
	Geometry Geometry
	Valid    bool // Valid is true iff Geometry is not NULL
}

NullGeometry represents a Geometry that may be NULL. It implements the database/sql.Scanner and database/sql.Valuer interfaces, so may be used as a scan destination or query argument in SQL queries.

func (*NullGeometry) Scan added in v0.8.0

func (ng *NullGeometry) Scan(value interface{}) error

Scan implements the the database/sql.Scanner interface.

func (NullGeometry) Value added in v0.8.0

func (ng NullGeometry) Value() (driver.Value, error)

Value implements the database/sql.Valuer interface.

type Point

type Point struct {
	// contains filtered or unexported fields
}

Point is a zero dimensional geometry that represents a single location in a coordinate space. It is immutable after creation.

The Point may be empty.

The zero value of Point is a 2D empty Point.

func NewEmptyPoint

func NewEmptyPoint(ctype CoordinatesType) Point

NewEmptyPoint creates a Point that is empty.

func NewPoint added in v0.10.0

func NewPoint(c Coordinates, _ ...ConstructorOption) Point

NewPoint creates a new point gives its Coordinates.

func NewPointFromXY added in v0.10.0

func NewPointFromXY(xy XY, _ ...ConstructorOption) Point

NewPointFromXY creates a new point from an XY.

func (Point) AppendWKT

func (p Point) AppendWKT(dst []byte) []byte

AppendWKT appends the WKT (Well Known Text) representation of this geometry to the input byte slice.

func (Point) AsBinary

func (p Point) AsBinary(w io.Writer) error

AsBinary writes the WKB (Well Known Binary) representation of the geometry to the writer.

func (Point) AsGeometry added in v0.4.0

func (p Point) AsGeometry() Geometry

AsGeometry converts this Point into a Geometry.

func (Point) AsMultiPoint added in v0.10.0

func (p Point) AsMultiPoint() MultiPoint

AsMultiPoint is a convenience function that converts this Point into a MultiPoint.

func (Point) AsText

func (p Point) AsText() string

AsText returns the WKT (Well Known Text) representation of this geometry.

func (Point) Boundary

func (p Point) Boundary() GeometryCollection

Boundary returns the spatial boundary for this Point, which is always the empty set. This is represented by the empty GeometryCollection.

func (Point) Centroid added in v0.8.0

func (p Point) Centroid() Point

Centroid of a point is that point.

func (Point) ConvexHull

func (p Point) ConvexHull() Geometry

ConvexHull returns the geometry representing the smallest convex geometry that contains this geometry.

func (Point) Coordinates

func (p Point) Coordinates() (Coordinates, bool)

Coordinates returns the coordinates of the point. The returned flag is set to true if and only if the point is non-empty.

func (Point) CoordinatesType added in v0.10.0

func (p Point) CoordinatesType() CoordinatesType

CoordinatesType returns the CoordinatesType used to represent the Point.

func (Point) Envelope

func (p Point) Envelope() (Envelope, bool)

Envelope returns a zero area Envelope covering the Point. If the Point is empty, then false is returned.

func (Point) EqualsExact

func (p Point) EqualsExact(other Geometry, opts ...EqualsExactOption) bool

EqualsExact checks if this Point is exactly equal to another Point.

func (Point) Force2D added in v0.10.0

func (p Point) Force2D() Point

Force2D returns a copy of the Point with Z and M values removed.

func (Point) ForceCoordinatesType added in v0.10.0

func (p Point) ForceCoordinatesType(newCType CoordinatesType) Point

ForceCoordinatesType returns a new Point with a different CoordinatesType. If a dimension is added, then new values are populated with 0.

func (Point) Intersection

func (p Point) Intersection(g Geometry) (Geometry, error)

Intersection calculates the of this geometry and another, i.e. the portion of the two geometries that are shared. It is not implemented for all geometry pairs, and returns an error for those cases.

func (Point) Intersects

func (p Point) Intersects(g Geometry) bool

Intersects return true if and only if this geometry intersects with the other, i.e. they shared at least one common point.

func (Point) IsEmpty

func (p Point) IsEmpty() bool

IsEmpty returns true if and only if this Point is the empty Point.

func (Point) IsSimple

func (p Point) IsSimple() bool

IsSimple returns true if this geometry contains no anomalous geometry points, such as self intersection or self tangency. Points are always simple, so this method always return true.

func (Point) IsValid

func (p Point) IsValid() bool

IsValid checks if this Point is valid, but there is not way to indicate if Point is valid, so this function always returns true

func (Point) MarshalJSON

func (p Point) MarshalJSON() ([]byte, error)

MarshalJSON implements the encoding/json.Marshaller interface by encoding this geometry as a GeoJSON geometry object.

func (Point) Reverse added in v0.6.0

func (p Point) Reverse() Point

Reverse in the case of Point outputs the same point.

func (Point) TransformXY

func (p Point) TransformXY(fn func(XY) XY, opts ...ConstructorOption) (Point, error)

TransformXY transforms this Point into another Point according to fn.

func (Point) Type added in v0.9.0

func (p Point) Type() string

Type return type string for Point

func (Point) Value

func (p Point) Value() (driver.Value, error)

Value implements the database/sql/driver.Valuer interface by returning the WKB (Well Known Binary) representation of this Geometry.

func (Point) XY

func (p Point) XY() (XY, bool)

XY gives the XY location of the point. The returned flag is set to true if and only if the point is non-empty.

type Polygon

type Polygon struct {
	// contains filtered or unexported fields
}

Polygon is a planar surface geometry. Its zero value is the empty Polygon. It is immutable after creation. When not empty, it is defined by one outer ring and zero or more interior rings. The outer ring defines the exterior boundary of the Polygon, and each inner ring defines a hole in the polygon.

For a Polygon to be valid, the following assertions must hold:

  1. The rings (outer and inner) must be valid linear rings. This means that they must be non-empty, simple, and closed.

2. Each pair of rings must only intersect at a single point.

3. The interior of the polygon must be connected.

4. The holes must be fully inside the outer ring.

func NewPolygonFromRings added in v0.10.0

func NewPolygonFromRings(rings []LineString, opts ...ConstructorOption) (Polygon, error)

NewPolygonFromRings creates a polygon given its rings. The outer ring is first, and any inner rings follow. If no rings are provided, then the returned Polygon is the empty Polygon. The coordinate type of the polygon is the lowest common coordinate type of its rings.

func (Polygon) AppendWKT

func (p Polygon) AppendWKT(dst []byte) []byte

AppendWKT appends the WKT (Well Known Text) representation of this geometry to the input byte slice.

func (Polygon) Area

func (p Polygon) Area() float64

Area of a Polygon is the outer ring's area minus the areas of all inner rings.

func (Polygon) AsBinary

func (p Polygon) AsBinary(w io.Writer) error

AsBinary writes the WKB (Well Known Binary) representation of the geometry to the writer.

func (Polygon) AsGeometry added in v0.4.0

func (p Polygon) AsGeometry() Geometry

AsGeometry converts this Polygon into a Geometry.

func (Polygon) AsMultiPolygon added in v0.2.0

func (p Polygon) AsMultiPolygon() MultiPolygon

AsMultiPolygon is a helper that converts this Polygon into a MultiPolygon.

func (Polygon) AsText

func (p Polygon) AsText() string

AsText returns the WKT (Well Known Text) representation of this geometry.

func (Polygon) Boundary

func (p Polygon) Boundary() MultiLineString

Boundary returns the spatial boundary of this Polygon. For non-empty Polygons, this is the MultiLineString collection containing all of the rings.

func (Polygon) Centroid

func (p Polygon) Centroid() Point

Centroid returns the polygon's centroid point. If returns an empty Point if the Polygon is empty.

func (Polygon) ConvexHull

func (p Polygon) ConvexHull() Geometry

ConvexHull returns the geometry representing the smallest convex geometry that contains this geometry.

func (Polygon) Coordinates

func (p Polygon) Coordinates() []Sequence

Coordinates returns the coordinates of the rings making up the Polygon (external ring first, then internal rings after).

func (Polygon) CoordinatesType added in v0.10.0

func (p Polygon) CoordinatesType() CoordinatesType

CoordinatesType returns the CoordinatesType used to represent points making up the geometry.

func (Polygon) Envelope

func (p Polygon) Envelope() (Envelope, bool)

Envelope returns the Envelope that most tightly surrounds the geometry. If the geometry is empty, then false is returned.

func (Polygon) EqualsExact

func (p Polygon) EqualsExact(other Geometry, opts ...EqualsExactOption) bool

EqualsExact checks if this Polygon is exactly equal to another Polygon.

func (Polygon) ExteriorRing

func (p Polygon) ExteriorRing() LineString

ExteriorRing gives the exterior ring of the polygon boundary. If the polygon is empty, then it returns the empty LineString.

func (Polygon) Force2D added in v0.10.0

func (p Polygon) Force2D() Polygon

Force2D returns a copy of the Polygon with Z and M values removed.

func (Polygon) ForceCoordinatesType added in v0.10.0

func (p Polygon) ForceCoordinatesType(newCType CoordinatesType) Polygon

ForceCoordinatesType returns a new Polygon with a different CoordinatesType. If a dimension is added, then new values are populated with 0.

func (Polygon) InteriorRingN

func (p Polygon) InteriorRingN(n int) LineString

InteriorRingN gives the nth (zero indexed) interior ring in the polygon boundary. It will panic if n is out of bounds with respect to the number of interior rings.

func (Polygon) Intersection

func (p Polygon) Intersection(g Geometry) (Geometry, error)

Intersection calculates the of this geometry and another, i.e. the portion of the two geometries that are shared. It is not implemented for all geometry pairs, and returns an error for those cases.

func (Polygon) Intersects

func (p Polygon) Intersects(g Geometry) bool

Intersects return true if and only if this geometry intersects with the other, i.e. they shared at least one common point.

func (Polygon) IsEmpty

func (p Polygon) IsEmpty() bool

IsEmpty returns true if and only if this Polygon is the empty Polygon. The empty Polygon doesn't have any rings and doesn't enclose any area.

func (Polygon) IsSimple

func (p Polygon) IsSimple() bool

IsSimple returns true if this geometry contains no anomalous geometry points, such as self intersection or self tangency. Because Polygons are always simple, this method always returns true.

func (Polygon) IsValid

func (p Polygon) IsValid() bool

IsValid checks if this Polygon is valid

func (Polygon) MarshalJSON

func (p Polygon) MarshalJSON() ([]byte, error)

MarshalJSON implements the encoding/json.Marshaller interface by encoding this geometry as a GeoJSON geometry object.

func (Polygon) NumInteriorRings

func (p Polygon) NumInteriorRings() int

NumInteriorRings gives the number of interior rings in the polygon boundary.

func (Polygon) Reverse added in v0.6.0

func (p Polygon) Reverse() Polygon

Reverse in the case of Polygon outputs the coordinates of each ring in reverse order, but note the order of the inner rings is unchanged.

func (Polygon) SignedArea added in v0.6.0

func (p Polygon) SignedArea() float64

SignedArea gives the positive area of the polygon when the outer rings are wound CCW and any inner rings are wound CW, and the negative area of the polygon when the outer rings are wound CW and any inner rings are wound CCW. If the windings of the inner and outer rings are the same, then the area will be inconsistent.

func (Polygon) TransformXY

func (p Polygon) TransformXY(fn func(XY) XY, opts ...ConstructorOption) (Polygon, error)

TransformXY transforms this Polygon into another Polygon according to fn.

func (Polygon) Type added in v0.9.0

func (p Polygon) Type() string

Type return type string for Polygon

func (Polygon) Value

func (p Polygon) Value() (driver.Value, error)

Value implements the database/sql/driver.Valuer interface by returning the WKB (Well Known Binary) representation of this Geometry.

type Sequence added in v0.10.0

type Sequence struct {
	// contains filtered or unexported fields
}

Sequence represents a list of point locations. It is immutable after creation. All locations in the Sequence are specified using the same coordinates type.

The zero value is an empty sequence of coordinate type DimXY.

func NewSequence added in v0.10.0

func NewSequence(coordinates []float64, ctype CoordinatesType) Sequence

NewSequence creates a new Sequence from a raw slice of float64 coordinates. The slice will be retained by the constructed Sequence and must NOT be modified by the caller after the function returns.

The CoordiantesType indicates what type of coordinates the Sequence will store (i.e. just XY, XYZ, XYM, or XYZM).

The coordinates in the passed slice should be interleaved. That is, all of the coordinates for the first point come first, followed by all of the coordinates for the second point etc. Coordinates must be in the order of X followed by Y, then Z (if using XYZ or XYZM), then M (if using XYM or XYZM).

The length of the coordinates slice must be a multiple of the dimensionality of the coordiantes type. If the length is not a multiple, then this is a programming error and the function will panic.

func (Sequence) CoordinatesType added in v0.10.0

func (s Sequence) CoordinatesType() CoordinatesType

CoordinatesType returns the coordinates type used to represent point locations in the Sequence.

func (Sequence) Force2D added in v0.10.0

func (s Sequence) Force2D() Sequence

Force2D returns a new Sequence with Z and M values removed (if present).

func (Sequence) ForceCoordinatesType added in v0.10.0

func (s Sequence) ForceCoordinatesType(newCType CoordinatesType) Sequence

ForceCoordinatesType returns a new Sequence with a different CoordinatesType. If a dimension is added, then its new value is set to zero for each point location in the Sequence.

func (Sequence) Get added in v0.10.0

func (s Sequence) Get(i int) Coordinates

Get returns the Coordinates of the ith point location in the Sequence. It panics if i is out of range with respect to the number of points in the Sequence.

func (Sequence) GetXY added in v0.10.0

func (s Sequence) GetXY(i int) XY

GetXY returns the XY of the ith point location in the Sequence. It panics if i is out of range with respect to the number of points in the Sequence.

func (Sequence) Length added in v0.10.0

func (s Sequence) Length() int

Length returns the number of point locations represented by the Sequence.

func (Sequence) Reverse added in v0.10.0

func (s Sequence) Reverse() Sequence

Reverse returns a new Sequence containing the same point locations, but in reversed order.

type XY

type XY struct {
	X, Y float64
}

XY represents a pair of X and Y coordinates. This can either represent a location on the XY plane, or a 2D vector in the real vector space.

func (XY) Add

func (w XY) Add(o XY) XY

Add returns the result of adding this XY to another XY (in the same manner as vector addition).

func (XY) Cross

func (w XY) Cross(o XY) float64

Cross returns the 2D cross product of this and another XY. This is defined as the 'z' coordinate of the regular 3D cross product.

func (XY) Dot

func (w XY) Dot(o XY) float64

Dot returns the dot product of this and another XY.

func (XY) Less

func (w XY) Less(o XY) bool

Less gives an ordering on XYs. If two XYs have different X values, then the one with the lower X value is ordered before the one with the higher X value. If the X values are then same, then the Y values are used (the lower Y value comes first).

func (XY) Midpoint

func (w XY) Midpoint(o XY) XY

Midpoint returns the midpoint of this and another XY.

func (XY) Scale

func (w XY) Scale(s float64) XY

Scale returns the XY where the X and Y have been scaled by s.

func (XY) Sub

func (w XY) Sub(o XY) XY

Sub returns the result of subtracting the other XY from this XY (in the same manner as vector subtraction).

Jump to

Keyboard shortcuts

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