geojson

package
v1.4.1-0...-a4d69fd Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2021 License: BSD-2-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package geojson implements GeoJSON encoding and decoding.

Index

Constants

This section is empty.

Variables

View Source
var DefaultLayout = geom.XY

DefaultLayout is the default layout for empty geometries. FIXME This should be Codec-specific, not global.

Functions

func Marshal

func Marshal(g geom.T, opts ...EncodeGeometryOption) ([]byte, error)

Marshal marshals an arbitrary geometry to a []byte.

func Unmarshal

func Unmarshal(data []byte, g *geom.T) error

Unmarshal unmarshalls a []byte to an arbitrary geometry.

Types

type CRS

type CRS struct {
	Type       string                 `json:"type"`
	Properties map[string]interface{} `json:"properties"`
}

CRS is a deprecated field but still populated in some programs (e.g. PostGIS). See https://geojson.org/geojson-spec for original specification of CRS.

type EncodeGeometryOption

type EncodeGeometryOption struct {
	// contains filtered or unexported fields
}

EncodeGeometryOption applies extra metadata to the Geometry GeoJSON encoding.

func EncodeGeometryWithBBox

func EncodeGeometryWithBBox() EncodeGeometryOption

EncodeGeometryWithBBox adds a bbox field to the Geometry GeoJSON encoding.

func EncodeGeometryWithCRS

func EncodeGeometryWithCRS(crs *CRS) EncodeGeometryOption

EncodeGeometryWithCRS adds the crs field to the Geometry GeoJSON encoding.

func EncodeGeometryWithMaxDecimalDigits

func EncodeGeometryWithMaxDecimalDigits(maxDecimalDigits int) EncodeGeometryOption

EncodeGeometryWithMaxDecimalDigits encodes the Geometry with maximum decimal digits in the JSON representation.

type ErrDimensionalityTooLow

type ErrDimensionalityTooLow int

ErrDimensionalityTooLow is returned when the dimensionality is too low.

func (ErrDimensionalityTooLow) Error

func (e ErrDimensionalityTooLow) Error() string

type ErrUnsupportedType

type ErrUnsupportedType string

ErrUnsupportedType is returned when the type is unsupported.

func (ErrUnsupportedType) Error

func (e ErrUnsupportedType) Error() string

type Feature

type Feature struct {
	ID         string
	BBox       *geom.Bounds
	Geometry   geom.T
	Properties map[string]interface{}
}

A Feature is a GeoJSON Feature.

func (*Feature) MarshalJSON

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

MarshalJSON implements json.Marshaler.MarshalJSON.

func (*Feature) UnmarshalJSON

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

UnmarshalJSON implements json.Unmarshaler.UnmarshalJSON.

type FeatureCollection

type FeatureCollection struct {
	BBox     *geom.Bounds
	Features []*Feature
}

A FeatureCollection is a GeoJSON FeatureCollection.

func (*FeatureCollection) MarshalJSON

func (fc *FeatureCollection) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.MarshalJSON.

func (*FeatureCollection) UnmarshalJSON

func (fc *FeatureCollection) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.UnmarshalJSON.

type Geometry

type Geometry struct {
	Type        string           `json:"type"`
	BBox        *json.RawMessage `json:"bbox,omitempty"`
	CRS         *CRS             `json:"crs,omitempty"`
	Coordinates *json.RawMessage `json:"coordinates,omitempty"`
	Geometries  *json.RawMessage `json:"geometries,omitempty"`
}

A Geometry is a geometry in GeoJSON format.

func Encode

func Encode(g geom.T, opts ...EncodeGeometryOption) (*Geometry, error)

Encode encodes g as a GeoJSON geometry.

func (*Geometry) Decode

func (g *Geometry) Decode() (geom.T, error)

Decode decodes g to a geometry.

Jump to

Keyboard shortcuts

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