Documentation ¶
Index ¶
- Constants
- type GroupDetails
- type QuadKey
- func (q QuadKey) ChildAtPos(pos int) (QuadKey, error)
- func (q QuadKey) Children() []QuadKey
- func (q QuadKey) Envelope() (geom.Envelope, error)
- func (q QuadKey) GetMinMaxEquivForZoomLevel(zoom byte) (QuadKey, QuadKey, error)
- func (q QuadKey) IsAncestorOf(desc QuadKey) bool
- func (q QuadKey) Parent() (QuadKey, error)
- func (q QuadKey) Range() (r QuadKeyRange)
- func (q QuadKey) SingleRange() QuadKeyRange
- func (q QuadKey) SlippyCoords() (uint32, uint32, byte)
- func (q QuadKey) Zoom() byte
- type QuadKeyRange
- type QuadMap
- func (qm *QuadMap) AddTile(t *Tile) error
- func (qm *QuadMap) CreateTileAtSlippyCoords(x uint32, y uint32, z uint32, groupID uint32, tileType TileType) (*Tile, error)
- func (qm *QuadMap) GetChildInPos(t *Tile, pos int) (*Tile, error)
- func (qm *QuadMap) GetExactTileForQuadKey(quadKey QuadKey) (*Tile, error)
- func (qm *QuadMap) GetExactTileForSlippy(x uint32, y uint32, z byte) (*Tile, error)
- func (qm *QuadMap) GetParentTile(t *Tile) (*Tile, error)
- func (qm *QuadMap) GetSlippyBoundsForGroupIDTileTypeAndZoom(groupID uint32, tileType TileType, zoom byte) (uint32, uint32, uint32, uint32, error)
- func (qm *QuadMap) GetTileDetailsForQuadkey(quadKey QuadKey, tileDetails *TileDetails, isTargetLevel bool) error
- func (qm *QuadMap) GetTileDetailsForSlippyCoords(x uint32, y uint32, z byte, tileDetails *TileDetails) error
- func (qm *QuadMap) GetTilesForTypeAndZoom(tt TileType, zoom byte) []*Tile
- func (qm *QuadMap) HaveTileForGroupIDAndTileType(quadKey QuadKey, groupID uint32, tileType TileType, actualTile bool) (bool, error)
- func (qm *QuadMap) HaveTileForSlippyGroupIDAndTileType(x uint32, y uint32, z byte, groupID uint32, tileType TileType) (bool, error)
- func (qm *QuadMap) NumberOfTiles() int
- func (qm *QuadMap) NumberOfTilesForZoom(zoom byte) int
- type Tile
- func (t *Tile) GetFullForGroupIDAndTileType(groupID uint32, tileType TileType) bool
- func (t *Tile) GetTileZoomLevel() byte
- func (t *Tile) HasTileType(groupID uint32, tt TileType) bool
- func (t *Tile) SetFullForGroupIDAndTileType(groupID uint32, tileType TileType, full bool) error
- func (t *Tile) SetTileType(groupID uint32, tt TileType) error
- type TileDetails
- type TileDetailsGroup
- type TileType
Constants ¶
const MaxZoom = 29
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GroupDetails ¶
type GroupDetails struct { GroupID uint32 // This tile is used for various tile types // use as bitmask. Assumption that will not have more than 16 tile types. Type TileType // This tile and all children/grandchildren/second cousins once removed etc... are present. // Full is tiletype specific. Full bool }
GroupDetails has bare information about the "group" that created the tile this is associated with. GroupID is the ID of the data feed (simply has to be unique) Type is the tiletype assocated with this group. Full determines if this tile+groupID+type is "full"... if true then all child tiles are also full/exist. TODO(kpfaulkner) investigate if this can simply be changed to a uint64.
type QuadKey ¶
type QuadKey uint64
QuadKey is a key representing a Slippy tile.
func GenerateQuadKeyIndexFromSlippy ¶
GenerateQuadKeyIndexFromSlippy generates the quadkey index from slippy coords
func (QuadKey) ChildAtPos ¶
ChildAtPos where pos is 0-3 based off https://learn.microsoft.com/en-us/bingmaps/articles/bing-maps-tile-system?redirectedfrom=MSDN
func (QuadKey) Envelope ¶
Envelope returns the lat/lon bounds of the slippy tile represented by a QuadKey.
func (QuadKey) GetMinMaxEquivForZoomLevel ¶
GetMinMaxEquivForZoomLevel given a quadkey and a desired zoom level, keep converting quadkey to desired zoom level and get min/max quadkeys (top left, bottom right) Practically this will only be valid if the tile associated with the quadKey is "full", but it's up the caller to check this. This name utterly sucks, please suggest a better one.
func (QuadKey) IsAncestorOf ¶
IsAncestorOf checks whether a QuadKey is an ancestor of (or equal to) another QuadKey.
func (QuadKey) Range ¶
func (q QuadKey) Range() (r QuadKeyRange)
Range returns the range of QuadKeys that contains q and all of its descendants.
func (QuadKey) SingleRange ¶
func (q QuadKey) SingleRange() QuadKeyRange
SingleRange returns a range that only contains this QuadKey.
func (QuadKey) SlippyCoords ¶
SlippyCoords generates the slippy coords from quadkey index
type QuadKeyRange ¶
type QuadKeyRange struct {
// Start and endpoints of the range, both inclusive.
// Note: Start and End aren't, in general, valid QuadKeys themselves.
Start, End uint64
}
QuadKeyRange is a range containing QuadKeys.
func (QuadKeyRange) Contains ¶
func (r QuadKeyRange) Contains(q QuadKey) bool
type QuadMap ¶
type QuadMap struct {
// contains filtered or unexported fields
}
QuadMap is a quadtree in disguise...
func NewQuadMap ¶
NewQuadMap create a new quadmap Should provide a large initialCapacity when dealing with large quadtree structures
func (*QuadMap) CreateTileAtSlippyCoords ¶
func (qm *QuadMap) CreateTileAtSlippyCoords(x uint32, y uint32, z uint32, groupID uint32, tileType TileType) (*Tile, error)
CreateTileAtSlippyCoords creates a tile to the quadmap at slippy coords If tile already exists at coords, then tile is modified with groupID/tiletype information Tile is returned
func (*QuadMap) GetChildInPos ¶
GetChildInPos returns child tile of passed in tile t which is in position pos pos is a number between 0 and 3, where 0 is top left, 1 is top right, 2 is bottom left and 3 is bottom right
func (*QuadMap) GetExactTileForQuadKey ¶
GetExactTileForQuadKey returns tile for quadkey match. Does NOT traverse up the ancestry
func (*QuadMap) GetExactTileForSlippy ¶
GetExactTileForSlippy returns tile for slippy co-ord match. Does NOT traverse up the ancestry
func (*QuadMap) GetParentTile ¶
GetParentTile returns parent tile of passed in tile t
func (*QuadMap) GetSlippyBoundsForGroupIDTileTypeAndZoom ¶
func (qm *QuadMap) GetSlippyBoundsForGroupIDTileTypeAndZoom(groupID uint32, tileType TileType, zoom byte) (uint32, uint32, uint32, uint32, error)
GetSlippyBoundsForGroupIDTileTypeAndZoom returns the minx,miny,maxx,maxy slippy coords for a given zoom level extracted from the quadmap. Brute forcing it for now.
func (*QuadMap) GetTileDetailsForQuadkey ¶
func (qm *QuadMap) GetTileDetailsForQuadkey(quadKey QuadKey, tileDetails *TileDetails, isTargetLevel bool) error
GetTileDetailsForQuadkey returns details for the tile for quadkey This may involve multiple groups (ie multiple data sets loaded into single quadmap) but also different tiletypes as well.
func (*QuadMap) GetTileDetailsForSlippyCoords ¶
func (qm *QuadMap) GetTileDetailsForSlippyCoords(x uint32, y uint32, z byte, tileDetails *TileDetails) error
GetTileDetailsForSlippyCoords returns details for the tile at slippy coord x,y,z. This may involve multiple groups (ie multiple data sets loaded into single quadmap) but also different tiletypes as well.
func (*QuadMap) GetTilesForTypeAndZoom ¶
GetTilesForTypeAndZoom gets tiles for a given tile type and zoom level
func (*QuadMap) HaveTileForGroupIDAndTileType ¶
func (qm *QuadMap) HaveTileForGroupIDAndTileType(quadKey QuadKey, groupID uint32, tileType TileType, actualTile bool) (bool, error)
HaveTileForGroupIDAndTileType returns bool indicating if we have details for a tile at the provided quadKey provided but also matching the tiletype and groupID. It will return true if tile requested is found OR an ancestor that is FULL The process is:
if quadkey exists, groupID exists and tiletype exists, return true
else
get parent quadkey
if parent quadkey exists and is full, return parent details
loop until no parent.
What happens if we hit a parent that is NOT full? No tile therefore return error? Returns tile (actual or parent), bool indicating if actual (true == actual, false == ancestor) and error
func (*QuadMap) HaveTileForSlippyGroupIDAndTileType ¶
func (qm *QuadMap) HaveTileForSlippyGroupIDAndTileType(x uint32, y uint32, z byte, groupID uint32, tileType TileType) (bool, error)
HaveTileForSlippyGroupIDAndTileType returns bool indicating if we have details for a tile at the provided slippy co-ords but also matching the tiletype and groupID.
func (*QuadMap) NumberOfTiles ¶
NumberOfTiles returns number of tiles in quadmap
func (*QuadMap) NumberOfTilesForZoom ¶
NumberOfTilesForZoom returns number of tiles for a given zoom level. It will NOT include parents that may be used when querying (and the parents are marked as full) Given we don't keep track of zoom levels separately, we need to traverse the entire quadmap. If this is a common operation we'll need to track/cache this information somewhere. Although for the limited test cases so far it's pretty much instant
type Tile ¶
type Tile struct { // stupid to keep it in here? // Will also store the zoom level in the key. QuadKey QuadKey // contains filtered or unexported fields }
Tile is a node within a quadtree. Although a Tile instance will only be in the quadmap once (for a given quadkey) it may be the case that the same tile+quadkey is used by multiple "groups" and also for multiple tiletypes within a group.
For example, if we populate the quadmap with one set of data (called group1) and group1 in turn has information about tiletype1 and tiletype2, this means that we'll need to track at a per quadkey level if the files are full (and for which tiletypes). Once the caller then populates with a completely different group, then we'll need to store that information as well (in the same tile). This means that we'll need to store a map of groupID -> GroupDetails.
We *could* skip all this if we wanted a separate quadmap per group, but given we need to search all groups at once, this would be incredibly inefficient
func NewTile ¶
NewTile creates a new tile at slippy co-ords x,y,z Will probably only be used for root tile
func (*Tile) GetFullForGroupIDAndTileType ¶
GetFullForGroupIDAndTileType gets the full flag for a given tile type. Defaults to false if no flag found
func (*Tile) GetTileZoomLevel ¶
GetTileZoomLevel returns zoom level of tile
func (*Tile) HasTileType ¶
HasTileType... needs to loop through array. Hopefully wouldn't be too many FIXME(kpfaulkner) measure and confirm
func (*Tile) SetFullForGroupIDAndTileType ¶
SetFullForGroupIDAndTileType sets the full flag for a given tile type. Only creates Full map at this stage (saves us creating a potential mass of unused maps)
type TileDetails ¶
type TileDetails struct {
Groups []TileDetailsGroup
}
TileDetails information about a tile, groups its associated with, tiletypes etc etc. TileDetails is used when returning query results and NOT actually part of the quadmap itself.
type TileDetailsGroup ¶
type TileDetailsGroup struct { GroupDetails QuadKey QuadKey }
TileDetailsGroup is same as TileDetails but we also want the quadkey that gave us the match. TileDetailsGroup is used when returning query results and NOT actually part of the quadmap itself.