Documentation
¶
Index ¶
- Constants
- func FromMap(input map[string]interface{}) interface{}
- func Parse(bytes []byte) (interface{}, error)
- func ParseFile(filename string) (interface{}, error)
- func ToGeometryArray(gjObject interface{}) []interface{}
- func WKT(input string) interface{}
- func Write(input interface{}) ([]byte, error)
- func WriteFile(input interface{}, filename string) error
- type BoundingBox
- func (bb BoundingBox) Antimeridian() bool
- func (bb BoundingBox) Centroid() *Point
- func (bb BoundingBox) Equals(test BoundingBox) bool
- func (bb BoundingBox) Overlaps(test BoundingBox) bool
- func (bb BoundingBox) Polygon() *Polygon
- func (bb BoundingBox) String() string
- func (bb BoundingBox) Valid() error
- type BoundingBoxIfc
- type Feature
- func (feature *Feature) ForceBbox() BoundingBox
- func (feature *Feature) IDStr() string
- func (feature *Feature) Map() map[string]interface{}
- func (feature *Feature) PropertyFloat(propertyName string) float64
- func (feature *Feature) PropertyInt(propertyName string) int
- func (feature *Feature) PropertyString(propertyName string) string
- func (feature *Feature) PropertyStringSlice(propertyName string) []string
- func (feature *Feature) ResolveGeometry()
- func (feature *Feature) String() string
- type FeatureCollection
- type GeometryCollection
- type LineString
- type Mapper
- type MultiLineString
- type MultiPoint
- type MultiPolygon
- type Point
- type Polygon
Constants ¶
const ( FEATURE = "Feature" GEOMETRY = "geometry" PROPERTIES = "properties" ID = "id" )
GeoJSON Feature constants
const ( FEATURECOLLECTION = "FeatureCollection" FEATURES = "features" )
GeoJSON FeatureCollection constants
const ( TYPE = "type" BBOX = "bbox" )
GeoJSON Constants
const ( COORDINATES = "coordinates" POINT = "Point" LINESTRING = "LineString" POLYGON = "Polygon" MULTIPOINT = "MultiPoint" MULTILINESTRING = "MultiLineString" MULTIPOLYGON = "MultiPolygon" GEOMETRYCOLLECTION = "GeometryCollection" GEOMETRIES = "geometries" )
GeoJSON Constants
Variables ¶
This section is empty.
Functions ¶
func FromMap ¶
func FromMap(input map[string]interface{}) interface{}
FromMap parses a map containing a GeoJSON object into a GeoJSON object pointer
func ToGeometryArray ¶
func ToGeometryArray(gjObject interface{}) []interface{}
ToGeometryArray takes a GeoJSON object and returns an array of its constituent geometry objects
func WKT ¶
func WKT(input string) interface{}
WKT returns a GeoJSON object based on the Well-Known Text input
Types ¶
type BoundingBox ¶
type BoundingBox []float64
The BoundingBox type supports bbox elements in GeoJSON Note that since this is an array, it is passed by value instead of pointer (unlike other GeoJSON objects)
func NewBoundingBox ¶
func NewBoundingBox(input interface{}) (BoundingBox, error)
NewBoundingBox creates a BoundingBox from a large number of inputs including a string and an n-dimensional coordinate array
func (BoundingBox) Antimeridian ¶
func (bb BoundingBox) Antimeridian() bool
Antimeridian returns true if the BoundingBox crosses the antimeridian
func (BoundingBox) Centroid ¶
func (bb BoundingBox) Centroid() *Point
Centroid returns the center of the BoundingBox, or nil if it has no coordinates or is otherwise invalid
func (BoundingBox) Equals ¶
func (bb BoundingBox) Equals(test BoundingBox) bool
Equals returns true if all points in the bounding boxes are equal
func (BoundingBox) Overlaps ¶
func (bb BoundingBox) Overlaps(test BoundingBox) bool
Overlaps returns true if the interiors of the two bounding boxes have any area in common
func (BoundingBox) Polygon ¶
func (bb BoundingBox) Polygon() *Polygon
Polygon returns the BoundingBox as a GeoJSON Polygon if the BoundingBox is two-dimensional
func (BoundingBox) String ¶
func (bb BoundingBox) String() string
String returns a string representation as minx,miny,maxx,maxy
func (BoundingBox) Valid ¶
func (bb BoundingBox) Valid() error
Valid returns nil if the bounding box is valid or an error object if it is invalid
type BoundingBoxIfc ¶
type BoundingBoxIfc interface {
ForceBbox() BoundingBox
}
BoundingBoxIfc is for objects that have a bounding box property
type Feature ¶
type Feature struct { Type string `json:"type"` Geometry interface{} `json:"geometry"` Properties map[string]interface{} `json:"properties,omitempty"` ID interface{} `json:"id,omitempty"` Bbox BoundingBox `json:"bbox,omitempty"` }
The Feature object represents an array of features
func FeatureFromBytes ¶
FeatureFromBytes constructs a Feature from a GeoJSON byte array and returns its pointer
func FeatureFromMap ¶
FeatureFromMap constructs a Feature from a map and returns its pointer
func NewFeature ¶
NewFeature is the normal factory method for a feature Note that id is expected to be a string or number
func (*Feature) ForceBbox ¶
func (feature *Feature) ForceBbox() BoundingBox
ForceBbox returns a bounding box, creating one by brute force if needed
func (*Feature) Map ¶
Map returns a map of the Feature's members This may be useful in wrapping a Feature with foreign members
func (*Feature) PropertyFloat ¶
PropertyFloat returns the floating point value of the property if it exists and is a float or is a parseable string, or math.NaN() otherwise
func (*Feature) PropertyInt ¶
PropertyInt returns the integer value of the property if it exists or 0 otherwise
func (*Feature) PropertyString ¶
PropertyString returns the string value of the property if it exists and is a string, or the empty string otherwise
func (*Feature) PropertyStringSlice ¶
PropertyStringSlice returns the string slice value of the property if it exists or an empty slice otherwise
func (*Feature) ResolveGeometry ¶
func (feature *Feature) ResolveGeometry()
ResolveGeometry reconstructs a Feature's geometries since unmarshaled objects come back as maps of interfaces, not real geometries
type FeatureCollection ¶
type FeatureCollection struct { Type string `json:"type"` Features []*Feature `json:"features"` Bbox BoundingBox `json:"bbox,omitempty"` }
The FeatureCollection object represents an array of features
func FeatureCollectionFromBytes ¶
func FeatureCollectionFromBytes(bytes []byte) (*FeatureCollection, error)
FeatureCollectionFromBytes constructs a FeatureCollection from a GeoJSON byte array and returns its pointer
func FeatureCollectionFromMap ¶
func FeatureCollectionFromMap(input map[string]interface{}) *FeatureCollection
FeatureCollectionFromMap constructs a FeatureCollection from a map and returns its pointer
func FromWFS ¶
func FromWFS(wfsURL, featureType string) (*FeatureCollection, error)
FromWFS returns a Feature Collection from the WFS provided. This is a convenience method only and not intended for serious processing. This function does not currently support WFS layers with large numbers of features.
func NewFeatureCollection ¶
func NewFeatureCollection(features []*Feature) *FeatureCollection
NewFeatureCollection is the normal factory method for a FeatureCollection
func (*FeatureCollection) FillProperties ¶
func (fc *FeatureCollection) FillProperties()
FillProperties iterates through all features to ensure that all properties are present on all features to meet the needs of some relational databases
func (*FeatureCollection) ForceBbox ¶
func (fc *FeatureCollection) ForceBbox() BoundingBox
ForceBbox returns a bounding box, creating one by brute force if needed
func (*FeatureCollection) Map ¶
func (fc *FeatureCollection) Map() map[string]interface{}
Map returns a map of the FeatureCollection's members This may be useful in wrapping a Feature Collection with foreign members
func (*FeatureCollection) String ¶
func (fc *FeatureCollection) String() string
String returns the string representation
type GeometryCollection ¶
type GeometryCollection struct { Type string `json:"type"` Geometries []interface{} `json:"geometries"` Bbox BoundingBox `json:"bbox,omitempty"` }
The GeometryCollection object contains a array of one or more polygons
func GeometryCollectionFromBytes ¶
func GeometryCollectionFromBytes(bytes []byte) (*GeometryCollection, error)
GeometryCollectionFromBytes constructs a GeometryCollection from a GeoJSON byte array
func NewGeometryCollection ¶
func NewGeometryCollection(geometries []interface{}) *GeometryCollection
NewGeometryCollection is the normal factory method for a GeometryCollection
func (GeometryCollection) ForceBbox ¶
func (gc GeometryCollection) ForceBbox() BoundingBox
ForceBbox returns a bounding box, creating one by brute force if needed
func (GeometryCollection) Map ¶
func (gc GeometryCollection) Map() map[string]interface{}
Map returns a map of the Geometry's members
func (GeometryCollection) String ¶
func (gc GeometryCollection) String() string
String returns the string representation
type LineString ¶
type LineString struct { Type string `json:"type"` Coordinates [][]float64 `json:"coordinates"` Bbox BoundingBox `json:"bbox,omitempty"` }
The LineString object contains a array of two or more positions
func LineStringFromBytes ¶
func LineStringFromBytes(bytes []byte) (*LineString, error)
LineStringFromBytes constructs a LineString from a GeoJSON byte array and returns its pointer
func NewLineString ¶
func NewLineString(coordinates [][]float64) *LineString
NewLineString is the normal factory method for a LineString
func (LineString) ForceBbox ¶
func (ls LineString) ForceBbox() BoundingBox
ForceBbox returns a bounding box, creating one by brute force if needed
func (LineString) Map ¶
func (ls LineString) Map() map[string]interface{}
Map returns a map of the Geometry's members
func (LineString) String ¶
func (ls LineString) String() string
String returns the string representation
type Mapper ¶
type Mapper interface {
Map() map[string]interface{}
}
Mapper is an interface for all GeoJSON objects to return itself as a Map
type MultiLineString ¶
type MultiLineString struct { Type string `json:"type"` Coordinates [][][]float64 `json:"coordinates"` Bbox BoundingBox `json:"bbox,omitempty"` }
The MultiLineString object contains a array of one or more line strings
func MultiLineStringFromBytes ¶
func MultiLineStringFromBytes(bytes []byte) (*MultiLineString, error)
MultiLineStringFromBytes constructs a MultiLineString from a GeoJSON byte array and returns its pointer
func NewMultiLineString ¶
func NewMultiLineString(coordinates [][][]float64) *MultiLineString
NewMultiLineString is the normal factory method for a MultiLineString
func (MultiLineString) ForceBbox ¶
func (mls MultiLineString) ForceBbox() BoundingBox
ForceBbox returns a bounding box, creating one by brute force if needed
func (MultiLineString) Map ¶
func (mls MultiLineString) Map() map[string]interface{}
Map returns a map of the Geometry's members
func (MultiLineString) String ¶
func (mls MultiLineString) String() string
String returns the string representation
type MultiPoint ¶
type MultiPoint struct { Type string `json:"type"` Coordinates [][]float64 `json:"coordinates"` Bbox BoundingBox `json:"bbox,omitempty"` }
The MultiPoint object contains a array of one or more points
func MultiPointFromBytes ¶
func MultiPointFromBytes(bytes []byte) (*MultiPoint, error)
MultiPointFromBytes constructs a MultiPoint from a GeoJSON byte array and returns its pointer
func NewMultiPoint ¶
func NewMultiPoint(coordinates [][]float64) *MultiPoint
NewMultiPoint is the normal factory method for a MultiPoint
func (MultiPoint) ForceBbox ¶
func (mp MultiPoint) ForceBbox() BoundingBox
ForceBbox returns a bounding box, creating one by brute force if needed
func (MultiPoint) Map ¶
func (mp MultiPoint) Map() map[string]interface{}
Map returns a map of the Geometry's members
func (MultiPoint) String ¶
func (mp MultiPoint) String() string
String returns the string representation
type MultiPolygon ¶
type MultiPolygon struct { Type string `json:"type"` Coordinates [][][][]float64 `json:"coordinates"` Bbox BoundingBox `json:"bbox,omitempty"` }
The MultiPolygon object contains a array of one or more polygons
func MultiPolygonFromBytes ¶
func MultiPolygonFromBytes(bytes []byte) (*MultiPolygon, error)
MultiPolygonFromBytes constructs a MultiPolygon from a GeoJSON byte array and returns its pointer
func NewMultiPolygon ¶
func NewMultiPolygon(coordinates [][][][]float64) *MultiPolygon
NewMultiPolygon is the normal factory method for a MultiPolygon
func (MultiPolygon) ForceBbox ¶
func (mp MultiPolygon) ForceBbox() BoundingBox
ForceBbox returns a bounding box, creating one by brute force if needed
func (MultiPolygon) Map ¶
func (mp MultiPolygon) Map() map[string]interface{}
Map returns a map of the Geometry's members
func (MultiPolygon) String ¶
func (mp MultiPolygon) String() string
String returns the string representation
type Point ¶
type Point struct { Type string `json:"type"` Coordinates []float64 `json:"coordinates"` Bbox BoundingBox `json:"bbox,omitempty"` }
The Point object contains a single position
func PointFromBytes ¶
PointFromBytes constructs a point from a GeoJSON byte array and returns its pointer
func (Point) ForceBbox ¶
func (point Point) ForceBbox() BoundingBox
ForceBbox returns a bounding box, creating one by brute force if needed
type Polygon ¶
type Polygon struct { Type string `json:"type"` Coordinates [][][]float64 `json:"coordinates"` Bbox BoundingBox `json:"bbox,omitempty"` }
The Polygon object contains a array of one or more linear rings
func NewPolygon ¶
NewPolygon is the normal factory method for a Polygon
func PolygonFromBytes ¶
PolygonFromBytes constructs a Polygon from a GeoJSON byte array and returns its pointer
func (Polygon) ForceBbox ¶
func (polygon Polygon) ForceBbox() BoundingBox
ForceBbox returns a bounding box, creating one by brute force if needed