geojson

package
v0.0.0-...-652815c Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2018 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoundsFromCenter

func BoundsFromCenter(lat, lon, meters float64) (latMin, lonMin, latMax, lonMax float64)

BoundsFromCenter calculates the bounding box surrounding a circle.

func SegmentIntersectsCircle

func SegmentIntersectsCircle(start, end, center Position, meters float64) bool

Types

type BBox

type BBox struct {
	Min Position
	Max Position
}

BBox is a bounding box

func BBoxesFromCenter

func BBoxesFromCenter(lat, lon, meters float64) (outer BBox)

BBoxesFromCenter calculates the bounding box surrounding a circle.

func New2DBBox

func New2DBBox(minX, minY, maxX, maxY float64) BBox

New2DBBox creates a new bounding box

func (BBox) ExternalJSON

func (b BBox) ExternalJSON() string

ExternalJSON is the simple json representation of the bounding box used for external applications.

func (BBox) Sparse

func (b BBox) Sparse(amount byte) []BBox

Sparse returns back an evenly distributed number of sub bboxs.

type Feature

type Feature struct {
	Geometry Object
	BBox     *BBox
	// contains filtered or unexported fields
}

Feature is a geojson object with the type "Feature"

func (Feature) Bytes

func (g Feature) Bytes() []byte

Bytes is the bytes representation of the object.

func (Feature) CalculatedBBox

func (g Feature) CalculatedBBox() BBox

CalculatedBBox is exterior bbox containing the object.

func (Feature) CalculatedPoint

func (g Feature) CalculatedPoint() Position

CalculatedPoint is a point representation of the object.

func (Feature) Clipped

func (g Feature) Clipped(bbox BBox) Object

Clip returns the object obtained by clipping this object by a bbox.

func (Feature) Geohash

func (g Feature) Geohash(precision int) (string, error)

Geohash converts the object to a geohash value.

func (Feature) Intersects

func (g Feature) Intersects(o Object) bool

Intersects detects if the object intersects another object.

func (Feature) IntersectsBBox

func (g Feature) IntersectsBBox(bbox BBox) bool

IntersectsBBox detects if the object intersects a bbox.

func (Feature) IntersectsCircle

func (g Feature) IntersectsCircle(center Position, meters float64) bool

IntersectsCircle detects if the object intersects a circle.

func (Feature) IsBBoxDefined

func (g Feature) IsBBoxDefined() bool

IsBBoxDefined returns true if the object has a defined bbox.

func (Feature) IsGeometry

func (g Feature) IsGeometry() bool

IsGeometry return true if the object is a geojson geometry object. false if it something else.

func (Feature) JSON

func (g Feature) JSON() string

JSON is the json representation of the object. This might not be exactly the same as the original.

func (Feature) MarshalJSON

func (g Feature) MarshalJSON() ([]byte, error)

MarshalJSON allows the object to be encoded in json.Marshal calls.

func (Feature) Nearby

func (g Feature) Nearby(center Position, meters float64) bool

Nearby detects if the object is nearby a position.

func (Feature) PositionCount

func (g Feature) PositionCount() int

PositionCount return the number of coordinates.

func (Feature) String

func (g Feature) String() string

String returns a string representation of the object. This might be JSON or something else.

func (Feature) Weight

func (g Feature) Weight() int

Weight returns the in-memory size of the object.

func (Feature) Within

func (g Feature) Within(o Object) bool

Within detects if the object is fully contained inside another object.

func (Feature) WithinBBox

func (g Feature) WithinBBox(bbox BBox) bool

WithinBBox detects if the object is fully contained inside a bbox.

func (Feature) WithinCircle

func (g Feature) WithinCircle(center Position, meters float64) bool

WithinCircle detects if the object is fully contained inside a circle.

type FeatureCollection

type FeatureCollection struct {
	Features []Object
	BBox     *BBox
	// contains filtered or unexported fields
}

FeatureCollection is a geojson object with the type "FeatureCollection"

func (FeatureCollection) Bytes

func (g FeatureCollection) Bytes() []byte

Bytes is the bytes representation of the object.

func (FeatureCollection) CalculatedBBox

func (g FeatureCollection) CalculatedBBox() BBox

CalculatedBBox is exterior bbox containing the object.

func (FeatureCollection) CalculatedPoint

func (g FeatureCollection) CalculatedPoint() Position

CalculatedPoint is a point representation of the object.

func (FeatureCollection) Clipped

func (g FeatureCollection) Clipped(bbox BBox) Object

Clip returns the object obtained by clipping this object by a bbox.

func (FeatureCollection) Geohash

func (g FeatureCollection) Geohash(precision int) (string, error)

Geohash converts the object to a geohash value.

func (FeatureCollection) Intersects

func (g FeatureCollection) Intersects(o Object) bool

Intersects detects if the object intersects another object.

func (FeatureCollection) IntersectsBBox

func (g FeatureCollection) IntersectsBBox(bbox BBox) bool

IntersectsBBox detects if the object intersects a bbox.

func (FeatureCollection) IntersectsCircle

func (g FeatureCollection) IntersectsCircle(center Position, meters float64) bool

IntersectsCircle detects if the object intersects a circle.

func (FeatureCollection) IsBBoxDefined

func (g FeatureCollection) IsBBoxDefined() bool

IsBBoxDefined returns true if the object has a defined bbox.

func (FeatureCollection) IsGeometry

func (g FeatureCollection) IsGeometry() bool

IsGeometry return true if the object is a geojson geometry object. false if it something else.

func (FeatureCollection) JSON

func (g FeatureCollection) JSON() string

JSON is the json representation of the object. This might not be exactly the same as the original.

func (FeatureCollection) MarshalJSON

func (g FeatureCollection) MarshalJSON() ([]byte, error)

MarshalJSON allows the object to be encoded in json.Marshal calls.

func (FeatureCollection) Nearby

func (g FeatureCollection) Nearby(center Position, meters float64) bool

Nearby detects if the object is nearby a position.

func (FeatureCollection) PositionCount

func (g FeatureCollection) PositionCount() int

PositionCount return the number of coordinates.

func (FeatureCollection) String

func (g FeatureCollection) String() string

String returns a string representation of the object. This might be JSON or something else.

func (FeatureCollection) Weight

func (g FeatureCollection) Weight() int

Weight returns the in-memory size of the object.

func (FeatureCollection) Within

func (g FeatureCollection) Within(o Object) bool

Within detects if the object is fully contained inside another object.

func (FeatureCollection) WithinBBox

func (g FeatureCollection) WithinBBox(bbox BBox) bool

WithinBBox detects if the object is fully contained inside a bbox.

func (FeatureCollection) WithinCircle

func (g FeatureCollection) WithinCircle(center Position, meters float64) bool

WithinCircle detects if the object is fully contained inside a circle.

type GeometryCollection

type GeometryCollection struct {
	Geometries []Object
	BBox       *BBox
	// contains filtered or unexported fields
}

GeometryCollection is a geojson object with the type "GeometryCollection"

func (GeometryCollection) Bytes

func (g GeometryCollection) Bytes() []byte

Bytes is the bytes representation of the object.

func (GeometryCollection) CalculatedBBox

func (g GeometryCollection) CalculatedBBox() BBox

CalculatedBBox is exterior bbox containing the object.

func (GeometryCollection) CalculatedPoint

func (g GeometryCollection) CalculatedPoint() Position

CalculatedPoint is a point representation of the object.

func (GeometryCollection) Clipped

func (g GeometryCollection) Clipped(bbox BBox) Object

Clip returns the object of the same type as this object, clipped by a bbox.

func (GeometryCollection) Geohash

func (g GeometryCollection) Geohash(precision int) (string, error)

Geohash converts the object to a geohash value.

func (GeometryCollection) Intersects

func (g GeometryCollection) Intersects(o Object) bool

Intersects detects if the object intersects another object.

func (GeometryCollection) IntersectsBBox

func (g GeometryCollection) IntersectsBBox(bbox BBox) bool

IntersectsBBox detects if the object intersects a bbox.

func (GeometryCollection) IntersectsCircle

func (g GeometryCollection) IntersectsCircle(center Position, meters float64) bool

IntersectsCircle detects if the object intersects a circle.

func (GeometryCollection) IsBBoxDefined

func (g GeometryCollection) IsBBoxDefined() bool

IsBBoxDefined returns true if the object has a defined bbox.

func (GeometryCollection) IsGeometry

func (g GeometryCollection) IsGeometry() bool

IsGeometry return true if the object is a geojson geometry object. false if it something else.

func (GeometryCollection) JSON

func (g GeometryCollection) JSON() string

JSON is the json representation of the object. This might not be exactly the same as the original.

func (GeometryCollection) MarshalJSON

func (g GeometryCollection) MarshalJSON() ([]byte, error)

MarshalJSON allows the object to be encoded in json.Marshal calls.

func (GeometryCollection) Nearby

func (g GeometryCollection) Nearby(center Position, meters float64) bool

Nearby detects if the object is nearby a position.

func (GeometryCollection) PositionCount

func (g GeometryCollection) PositionCount() int

PositionCount return the number of coordinates.

func (GeometryCollection) String

func (g GeometryCollection) String() string

String returns a string representation of the object. This might be JSON or something else.

func (GeometryCollection) Weight

func (g GeometryCollection) Weight() int

Weight returns the in-memory size of the object.

func (GeometryCollection) Within

func (g GeometryCollection) Within(o Object) bool

Within detects if the object is fully contained inside another object.

func (GeometryCollection) WithinBBox

func (g GeometryCollection) WithinBBox(bbox BBox) bool

WithinBBox detects if the object is fully contained inside a bbox.

func (GeometryCollection) WithinCircle

func (g GeometryCollection) WithinCircle(center Position, meters float64) bool

WithinCircle detects if the object is fully contained inside a circle.

type LineString

type LineString struct {
	Coordinates []Position
	BBox        *BBox
	// contains filtered or unexported fields
}

LineString is a geojson object with the type "LineString"

func (LineString) CalculatedBBox

func (g LineString) CalculatedBBox() BBox

CalculatedBBox is exterior bbox containing the object.

func (LineString) CalculatedPoint

func (g LineString) CalculatedPoint() Position

CalculatedPoint is a point representation of the object.

func (LineString) Clipped

func (g LineString) Clipped(bbox BBox) Object

Clip returns the object obtained by clipping this object by a bbox.

func (LineString) Geohash

func (g LineString) Geohash(precision int) (string, error)

Geohash converts the object to a geohash value.

func (LineString) Intersects

func (g LineString) Intersects(o Object) bool

Intersects detects if the object intersects another object.

func (LineString) IntersectsBBox

func (g LineString) IntersectsBBox(bbox BBox) bool

IntersectsBBox detects if the object intersects a bbox.

func (LineString) IntersectsCircle

func (g LineString) IntersectsCircle(center Position, meters float64) bool

IntersectsCircle detects if the object intersects a circle.

func (LineString) IsBBoxDefined

func (g LineString) IsBBoxDefined() bool

IsBBoxDefined returns true if the object has a defined bbox.

func (LineString) IsGeometry

func (g LineString) IsGeometry() bool

IsGeometry return true if the object is a geojson geometry object. false if it something else.

func (LineString) JSON

func (g LineString) JSON() string

JSON is the json representation of the object. This might not be exactly the same as the original.

func (LineString) MarshalJSON

func (g LineString) MarshalJSON() ([]byte, error)

MarshalJSON allows the object to be encoded in json.Marshal calls.

func (LineString) Nearby

func (g LineString) Nearby(center Position, meters float64) bool

Nearby detects if the object is nearby a position.

func (LineString) PositionCount

func (g LineString) PositionCount() int

PositionCount return the number of coordinates.

func (LineString) String

func (g LineString) String() string

String returns a string representation of the object. This might be JSON or something else.

func (LineString) Weight

func (g LineString) Weight() int

Weight returns the in-memory size of the object.

func (LineString) Within

func (g LineString) Within(o Object) bool

Within detects if the object is fully contained inside another object.

func (LineString) WithinBBox

func (g LineString) WithinBBox(bbox BBox) bool

WithinBBox detects if the object is fully contained inside a bbox.

func (LineString) WithinCircle

func (g LineString) WithinCircle(center Position, meters float64) bool

WithinCircle detects if the object is fully contained inside a circle.

type MultiLineString

type MultiLineString struct {
	Coordinates [][]Position
	BBox        *BBox
	// contains filtered or unexported fields
}

MultiLineString is a geojson object with the type "MultiLineString"

func (MultiLineString) CalculatedBBox

func (g MultiLineString) CalculatedBBox() BBox

CalculatedBBox is exterior bbox containing the object.

func (MultiLineString) CalculatedPoint

func (g MultiLineString) CalculatedPoint() Position

CalculatedPoint is a point representation of the object.

func (MultiLineString) Clipped

func (g MultiLineString) Clipped(bbox BBox) Object

Clip returns the object obtained by clipping this object by a bbox.

func (MultiLineString) Geohash

func (g MultiLineString) Geohash(precision int) (string, error)

Geohash converts the object to a geohash value.

func (MultiLineString) Intersects

func (g MultiLineString) Intersects(o Object) bool

Intersects detects if the object intersects another object.

func (MultiLineString) IntersectsBBox

func (g MultiLineString) IntersectsBBox(bbox BBox) bool

IntersectsBBox detects if the object intersects a bbox.

func (MultiLineString) IntersectsCircle

func (g MultiLineString) IntersectsCircle(center Position, meters float64) bool

IntersectsCircle detects if the object intersects a circle.

func (MultiLineString) IsBBoxDefined

func (g MultiLineString) IsBBoxDefined() bool

IsBBoxDefined returns true if the object has a defined bbox.

func (MultiLineString) IsGeometry

func (g MultiLineString) IsGeometry() bool

IsGeometry return true if the object is a geojson geometry object. false if it something else.

func (MultiLineString) JSON

func (g MultiLineString) JSON() string

JSON is the json representation of the object. This might not be exactly the same as the original.

func (MultiLineString) MarshalJSON

func (g MultiLineString) MarshalJSON() ([]byte, error)

MarshalJSON allows the object to be encoded in json.Marshal calls.

func (MultiLineString) Nearby

func (g MultiLineString) Nearby(center Position, meters float64) bool

Nearby detects if the object is nearby a position.

func (MultiLineString) PositionCount

func (g MultiLineString) PositionCount() int

PositionCount return the number of coordinates.

func (MultiLineString) String

func (g MultiLineString) String() string

String returns a string representation of the object. This might be JSON or something else.

func (MultiLineString) Weight

func (g MultiLineString) Weight() int

Weight returns the in-memory size of the object.

func (MultiLineString) Within

func (g MultiLineString) Within(o Object) bool

Within detects if the object is fully contained inside another object.

func (MultiLineString) WithinBBox

func (g MultiLineString) WithinBBox(bbox BBox) bool

WithinBBox detects if the object is fully contained inside a bbox.

func (MultiLineString) WithinCircle

func (g MultiLineString) WithinCircle(center Position, meters float64) bool

WithinCircle detects if the object is fully contained inside a circle.

type MultiPoint

type MultiPoint struct {
	Coordinates []Position
	BBox        *BBox
	// contains filtered or unexported fields
}

MultiPoint is a geojson object with the type "MultiPoint"

func (MultiPoint) CalculatedBBox

func (g MultiPoint) CalculatedBBox() BBox

CalculatedBBox is exterior bbox containing the object.

func (MultiPoint) CalculatedPoint

func (g MultiPoint) CalculatedPoint() Position

CalculatedPoint is a point representation of the object.

func (MultiPoint) Clipped

func (g MultiPoint) Clipped(bbox BBox) Object

Clip returns the object obtained by clipping this object by a bbox.

func (MultiPoint) Geohash

func (g MultiPoint) Geohash(precision int) (string, error)

Geohash converts the object to a geohash value.

func (MultiPoint) Intersects

func (g MultiPoint) Intersects(o Object) bool

Intersects detects if the object intersects another object.

func (MultiPoint) IntersectsBBox

func (g MultiPoint) IntersectsBBox(bbox BBox) bool

IntersectsBBox detects if the object intersects a bbox.

func (MultiPoint) IntersectsCircle

func (g MultiPoint) IntersectsCircle(center Position, meters float64) bool

IntersectsCircle detects if the object intersects a circle.

func (MultiPoint) IsBBoxDefined

func (g MultiPoint) IsBBoxDefined() bool

IsBBoxDefined returns true if the object has a defined bbox.

func (MultiPoint) IsGeometry

func (g MultiPoint) IsGeometry() bool

IsGeometry return true if the object is a geojson geometry object. false if it something else.

func (MultiPoint) JSON

func (g MultiPoint) JSON() string

JSON is the json representation of the object. This might not be exactly the same as the original.

func (MultiPoint) MarshalJSON

func (g MultiPoint) MarshalJSON() ([]byte, error)

MarshalJSON allows the object to be encoded in json.Marshal calls.

func (MultiPoint) Nearby

func (g MultiPoint) Nearby(center Position, meters float64) bool

Nearby detects if the object is nearby a position.

func (MultiPoint) PositionCount

func (g MultiPoint) PositionCount() int

PositionCount return the number of coordinates.

func (MultiPoint) String

func (g MultiPoint) String() string

String returns a string representation of the object. This might be JSON or something else.

func (MultiPoint) Weight

func (g MultiPoint) Weight() int

Weight returns the in-memory size of the object.

func (MultiPoint) Within

func (g MultiPoint) Within(o Object) bool

Within detects if the object is fully contained inside another object.

func (MultiPoint) WithinBBox

func (g MultiPoint) WithinBBox(bbox BBox) bool

WithinBBox detects if the object is fully contained inside a bbox.

func (MultiPoint) WithinCircle

func (g MultiPoint) WithinCircle(center Position, meters float64) bool

WithinCircle detects if the object is fully contained inside a circle.

type MultiPolygon

type MultiPolygon struct {
	Coordinates [][][]Position
	BBox        *BBox
	// contains filtered or unexported fields
}

MultiPolygon is a geojson object with the type "MultiPolygon"

func (MultiPolygon) CalculatedBBox

func (g MultiPolygon) CalculatedBBox() BBox

CalculatedBBox is exterior bbox containing the object.

func (MultiPolygon) CalculatedPoint

func (g MultiPolygon) CalculatedPoint() Position

CalculatedPoint is a point representation of the object.

func (MultiPolygon) Clipped

func (g MultiPolygon) Clipped(bbox BBox) Object

Clip returns the object obtained by clipping this object by a bbox.

func (MultiPolygon) Geohash

func (g MultiPolygon) Geohash(precision int) (string, error)

Geohash converts the object to a geohash value.

func (MultiPolygon) Intersects

func (g MultiPolygon) Intersects(o Object) bool

Intersects detects if the object intersects another object.

func (MultiPolygon) IntersectsBBox

func (g MultiPolygon) IntersectsBBox(bbox BBox) bool

IntersectsBBox detects if the object intersects a bbox.

func (MultiPolygon) IntersectsCircle

func (g MultiPolygon) IntersectsCircle(center Position, meters float64) bool

IntersectsCircle detects if the object intersects a circle.

func (MultiPolygon) IsBBoxDefined

func (g MultiPolygon) IsBBoxDefined() bool

IsBBoxDefined returns true if the object has a defined bbox.

func (MultiPolygon) IsGeometry

func (g MultiPolygon) IsGeometry() bool

IsGeometry return true if the object is a geojson geometry object. false if it something else.

func (MultiPolygon) JSON

func (g MultiPolygon) JSON() string

JSON is the json representation of the object. This might not be exactly the same as the original.

func (MultiPolygon) MarshalJSON

func (g MultiPolygon) MarshalJSON() ([]byte, error)

MarshalJSON allows the object to be encoded in json.Marshal calls.

func (MultiPolygon) Nearby

func (g MultiPolygon) Nearby(center Position, meters float64) bool

Nearby detects if the object is nearby a position.

func (MultiPolygon) PositionCount

func (g MultiPolygon) PositionCount() int

PositionCount return the number of coordinates.

func (MultiPolygon) String

func (g MultiPolygon) String() string

String returns a string representation of the object. This might be JSON or something else.

func (MultiPolygon) Weight

func (g MultiPolygon) Weight() int

Weight returns the in-memory size of the object.

func (MultiPolygon) Within

func (g MultiPolygon) Within(o Object) bool

Within detects if the object is fully contained inside another object.

func (MultiPolygon) WithinBBox

func (g MultiPolygon) WithinBBox(bbox BBox) bool

WithinBBox detects if the object is fully contained inside a bbox.

func (MultiPolygon) WithinCircle

func (g MultiPolygon) WithinCircle(center Position, meters float64) bool

WithinCircle detects if the object is fully contained inside a circle.

type Object

type Object interface {

	// WithinBBox detects if the object is fully contained inside a bbox.
	WithinBBox(bbox BBox) bool
	// IntersectsBBox detects if the object intersects a bbox.
	IntersectsBBox(bbox BBox) bool
	// Within detects if the object is fully contained inside another object.
	Within(o Object) bool
	// Intersects detects if the object intersects another object.
	Intersects(o Object) bool
	// WithinCircle detects if the object is fully contained inside a circle.
	WithinCircle(center Position, meters float64) bool
	// IntersectsCircle detects if the object intersects a circle.
	IntersectsCircle(center Position, meters float64) bool
	// Nearby detects if the object is nearby a position.
	Nearby(center Position, meters float64) bool
	// CalculatedBBox is exterior bbox containing the object.
	CalculatedBBox() BBox
	// CalculatedPoint is a point representation of the object.
	CalculatedPoint() Position
	// JSON is the json representation of the object. This might not be exactly the same as the original.
	JSON() string
	// String returns a string representation of the object. This may be JSON or something else.
	String() string
	// PositionCount return the number of coordinates.
	PositionCount() int
	// Weight returns the in-memory size of the object.
	Weight() int
	// MarshalJSON allows the object to be encoded in json.Marshal calls.
	MarshalJSON() ([]byte, error)
	// Geohash converts the object to a geohash value.
	Geohash(precision int) (string, error)
	// IsBBoxDefined returns true if the object has a defined bbox.
	IsBBoxDefined() bool
	// IsGeometry return true if the object is a geojson geometry object. false if it something else.
	IsGeometry() bool
	// Clip returns the object obtained by clipping this object by a bbox.
	Clipped(bbox BBox) Object
	// contains filtered or unexported methods
}

Object is a geojson object

func ObjectJSON

func ObjectJSON(json string) (Object, error)

ObjectJSON parses geojson and returns an Object

type Point

type Point struct {
	Coordinates Position
	BBox        *BBox
	// contains filtered or unexported fields
}

Point is a geojson object with the type "Point"

func (Point) CalculatedBBox

func (g Point) CalculatedBBox() BBox

CalculatedBBox is exterior bbox containing the object.

func (Point) CalculatedPoint

func (g Point) CalculatedPoint() Position

CalculatedPoint is a point representation of the object.

func (Point) Clipped

func (g Point) Clipped(bbox BBox) Object

Clip returns the object obtained by clipping this object by a bbox.

func (Point) Geohash

func (g Point) Geohash(precision int) (string, error)

Geohash converts the object to a geohash value.

func (Point) Intersects

func (g Point) Intersects(o Object) bool

Intersects detects if the object intersects another object.

func (Point) IntersectsBBox

func (g Point) IntersectsBBox(bbox BBox) bool

IntersectsBBox detects if the object intersects a bbox.

func (Point) IntersectsCircle

func (g Point) IntersectsCircle(center Position, meters float64) bool

IntersectsCircle detects if the object intersects a circle.

func (Point) IsBBoxDefined

func (g Point) IsBBoxDefined() bool

IsBBoxDefined returns true if the object has a defined bbox.

func (Point) IsGeometry

func (g Point) IsGeometry() bool

IsGeometry return true if the object is a geojson geometry object. false if it something else.

func (Point) JSON

func (g Point) JSON() string

JSON is the json representation of the object. This might not be exactly the same as the original.

func (Point) MarshalJSON

func (g Point) MarshalJSON() ([]byte, error)

MarshalJSON allows the object to be encoded in json.Marshal calls.

func (Point) Nearby

func (g Point) Nearby(center Position, meters float64) bool

Nearby detects if the object is nearby a position.

func (Point) PositionCount

func (g Point) PositionCount() int

PositionCount return the number of coordinates.

func (Point) String

func (g Point) String() string

String returns a string representation of the object. This might be JSON or something else.

func (Point) Weight

func (g Point) Weight() int

Weight returns the in-memory size of the object.

func (Point) Within

func (g Point) Within(o Object) bool

Within detects if the object is fully contained inside another object.

func (Point) WithinBBox

func (g Point) WithinBBox(bbox BBox) bool

WithinBBox detects if the object is fully contained inside a bbox.

func (Point) WithinCircle

func (g Point) WithinCircle(center Position, meters float64) bool

WithinCircle detects if the object is fully contained inside a circle.

type Polygon

type Polygon struct {
	Coordinates [][]Position
	BBox        *BBox
	// contains filtered or unexported fields
}

Polygon is a geojson object with the type "Polygon"

func CirclePolygon

func CirclePolygon(x, y, meters float64, steps int) Polygon

CirclePolygon returns a Polygon around the radius.

func (Polygon) CalculatedBBox

func (g Polygon) CalculatedBBox() BBox

CalculatedBBox is exterior bbox containing the object.

func (Polygon) CalculatedPoint

func (g Polygon) CalculatedPoint() Position

CalculatedPoint is a point representation of the object.

func (Polygon) Clipped

func (g Polygon) Clipped(bbox BBox) Object

Clip returns the object obtained by clipping this object by a bbox.

func (Polygon) Geohash

func (g Polygon) Geohash(precision int) (string, error)

Geohash converts the object to a geohash value.

func (Polygon) Intersects

func (g Polygon) Intersects(o Object) bool

Intersects detects if the object intersects another object.

func (Polygon) IntersectsBBox

func (g Polygon) IntersectsBBox(bbox BBox) bool

IntersectsBBox detects if the object intersects a bbox.

func (Polygon) IntersectsCircle

func (g Polygon) IntersectsCircle(center Position, meters float64) bool

IntersectsCircle detects if the object intersects a circle.

func (Polygon) IsBBoxDefined

func (g Polygon) IsBBoxDefined() bool

IsBBoxDefined returns true if the object has a defined bbox.

func (Polygon) IsGeometry

func (g Polygon) IsGeometry() bool

IsGeometry return true if the object is a geojson geometry object. false if it something else.

func (Polygon) JSON

func (g Polygon) JSON() string

JSON is the json representation of the object. This might not be exactly the same as the original.

func (Polygon) MarshalJSON

func (g Polygon) MarshalJSON() ([]byte, error)

MarshalJSON allows the object to be encoded in json.Marshal calls.

func (Polygon) Nearby

func (g Polygon) Nearby(center Position, meters float64) bool

Nearby detects if the object is nearby a position.

func (Polygon) PositionCount

func (g Polygon) PositionCount() int

PositionCount return the number of coordinates.

func (Polygon) String

func (g Polygon) String() string

String returns a string representation of the object. This might be JSON or something else.

func (Polygon) Weight

func (g Polygon) Weight() int

Weight returns the in-memory size of the object.

func (Polygon) Within

func (g Polygon) Within(o Object) bool

Within detects if the object is fully contained inside another object.

func (Polygon) WithinBBox

func (g Polygon) WithinBBox(bbox BBox) bool

WithinBBox detects if the object is fully contained inside a bbox.

func (Polygon) WithinCircle

func (g Polygon) WithinCircle(center Position, meters float64) bool

WithinCircle detects if the object is fully contained inside a circle.

type Position

type Position poly.Point

Position is a simple point

func ClipRing

func ClipRing(ring []Position, bbox BBox) (resRing []Position)

Sutherland-Hodgman Polygon Clipping https://www.cs.helsinki.fi/group/goa/viewing/leikkaus/intro2.html

func ClipSegment

func ClipSegment(start, end Position, bbox BBox) (resStart, resEnd Position, rejected bool)

Cohen-Sutherland Line Clipping https://www.cs.helsinki.fi/group/goa/viewing/leikkaus/lineClip.html

func (Position) Destination

func (p Position) Destination(meters, bearingDegrees float64) Position

Destination calculates a new position based on the distance and bearing.

func (Position) DistanceTo

func (p Position) DistanceTo(position Position) float64

DistanceTo calculates the distance to a position

func (Position) ExternalJSON

func (p Position) ExternalJSON() string

ExternalJSON is the simple json representation of the position used for external applications.

type SimplePoint

type SimplePoint struct {
	X, Y float64
}

SimplePoint is a geojson object with the type "Point" and where there coordinate is 2D and there is no bbox.

func New2DPoint

func New2DPoint(x, y float64) SimplePoint

New2DPoint creates a SimplePoint

func (SimplePoint) CalculatedBBox

func (g SimplePoint) CalculatedBBox() BBox

CalculatedBBox is exterior bbox containing the object.

func (SimplePoint) CalculatedPoint

func (g SimplePoint) CalculatedPoint() Position

CalculatedPoint is a point representation of the object.

func (SimplePoint) Clipped

func (g SimplePoint) Clipped(bbox BBox) Object

Clip returns the object obtained by clipping this object by a bbox.

func (SimplePoint) Geohash

func (g SimplePoint) Geohash(precision int) (string, error)

Geohash converts the object to a geohash value.

func (SimplePoint) Intersects

func (g SimplePoint) Intersects(o Object) bool

Intersects detects if the object intersects another object.

func (SimplePoint) IntersectsBBox

func (g SimplePoint) IntersectsBBox(bbox BBox) bool

IntersectsBBox detects if the object intersects a bbox.

func (SimplePoint) IntersectsCircle

func (g SimplePoint) IntersectsCircle(center Position, meters float64) bool

IntersectsCircle detects if the object intersects a circle.

func (SimplePoint) IsBBoxDefined

func (g SimplePoint) IsBBoxDefined() bool

IsBBoxDefined returns true if the object has a defined bbox.

func (SimplePoint) IsGeometry

func (g SimplePoint) IsGeometry() bool

IsGeometry return true if the object is a geojson geometry object. false if it something else.

func (SimplePoint) JSON

func (g SimplePoint) JSON() string

JSON is the json representation of the object. This might not be exactly the same as the original.

func (SimplePoint) MarshalJSON

func (g SimplePoint) MarshalJSON() ([]byte, error)

MarshalJSON allows the object to be encoded in json.Marshal calls.

func (SimplePoint) Nearby

func (g SimplePoint) Nearby(center Position, meters float64) bool

Nearby detects if the object is nearby a position.

func (SimplePoint) PositionCount

func (g SimplePoint) PositionCount() int

PositionCount return the number of coordinates.

func (SimplePoint) String

func (g SimplePoint) String() string

String returns a string representation of the object. This might be JSON or something else.

func (SimplePoint) Weight

func (g SimplePoint) Weight() int

Weight returns the in-memory size of the object.

func (SimplePoint) Within

func (g SimplePoint) Within(o Object) bool

Within detects if the object is fully contained inside another object.

func (SimplePoint) WithinBBox

func (g SimplePoint) WithinBBox(bbox BBox) bool

WithinBBox detects if the object is fully contained inside a bbox.

func (SimplePoint) WithinCircle

func (g SimplePoint) WithinCircle(center Position, meters float64) bool

WithinCircle detects if the object is fully contained inside a circle.

type String

type String string

String is a not a geojson object, but just a string

func (String) Bytes

func (s String) Bytes() []byte

Bytes is the bytes representation of the object.

func (String) CalculatedBBox

func (s String) CalculatedBBox() BBox

CalculatedBBox is exterior bbox containing the object.

func (String) CalculatedPoint

func (s String) CalculatedPoint() Position

CalculatedPoint is a point representation of the object.

func (String) Clipped

func (s String) Clipped(bbox BBox) Object

Clip returns the object obtained by clipping this object by a bbox.

func (String) Geohash

func (s String) Geohash(precision int) (string, error)

Geohash converts the object to a geohash value.

func (String) Intersects

func (s String) Intersects(o Object) bool

Intersects detects if the object intersects another object.

func (String) IntersectsBBox

func (s String) IntersectsBBox(bbox BBox) bool

IntersectsBBox detects if the object intersects a bbox.

func (String) IntersectsCircle

func (s String) IntersectsCircle(center Position, meters float64) bool

func (String) IsBBoxDefined

func (s String) IsBBoxDefined() bool

IsBBoxDefined returns true if the object has a defined bbox.

func (String) IsGeometry

func (s String) IsGeometry() bool

IsGeometry return true if the object is a geojson geometry object. false if it something else.

func (String) JSON

func (s String) JSON() string

JSON is the json representation of the object. This might not be exactly the same as the original.

func (String) MarshalJSON

func (s String) MarshalJSON() ([]byte, error)

MarshalJSON allows the object to be encoded in json.Marshal calls.

func (String) Nearby

func (s String) Nearby(center Position, meters float64) bool

Nearby detects if the object is nearby a position.

func (String) PositionCount

func (s String) PositionCount() int

PositionCount return the number of coordinates.

func (String) String

func (s String) String() string

String returns a string representation of the object. This might be JSON or something else.

func (String) Weight

func (s String) Weight() int

Weight returns the in-memory size of the object.

func (String) Within

func (s String) Within(o Object) bool

Within detects if the object is fully contained inside another object.

func (String) WithinBBox

func (s String) WithinBBox(bbox BBox) bool

WithinBBox detects if the object is fully contained inside a bbox.

func (String) WithinCircle

func (s String) WithinCircle(center Position, meters float64) bool

WithinCircle detects if the object is fully contained inside a circle.

Directories

Path Synopsis
Package poly provides polygon detection methods.
Package poly provides polygon detection methods.

Jump to

Keyboard shortcuts

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