geojson

package module
v0.0.0-...-2014597 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2019 License: Apache-2.0 Imports: 6 Imported by: 4

README

go-geojson has moved to github.com/everystreet/go-geojson

Documentation

Index

Constants

View Source
const TypePropFeature = "Feature"

TypePropFeature is the value of the "type" property for Features.

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

type BoundingBox struct {
	BottomLeft Position
	TopRight   Position
}

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

func NewLineString(pos1, pos2 Position, others ...Position) *Feature

NewLineString returns a LineString from the supplied positions.

func NewMultiLineString

func NewMultiLineString(ls ...[]Position) *Feature

NewMultiLineString returns a new MultiLineString from the supplied position "strings".

func NewMultiPoint

func NewMultiPoint(pos ...Position) *Feature

NewMultiPoint returns a MultiPoint from the specified set of position.

func NewMultiPolygon

func NewMultiPolygon(p ...[][]Position) *Feature

NewMultiPolygon returns a new MultiPolygon from the supplied polygons.

func NewPoint

func NewPoint(long, lat float64) *Feature

NewPoint returns a Point Feature with the specified longitude and latitude.

func NewPointWithElevation

func NewPointWithElevation(long, lat, elevation float64) *Feature

NewPointWithElevation returns a Point Feature with the specified longitude, latitude and elevation.

func NewPolygon

func NewPolygon(rings ...[]Position) *Feature

NewPolygon returns a new Polygon from the supplied linear rings.

func (*Feature) AddProperty

func (f *Feature) AddProperty(name string, value interface{}) *Feature

AddProperty appends a new property.

func (*Feature) MarshalJSON

func (f *Feature) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON encoding of the Feature.

func (*Feature) UnmarshalJSON

func (f *Feature) UnmarshalJSON(data []byte) error

UnmarshalJSON parses the JSON-encoded data and stores the result.

func (*Feature) WithBoundingBox

func (f *Feature) WithBoundingBox(bottomLeft, topRight Position) *Feature

WithBoundingBox sets the optional bounding box.

func (*Feature) WithProperties

func (f *Feature) WithProperties(props ...Property) *Feature

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

func (*LineString) Type() GeometryType

Type returns the geometry type.

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

func (*MultiPoint) Type() GeometryType

Type returns the geometry type.

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

func (p *Point) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON encoding of the Point.

func (*Point) Type

func (*Point) Type() GeometryType

Type returns the geometry type.

func (*Point) UnmarshalJSON

func (p *Point) UnmarshalJSON(data []byte) error

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

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

MarshalJSON returns the JSON encoding of the Polygon.

func (*Polygon) Type

func (*Polygon) Type() GeometryType

Type returns the geometry type.

func (*Polygon) UnmarshalJSON

func (p *Polygon) UnmarshalJSON(data []byte) error

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

func NewPosition(long, lat float64) Position

NewPosition from longitude and latitude.

func NewPositionWithElevation

func NewPositionWithElevation(long, lat, elevation float64) Position

NewPositionWithElevation from longitude, latitude and elevation.

func (*Position) MarshalJSON

func (p *Position) MarshalJSON() ([]byte, error)

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

func (p Position) String() string

func (*Position) UnmarshalJSON

func (p *Position) UnmarshalJSON(data []byte) error

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.

func (*Property) GetValue

func (p *Property) GetValue(dest interface{}) error

GetValue assigns the value to dest if the types are equal.

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.

Jump to

Keyboard shortcuts

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