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 location 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
Index ¶
- func DropEdgeTiles(tiles []maptile.Tile) []maptile.Tile
- func EnsureInside(geopolys []*geometry.Poly, tiles []maptile.Tile) []maptile.Tile
- func PreIndexLocation(input *pb.Location, idxZoom, aggZoom, maxZoomLevelToKeep maptile.Zoom, ...) ([]*pb.PreindexLocation, error)
- func PreIndexLocations(input *pb.Locations, idxZoom, aggZoom, maxZoomLevelToKeep maptile.Zoom, ...) *pb.PreindexLocations
- func PreIndexLocationsToGeoJSON(input *pb.PreindexLocations) []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 location.
func EnsureInside ¶
func PreIndexLocation ¶
func PreIndexLocation(input *pb.Location, idxZoom, aggZoom, maxZoomLevelToKeep maptile.Zoom, dropEdgeLayger int) ([]*pb.PreindexLocation, error)
PreIndexLocation will gen tiles at idxZoom level and merge up to aggZoom.
The `idxZoom` level tiles will be removed before final return.
func PreIndexLocations ¶
func PreIndexLocationsToGeoJSON ¶
func PreIndexLocationsToGeoJSON(input *pb.PreindexLocations) []byte
Types ¶
This section is empty.