geo

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2019 License: MIT Imports: 13 Imported by: 0

README

geo

geo defines geographic operations in two-dimensional space

Functions

Line(points) Line

Line constructor. Takes either an array of coordinate pairs or an array of point objects and returns the line that connects them. Points do not need to be collinear, providing a single point returns a line with a length of 0

parameters:

name type description
points `[[]float Point]`
MultiPolygon(polygons) MultiPolygon

MultiPolygon constructor. MultiPolygon groups a list of polygons to behave like a single polygon

parameters:

name type description
polygons [Polygon]
Point(x,y) Point

Point constructor, takes an x(longitude) and y(latitude) value and returns a Point object

parameters:

name type description
x float x-dimension value (longitude if using geodesic space)
y float y-dimension value (latitude if using geodesic space)
Polygon(rings) Polygon

Polygon constructor. Takes a list of lists of coordinate pairs (or point objects) that define the outer boundary and any holes / inner boundaries that represent a polygon. In GIS tradition, lists of coordinates that wind clockwise are filled regions and anti-clockwise represent holes.

parameters:

name type description
rings [Line] list of closed lines that constitute the polygon
parseGeoJSON(data) (geoms, properties)

Parses string data in IETF-7946 format (https://tools.ietf.org/html/rfc7946) returning a list of geometries and equal-length list of properties for each geometry

parameters:

name type description
data string string of GeoJSON data
within(geom,polygon) bool

Returns True if geom is entirely contained by polygon

parameters:

name type description
geom [point,line,polygon] maybe-inner geometry
polygon [Polygon,MultiPolygon] maybe-outer polygon

Types

Line

an ordered list of points that define a line Methods

length() float

Euclidean Length

geodesicLength() float

Line length on the surface of a sphere with the same radius as Earth

MultiPolygon

MultiPolygon groups a list of polygons to behave like a single polygon### Point a two-dimensional point in space Methods

distance(p2) float

Euclidean Distance to the other point

parameters:

name type description
p2 `` point to measure distance to
distanceGeodesic(p2) float

Distance on the surface of a sphere with the same radius as Earth

parameters:

name type description
p2 point point to measure distance to
Polygon

an ordered list of closed lines (rings) that define a shape. lists of coordinates that wind clockwise are filled regions and anti-clockwise represent holes.

Documentation

Overview

Package geo defines geographic operations

outline: geo
  geo defines geographic operations in two-dimensional space

  functions:
    Point(x,y) Point
      Point constructor, takes an x(longitude) and y(latitude) value and
      returns a Point object
      params:
        x float
          x-dimension value (longitude if using geodesic space)
        y float
          y-dimension value (latitude if using geodesic space)
    Line(points) Line
      Line constructor. Takes either an array of coordinate pairs or an array
      of point objects and returns the line that connects them. Points do not
      need to be collinear, providing a single point returns a line with a
      length of 0
      params:
        points [[]float|Point]
          list of points on the line
    Polygon(rings) Polygon
      Polygon constructor. Takes a list of lists of coordinate pairs (or point
      objects) that define the outer boundary and any holes / inner boundaries
      that represent a polygon. In GIS tradition, lists of coordinates that
      wind clockwise are filled regions and  anti-clockwise represent holes.
      params:
        rings [Line]
          list of closed lines that constitute the polygon
    MultiPolygon(polygons) MultiPolygon
      MultiPolygon constructor. MultiPolygon groups a list of polygons to
      behave like a single polygon
      params:
        polygons [Polygon]
    within(geom,polygon) bool
      Returns True if geom is entirely contained by polygon
      params:
        geom [point,line,polygon]
          maybe-inner geometry
        polygon [Polygon,MultiPolygon]
          maybe-outer polygon
    parseGeoJSON(data) (geoms, properties)
      Parses string data in IETF-7946 format (https://tools.ietf.org/html/rfc7946)
      returning a list of geometries and equal-length list of properties for
      each geometry
      params:
        data string
          string of GeoJSON data
  types:
    Point
      a two-dimensional point in space
      methods:
        distance(p2) float
          Euclidean Distance to the other point
          params:
            p2  point
              point to measure distance to
        distanceGeodesic(p2) float
          Distance on the surface of a sphere with the same radius as Earth
          params:
            p2 point
              point to measure distance to
    Line
      an ordered list of points that define a line
      methods:
        length() float
          Euclidean Length
        lengthGeodesic() float
          Line length on the surface of a sphere with the same radius as Earth
    Polygon
      an ordered list of closed lines (rings) that define a shape. lists of
      coordinates that wind clockwise are filled regions and  anti-clockwise
      represent holes.
    MultiPolygon
      MultiPolygon groups a list of polygons to behave like a single polygon

Index

Constants

View Source
const (
	// ModuleName defines the expected name for this Module when used
	// in starlark's load() function, eg: load('geo.star', 'geo')
	ModuleName = "geo.star"
)

Variables

This section is empty.

Functions

func LoadModule

func LoadModule() (starlark.StringDict, error)

LoadModule loads the geo module. It is concurrency-safe and idempotent.

Types

type Line

type Line []Point

Line is the starlark geographic line type

func (Line) Attr

func (l Line) Attr(name string) (starlark.Value, error)

Attr gets an attribute of a line

func (Line) AttrNames

func (l Line) AttrNames() []string

AttrNames returns all possible attribute names

func (Line) Freeze

func (l Line) Freeze()

Freeze implements the starlark.Value interface, line is immutable

func (Line) Hash

func (l Line) Hash() (h uint32, err error)

Hash implements the starlark.Value interface

func (Line) Index

func (l Line) Index(i int) starlark.Value

Index implements the starlark indexable interface

func (Line) IsClosed

func (l Line) IsClosed() bool

IsClosed checks that first & last points on the line are equal

func (Line) Iterate

func (l Line) Iterate() starlark.Iterator

Iterate implements the starlark iterator interface

func (Line) Len

func (l Line) Len() int

Len implements the starlark indexable interface

func (Line) OrbLineString

func (l Line) OrbLineString() orb.LineString

OrbLineString converts line to a orb.LineString

func (Line) OrbRing

func (l Line) OrbRing() orb.Ring

OrbRing converts line to a orb.Ring

func (Line) String

func (l Line) String() string

String implements the starlark.Value interface

func (Line) Truth

func (l Line) Truth() starlark.Bool

Truth implements the starlark.Value interface

func (Line) Type

func (l Line) Type() string

Type implements the starlark.Value interface

type MultiPolygon

type MultiPolygon []Polygon

MultiPolygon is the starlark geographic collection-of-polygons type

func (MultiPolygon) Attr

func (p MultiPolygon) Attr(name string) (starlark.Value, error)

Attr gets an attribute of a polygon

func (MultiPolygon) AttrNames

func (p MultiPolygon) AttrNames() []string

AttrNames returns all possible attribute names

func (MultiPolygon) Freeze

func (p MultiPolygon) Freeze()

Freeze implements the starlark.Value interface, polygon is immutable

func (MultiPolygon) Hash

func (p MultiPolygon) Hash() (h uint32, err error)

Hash implements the starlark.Value interface

func (MultiPolygon) Index

func (p MultiPolygon) Index(i int) starlark.Value

Index implements the starlark indexable interface

func (MultiPolygon) Iterate

func (p MultiPolygon) Iterate() starlark.Iterator

Iterate implements the starlark iterator interface

func (MultiPolygon) Len

func (p MultiPolygon) Len() int

Len implements the starlark indexable interface

func (MultiPolygon) OrbMultiPolygon

func (p MultiPolygon) OrbMultiPolygon() orb.MultiPolygon

OrbMultiPolygon formats polygon as an orb.MultiPolygon

func (MultiPolygon) String

func (p MultiPolygon) String() string

String implements the starlark.Value interface

func (MultiPolygon) Truth

func (p MultiPolygon) Truth() starlark.Bool

Truth implements the starlark.Value interface

func (MultiPolygon) Type

func (p MultiPolygon) Type() string

Type implements the starlark.Value interface

type Point

type Point [2]float64

Point is the starlark geographic point type

func (Point) Attr

func (p Point) Attr(name string) (starlark.Value, error)

Attr gets an attribute of point

func (Point) AttrNames

func (p Point) AttrNames() []string

AttrNames returns all possible attribute names

func (Point) Freeze

func (p Point) Freeze()

Freeze implements the starlark.Value interface, point is immutable

func (Point) Hash

func (p Point) Hash() (uint32, error)

Hash implements the starlark.Value interface

func (Point) String

func (p Point) String() string

String implements the starlark.Value interface

func (Point) Truth

func (p Point) Truth() starlark.Bool

Truth implements the starlark.Value interface

func (Point) Type

func (p Point) Type() string

Type implements the starlark.Value interface

type Polygon

type Polygon []Line

Polygon is the starlark geographic polygon type

func (Polygon) Attr

func (p Polygon) Attr(name string) (starlark.Value, error)

Attr gets an attribute of a polygon

func (Polygon) AttrNames

func (p Polygon) AttrNames() []string

AttrNames returns all possible attribute names

func (Polygon) Freeze

func (p Polygon) Freeze()

Freeze implements the starlark.Value interface, polygon is immutable

func (Polygon) Hash

func (p Polygon) Hash() (h uint32, err error)

Hash implements the starlark.Value interface

func (Polygon) Index

func (p Polygon) Index(i int) starlark.Value

Index implements the starlark indexable interface

func (Polygon) Iterate

func (p Polygon) Iterate() starlark.Iterator

Iterate implements the starlark iterator interface

func (Polygon) Len

func (p Polygon) Len() int

Len implements the starlark indexable interface

func (Polygon) OrbPolygon

func (p Polygon) OrbPolygon() orb.Polygon

OrbPolygon formats polygon as an orb.Polygon

func (Polygon) String

func (p Polygon) String() string

String implements the starlark.Value interface

func (Polygon) Truth

func (p Polygon) Truth() starlark.Bool

Truth implements the starlark.Value interface

func (Polygon) Type

func (p Polygon) Type() string

Type implements the starlark.Value interface

Jump to

Keyboard shortcuts

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