Documentation ¶
Overview ¶
Package math contains generic math functions that we need for doing transforms. this package will augment the go math library.
Index ¶
- Constants
- func AreaOfPolygon(p tegola.Polygon) (area float64)
- func AreaOfPolygonLineString(line tegola.LineString) (area float64)
- func AreaOfRing(points ...Pt) (area float64)
- func AreaOfTriangle(v0, v1, v2 Pt) float64
- func Contains(subject []float64, pt Pt) (bool, error)
- func DegToRad(deg float64) float64
- func DistOfLine(l tegola.LineString) (dist float64)
- func DoesIntersect(s1, s2 Line) bool
- func Exp2(p uint64) uint64
- func FindAllIntersectsWithEventQueueWithoutIntersectNotPolygon(eq []event, segments []Line, skipfn func(srcIdx, destIdx int) bool, ...)
- func FindIntersects(segments []Line, fn func(srcIdx, destIdx int, ptfn func() Pt) bool)
- func FindIntersectsWithEventQueue(polygonCheck bool, eq []event, segments []Line, ...)
- func FindIntersectsWithEventQueueWithoutIntersect(polygonCheck bool, eq []event, segments []Line, ...)
- func FindIntersectsWithEventQueueWithoutIntersectNew(polygonCheck bool, eq []event, segments []Line, ...)
- func FindIntersectsWithEventQueueWithoutIntersectNotPolygon(eq []event, segments []Line, fn func(srcIdx, destIdx int) bool)
- func FindIntersectsWithoutIntersect(segments []Line, fn func(srcIdx, destIdx int) bool)
- func FindPolygonIntersects(segments []Line, fn func(srcIdx, destIdx int, ptfn func() Pt) bool)
- func MakeValid(plygs ...[]Line) (polygons [][][]Pt, err error)
- func Min(x, y uint) uint
- func NewEventQueue(segments []Line) []event
- func PointPairs(pts []Pt) ([][2]Pt, error)
- func RadToDeg(rad float64) float64
- func XYOrder(pt1, pt2 Pt) int
- func YXorder(pt1, pt2 Pt) int
- type ByXY
- type ByXYLine
- type EdgeMap
- type Eventer
- type Label
- type Line
- func (l Line) Clamp(pt Pt) (p Pt)
- func (l Line) DeltaX() float64
- func (l Line) DeltaY() float64
- func (l Line) DistanceFromPoint(pt Pt) float64
- func (s1 Line) DoesIntersect(s2 Line) bool
- func (l Line) ExInBetween(pt Pt) bool
- func (l Line) InBetween(pt Pt) bool
- func (l Line) IntersectsLines(lines []Line, fn func(idx int) bool)
- func (l Line) IsHorizontal() bool
- func (l Line) IsLeft(pt Pt) float64
- func (l Line) IsVertical() bool
- func (l1 Line) LeftRightMostAsLine() Line
- func (l Line) LeftRightMostPts() (Pt, Pt)
- func (l Line) SlopeIntercept() (m, b float64, defined bool)
- func (l Line) XYOrderedPtsIdx() (left, right int)
- type PointList
- type PointNode
- type Pointer
- type Pt
- type Rectangle
- type Ring
- type Triangle
- func (t *Triangle) Area() float64
- func (t *Triangle) Center() Pt
- func (t *Triangle) Edge(n int) Line
- func (t *Triangle) EdgeIdx(pt1, pt2 Pt) int
- func (t *Triangle) Edges() [3]Line
- func (t *Triangle) Equal(t1 *Triangle) bool
- func (t *Triangle) EqualAnyPt(pts ...Pt) bool
- func (t *Triangle) FindEdge(e Line) (idx int, err error)
- func (t *Triangle) Key() string
- func (t *Triangle) LREdge(n int) Line
- func (t *Triangle) LREdges() [3]Line
- func (t *Triangle) Len() int
- func (t *Triangle) Less(i, j int) bool
- func (t *Triangle) Point(i int) Pt
- func (t *Triangle) Points() []Pt
- func (t *Triangle) Swap(i, j int)
- type TriangleEdge
- type TriangleGraph
- type TriangleNode
- type WindingOrder
- type XYOrderedEventPtr
Constants ¶
const ( LEFT eventType = iota RIGHT )
Variables ¶
This section is empty.
Functions ¶
func AreaOfPolygon ¶
AreaOfPolygon will calculate the Area of a polygon using the surveyor's formula (https://en.wikipedia.org/wiki/Shoelace_formula)
func AreaOfPolygonLineString ¶ added in v0.4.0
func AreaOfPolygonLineString(line tegola.LineString) (area float64)
func AreaOfRing ¶ added in v0.4.0
func AreaOfTriangle ¶ added in v0.4.0
func Contains ¶ added in v0.4.0
Contains takes a subject (made up of point pairs) and a pt, and returns weather the pt is contained by the subject.
func DistOfLine ¶ added in v0.4.0
func DistOfLine(l tegola.LineString) (dist float64)
DistOfLine will calculate the Manhattan distance of a line.
func DoesIntersect ¶ added in v0.4.0
DoesIntersect does a quick intersect check using the saddle method.
func FindAllIntersectsWithEventQueueWithoutIntersectNotPolygon ¶ added in v0.4.0
func FindIntersects ¶ added in v0.4.0
FindIntersects call the provided function with the indexs of the lines from the segments slice that intersect with each other. If the function returns false, it will stop iteration. To find the intersection point call the ptfn that is passed to the call back.
func FindIntersectsWithEventQueue ¶ added in v0.4.0
func FindIntersectsWithEventQueueWithoutIntersect ¶ added in v0.4.0
func FindIntersectsWithEventQueueWithoutIntersectNew ¶ added in v0.4.0
func FindIntersectsWithEventQueueWithoutIntersectNotPolygon ¶ added in v0.4.0
func FindIntersectsWithoutIntersect ¶ added in v0.4.0
FindIntersects call the provided function with the indexs of the lines from the segments slice that intersect with each other. If the function returns false, it will stop iteration. To find the intersection point call the ptfn that is passed to the call back.
func FindPolygonIntersects ¶ added in v0.4.0
FindPolygonIntersects calls the provided function with the indexes of the lines from the segments slice that intersect with each other. If the function returns false, it will stop iteration. To find the intersection point call the ptfn that is passed to the call back. The function assumes that the the segments are consecutive.
func NewEventQueue ¶ added in v0.4.0
func NewEventQueue(segments []Line) []event
Code adapted from http://geomalgorithms.com/a09-_intersect-3.html#simple_Polygon()
func PointPairs ¶ added in v0.4.0
Types ¶
type EdgeMap ¶ added in v0.4.0
type EdgeMap struct { Keys []Pt Map map[Pt]map[Pt]bool Segments []Line BBox [4]Pt // contains filtered or unexported fields }
func (*EdgeMap) FindTriangles ¶ added in v0.4.0
func (em *EdgeMap) FindTriangles() (*TriangleGraph, error)
func (*EdgeMap) Triangulate ¶ added in v0.4.0
func (em *EdgeMap) Triangulate()
func (*EdgeMap) Triangulate1 ¶ added in v0.4.0
func (em *EdgeMap) Triangulate1()
type Label ¶ added in v0.4.0
type Label uint8
label is the he label for the triangle. Is in "inside" or "outside". TODO: gdey — would be make more sense to just have a bool here? IsInside or somthing like that?
type Line ¶ added in v0.4.0
type Line [2]Pt
func NewLineFloat64 ¶ added in v0.6.0
func NewLineWith2Float64 ¶ added in v0.6.0
NewLineWith2Float64 is a transistional function till I have had a change to move over the geom package and covert the maths functions to use it or they have migrated over to it. TODO: gdey – remove this function one the transition is over.
func NewLinesFloat64 ¶ added in v0.6.0
func NewSegments ¶ added in v0.4.0
func (Line) Clamp ¶ added in v0.4.0
Clamp will return a point that is on the line based on pt. It will do this by restricting each of the coordinates to the line.
func (Line) DeltaX ¶ added in v0.4.0
DeltaX returns the difference between the x coordinates of point2 and point1.
func (Line) DeltaY ¶ added in v0.4.0
DeltaY returns the difference between the y coordinates of point2 and point1.
func (Line) DistanceFromPoint ¶ added in v0.4.0
InsideEx will return true if the given point is consider to be on the inside of the line, for the given winding order. The inside region excludes the line. For clockwise the inside edge for a line heading in the upward direction is any point to the right of the line. For clockwise the inside edge for a line heading in the downward direction is any point to the left of the line. For clockwise the inside edge for a line heading in the rightward direction is any point to the bottom of the line. For clockwise the inside edge for a line heading in the leftward direction is any point above the line.
func (l Line) InsideEx(w WindingOrder, pt Pt) bool { insideX, insideY := true, true clockwise = w.IsClockwise()
deltaX := l[1].X - l[0].X deltaY := l[1].Y - l[0].Y // Dealing with a horizontal line. if deltaX == 0 { ptDelta := l[0].X - pt.X if clockwise { } } switch { case w.IsClockwise() && deltaX > 0: // right ward. goody = }
}
DistanceFromPoint will return the perpendicular distance from the point.
func (Line) DoesIntersect ¶ added in v0.4.0
=================================== LINE methods ================================================= //
func (Line) ExInBetween ¶ added in v0.4.0
func (Line) InBetween ¶ added in v0.4.0
InBetween will check to see if the given point lies on the line provided between the endpoints.
func (Line) IntersectsLines ¶ added in v0.4.0
IntersectsLines call fn with line, and intersect point that the line intersects with. from the given set of lines that intersect this line and their intersect points.
func (Line) IsHorizontal ¶ added in v0.4.0
func (Line) IsLeft ¶ added in v0.4.0
IsLeft tests if point P2 is Left|On|Right of the line P0 to P1.
returns: >0 for left, 0 for on, and <0 for right of the line.
func (Line) IsVertical ¶ added in v0.4.0
func (Line) LeftRightMostAsLine ¶ added in v0.4.0
LeftRightMostAsLine returns the left most and right most points as a line going from the left to the right.
func (Line) LeftRightMostPts ¶ added in v0.4.0
LeftRightMostPt returns the left and right most points of the vertexes of the line.
func (Line) SlopeIntercept ¶ added in v0.4.0
SlopeIntercept will find the slop (if there is one) and the intercept of the line. If there isn't a slope because the line is verticle, the defined will be false.
func (Line) XYOrderedPtsIdx ¶ added in v0.4.0
type PointList ¶ added in v0.4.0
func NewPointList ¶ added in v0.4.0
func (*PointList) IsComplete ¶ added in v0.4.0
func (*PointList) TryAddLine ¶ added in v0.4.0
type Pt ¶ added in v0.4.0
Pt describes a 2d Point.
type Ring ¶ added in v0.4.0
type Ring []Pt
Ring defines a set of points that are all connected. The last point and the first point should not be duplicated.
type Triangle ¶ added in v0.4.0
type Triangle [3]Pt
func NewTriangle ¶ added in v0.4.0
Will create a new Triangle and sort the points.k
func (*Triangle) EqualAnyPt ¶ added in v0.4.0
type TriangleEdge ¶ added in v0.4.0
type TriangleEdge struct { Node *TriangleNode IsConstrained bool }
func (*TriangleEdge) Dump ¶ added in v0.4.0
func (te *TriangleEdge) Dump()
type TriangleGraph ¶ added in v0.4.0
type TriangleGraph struct {
// contains filtered or unexported fields
}
func NewTriangleGraph ¶ added in v0.4.0
func NewTriangleGraph(tri []*TriangleNode, bbox [4]Pt) (tg *TriangleGraph)
func (*TriangleGraph) Inside ¶ added in v0.4.0
func (tg *TriangleGraph) Inside() []*TriangleNode
func (*TriangleGraph) Outside ¶ added in v0.4.0
func (tg *TriangleGraph) Outside() []*TriangleNode
func (*TriangleGraph) Rings ¶ added in v0.4.0
func (tg *TriangleGraph) Rings() (rings [][]Line)
func (*TriangleGraph) Triangles ¶ added in v0.4.0
func (tg *TriangleGraph) Triangles() []*TriangleNode
func (*TriangleGraph) TrianglesAsMP ¶ added in v0.4.0
func (tg *TriangleGraph) TrianglesAsMP() (mp [][][]Pt)
type TriangleNode ¶ added in v0.4.0
type TriangleNode struct { Triangle // Edge 0 has pt's 0 and 1. // Edge 1 has pt's 1 and 2. // Edge 2 has pt's 0 and 2. Neighbors [3]TriangleEdge Label Label }
func (*TriangleNode) Dump ¶ added in v0.4.0
func (tn *TriangleNode) Dump()
func (*TriangleNode) LabelAs ¶ added in v0.4.0
func (tn *TriangleNode) LabelAs(l Label, force bool) (unlabled []*TriangleNode)
type WindingOrder ¶ added in v0.4.0
type WindingOrder uint8
WindingOrder the direction the line strings.
const ( Clockwise WindingOrder = iota CounterClockwise )
func WindingOrderOf ¶ added in v0.4.0
func WindingOrderOf(sub []float64) WindingOrder
func WindingOrderOfLine ¶ added in v0.4.0
func WindingOrderOfLine(l tegola.LineString) WindingOrder
func WindingOrderOfPts ¶ added in v0.4.0
func WindingOrderOfPts(pts []Pt) WindingOrder
func (WindingOrder) IsClockwise ¶ added in v0.4.0
func (w WindingOrder) IsClockwise() bool
func (WindingOrder) IsCounterClockwise ¶ added in v0.4.0
func (w WindingOrder) IsCounterClockwise() bool
func (WindingOrder) Not ¶ added in v0.4.0
func (w WindingOrder) Not() WindingOrder
func (WindingOrder) String ¶ added in v0.4.0
func (w WindingOrder) String() string
type XYOrderedEventPtr ¶ added in v0.4.0
type XYOrderedEventPtr []event
func (XYOrderedEventPtr) Len ¶ added in v0.4.0
func (a XYOrderedEventPtr) Len() int
func (XYOrderedEventPtr) Less ¶ added in v0.4.0
func (a XYOrderedEventPtr) Less(i, j int) bool
func (XYOrderedEventPtr) Swap ¶ added in v0.4.0
func (a XYOrderedEventPtr) Swap(i, j int)
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
internal
|
|
Package webmercator does the translation to and from WebMercator and WGS84 Gotten from: http://wiki.openstreetmap.org/wiki/Mercator#C.23
|
Package webmercator does the translation to and from WebMercator and WGS84 Gotten from: http://wiki.openstreetmap.org/wiki/Mercator#C.23 |