Documentation
¶
Index ¶
- Variables
- func LineSegmentToCarthesian(p1, p2 Point) (a, b, c float64)
- type BBox
- type ChunkedDecoder
- type ChunkedEncoder
- type Chunks
- type Clippable
- type Codec
- type ConvertFunc
- type Decoder
- type Encoder
- type Feature
- type FeatureCollection
- type Filterable
- type Geom
- func (g *Geom) BBox() BBox
- func (g *Geom) ClipToBBox(bbox BBox) []Geom
- func (g *Geom) Copy() Geom
- func (g *Geom) LineString() (Line, error)
- func (g Geom) MarshalJSON() ([]byte, error)
- func (g Geom) MarshalWKB() ([]byte, error)
- func (g *Geom) MustLineString() Line
- func (g *Geom) MustPoint() *Point
- func (g *Geom) MustPolygon() Polygon
- func (g *Geom) Overlaps(bbox BBox) bool
- func (g *Geom) Point() (*Point, error)
- func (g *Geom) Polygon() (Polygon, error)
- func (g Geom) Project(fn ConvertFunc)
- func (g Geom) Simplify(e float64) Geom
- func (g Geom) String() string
- func (g *Geom) Typ() GeomType
- func (g *Geom) UnmarshalJSON(buf []byte) error
- func (g *Geom) UnmarshalJSONCoords(typ string, inner json.RawMessage) error
- func (g *Geom) UnmarshalWKB(r io.Reader) error
- func (g *Geom) ValidTopology() bool
- type GeomType
- type Line
- func (l Line) Area() float64
- func (l Line) BBox() BBox
- func (l Line) Center() Point
- func (l Line) ClipToBBox(bbox BBox) []Geom
- func (l Line) Clockwise() bool
- func (l Line) Closed() bool
- func (l Line) Copy() Projectable
- func (l Line) Intersections(segments []Segment) []Point
- func (l1 Line) IsExtendedBy(l2 Line) bool
- func (l Line) Project(proj ConvertFunc)
- func (l Line) Reverse()
- func (l Line) Segments() []Segment
- func (l Line) SegmentsWithClosing() []Segment
- func (l Line) Simplify(e float64) Line
- func (l Line) String() string
- type Point
- func (p Point) ClipToBBox(b BBox) []Geom
- func (p Point) Copy() Projectable
- func (p *Point) HaversineDistance(p2 *Point) float64
- func (p Point) InBBox(b BBox) bool
- func (p Point) InPolygon(poly Polygon) bool
- func (p Point) MarshalJSON() ([]byte, error)
- func (p *Point) Project(proj ConvertFunc)
- func (p Point) RoundedCoords() Point
- func (p *Point) SetX(x float64)
- func (p *Point) SetY(y float64)
- func (p Point) String() string
- func (p *Point) UnmarshalJSON(buf []byte) error
- type Polygon
- type Projectable
- type PropertyRetriever
- type RTreeCollection
- type Segment
- func (s Segment) Bearing() float64
- func (s *Segment) ClipToBBox(sw, ne Point) []Segment
- func (s Segment) DistanceToPt(p Point) float64
- func (s *Segment) FullyInBBox(sw, ne Point) bool
- func (s *Segment) HasPoint(pt Point) bool
- func (s *Segment) Intersection(s2 Segment) (Point, bool)
- func (s *Segment) JSON() []byte
- func (s *Segment) Length() float64
- func (s *Segment) SplitAt(p Point) (Segment, Segment)
- type Validatable
- type WKBable
- type WKBableWithProps
Constants ¶
This section is empty.
Variables ¶
var (
ErrorEmptyGeomType = errors.New("empty geometry type")
)
Functions ¶
func LineSegmentToCarthesian ¶
LineSegmentToCarthesian converts a line segment into a carthesian representation. Possible improvement: normalization of values
Types ¶
type ChunkedEncoder ¶
type Chunks ¶
type Chunks interface { Next() bool Scan(fc *FeatureCollection) error }
type Codec ¶
type Codec interface {
Extensions() []string
}
A Codec needs to be able to tell which file extensions (e.g. "geojson") are commonly used to persist files. Moreover a Codec SHOULD either implement a Decoder or Encoder.
type ConvertFunc ¶
type Feature ¶
Feature is a data structure which holds geometry and tags/properties of a geographical feature.
func MergeFeatures ¶
MergeFeatures aggregates features that have the same properties, if possible.
func NewFeature ¶
func NewFeature() Feature
func (Feature) MarshalJSON ¶
func (*Feature) MarshalWKB ¶
func (*Feature) Properties ¶
type FeatureCollection ¶
type FeatureCollection struct { Features []Feature `json:"features"` SRID string `json:"-"` } // TODO: consider adding properties field
func NewFeatureCollection ¶
func NewFeatureCollection() *FeatureCollection
func (*FeatureCollection) Filter ¶
func (fc *FeatureCollection) Filter(bbox BBox) []Feature
func (FeatureCollection) MarshalJSON ¶
func (fc FeatureCollection) MarshalJSON() ([]byte, error)
Deprecated. Please use geojson.Codec.
type Filterable ¶
type Geom ¶
type Geom struct {
// contains filtered or unexported fields
}
func MustNewGeom ¶
func MustNewGeom(g interface{}) Geom
func (*Geom) ClipToBBox ¶
Clips a geometry and returns a cropped copy. Returns a slice, because clip might result in multiple sub-Geoms.
func (*Geom) LineString ¶
func (Geom) MarshalJSON ¶
func (Geom) MarshalWKB ¶
TODO: maybe MarshalWKB could take an io.Writer instead of returning a buffer?
func (*Geom) MustLineString ¶
func (*Geom) MustPolygon ¶
func (Geom) Project ¶
func (g Geom) Project(fn ConvertFunc)
func (*Geom) UnmarshalJSON ¶
func (*Geom) UnmarshalJSONCoords ¶
func (g *Geom) UnmarshalJSONCoords(typ string, inner json.RawMessage) error
func (*Geom) ValidTopology ¶
type Line ¶
type Line []Point
func NewLinesFromSegments ¶
NewLinesFromSegments creates a line from continous segments.
func (Line) ClipToBBox ¶
func (Line) Copy ¶
func (l Line) Copy() Projectable
func (Line) Intersections ¶
func (Line) IsExtendedBy ¶
func (Line) Project ¶
func (l Line) Project(proj ConvertFunc)
func (Line) SegmentsWithClosing ¶
type Point ¶
type Point struct{ X, Y float64 }
func (Point) ClipToBBox ¶
func (Point) Copy ¶
func (p Point) Copy() Projectable
func (*Point) HaversineDistance ¶
DistanceTo returns the distance in meters between the points.
func (Point) MarshalJSON ¶
func (*Point) Project ¶
func (p *Point) Project(proj ConvertFunc)
func (Point) RoundedCoords ¶
func (*Point) UnmarshalJSON ¶
type Polygon ¶
type Polygon []Line
Polygon is a data type for storing simple polygons.
func (Polygon) ClipToBBox ¶
func (Polygon) Copy ¶
func (p Polygon) Copy() Projectable
func (Polygon) FixWinding ¶
func (p Polygon) FixWinding()
func (Polygon) Project ¶
func (p Polygon) Project(proj ConvertFunc)
func (Polygon) ValidTopology ¶
type Projectable ¶
type Projectable interface { Project(ConvertFunc) Copy() Projectable }
type PropertyRetriever ¶
type PropertyRetriever interface {
Properties() map[string]interface{}
}
type RTreeCollection ¶
type RTreeCollection struct {
// contains filtered or unexported fields
}
RTreeCollection is a FeatureCollection which is backed by a rtree.
func NewRTreeCollection ¶
func NewRTreeCollection(features ...Feature) *RTreeCollection
func (*RTreeCollection) Add ¶
func (rt *RTreeCollection) Add(feature Feature)
func (*RTreeCollection) Filter ¶
func (rt *RTreeCollection) Filter(bbox BBox) []Feature
type Segment ¶
type Segment [2]Point
func BBoxBorders ¶
BBoxBorders returns the lines which describe the rectangle of the BBox. Segments are returned in counter-clockwise order.
func (Segment) Bearing ¶
Bearing returns the heading direction between the first and the second point in degrees.
func (*Segment) ClipToBBox ¶
ClipToBBox returns 0 or 1 Segment which is inside bbox.
func (Segment) DistanceToPt ¶
DistanceToPt determines the Segment's perpendicular distance to the point.
func (*Segment) FullyInBBox ¶
func (*Segment) Intersection ¶
LineIntersect returns a point where the two lines intersect and whether the point is on both segments.
type Validatable ¶
type Validatable interface {
ValidTopology() bool
}
type WKBableWithProps ¶
type WKBableWithProps interface { WKBable PropertyRetriever }