geom

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2020 License: MIT Imports: 14 Imported by: 25

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 is a theoretical concern that hasn't yet been observed in practice).

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.

func DisableExpensiveValidations

func DisableExpensiveValidations(o *ctorOptionSet)

DisableExpensiveValidations gives a hint that geometry constructors may opt to skip any expensive validations. All of the caveats that come with the DisableAllValidations option also come with this option.

This option should be used with caution, but can safely be used with geometries that are known to be valid a priori.

Types

type ConstructorOption

type ConstructorOption func(o *ctorOptionSet)

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

type Coordinates

type Coordinates struct {
	XY
}

func (Coordinates) Equals

func (c Coordinates) Equals(other Coordinates) bool

func (Coordinates) MarshalJSON

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

type EmptySet

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

EmptySet is a 0-dimensional geometry that represents the empty pointset.

func NewEmptyLineString

func NewEmptyLineString(opts ...ConstructorOption) EmptySet

func NewEmptyPoint

func NewEmptyPoint(opts ...ConstructorOption) EmptySet

func NewEmptyPolygon

func NewEmptyPolygon(opts ...ConstructorOption) EmptySet

func (EmptySet) AppendWKT

func (e EmptySet) AppendWKT(dst []byte) []byte

func (EmptySet) AsBinary

func (e EmptySet) AsBinary(w io.Writer) error

func (EmptySet) AsGeometry added in v0.4.0

func (e EmptySet) AsGeometry() Geometry

AsGeometry converts this EmptySet into a Geometry.

func (EmptySet) AsText

func (e EmptySet) AsText() string

func (EmptySet) Boundary

func (e EmptySet) Boundary() EmptySet

func (EmptySet) ConvexHull

func (e EmptySet) ConvexHull() Geometry

ConvexHull returns the convex hull of this geometry. The convex hull of an empty set is always an empty set.

func (EmptySet) Dimension

func (e EmptySet) Dimension() int

func (EmptySet) Envelope

func (e EmptySet) Envelope() (Envelope, bool)

func (EmptySet) Equals

func (e EmptySet) Equals(other Geometry) (bool, error)

func (EmptySet) EqualsExact

func (e EmptySet) EqualsExact(other Geometry, opts ...EqualsExactOption) bool

EqualsExact checks if this EmptySet is exactly equal to another geometry by checking if the other geometry is an empty set of the same type.

func (EmptySet) Intersection

func (e EmptySet) Intersection(g Geometry) (Geometry, error)

func (EmptySet) Intersects

func (e EmptySet) Intersects(g Geometry) bool

func (EmptySet) IsSimple

func (e EmptySet) IsSimple() bool

func (EmptySet) IsValid

func (e EmptySet) IsValid() bool

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

func (EmptySet) MarshalJSON

func (e EmptySet) MarshalJSON() ([]byte, error)

func (EmptySet) Reverse added in v0.6.0

func (e EmptySet) Reverse() EmptySet

Reverse in the case of EmptySet produces no changes.

func (EmptySet) TransformXY

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

TransformXY transforms this EmptySet into another EmptySet according to fn. It does this by ignoring fn and returning itself.

func (EmptySet) Value

func (e EmptySet) Value() (driver.Value, error)

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

Width returns the difference between the maximum and minimum Y 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 Tolerance

func Tolerance(within float64) EqualsExactOption

Tolerance modifies the behaviour of the EqualsExact method by allowing two geometry control points be be considered equal if they 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.

func UnmarshalGeoJSON

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

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) 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) AsEmptySet added in v0.4.0

func (g Geometry) AsEmptySet() EmptySet

AsEmptySet returns the geometry as an EmptySet. It panics if the geometry is not an EmptySet.

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 representation of the geometry.

func (Geometry) Boundary

func (g Geometry) Boundary() Geometry

Boundary returns the Geometry representing the limit of this geometry.

func (Geometry) Centroid added in v0.4.0

func (g Geometry) Centroid() (Point, bool)

Centroid returns a default point and false if the geometry is empty, otherwise returns the centroid and true.

func (Geometry) ConvexHull

func (g Geometry) ConvexHull() Geometry

Convex hull returns a Geometry that represents the smallest convex set that contains this geometry.

func (Geometry) Dimension

func (g Geometry) Dimension() int

Dimension returns the dimension of the Geometry. This is 0 for points, 1 for curves, and 2 for surfaces (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) Equals

func (g Geometry) Equals(other Geometry) (bool, error)

Equals checks if this geometry is equal to another geometry. Two geometries are equal if they contain exactly the same points.

It is not implemented for all possible pairs of geometries, and returns an error in those cases.

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

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

Intersection returns a geometric object that represents the point set intersection of this geometry with another geometry.

It is not implemented for all possible pairs of geometries, and returns an error in those cases.

func (Geometry) Intersects

func (g Geometry) Intersects(other Geometry) bool

Intersects returns true if the intersection of this gemoetry with the specified other geometry is not empty, or false if it is empty.

func (Geometry) IsEmpty

func (g Geometry) IsEmpty() bool

IsEmpty returns true if this object an empty geometry.

func (Geometry) IsEmptySet added in v0.4.0

func (g Geometry) IsEmptySet() bool

IsEmptySet return true iff the Geometry is an EmptySet geometry.

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 returning 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) 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 collection of geometries.

Its assertions are:

1. It must contain only valid geometries.

2. It must contain zero or more geometries.

func NewGeometryCollection

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

NewGeometryCollection creates a potentially heterogenous collection of geometries. There are no constraints on the collection.

func (GeometryCollection) AppendWKT

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

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

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

func (GeometryCollection) Boundary

func (GeometryCollection) Centroid added in v0.8.0

func (c GeometryCollection) Centroid() (Point, bool)

Centroid of a GeometryCollection is the centroid of its parts' centroids. It returns true iff the centroid is well defined.

func (GeometryCollection) ConvexHull

func (c GeometryCollection) ConvexHull() Geometry

func (GeometryCollection) Dimension

func (c GeometryCollection) Dimension() int

func (GeometryCollection) Envelope

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

func (GeometryCollection) Equals

func (c GeometryCollection) Equals(other Geometry) (bool, error)

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

func (GeometryCollection) Intersects

func (c GeometryCollection) Intersects(g Geometry) bool

func (GeometryCollection) IsEmpty

func (c GeometryCollection) IsEmpty() bool

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)

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. As a special case, if the input GeometryCollection has no elements or only contains empty elements, then the returned GeometryCollection doesn't contain any elements.

func (GeometryCollection) TransformXY

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

TransformXY transforms this GeometryCollection into another GeometryCollection according to fn.

func (GeometryCollection) Value

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

type Line

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

Line is a single line segment between two points.

Its assertions are:

1. The two points must be distinct.

func NewLineC

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

NewLineC creates a line segment given the Coordinates of its two endpoints.

func NewLineXY

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

NewLineXY creates a line segment given the XYs of its two endpoints.

func (Line) AppendWKT

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

func (Line) AsBinary

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

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

func (Line) Boundary

func (n Line) Boundary() MultiPoint

func (Line) Centroid added in v0.8.0

func (n Line) Centroid() Point

func (Line) ConvexHull

func (n Line) ConvexHull() Geometry

func (Line) Coordinates

func (n Line) Coordinates() []Coordinates

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

func (Line) EndPoint

func (n Line) EndPoint() Point

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

func (Line) Envelope

func (n Line) Envelope() (Envelope, bool)

func (Line) Equals

func (n Line) Equals(other Geometry) (bool, error)

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

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

func (Line) Intersects

func (n Line) Intersects(g Geometry) bool

func (Line) IsSimple

func (n Line) IsSimple() bool

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)

func (Line) NumPoints

func (Line) NumPoints() int

NumPoints always returns 2.

func (Line) PointN

func (ln Line) PointN(n int) Point

PointN returns the first point when n is 0, and the second point when n is 1. It panics if n 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() Point

StartPoint gives the first point of the line.

func (Line) TransformXY

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

TransformXY transforms this Line into another Line according to fn.

func (Line) Value

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

type LineString

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

LineString is a curve defined by linear interpolation between a finite set of points. Each consecutive pair of points defines a line segment.

Its assertions are:

1. It must contain at least 2 distinct points.

func NewLineStringC

func NewLineStringC(pts []Coordinates, opts ...ConstructorOption) (LineString, error)

NewLineStringC creates a line string from the coordinates defining its points.

func NewLineStringXY

func NewLineStringXY(pts []XY, opts ...ConstructorOption) (LineString, error)

NewLineStringXY creates a line string from the XYs defining its points.

func (LineString) AppendWKT

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

func (LineString) AsBinary

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

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 convinience function that converts this LineString into a MultiLineString.

func (LineString) AsText

func (s LineString) AsText() string

func (LineString) Boundary

func (s LineString) Boundary() MultiPoint

func (LineString) Centroid added in v0.8.0

func (s LineString) Centroid() (Point, bool)

Centroid gives the centroid of the coordinates of the line string. It returns true iff the centroid is well defined.

func (LineString) ConvexHull

func (s LineString) ConvexHull() Geometry

func (LineString) Coordinates

func (s LineString) Coordinates() []Coordinates

Coordinates returns the coordinates of each point along the LineString.

func (LineString) EndPoint

func (s LineString) EndPoint() Point

EndPoint gives the last point of the line string.

func (LineString) Envelope

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

func (LineString) Equals

func (s LineString) Equals(other Geometry) (bool, error)

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

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

func (LineString) Intersects

func (s LineString) Intersects(g Geometry) bool

func (LineString) IsClosed

func (s LineString) IsClosed() bool

func (LineString) IsEmpty

func (s LineString) IsEmpty() bool

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 iff the curve defined by the LineString doesn't pass through the same point twice (with the possible exception 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) LineN added in v0.7.0

func (s LineString) LineN(n int) Line

func (LineString) MarshalJSON

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

func (LineString) NumLines added in v0.7.0

func (s LineString) NumLines() int

func (LineString) NumPoints

func (s LineString) NumPoints() int

NumPoints gives the number of control points in the line string.

func (LineString) PointN

func (s LineString) PointN(n int) Point

PointN gives the nth (zero indexed) point in the line string. Panics if n is out of range with respect to the number of points.

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 line string.

func (LineString) TransformXY

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

TransformXY transforms this LineString into another LineString according to fn.

func (LineString) Value

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

type MultiLineString

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

MultiLineString is a multicurve whose elements are LineStrings.

Its assertions are:

1. It must be made of up zero or more valid LineStrings.

func NewMultiLineString

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

NewMultiLineString creates a MultiLineString from its constintuent LineStrings.

func NewMultiLineStringC

func NewMultiLineStringC(coords [][]Coordinates, opts ...ConstructorOption) (MultiLineString, error)

NewMultiLineStringC creates a MultiLineString from its coordinates. The first dimension of the coordinates slice indicates the LineString, and the second dimension indicates the Coordinate within a LineString.

func NewMultiLineStringXY

func NewMultiLineStringXY(pts [][]XY, opts ...ConstructorOption) (MultiLineString, error)

NewMultiLineStringXY creates a MultiLineString from its XYs. The first dimension of the XYs slice indicates the LineString, and the second dimension indicates the XY within a LineString.

func (MultiLineString) AppendWKT

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

func (MultiLineString) AsBinary

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

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

func (MultiLineString) Boundary

func (m MultiLineString) Boundary() MultiPoint

func (MultiLineString) Centroid added in v0.8.0

func (m MultiLineString) Centroid() (Point, bool)

Centroid gives the centroid of the coordinates of the multi line string. It returns true iff the centroid is well defined.

func (MultiLineString) ConvexHull

func (m MultiLineString) ConvexHull() Geometry

func (MultiLineString) Coordinates

func (m MultiLineString) Coordinates() [][]Coordinates

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

func (MultiLineString) Envelope

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

func (MultiLineString) Equals

func (m MultiLineString) Equals(other Geometry) (bool, error)

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

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

func (MultiLineString) Intersects

func (m MultiLineString) Intersects(g Geometry) bool

func (MultiLineString) IsEmpty

func (m MultiLineString) IsEmpty() bool

func (MultiLineString) IsSimple

func (m MultiLineString) IsSimple() bool

IsSimple returns true iff 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)

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) (Geometry, error)

TransformXY transforms this MultiLineString into another MultiLineString according to fn.

func (MultiLineString) Value

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

type MultiPoint

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

MultiPoint is a 0-dimensional geometric collection of points. The points are not connected or ordered.

Its assertions are:

1. It must be made up of 0 or more valid Points.

func NewMultiPoint

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

func NewMultiPointC

func NewMultiPointC(coords []Coordinates, opts ...ConstructorOption) MultiPoint

NewMultiPointC creates a new MultiPoint consisting of a point for each coordinate.

func NewMultiPointOC

func NewMultiPointOC(coords []OptionalCoordinates, opts ...ConstructorOption) MultiPoint

NewMultiPointOC creates a new MultiPoint consisting of a Point for each non-empty OptionalCoordinate.

func NewMultiPointXY

func NewMultiPointXY(pts []XY, opts ...ConstructorOption) MultiPoint

NewMultiPointXY creates a new MultiPoint consisting of a point for each XY.

func (MultiPoint) AppendWKT

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

func (MultiPoint) AsBinary

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

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

func (MultiPoint) Boundary

func (m MultiPoint) Boundary() GeometryCollection

func (MultiPoint) Centroid added in v0.8.0

func (m MultiPoint) Centroid() (Point, bool)

Centroid gives the centroid of the coordinates of the multi line string. It returns true iff the centroid is well defined.

func (MultiPoint) ConvexHull

func (m MultiPoint) ConvexHull() Geometry

ConvexHull finds the convex hull of the set of points. This may either be the empty set, a single point, a line, or a polygon.

func (MultiPoint) Coordinates

func (m MultiPoint) Coordinates() []Coordinates

Coordinates returns the coordinates of the points represented by the MultiPoint.

func (MultiPoint) Envelope

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

func (MultiPoint) Equals

func (m MultiPoint) Equals(other Geometry) (bool, error)

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

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

func (MultiPoint) Intersects

func (m MultiPoint) Intersects(g Geometry) bool

func (MultiPoint) IsEmpty

func (m MultiPoint) IsEmpty() bool

func (MultiPoint) IsSimple

func (m MultiPoint) IsSimple() bool

IsSimple returns true iff no two of its points are equal.

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)

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) (Geometry, error)

TransformXY transforms this MultiPoint into another MultiPoint according to fn.

func (MultiPoint) Value

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

type MultiPolygon

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

MultiPolygon is a multi surface whose elements are polygons.

Its assertions are:

1. It must be made up of zero or more valid Polygons.

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 NewMultiPolygon

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

NewMultiPolygon creates a MultiPolygon from its constituent Polygons. It gives an error if any of the MultiPolygon assertions are not maintained.

func NewMultiPolygonC

func NewMultiPolygonC(coords [][][]Coordinates, opts ...ConstructorOption) (MultiPolygon, error)

NewMultiPolygonC creates a new MultiPolygon from its constituent Coordinate values.

func NewMultiPolygonXY

func NewMultiPolygonXY(pts [][][]XY, opts ...ConstructorOption) (MultiPolygon, error)

NewMultiPolygonXY creates a new MultiPolygon from its constituent XY values.

func (MultiPolygon) AppendWKT

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

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

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

func (MultiPolygon) Boundary

func (m MultiPolygon) Boundary() MultiLineString

func (MultiPolygon) Centroid

func (m MultiPolygon) Centroid() (Point, bool)

Centroid returns the multi polygon's centroid point. It returns true iff the centroid is well defined. It returns false if the multi polygon is empty (in which case, there is no sensible definition for a centroid).

func (MultiPolygon) ConvexHull

func (m MultiPolygon) ConvexHull() Geometry

func (MultiPolygon) Coordinates

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

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

func (MultiPolygon) Envelope

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

func (MultiPolygon) Equals

func (m MultiPolygon) Equals(other Geometry) (bool, error)

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

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

func (MultiPolygon) Intersects

func (m MultiPolygon) Intersects(g Geometry) bool

func (MultiPolygon) IsEmpty

func (m MultiPolygon) IsEmpty() bool

func (MultiPolygon) IsSimple

func (m MultiPolygon) IsSimple() bool

IsSimple returns true. All MultiPolygons are simple by definition.

func (MultiPolygon) IsValid

func (m MultiPolygon) IsValid() bool

IsValid checks if this MultiPolygon is valid

func (MultiPolygon) MarshalJSON

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

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) (Geometry, error)

TransformXY transforms this MultiPolygon into another MultiPolygon according to fn.

func (MultiPolygon) Value

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

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 OptionalCoordinates

type OptionalCoordinates struct {
	Empty bool
	Value Coordinates
}

type Point

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

Point is a 0-dimensional geometry, and represents a single location in a coordinate space.

There aren't any assertions about what constitutes a valid point, other than that it must be able to be represented by an XY.

func NewPointC

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

NewPointC creates a new point gives its Coordinates.

func NewPointF

func NewPointF(x, y float64, _ ...ConstructorOption) Point

NewPointF creates a new point from float64 x and y values.

func NewPointXY

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

NewPointXY creates a new point from an XY.

func (Point) AppendWKT

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

func (Point) AsBinary

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

func (Point) AsGeometry added in v0.4.0

func (p Point) AsGeometry() Geometry

AsGeometry converts this Point into a Geometry.

func (Point) AsText

func (p Point) AsText() string

func (Point) Boundary

func (p Point) Boundary() GeometryCollection

func (Point) Centroid added in v0.8.0

func (p Point) Centroid() Point

Centroid of a point it that point.

func (Point) ConvexHull

func (p Point) ConvexHull() Geometry

ConvexHull returns the convex hull of this Point, which is always the same point.

func (Point) Coordinates

func (p Point) Coordinates() Coordinates

Coordinates returns the coordinates of the point.

func (Point) Envelope

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

func (Point) Equals

func (p Point) Equals(other Geometry) (bool, error)

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

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

func (Point) Intersects

func (p Point) Intersects(g Geometry) bool

func (Point) IsSimple

func (p Point) IsSimple() bool

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)

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) (Geometry, error)

TransformXY transforms this Point into another Point according to fn.

func (Point) Value

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

func (Point) XY

func (p Point) XY() XY

XY gives the XY location of the point.

type Polygon

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

Polygon is a planar surface, defined by 1 exiterior boundary and 0 or more interior boundaries. Each interior boundary defines a hole in the polygon.

Its assertions are:

  1. The outer ring and holes must be valid linear rings (i.e. be simple and closed LineStrings).

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

3. The interior of the polygon is connected.

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

func NewPolygon

func NewPolygon(outer LineString, holes []LineString, opts ...ConstructorOption) (Polygon, error)

NewPolygon creates a polygon given its outer and inner rings. No rings may cross each other, and can only intersect each with each other at a point.

func NewPolygonC

func NewPolygonC(coords [][]Coordinates, opts ...ConstructorOption) (Polygon, error)

NewPolygonC creates a new polygon from its Coordinates. The first dimension of the Coordinates slice is the ring number, and the second dimension of the Coordinates slice is the position within the ring.

func NewPolygonXY

func NewPolygonXY(pts [][]XY, opts ...ConstructorOption) (Polygon, error)

NewPolygonXY creates a new polygon from its XYs. The first dimension of the XYs slice is the ring number, and the second dimension of the Coordinates slice is the position within the ring.

func (Polygon) AppendWKT

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

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

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

func (Polygon) Boundary

func (p Polygon) Boundary() MultiLineString

func (Polygon) Centroid

func (p Polygon) Centroid() (Point, bool)

Centroid returns the polygon's centroid point. Returns true iff the polygon has a non-zero area, and thus the centroid is well defined.

func (Polygon) ConvexHull

func (p Polygon) ConvexHull() Geometry

ConvexHull returns the convex hull of the Polygon, which is always another Polygon.

func (Polygon) Coordinates

func (p Polygon) Coordinates() [][]Coordinates

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

func (Polygon) Envelope

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

func (Polygon) Equals

func (p Polygon) Equals(other Geometry) (bool, error)

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.

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)

func (Polygon) Intersects

func (p Polygon) Intersects(g Geometry) bool

func (Polygon) IsEmpty

func (p Polygon) IsEmpty() bool

func (Polygon) IsSimple

func (p Polygon) IsSimple() bool

IsSimple always returns true. All Polygons are simple.

func (Polygon) IsValid

func (p Polygon) IsValid() bool

IsValid checks if this Polygon is valid

func (Polygon) MarshalJSON

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

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) (Geometry, error)

TransformXY transforms this Polygon into another Polygon according to fn.

func (Polygon) Value

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

type XY

type XY struct {
	X, Y float64
}

func (XY) Add

func (w XY) Add(o XY) XY

func (XY) Cross

func (w XY) Cross(o XY) float64

func (XY) Dot

func (w XY) Dot(o XY) float64

func (XY) Equals

func (w XY) Equals(o XY) bool

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

func (XY) Scale

func (w XY) Scale(s float64) XY

func (XY) Sub

func (w XY) Sub(o XY) XY

Jump to

Keyboard shortcuts

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