Documentation ¶
Index ¶
- func LegalCoord(lat, long float64) bool
- func Overlaps(a, b *Rectangle) bool
- type Point
- type Rectangle
- func (a *Rectangle) Area() float64
- func (a *Rectangle) AreaDifference(b *Rectangle) float64
- func (a *Rectangle) Center() Point
- func (a *Rectangle) ContainsPoint(p Point) bool
- func (a *Rectangle) ContainsRectangle(b *Rectangle) bool
- func (a *Rectangle) MBRWith(r *Rectangle) *Rectangle
- func (a *Rectangle) Margin() float64
- func (a *Rectangle) Max() Point
- func (a *Rectangle) Min() Point
- func (a *Rectangle) OverlapWith(b *Rectangle) float64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LegalCoord ¶
LegalCoord returns true if the given coordinates are legal. lat=-90 and lon=-180 are permitted because they're useful in search rectangles.
Types ¶
type Point ¶
type Point struct { Lat float64 //latitude, eg. 29.260799° N Long float64 //longitude, eg. 94.87287° W }
Point is a set of <latitude, longitude> coordinates.
func (Point) DistanceTo ¶
DistanceTo returns the point's distance to another point.
func (Point) MarshalJSON ¶
MarshalJSON returns the GeoJSON representation of the coordinates.
func (*Point) UnmarshalJSON ¶
UnmarshalJSON unmarshals the JSON-data in b to a Point-object.
type Rectangle ¶
type Rectangle struct {
// contains filtered or unexported fields
}
Rectangle consists of two <lat,long> Points. "max" contains the point with the highest latitude and the hightest longitude "min" contains the point with the lowest latitude and the lowest longitude
func NewRectangle ¶
NewRectangle returns a pointer to a new Rectangle.
func SplitViewRect ¶
SplitViewRect maps any rectangular view of the earth to a set of non-overlapping, valid rectangles. More than one rectangle is needed if the view crosses the date line or a pole. (the latter is'nt supported yet)
func (*Rectangle) AreaDifference ¶
AreaDifference returns the difference in area between two rectangles.
func (*Rectangle) ContainsPoint ¶
ContainsPoint checks if the Rectangle contains a given point.
func (*Rectangle) ContainsRectangle ¶
ContainsRectangle checks if the Rectangle contains a given other Rectangle.
func (*Rectangle) MBRWith ¶
MBRWith returns the minimum bounding rectangle which contains both of the rectangles.
func (*Rectangle) Max ¶
Max returns the highest (most north-eastern) <lat,long> Point of the rectangle.
func (*Rectangle) Min ¶
Min returns the lowest (most south-western) <lat,long> Point of the rectangle.
func (*Rectangle) OverlapWith ¶
OverlapWith returns the area of the overlapping area of the two rectangles.