Documentation
¶
Index ¶
- Variables
- func DisableAllValidations(o *ctorOptionSet)
- func DisableExpensiveValidations(o *ctorOptionSet)
- type ConstructorOption
- type Coordinates
- type EmptySet
- func (e EmptySet) AppendWKT(dst []byte) []byte
- func (e EmptySet) AsBinary(w io.Writer) error
- func (e EmptySet) AsGeometry() Geometry
- func (e EmptySet) AsText() string
- func (e EmptySet) Boundary() Geometry
- func (e EmptySet) ConvexHull() Geometry
- func (e EmptySet) Dimension() int
- func (e EmptySet) Envelope() (Envelope, bool)
- func (e EmptySet) Equals(other Geometry) (bool, error)
- func (e EmptySet) EqualsExact(other Geometry, opts ...EqualsExactOption) bool
- func (e EmptySet) Intersection(g Geometry) (Geometry, error)
- func (e EmptySet) Intersects(g Geometry) bool
- func (e EmptySet) IsSimple() bool
- func (e EmptySet) IsValid() bool
- func (e EmptySet) MarshalJSON() ([]byte, error)
- func (e EmptySet) TransformXY(fn func(XY) XY, opts ...ConstructorOption) (Geometry, error)
- func (e EmptySet) Value() (driver.Value, error)
- type Envelope
- func (e Envelope) Area() float64
- func (e Envelope) AsGeometry() Geometry
- func (e Envelope) Center() XY
- func (e Envelope) Contains(p XY) bool
- func (e Envelope) Covers(o Envelope) bool
- func (e Envelope) Distance(o Envelope) float64
- func (e Envelope) ExpandBy(x, y float64) (Envelope, bool)
- func (e Envelope) ExpandToIncludeEnvelope(other Envelope) Envelope
- func (e Envelope) ExtendToIncludePoint(point XY) Envelope
- func (e Envelope) Height() float64
- func (e Envelope) Intersects(o Envelope) bool
- func (e Envelope) Max() XY
- func (e Envelope) Min() XY
- func (e Envelope) Width() float64
- type EqualsExactOption
- type GeoJSONFeature
- type GeoJSONFeatureCollection
- type Geometry
- func (g Geometry) Area() (float64, bool)
- func (g Geometry) AsBinary(w io.Writer) error
- func (g Geometry) AsEmptySet() EmptySet
- func (g Geometry) AsGeometryCollection() GeometryCollection
- func (g Geometry) AsLine() Line
- func (g Geometry) AsLineString() LineString
- func (g Geometry) AsMultiLineString() MultiLineString
- func (g Geometry) AsMultiPoint() MultiPoint
- func (g Geometry) AsMultiPolygon() MultiPolygon
- func (g Geometry) AsPoint() Point
- func (g Geometry) AsPolygon() Polygon
- func (g Geometry) AsText() string
- func (g Geometry) Boundary() Geometry
- func (g Geometry) Centroid() (Point, bool)
- func (g Geometry) ConvexHull() Geometry
- func (g Geometry) Dimension() int
- func (g Geometry) Envelope() (Envelope, bool)
- func (g Geometry) Equals(other Geometry) (bool, error)
- func (g Geometry) EqualsExact(other Geometry, opts ...EqualsExactOption) bool
- func (g Geometry) Intersection(other Geometry) (Geometry, error)
- func (g Geometry) Intersects(other Geometry) bool
- func (g Geometry) IsEmpty() bool
- func (g Geometry) IsEmptySet() bool
- func (g Geometry) IsGeometryCollection() bool
- func (g Geometry) IsLine() bool
- func (g Geometry) IsLineString() bool
- func (g Geometry) IsMultiLineString() bool
- func (g Geometry) IsMultiPoint() bool
- func (g Geometry) IsMultiPolygon() bool
- func (g Geometry) IsPoint() bool
- func (g Geometry) IsPolygon() bool
- func (g Geometry) IsSimple() (isSimple bool, wellDefined bool)
- func (g Geometry) IsValid() bool
- func (g Geometry) Length() (float64, bool)
- func (g Geometry) MarshalJSON() ([]byte, error)
- func (g *Geometry) Scan(src interface{}) error
- func (g Geometry) TransformXY(fn func(XY) XY, opts ...ConstructorOption) (Geometry, error)
- func (g *Geometry) UnmarshalJSON(p []byte) error
- func (g Geometry) Value() (driver.Value, error)
- type GeometryCollection
- func (c GeometryCollection) AppendWKT(dst []byte) []byte
- func (c GeometryCollection) AsBinary(w io.Writer) error
- func (c GeometryCollection) AsGeometry() Geometry
- func (c GeometryCollection) AsText() string
- func (c GeometryCollection) Boundary() Geometry
- func (c GeometryCollection) ConvexHull() Geometry
- func (c GeometryCollection) Dimension() int
- func (c GeometryCollection) Envelope() (Envelope, bool)
- func (c GeometryCollection) Equals(other Geometry) (bool, error)
- func (c GeometryCollection) EqualsExact(other Geometry, opts ...EqualsExactOption) bool
- func (c GeometryCollection) GeometryN(n int) Geometry
- func (c GeometryCollection) Intersection(g Geometry) (Geometry, error)
- func (c GeometryCollection) Intersects(g Geometry) bool
- func (c GeometryCollection) IsEmpty() bool
- func (c GeometryCollection) IsValid() bool
- func (c GeometryCollection) MarshalJSON() ([]byte, error)
- func (c GeometryCollection) NumGeometries() int
- func (c GeometryCollection) TransformXY(fn func(XY) XY, opts ...ConstructorOption) (Geometry, error)
- func (c GeometryCollection) Value() (driver.Value, error)
- type Line
- func (n Line) AppendWKT(dst []byte) []byte
- func (n Line) AsBinary(w io.Writer) error
- func (n Line) AsGeometry() Geometry
- func (n Line) AsLineString() LineString
- func (n Line) AsText() string
- func (n Line) Boundary() Geometry
- func (n Line) ConvexHull() Geometry
- func (n Line) Coordinates() []Coordinates
- func (n Line) EndPoint() Point
- func (n Line) Envelope() (Envelope, bool)
- func (n Line) Equals(other Geometry) (bool, error)
- func (n Line) EqualsExact(other Geometry, opts ...EqualsExactOption) bool
- func (n Line) Intersection(g Geometry) (Geometry, error)
- func (n Line) Intersects(g Geometry) bool
- func (n Line) IsSimple() bool
- func (n Line) IsValid() bool
- func (n Line) Length() float64
- func (n Line) MarshalJSON() ([]byte, error)
- func (Line) NumPoints() int
- func (ln Line) PointN(n int) Point
- func (n Line) StartPoint() Point
- func (n Line) TransformXY(fn func(XY) XY, opts ...ConstructorOption) (Geometry, error)
- func (n Line) Value() (driver.Value, error)
- type LineString
- func (s LineString) AppendWKT(dst []byte) []byte
- func (s LineString) AsBinary(w io.Writer) error
- func (s LineString) AsGeometry() Geometry
- func (s LineString) AsMultiLineString() MultiLineString
- func (s LineString) AsText() string
- func (s LineString) Boundary() Geometry
- func (s LineString) ConvexHull() Geometry
- func (s LineString) Coordinates() []Coordinates
- func (s LineString) EndPoint() Point
- func (s LineString) Envelope() (Envelope, bool)
- func (s LineString) Equals(other Geometry) (bool, error)
- func (s LineString) EqualsExact(other Geometry, opts ...EqualsExactOption) bool
- func (s LineString) Intersection(g Geometry) (Geometry, error)
- func (s LineString) Intersects(g Geometry) bool
- func (s LineString) IsClosed() bool
- func (s LineString) IsEmpty() bool
- func (s LineString) IsRing() bool
- func (s LineString) IsSimple() bool
- func (s LineString) IsValid() bool
- func (s LineString) Length() float64
- func (s LineString) MarshalJSON() ([]byte, error)
- func (s LineString) NumPoints() int
- func (s LineString) PointN(n int) Point
- func (s LineString) StartPoint() Point
- func (s LineString) TransformXY(fn func(XY) XY, opts ...ConstructorOption) (Geometry, error)
- func (s LineString) Value() (driver.Value, error)
- type MultiLineString
- func (m MultiLineString) AppendWKT(dst []byte) []byte
- func (m MultiLineString) AsBinary(w io.Writer) error
- func (m MultiLineString) AsGeometry() Geometry
- func (m MultiLineString) AsText() string
- func (m MultiLineString) Boundary() Geometry
- func (m MultiLineString) ConvexHull() Geometry
- func (m MultiLineString) Coordinates() [][]Coordinates
- func (m MultiLineString) Envelope() (Envelope, bool)
- func (m MultiLineString) Equals(other Geometry) (bool, error)
- func (m MultiLineString) EqualsExact(other Geometry, opts ...EqualsExactOption) bool
- func (m MultiLineString) Intersection(g Geometry) (Geometry, error)
- func (m MultiLineString) Intersects(g Geometry) bool
- func (m MultiLineString) IsEmpty() bool
- func (m MultiLineString) IsSimple() bool
- func (m MultiLineString) IsValid() bool
- func (m MultiLineString) Length() float64
- func (m MultiLineString) LineStringN(n int) LineString
- func (m MultiLineString) MarshalJSON() ([]byte, error)
- func (m MultiLineString) NumLineStrings() int
- func (m MultiLineString) TransformXY(fn func(XY) XY, opts ...ConstructorOption) (Geometry, error)
- func (m MultiLineString) Value() (driver.Value, error)
- type MultiPoint
- func NewMultiPoint(pts []Point, opts ...ConstructorOption) MultiPoint
- func NewMultiPointC(coords []Coordinates, opts ...ConstructorOption) MultiPoint
- func NewMultiPointOC(coords []OptionalCoordinates, opts ...ConstructorOption) MultiPoint
- func NewMultiPointXY(pts []XY, opts ...ConstructorOption) MultiPoint
- func (m MultiPoint) AppendWKT(dst []byte) []byte
- func (m MultiPoint) AsBinary(w io.Writer) error
- func (m MultiPoint) AsGeometry() Geometry
- func (m MultiPoint) AsText() string
- func (m MultiPoint) Boundary() Geometry
- func (m MultiPoint) ConvexHull() Geometry
- func (m MultiPoint) Coordinates() []Coordinates
- func (m MultiPoint) Envelope() (Envelope, bool)
- func (m MultiPoint) Equals(other Geometry) (bool, error)
- func (m MultiPoint) EqualsExact(other Geometry, opts ...EqualsExactOption) bool
- func (m MultiPoint) Intersection(g Geometry) (Geometry, error)
- func (m MultiPoint) Intersects(g Geometry) bool
- func (m MultiPoint) IsEmpty() bool
- func (m MultiPoint) IsSimple() bool
- func (m MultiPoint) IsValid() bool
- func (m MultiPoint) MarshalJSON() ([]byte, error)
- func (m MultiPoint) NumPoints() int
- func (m MultiPoint) PointN(n int) Point
- func (m MultiPoint) TransformXY(fn func(XY) XY, opts ...ConstructorOption) (Geometry, error)
- func (m MultiPoint) Value() (driver.Value, error)
- type MultiPolygon
- func (m MultiPolygon) AppendWKT(dst []byte) []byte
- func (m MultiPolygon) Area() float64
- func (m MultiPolygon) AsBinary(w io.Writer) error
- func (m MultiPolygon) AsGeometry() Geometry
- func (m MultiPolygon) AsText() string
- func (m MultiPolygon) Boundary() Geometry
- func (m MultiPolygon) Centroid() (Point, bool)
- func (m MultiPolygon) ConvexHull() Geometry
- func (m MultiPolygon) Coordinates() [][][]Coordinates
- func (m MultiPolygon) Envelope() (Envelope, bool)
- func (m MultiPolygon) Equals(other Geometry) (bool, error)
- func (m MultiPolygon) EqualsExact(other Geometry, opts ...EqualsExactOption) bool
- func (m MultiPolygon) Intersection(g Geometry) (Geometry, error)
- func (m MultiPolygon) Intersects(g Geometry) bool
- func (m MultiPolygon) IsEmpty() bool
- func (m MultiPolygon) IsSimple() bool
- func (m MultiPolygon) IsValid() bool
- func (m MultiPolygon) MarshalJSON() ([]byte, error)
- func (m MultiPolygon) NumPolygons() int
- func (m MultiPolygon) PolygonN(n int) Polygon
- func (m MultiPolygon) TransformXY(fn func(XY) XY, opts ...ConstructorOption) (Geometry, error)
- func (m MultiPolygon) Value() (driver.Value, error)
- type OptionalCoordinates
- type Point
- func (p Point) AppendWKT(dst []byte) []byte
- func (p Point) AsBinary(w io.Writer) error
- func (p Point) AsGeometry() Geometry
- func (p Point) AsText() string
- func (p Point) Boundary() Geometry
- func (p Point) ConvexHull() Geometry
- func (p Point) Coordinates() Coordinates
- func (p Point) Envelope() (Envelope, bool)
- func (p Point) Equals(other Geometry) (bool, error)
- func (p Point) EqualsExact(other Geometry, opts ...EqualsExactOption) bool
- func (p Point) Intersection(g Geometry) (Geometry, error)
- func (p Point) Intersects(g Geometry) bool
- func (p Point) IsSimple() bool
- func (p Point) IsValid() bool
- func (p Point) MarshalJSON() ([]byte, error)
- func (p Point) TransformXY(fn func(XY) XY, opts ...ConstructorOption) (Geometry, error)
- func (p Point) Value() (driver.Value, error)
- func (p Point) XY() XY
- type Polygon
- func (p Polygon) AppendWKT(dst []byte) []byte
- func (p Polygon) Area() float64
- func (p Polygon) AsBinary(w io.Writer) error
- func (p Polygon) AsGeometry() Geometry
- func (p Polygon) AsMultiPolygon() MultiPolygon
- func (p Polygon) AsText() string
- func (p Polygon) Boundary() Geometry
- func (p Polygon) Centroid() Point
- func (p Polygon) ConvexHull() Geometry
- func (p Polygon) Coordinates() [][]Coordinates
- func (p Polygon) Envelope() (Envelope, bool)
- func (p Polygon) Equals(other Geometry) (bool, error)
- func (p Polygon) EqualsExact(other Geometry, opts ...EqualsExactOption) bool
- func (p Polygon) ExteriorRing() LineString
- func (p Polygon) InteriorRingN(n int) LineString
- func (p Polygon) Intersection(g Geometry) (Geometry, error)
- func (p Polygon) Intersects(g Geometry) bool
- func (p Polygon) IsEmpty() bool
- func (p Polygon) IsSimple() bool
- func (p Polygon) IsValid() bool
- func (p Polygon) MarshalJSON() ([]byte, error)
- func (p Polygon) NumInteriorRings() int
- func (p Polygon) TransformXY(fn func(XY) XY, opts ...ConstructorOption) (Geometry, error)
- func (p Polygon) Value() (driver.Value, error)
- type XY
Constants ¶
This section is empty.
Variables ¶
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:
- If the geometry is invalid, then any geometric calculations resulting from the geometry may be invalid.
- 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) AsGeometry ¶ added in v0.4.0
AsGeometry converts this EmptySet into a Geometry.
func (EmptySet) ConvexHull ¶
ConvexHull returns the convex hull of this geometry. The convex hull of an empty set is always an empty set.
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) Intersects ¶
func (EmptySet) IsValid ¶
IsValid checks if this EmptySet is valid. However, this is no constraints on EmptySet, so this function always returns true
func (EmptySet) MarshalJSON ¶
func (EmptySet) TransformXY ¶
TransformXY transforms this EmptySet into another EmptySet according to fn. It does this by ignoring fn and returning itself.
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 ¶
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 ¶
NewEnvelope returns the smallest envelope that contains all provided points.
func (Envelope) AsGeometry ¶
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) Covers ¶
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 ¶
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 ¶
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 ¶
ExpandToIncludeEnvelope returns the smallest envelope that contains all of the points in this envelope and another envelope.
func (Envelope) ExtendToIncludePoint ¶
ExtendToIncludePoint returns the smallest envelope that contains all of the points in this envelope along with the provided point.
func (Envelope) Height ¶
Width returns the difference between the maximum and minimum Y coordinates of the envelope.
func (Envelope) Intersects ¶
Intersects returns true iff this envelope has any points in common with another 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
Area gives the area of the Polygon or MultiPolygon. If the Geometry is not a Polygon or MultiPolygon, then false is returned.
TODO: This is not in live with the behaviour of PostGIS. Instead, the area should be returned as zero for non polygonal geometries. See https://github.com/peterstace/simplefeatures/issues/84
func (Geometry) AsBinary ¶
AsBinary writes the WKB (Well Known Binary) representation of the geometry to the writer.
func (Geometry) AsEmptySet ¶ added in v0.4.0
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
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
AsPoint returns the geometry as a Point. It panics if the geometry is not a Point.
func (Geometry) AsPolygon ¶ added in v0.4.0
AsPolygon returns the geometry as a Polygon. It panics if the geometry is not a Polygon.
func (Geometry) Centroid ¶ added in v0.4.0
Centroid returns the Polygon or MultiPolygon's centroid point. If the Geometry is not a non-empty Polygon or MultiPolygon, then false is returned.
TODO: This is not in line with the behaviour of ST_Centroid. See https://github.com/peterstace/simplefeatures/issues/83
func (Geometry) ConvexHull ¶
Convex hull returns a Geometry that represents the smallest convex set that contains this geometry.
func (Geometry) Dimension ¶
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 ¶
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 ¶
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 ¶
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 ¶
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) IsEmptySet ¶ added in v0.4.0
IsEmptySet return true iff the Geometry is an EmptySet geometry.
func (Geometry) IsGeometryCollection ¶ added in v0.4.0
IsGeometryCollection return true iff the Geometry is a GeometryCollection geometry.
func (Geometry) IsLineString ¶ added in v0.4.0
IsLineString return true iff the Geometry is a LineString geometry.
func (Geometry) IsMultiLineString ¶ added in v0.4.0
IsMultiLineString return true iff the Geometry is a MultiLineString geometry.
func (Geometry) IsMultiPoint ¶ added in v0.4.0
IsMultiPoint return true iff the Geometry is a MultiPoint geometry.
func (Geometry) IsMultiPolygon ¶ added in v0.4.0
IsMultiPolygon return true iff the Geometry is a MultiPolygon geometry.
func (Geometry) IsPolygon ¶ added in v0.4.0
IsPolygon return true iff the Geometry is a Polygon geometry.
func (Geometry) IsSimple ¶ added in v0.4.0
IsSimple calculates whether or not the geometry contains any anomolous geometric ponits 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 fales is returned.
func (Geometry) IsValid ¶
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
Length gives the length of the geometry, if defined. It is only defined for Lines, LineStrings, and MultiLineStrings. The returned flag indicates if the length is defined.
TODO: This doesn't match PostGIS behaviour. See https://github.com/peterstace/simplefeatures/issues/86
func (Geometry) MarshalJSON ¶ added in v0.4.0
MarshalJSON implements the encoding/json.Marshaller interface by returning a GeoJSON geometry object.
func (*Geometry) Scan ¶ added in v0.4.0
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 ¶
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
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).
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) 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 (c GeometryCollection) Boundary() Geometry
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) 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) 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) TransformXY ¶
func (c GeometryCollection) TransformXY(fn func(XY) XY, opts ...ConstructorOption) (Geometry, error)
TransformXY transforms this GeometryCollection into another GeometryCollection according to fn.
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) AsGeometry ¶ added in v0.4.0
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) ConvexHull ¶
func (Line) Coordinates ¶
func (n Line) Coordinates() []Coordinates
Coordinates returns the coordinates of the start and end point of 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) Intersects ¶
func (Line) MarshalJSON ¶
func (Line) PointN ¶
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) StartPoint ¶
StartPoint gives the first point of the line.
func (Line) TransformXY ¶
TransformXY transforms this Line into another Line according to fn.
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) 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() Geometry
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) 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) MarshalJSON ¶
func (s LineString) MarshalJSON() ([]byte, error)
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) 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.
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) 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() Geometry
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) 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 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) TransformXY ¶
func (m MultiLineString) TransformXY(fn func(XY) XY, opts ...ConstructorOption) (Geometry, error)
TransformXY transforms this MultiLineString into another MultiLineString according to fn.
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) 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() Geometry
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) 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) TransformXY ¶
func (m MultiPoint) TransformXY(fn func(XY) XY, opts ...ConstructorOption) (Geometry, error)
TransformXY transforms this MultiPoint into another MultiPoint according to fn.
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 gives the area of the multi polygon.
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() Geometry
func (MultiPolygon) Centroid ¶
func (m MultiPolygon) Centroid() (Point, bool)
Centroid returns the multi polygon's centroid point. 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) 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) TransformXY ¶
func (m MultiPolygon) TransformXY(fn func(XY) XY, opts ...ConstructorOption) (Geometry, error)
TransformXY transforms this MultiPolygon into another MultiPolygon according to fn.
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) AsGeometry ¶ added in v0.4.0
AsGeometry converts this Point into a Geometry.
func (Point) ConvexHull ¶
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) EqualsExact ¶
func (p Point) EqualsExact(other Geometry, opts ...EqualsExactOption) bool
EqualsExact checks if this Point is exactly equal to another Point.
func (Point) Intersects ¶
func (Point) IsValid ¶
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 (Point) TransformXY ¶
TransformXY transforms this Point into another Point according to fn.
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:
- 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) AsGeometry ¶ added in v0.4.0
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) ConvexHull ¶
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) 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) Intersects ¶
func (Polygon) MarshalJSON ¶
func (Polygon) NumInteriorRings ¶
NumInteriorRings gives the number of interior rings in the polygon boundary.
func (Polygon) TransformXY ¶
TransformXY transforms this Polygon into another Polygon according to fn.
type XY ¶
type XY struct {
X, Y float64
}
Source Files
¶
- alg_convex_hull.go
- alg_equals.go
- alg_equals_exact.go
- alg_intersection.go
- alg_intersects.go
- alg_orientation.go
- alg_point_in_ring.go
- canonicalise.go
- ctor_options.go
- float_helpers.go
- geojson_feature_collection.go
- geojson_geometry.go
- graph.go
- line_heap.go
- transform.go
- type_coordinates.go
- type_empty.go
- type_envelope.go
- type_geometry_collection.go
- type_line.go
- type_line_string.go
- type_multi_line_string.go
- type_multi_point.go
- type_multi_polygon.go
- type_point.go
- type_polygon.go
- type_sum.go
- util.go
- wkb_marshal.go
- wkb_parser.go
- wkt_lexer.go
- wkt_parser.go
- xy.go