geojson

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2016 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FEATURE    = "Feature"
	GEOMETRY   = "geometry"
	PROPERTIES = "properties"
	ID         = "id"
)

GeoJSON Feature constants

View Source
const (
	FEATURECOLLECTION = "FeatureCollection"
	FEATURES          = "features"
)

GeoJSON FeatureCollection constants

View Source
const (
	TYPE = "type"
	BBOX = "bbox"
)

GeoJSON Constants

View Source
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 Parse

func Parse(bytes []byte) (interface{}, error)

Parse parses a GeoJSON string into a GeoJSON object pointer

func ParseFile

func ParseFile(filename string) (interface{}, error)

ParseFile parses a file containing a GeoJSON string 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

func Write

func Write(input interface{}) ([]byte, error)

Write writes a GeoJSON object into a byte array

func WriteFile

func WriteFile(input interface{}, filename string) error

WriteFile writes a GeoJSON object to the file specified

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

func FeatureFromBytes(bytes []byte) (*Feature, error)

FeatureFromBytes constructs a Feature from a GeoJSON byte array and returns its pointer

func FeatureFromMap

func FeatureFromMap(input map[string]interface{}) *Feature

FeatureFromMap constructs a Feature from a map and returns its pointer

func NewFeature

func NewFeature(geometry interface{}, id interface{}, properties map[string]interface{}) *Feature

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

func (feature *Feature) IDStr() string

IDStr returns the ID as a string

func (*Feature) Map

func (feature *Feature) Map() map[string]interface{}

Map returns a map of the Feature's members This may be useful in wrapping a Feature with foreign members

func (*Feature) PropertyFloat

func (feature *Feature) PropertyFloat(propertyName string) float64

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

func (feature *Feature) PropertyInt(propertyName string) int

PropertyInt returns the integer value of the property if it exists or 0 otherwise

func (*Feature) PropertyString

func (feature *Feature) PropertyString(propertyName string) string

PropertyString returns the string value of the property if it exists and is a string, or the empty string otherwise

func (*Feature) PropertyStringSlice

func (feature *Feature) PropertyStringSlice(propertyName string) []string

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

func (*Feature) String

func (feature *Feature) String() string

String returns the string representation

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 NewPoint

func NewPoint(coordinates []float64) *Point

NewPoint is the normal factory method for a Point

func PointFromBytes

func PointFromBytes(bytes []byte) (*Point, error)

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

func (Point) Map

func (point Point) Map() map[string]interface{}

Map returns a map of the Geometry's members

func (Point) String

func (point Point) String() string

String returns the string representation

func (Point) WKT

func (point Point) WKT() string

WKT returns the Well Known Text representation of the point

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

func NewPolygon(coordinates [][][]float64) *Polygon

NewPolygon is the normal factory method for a Polygon

func PolygonFromBytes

func PolygonFromBytes(bytes []byte) (*Polygon, error)

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

func (Polygon) Map

func (polygon Polygon) Map() map[string]interface{}

Map returns a map of the Geometry's members

func (Polygon) String

func (polygon Polygon) String() string

String returns the string representation

Jump to

Keyboard shortcuts

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