Documentation ¶
Overview ¶
Package preindex
Background ¶
The Ray Casting algorithm's time complexity is $O(n^2)$ which is expensive for high throughput API that severing geo based data like weather forecasts. And most of these requests are came from big cities around the world.
If we can reduce these location's query execution times, our API could got performance improvements.
How to ¶
Preindex's logic is very simple, generate map tiles around a multi polygon, and exclude 1/2 edge layer, then merge to upper tiles. Then dumps all the tiles's X/Y/Z and timezone to Protocol Buffer based data.
A sample image of output tiles show on maps: https://user-images.githubusercontent.com/13536789/200174943-7d40661e-bda5-4b79-a867-ec637e245a49.png
Some areas are excluded from prefindex, since default most small tile `level==11` couldn't cover polygon shape details, see tzf#76 for more backgrounds. Latest excluded areas can be views here exclude.geojson
Index ¶
- func DropEdgeTiles(tiles []maptile.Tile) []maptile.Tile
- func EnsureInside(geopolys []*geometry.Poly, tiles []maptile.Tile) []maptile.Tile
- func PreIndexTimezone(input *pb.Timezone, idxZoom, aggZoom, maxZoomLevelToKeep maptile.Zoom, ...) ([]*pb.PreindexTimezone, error)
- func PreIndexTimezones(input *pb.Timezones, idxZoom, aggZoom, maxZoomLevelToKeep maptile.Zoom, ...) *pb.PreindexTimezones
- func PreIndexTimezonesToGeoJSON(input *pb.PreindexTimezones) []byte
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DropEdgeTiles ¶
Drop most outside layer of tile, since tile may cover area not included in timezone.
func EnsureInside ¶ added in v0.10.0
func PreIndexTimezone ¶
func PreIndexTimezone(input *pb.Timezone, idxZoom, aggZoom, maxZoomLevelToKeep maptile.Zoom, dropEdgeLayger int) ([]*pb.PreindexTimezone, error)
PreIndexTimezone will gen tiles at idxZoom level and merge up to aggZoom.
The `idxZoom` level tiles will be removed before final return.
func PreIndexTimezones ¶
func PreIndexTimezonesToGeoJSON ¶
func PreIndexTimezonesToGeoJSON(input *pb.PreindexTimezones) []byte
Types ¶
This section is empty.