Documentation ¶
Index ¶
- Constants
- type BoundingBox
- type Feature
- func NewLineString(pos1, pos2 Position, others ...Position) *Feature
- func NewMultiLineString(ls ...[]Position) *Feature
- func NewMultiPoint(pos ...Position) *Feature
- func NewMultiPolygon(p ...[][]Position) *Feature
- func NewPoint(long, lat float64) *Feature
- func NewPointWithElevation(long, lat, elevation float64) *Feature
- func NewPolygon(rings ...[]Position) *Feature
- func (f *Feature) AddProperty(name string, value interface{}) *Feature
- func (f *Feature) MarshalJSON() ([]byte, error)
- func (f *Feature) UnmarshalJSON(data []byte) error
- func (f *Feature) WithBoundingBox(bottomLeft, topRight Position) *Feature
- func (f *Feature) WithProperties(props ...Property) *Feature
- type FeatureCollection
- type Geometry
- type GeometryType
- type LineString
- type MultiLineString
- type MultiPoint
- type MultiPolygon
- type OptionalFloat64
- type Point
- type Polygon
- type Position
- type Property
- type PropertyList
Constants ¶
const TypePropFeature = "Feature"
TypePropFeature is the value of the "type" property for Features.
const TypePropFeatureCollection = "FeatureCollection"
TypePropFeatureCollection is the value of the "type" property for Feature Collections.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BoundingBox ¶
BoundingBox represents a bounding box in either 2D or 3D space.
func (*BoundingBox) MarshalJSON ¶
func (b *BoundingBox) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON encoding of the box. It is an error if only 1 elevation value is set - either both positions or neither must have it.
func (*BoundingBox) UnmarshalJSON ¶
func (b *BoundingBox) UnmarshalJSON(data []byte) error
UnmarshalJSON parses the JSON-encoded data and stores the results.
type Feature ¶
type Feature struct { Geometry Geometry BBox *BoundingBox Properties PropertyList }
Feature consists of a specific geometry type and a list of properties.
func NewLineString ¶
NewLineString returns a LineString from the supplied positions.
func NewMultiLineString ¶
NewMultiLineString returns a new MultiLineString from the supplied position "strings".
func NewMultiPoint ¶
NewMultiPoint returns a MultiPoint from the specified set of position.
func NewMultiPolygon ¶
NewMultiPolygon returns a new MultiPolygon from the supplied polygons.
func NewPointWithElevation ¶
NewPointWithElevation returns a Point Feature with the specified longitude, latitude and elevation.
func NewPolygon ¶
NewPolygon returns a new Polygon from the supplied linear rings.
func (*Feature) AddProperty ¶
AddProperty appends a new property.
func (*Feature) MarshalJSON ¶
MarshalJSON returns the JSON encoding of the Feature.
func (*Feature) UnmarshalJSON ¶
UnmarshalJSON parses the JSON-encoded data and stores the result.
func (*Feature) WithBoundingBox ¶
WithBoundingBox sets the optional bounding box.
func (*Feature) WithProperties ¶
WithProperties sets the optional properties, removing all existing properties.
type FeatureCollection ¶
type FeatureCollection struct { Features []Feature BBox *BoundingBox }
FeatureCollection is a list of Features.
func NewFeatureCollection ¶
func NewFeatureCollection(features ...*Feature) *FeatureCollection
NewFeatureCollection returns a FeatureCollection consisting of the supplied Features.
func (*FeatureCollection) MarshalJSON ¶
func (c *FeatureCollection) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON encoding of the FeatureCollection.
func (*FeatureCollection) UnmarshalJSON ¶
func (c *FeatureCollection) UnmarshalJSON(data []byte) error
UnmarshalJSON parses the JSON-encoded data and stores the result.
func (*FeatureCollection) WithBoundingBox ¶
func (c *FeatureCollection) WithBoundingBox(bottomLeft, topRight Position) *FeatureCollection
WithBoundingBox sets the optional bounding box.
type Geometry ¶
type Geometry interface { Type() GeometryType json.Marshaler json.Unmarshaler }
Geometry contains the points represented by a particular geometry type.
type GeometryType ¶
type GeometryType string
GeometryType is a supported geometry type.
const ( PointGeometryType GeometryType = "Point" MultiPointGeometryType GeometryType = "MultiPoint" LineStringGeometryType GeometryType = "LineString" MultiLineStringGeometryType GeometryType = "MultiLineString" PolygonGeometryType GeometryType = "Polygon" MultiPolygonGeometryType GeometryType = "MultiPolygon" )
Types of geometry.
type LineString ¶
type LineString []Position
LineString is a set of two or more Positions.
func (*LineString) MarshalJSON ¶
func (l *LineString) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON encoding of the LineString.
func (*LineString) UnmarshalJSON ¶
func (l *LineString) UnmarshalJSON(data []byte) error
UnmarshalJSON parses the JSON-encoded data and stores the result.
type MultiLineString ¶
type MultiLineString [][]Position
MultiLineString is a set of LineStrings.
func (*MultiLineString) MarshalJSON ¶
func (m *MultiLineString) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON encoding of the MultiLineString.
func (*MultiLineString) Type ¶
func (*MultiLineString) Type() GeometryType
Type returns the geometry type.
func (*MultiLineString) UnmarshalJSON ¶
func (m *MultiLineString) UnmarshalJSON(data []byte) error
UnmarshalJSON parses the JSON-encoded data and stores the result.
type MultiPoint ¶
type MultiPoint []Position
MultiPoint is a set of Position.
func (*MultiPoint) MarshalJSON ¶
func (m *MultiPoint) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON encoding of the MultiPoint.
func (*MultiPoint) UnmarshalJSON ¶
func (m *MultiPoint) UnmarshalJSON(data []byte) error
UnmarshalJSON parses the JSON-encoded data and stores the result.
type MultiPolygon ¶
type MultiPolygon [][][]Position
MultiPolygon is a set of Polygons.
func (*MultiPolygon) MarshalJSON ¶
func (m *MultiPolygon) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON encoding of the MultiPolygon.
func (*MultiPolygon) Type ¶
func (*MultiPolygon) Type() GeometryType
Type returns the geometry type.
func (*MultiPolygon) UnmarshalJSON ¶
func (m *MultiPolygon) UnmarshalJSON(data []byte) error
UnmarshalJSON parses the JSON-encoded data and stores the result.
type OptionalFloat64 ¶
type OptionalFloat64 struct {
// contains filtered or unexported fields
}
OptionalFloat64 is a type that represents a float64 that can be optionally set.
func NewOptionalFloat64 ¶
func NewOptionalFloat64(val float64) OptionalFloat64
NewOptionalFloat64 creates a new OptionalFloat64 set to the specified value.
func (OptionalFloat64) Get ¶
func (o OptionalFloat64) Get() (float64, bool)
Get the float64 value and whether or not it's set.
func (OptionalFloat64) IsSet ¶
func (o OptionalFloat64) IsSet() bool
IsSet returns true if the value is set, and false if not.
func (OptionalFloat64) String ¶
func (o OptionalFloat64) String() string
func (OptionalFloat64) Value ¶
func (o OptionalFloat64) Value() float64
Value returns the value. Should call this method if OptionalFloat64.IsSet() returns true.
type Point ¶
type Point Position
Point is a single set of Position.
func (*Point) MarshalJSON ¶
MarshalJSON returns the JSON encoding of the Point.
func (*Point) UnmarshalJSON ¶
UnmarshalJSON parses the JSON-encoded data and stores the result.
type Polygon ¶
type Polygon [][]Position
Polygon is a set of linear rings (closed LineStrings).
func (*Polygon) MarshalJSON ¶
MarshalJSON returns the JSON encoding of the Polygon.
func (*Polygon) UnmarshalJSON ¶
UnmarshalJSON parses the JSON-encoded data and stores the result.
type Position ¶
type Position struct { Longitude float64 Latitude float64 Elevation OptionalFloat64 }
Position represents a longitude and latitude with optional elevation/altitude.
func NewPosition ¶
NewPosition from longitude and latitude.
func NewPositionWithElevation ¶
NewPositionWithElevation from longitude, latitude and elevation.
func (*Position) MarshalJSON ¶
MarshalJSON returns the JSON encoding of the Position. The JSON encoding is an array of numbers with the longitude followed by the latitude, and optional elevation.
func (*Position) UnmarshalJSON ¶
UnmarshalJSON parses the JSON-encoded data and stores the results.
type Property ¶
type Property struct { Name string Value interface{} }
Property represents a single property of arbitrary type.
type PropertyList ¶
type PropertyList []Property
PropertyList is a list of Properties.
func NewPropertyList ¶
func NewPropertyList(props ...Property) PropertyList
NewPropertyList creates a new PropertyList from the supplied Properties.
func (*PropertyList) Get ¶
func (l *PropertyList) Get(name string) (*Property, bool)
Get a Property from the list.
func (*PropertyList) GetValue ¶
func (l *PropertyList) GetValue(name string, dest interface{}) error
GetValue assigns a named property to dest if the types are equal.
func (*PropertyList) MarshalJSON ¶
func (l *PropertyList) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON encoding of the PropertyList.
func (*PropertyList) UnmarshalJSON ¶
func (l *PropertyList) UnmarshalJSON(data []byte) error
UnmarshalJSON parses the JSON-encoded data and stores the result.