Documentation ¶
Overview ¶
Package fdbgeo contains tools for building geospatial layers using FoundationDB with Geohash-encoded keys.
This package uses its complimentary "zrange" package: https://github.com/umpc/go-zrange, for performing geospatial range queries using FoundationDB with Geohash-encoded keys and a search radius.
The RadialRange method appears to be sufficient for range queries of around 5,000km or less. Changes that efficiently add support for larger query ranges are welcome here: https://github.com/umpc/go-zrange.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type RadialRangeParams ¶
type RadialRangeParams struct { BitsOfPrecision uint Radius, Latitude, Longitude float64 Subspace subspace.Subspace }
RadialRangeParams specifies arguments for the RadialRange method. A subspace will be prepended if one is set.
func (RadialRangeParams) RadialRange ¶
func (params RadialRangeParams) RadialRange() []fdb.KeyRange
RadialRange uses a radius in kilometers, a latitude, and a longitude to return a slice of one or more ranges of keys that can be used to efficiently perform Geohash-based spatial queries.
This method uses an algorithm that was derived from the "Search" section of this page: https://web.archive.org/web/20180526044934/https://github.com/yinqiwen/ardb/wiki/Spatial-Index#search
RadialRange expands upon the ideas referenced above, by:
• Sorting key ranges
• Combining overlapping key ranges
• Handling overflows resulting from bitshifting, such as when querying for: (-90, -180)
func (RadialRangeParams) WithinRadius ¶
func (params RadialRangeParams) WithinRadius(geohashID uint64) bool
WithinRadius determines whether a Geohash is within the specified radius. Running WithinRadius in a RangeIterator loop may double transaction time though make parsing more efficient. Its potential benefits are dependent on the data model in use.