Documentation ¶
Overview ¶
Package geoquad provides a simple way to generate a quadtree for a given set of lat/lon coordinates. The quadtree is laid out like described in: https://www.maptiler.com/google-maps-coordinates-tile-bounds-projection/ to represent a tileset that is used by Google Maps, OpenStreetMap, etc. This will allow us to quickly find all coordinates within a given tile, or all coordinates within a given bounding box, as well as the closest coordinate to a given coordinate.
Index ¶
- Constants
- type Point
- type QuadTree
- func (qt *QuadTree) ExportToPNG(filename string) error
- func (qt *QuadTree) FindLeafTile(point Point) *QuadTree
- func (qt *QuadTree) FindNearestNeighbor(point Point) (Point, bool)
- func (qt *QuadTree) FindPoint(point Point) *QuadTree
- func (qt *QuadTree) FindPointsInRect(rect Rect) []Point
- func (qt *QuadTree) FindPointsInTile(x, y, zoom int) []Point
- func (qt *QuadTree) Verify()
- type Rect
- type TileCoordinates
Constants ¶
const ( MinLongitude float64 = -180.0 MaxLongitude float64 = 180.0 MinLatitude float64 = -90.0 MaxLatitude float64 = 90.0 )
min and max latitude and longitude.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type QuadTree ¶
type QuadTree struct { TileCoordinates // The coordinates and zoom of the tile this quadtree represents. Points []Point Bounds Rect // The bounds of the tile this quadtree represents. // The four child quadtrees. // The first two are the top left and top right quadtrees. // The second two are the bottom left and bottom right quadtrees. Children [4]*QuadTree Parent *QuadTree }
QuadTree represents a quadtree.
func NewQuadTree ¶
NewQuadTree creates a new quadtree for the given points.
func (*QuadTree) ExportToPNG ¶
ExportToPNG exports the quadtree to a PNG image.
func (*QuadTree) FindLeafTile ¶
FindLeafTile returns the leaf tile that contains the given point.
func (*QuadTree) FindNearestNeighbor ¶
FindNearestNeighbor returns the closest point to the given point within the quadtree.
func (*QuadTree) FindPointsInRect ¶
FindPointsInRect returns all points in the given rectangle.
func (*QuadTree) FindPointsInTile ¶
FindPointsInTile returns all points in the given tile.
type TileCoordinates ¶
type TileCoordinates struct {
X, Y, Zoom int
}
func (TileCoordinates) String ¶
func (t TileCoordinates) String() string