Documentation ¶
Overview ¶
Package intgeom resembles github.com/go-spatial/geom but uses int64s internally to avoid floating point errors when performing arithmetic with the coords. The idea is that an int64's range (math.MaxInt64) is enough for (most) (earthly) geom operations. See https://www.explainxkcd.com/wiki/index.php/2170:_Coordinate_Precision. Using the last 9 digits as decimals should be enough for identifying the location of a grain of sand (in degrees). That leaves 10 digits for the whole units of measurement in your SRS. If that unit is degrees, it's more than enough (a circle only has 360). If that unit is feet, earth's circumference (131 482 560) also still fits. This is not intended to cover everything. go-spatial/geom has much more functionality. You are not required to use this.
Index ¶
- Constants
- func FromGeomOrd(o float64) int64
- func SegmentIntersect(l1, l2 Line) ([2]int64, bool)
- func ToGeomOrd(o int64) float64
- type ClockwiseFunc
- type Extent
- func (e Extent) Edges(cwfn ClockwiseFunc) [][2][2]int64
- func (e Extent) Extent() [4]int64
- func (e Extent) MaxX() int64
- func (e Extent) MaxY() int64
- func (e Extent) MinX() int64
- func (e Extent) MinY() int64
- func (e Extent) ToGeomExtent() geom.Extent
- func (e Extent) Vertices() [][2]int64
- func (e Extent) XSpan() int64
- func (e Extent) YSpan() int64
- type Extenter
- type Line
- type MinMaxer
- type Point
Constants ¶
const (
Precision = 1e09
)
Variables ¶
This section is empty.
Functions ¶
func FromGeomOrd ¶
FromGeomOrd turns a floating point ordinate into a representation by an integer
func SegmentIntersect ¶
SegmentIntersect will find the intersection point (x,y) between two lines if there is one. Ok will be true if it found an intersection point and if the point is on both lines. ref: https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection#Given_two_points_on_each_line TODO implement this with integers
Types ¶
type ClockwiseFunc ¶
ClockwiseFunc returns whether the set of points should be considered clockwise or counterclockwise. The last point is not the same as the first point, and the function should connect these points as needed.
type Extent ¶
type Extent [4]int64
Extent represents the minx, miny, maxx and maxy A nil extent represents the whole universe.
func FromGeomExtent ¶
func (Extent) Edges ¶
func (e Extent) Edges(cwfn ClockwiseFunc) [][2][2]int64
Edges returns the clockwise order of the edges that make up the extent.
func (Extent) ToGeomExtent ¶
type Extenter ¶
type Extenter interface {
Extent() (extent [4]int64)
}
Extenter represents an interface that returns a boundbox.
type Line ¶
type Line [2][2]int64
Line has exactly two points
func FromGeomLine ¶
func (Line) ContainsPoint ¶
ContainsPoint checks to see if the given pont lines on the line segment. (Including the end points.)
func (Line) IsHorizontal ¶
IsHorizontal returns true if the `x` elements of the points that make the line (l) are equal.
func (Line) IsVertical ¶
IsVertical returns true if the `y` elements of the points that make up the line (l) are equal.
func (Line) ToGeomLine ¶
type Point ¶
type Point [2]int64
Point describes a simple 2D point