geometry

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2022 License: MIT Imports: 4 Imported by: 19

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Collection

type Collection struct {
	Type       geojson.OBjectType `json:"type"`
	Geometries []Geometry         `json:"geometries"`
}

Collection type https://tools.ietf.org/html/rfc7946#section-3.1.8

func CollectionFromJSON

func CollectionFromJSON(gjson string) (*Collection, error)

CollectionFromJSON returns a new Collection by passing in a valid JSON string.

func NewGeometryCollection

func NewGeometryCollection(geometries []Geometry) (*Collection, error)

NewGeometryCollection initializes a new instance of GeometryCollection

type Geometry

type Geometry struct {
	// GeoJSONType describes the type of GeoJSON Geometry, Feature or FeatureCollection this object is.
	GeoJSONType geojson.OBjectType `json:"type"`
	Coordinates interface{}        `json:"coordinates"`
}

Geometry type https://tools.ietf.org/html/rfc7946#section-3

func FromJSON

func FromJSON(gjson string) (*Geometry, error)

FromJSON returns a new Geometry by passing in a valid JSON string.

func (*Geometry) ToLineString

func (g *Geometry) ToLineString() (*LineString, error)

ToLineString converts a ToLineString Geometry to ToLineString geometry.

func (*Geometry) ToMultiLineString

func (g *Geometry) ToMultiLineString() (*MultiLineString, error)

ToMultiLineString converts a MultiLineString faeture to MultiLineString geometry.

func (*Geometry) ToMultiPoint

func (g *Geometry) ToMultiPoint() (*MultiPoint, error)

ToMultiPoint converts the Geometry to MultiPoint

func (*Geometry) ToMultiPolygon

func (g *Geometry) ToMultiPolygon() (*MultiPolygon, error)

ToMultiPolygon converts a MultiPolygon Feature to MultiPolygon geometry.

func (*Geometry) ToPoint

func (g *Geometry) ToPoint() (*Point, error)

ToPoint converts the Geometry to Point

func (*Geometry) ToPolygon

func (g *Geometry) ToPolygon() (*Polygon, error)

ToPolygon convert the Geometry to Polygon

type LineString

type LineString struct {
	Coordinates []Point
}

LineString defines the linestring type.

func NewLineString

func NewLineString(coordinates []Point) (*LineString, error)

NewLineString initializes a new LineString

func (*LineString) IsClosed

func (l *LineString) IsClosed() bool

IsClosed determines if the Linestring is closed which means that has its first and last coordinate at the same position

func (*LineString) IsLinearRing

func (l *LineString) IsLinearRing() bool

IsLinearRing returns true if it is a closed LineString with four or more positions https://tools.ietf.org/html/rfc7946#section-3.1.1

type MultiLineString

type MultiLineString struct {
	Coordinates []LineString
}

MultiLineString type https://tools.ietf.org/html/rfc7946#section-3.1.5

func NewMultiLineString

func NewMultiLineString(coordinates []LineString) (*MultiLineString, error)

NewMultiLineString initializes a new MultiLineString

type MultiPoint

type MultiPoint struct {
	Coordinates []Point
}

MultiPoint defines the MultiPoint type https://tools.ietf.org/html/rfc7946#section-3.1.3

func NewMultiPoint

func NewMultiPoint(coordinates []Point) (*MultiPoint, error)

NewMultiPoint initializes a new MultiLineString

type MultiPolygon

type MultiPolygon struct {
	Coordinates []Polygon
}

MultiPolygon defines the MultiPolygon type For type "MultiPolygon", the "coordinates" member is an array of Polygon coordinate arrays. https://tools.ietf.org/html/rfc7946#section-3.1.7

func NewMultiPolygon

func NewMultiPolygon(coordinates []Polygon) (*MultiPolygon, error)

NewMultiPolygon initialize a new MultiPolygon

type Object

type Object struct {
	Type geojson.OBjectType
}

Object is the base interface for GeometryObject types

type Point

type Point struct {
	Lat float64
	Lng float64
}

Point represents a geolocation using ESPG-900913/(ESPG-3875) Projection. For type "Point" the coordinates member must be a single position.

func NewPoint

func NewPoint(lat, lng float64) *Point

NewPoint initializes a new Point

type Polygon

type Polygon struct {
	Coordinates []LineString
}

Polygon defines a polygon type https://tools.ietf.org/html/rfc7946#section-3.1.6

func NewPolygon

func NewPolygon(coordinates []LineString) (*Polygon, error)

NewPolygon initializes a new instance of a Polygon The coordinates of a polygon must be an array of linear ring coordinate arrays. For Polygons with more than one of these rings, the first MUST be the exterior ring, and any others MUST be interior rings. The exterior ring bounds the surface, and the interior ring bound holes within the surface.

type Position

type Position struct {
	Altitude  *float64
	Latitude  float64
	Longitude float64
}

Position is the fundamental geometry construct, consisting of Latitude, Longtitude and Altitude

func NewPosition

func NewPosition(altitude *float64, latitude, longitude float64) *Position

NewPosition initializes a new instance of the Position

func (*Position) ToPoint

func (p *Position) ToPoint() Point

ToPoint converts a Position to Point

Jump to

Keyboard shortcuts

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