Documentation ¶
Overview ¶
Package geo provides a small set of geometrical types and operations on them. This package aims to be simple and very high quality.
Index ¶
- Constants
- Variables
- type Circle
- func (c Circle) Compare(g Geometry) bool
- func (c Circle) Contains(p Point) bool
- func (c Circle) ContainsEquirectangular(p Point) bool
- func (c Circle) ContainsHaversine(p Point) bool
- func (c Circle) ContainsSLC(p Point) bool
- func (c Circle) MarshalJSON() ([]byte, error)
- func (c *Circle) Scan(src interface{}) error
- func (c Circle) String() string
- func (c *Circle) UnmarshalJSON(data []byte) error
- func (c Circle) Value() (driver.Value, error)
- type Feature
- func (f Feature) Compare(g Geometry) bool
- func (f Feature) Contains(p Point) bool
- func (f Feature) MarshalJSON() ([]byte, error)
- func (f *Feature) Scan(src interface{}) error
- func (f Feature) String() string
- func (f *Feature) UnmarshalJSON(data []byte) error
- func (f Feature) Value() (driver.Value, error)
- type FeatureCollection
- func (coll FeatureCollection) Compare(g Geometry) bool
- func (coll FeatureCollection) Contains(p Point) bool
- func (coll FeatureCollection) MarshalJSON() ([]byte, error)
- func (coll *FeatureCollection) Scan(src interface{}) error
- func (coll FeatureCollection) String() string
- func (coll *FeatureCollection) UnmarshalJSON(data []byte) error
- func (coll FeatureCollection) Value() (driver.Value, error)
- type Geometry
- type Line
- type MultiPoint
- type Point
- func (point Point) Compare(g Geometry) bool
- func (point Point) Contains(other Point) bool
- func (point Point) DistanceFrom(other Point) float64
- func (point Point) MarshalJSON() ([]byte, error)
- func (point Point) RayhIntersects(a, b Point) bool
- func (point *Point) Scan(src interface{}) error
- func (point Point) String() string
- func (point Point) Value() (driver.Value, error)
- type Polygon
- func (polygon Polygon) Compare(g Geometry) bool
- func (polygon Polygon) Contains(point Point) bool
- func (polygon Polygon) MarshalJSON() ([]byte, error)
- func (polygon *Polygon) Scan(src interface{}) error
- func (polygon Polygon) String() string
- func (polygon *Polygon) UnmarshalJSON(data []byte) error
- func (polygon Polygon) Value() (driver.Value, error)
Constants ¶
const ( CircleType = "Circle" FeatureCollectionType = "FeatureCollection" FeatureType = "Feature" LineType = "LineString" PointType = "Point" PolygonType = "Polygon" )
Geometry types.
Variables ¶
var ( // CircleContainsMethod provides a way to control // which algorithm is used to calculate if a point is // inside a circle. CircleContainsMethod = "equirectangular" )
Functions ¶
This section is empty.
Types ¶
type Circle ¶
Circle is a circle in the XY plane.
func (Circle) Contains ¶
Contains determines if the circle contains the point. This assumes radius is specified in feet. This method uses the package variable
CircleContainsMethod
to choose a way to calculate if the point is in the circle. See http://www.movable-type.co.uk/scripts/latlong.html for more info. If CircleContainsMethod is not set to one of
- "haversine"
- "equirectangular"
- "slc"
then this method panics.
func (Circle) ContainsEquirectangular ¶
ContainsEquirectangular uses equirectangular projection to determine if the point is contained in the circle.
func (Circle) ContainsHaversine ¶
ContainsHaversine uses the haversine formula to determine if the point is contained in the circle.
func (Circle) ContainsSLC ¶
ContainsSLC uses the spherical law of cosines to determine if the point is contained in the circle.
func (Circle) MarshalJSON ¶
MarshalJSON marshals a circle to GeoJSON. See https://github.com/geojson/geojson-spec/wiki/Proposal---Circles-and-Ellipses-Geoms
func (*Circle) UnmarshalJSON ¶
UnmarshalJSON unmarshals the circle from GeoJSON.
type Feature ¶
type Feature struct { Geometry Geometry `json:"geometry"` Properties interface{} `json:"properties,omitempty"` }
Feature is a GeoJSON feature.
func (Feature) Compare ¶
Compare compares one feature to another. Note that this method does not compare properties.
func (Feature) MarshalJSON ¶
MarshalJSON marshals the feature to GeoJSON.
func (*Feature) UnmarshalJSON ¶
UnmarshalJSON unmarshals a feature from JSON.
type FeatureCollection ¶
type FeatureCollection []Feature
FeatureCollection represents a feature collection.
func (FeatureCollection) Compare ¶
func (coll FeatureCollection) Compare(g Geometry) bool
Compare compares one feature collection to another.
func (FeatureCollection) Contains ¶
func (coll FeatureCollection) Contains(p Point) bool
Contains returns true if every feature in the collection contains the p, and false otherwise.
func (FeatureCollection) MarshalJSON ¶
func (coll FeatureCollection) MarshalJSON() ([]byte, error)
MarshalJSON marshals the feature collection to geojson.
func (*FeatureCollection) Scan ¶
func (coll *FeatureCollection) Scan(src interface{}) error
Scan scans the feature collection from WKT. This method expects a GEOMETRYCOLLECTION. TODO: implement this.
func (FeatureCollection) String ¶
func (coll FeatureCollection) String() string
String converts the feature collection to a GEOMETRYCOLLECTION.
func (*FeatureCollection) UnmarshalJSON ¶
func (coll *FeatureCollection) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals the feature collection from geojson.
type Geometry ¶
type Geometry interface { json.Marshaler sql.Scanner driver.Valuer Compare(g Geometry) bool Contains(p Point) bool String() string }
Geometry defines the interface of every geometry type.
func ScanGeometry ¶
ScanGeometry scans a geometry from well known text.
func UnmarshalGeometry ¶
UnmarshalGeometry unmarshals a geometry from geojson data.
type Line ¶
type Line [][2]float64
Line is a line.
func (Line) MarshalJSON ¶
MarshalJSON marshals the line to JSON.
type Point ¶
type Point [2]float64
Point defines a point.
func (Point) DistanceFrom ¶
DistanceFrom computes the distance from one point to another.
func (Point) MarshalJSON ¶
MarshalJSON returns the GeoJSON representation of the point.
func (Point) RayhIntersects ¶
RayhIntersects returns true if the horizontal ray going from point to positive infinity intersects the line that connects a and b.
type Polygon ¶
type Polygon [][][2]float64
Polygon is a GeoJSON Polygon.
func (Polygon) Contains ¶
Contains uses the ray casting algorithm to decide if the point is contained in the polygon.
func (Polygon) MarshalJSON ¶
MarshalJSON returns the GeoJSON representation of the polygon.
func (*Polygon) UnmarshalJSON ¶
UnmarshalJSON unmarshals the polygon from GeoJSON.