Git Product home page Git Product logo

tiles's Introduction

#tiles Build Status A map tiling library written in pure Go with no external dependencies outside of the golang stdlib. Converts between WGS84 coordinates to Slippy Map Tiles and Quadkeys. Includes a TileIndex that can be used to aggregate data into parent tiles.

go get github.com/buckhx/tiles

The godoc has good documentation and a couple examples, but here are a few as well

Coordinate/Tile conversion
// Empire State Build coordinates and zoom level 18
z := 18
lat := 40.7484
lon := -73.9857

// Basic usage
t1 := tiles.FromCoordinate(lat, lon, z)

// If you want a little more granularity
x := tiles.Coordinate{Lat: lat, Lon: lon}
p := x.ToPixel(z)
t2, _ := p.ToTile()
// t1 == t2
TileIndex

The TileIndex allows for data to be indexed by tiles and aggregated up to their parents when requested

idx := tiles.NewTileIndex()
esb := tiles.FromCoordinate(40.7484, -73.9857, 18)
sol := tiles.FromCoordinate(40.6892, -74.0445, 18)
bbn := tiles.FromCoordinate(51.5007, -0.1246, 18)
idx.Add(esb, "EmpireStateBuilding")
idx.Add(sol, "StatueOfLiberty")
idx.Add(bbn, "BigBen")
nyc := tiles.Tile{X: 75, Y: 96, Z: 8}
den := tiles.Tile{X: 106, Y: 194, Z: 9}
fmt.Println("ESB Tile: ", idx.Values(esb))
fmt.Println("SOL Tile: ", idx.Values(sol))
fmt.Println("NYC Tile: ", idx.Values(nyc))    //contains esb & sol values!
fmt.Println("DENVER Tile: ", idx.Values(den)) //contains no values!
Benchmarks

Here are some microbenchmarks for converting a location at zoom level 18. There's nothing really to compare them to, but should give a sense of op time on a 2.3 GHz core i7 MBP.

$ go test -bench=. -benchmem -benchtime 10s
BenchmarkTileFromCoordinate-8	100000000	       165 ns/op	       0 B/op	       0 allocs/op
BenchmarkTileFromQuadkey-8   	300000000	        43.7 ns/op	       0 B/op	       0 allocs/op
BenchmarkQuadkeyFromTile-8   	200000000	        95.4 ns/op	      32 B/op	       1 allocs/op

tiles's People

Contributors

buckhx avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.