Giter Club home page Giter Club logo

globe's Introduction

globe

Globe wireframe visualizations in Golang backed by pinhole.

go.dev Reference Build status

Getting Started

Install globe with

$ go get -u github.com/mmcloughlin/globe

Start with a blank globe with a graticule at 10 degree intervals.

g := globe.New()
g.DrawGraticule(10.0)
g.SavePNG("graticule.png", 400)

Add some land boundaries and center it on a point. Alternatively DrawCountryBoundaries will give you countries.

g := globe.New()
g.DrawGraticule(10.0)
g.DrawLandBoundaries()
g.CenterOn(51.453349, -2.588323)
g.SavePNG("land.png", 400)

Here's all the Starbucks locations. Note color.NRGBA recommended to avoid artifacts.

shops, err := LoadCoffeeShops("./starbucks.json")
if err != nil {
	log.Fatal(err)
}

green := color.NRGBA{0x00, 0x64, 0x3c, 192}
g := globe.New()
g.DrawGraticule(10.0)
for _, s := range shops {
	g.DrawDot(s.Lat, s.Lng, 0.05, globe.Color(green))
}
g.CenterOn(40.645423, -73.903879)
err = g.SavePNG("starbucks.png", 400)
if err != nil {
	log.Fatal(err)
}

You can also do lines along great circles.

g := globe.New()
g.DrawGraticule(10.0)
g.DrawLandBoundaries()
g.DrawLine(
	51.453349, -2.588323,
	40.645423, -73.903879,
	globe.Color(color.NRGBA{255, 0, 0, 255}),
)
g.CenterOn(50.244440, -37.207949)
g.SavePNG("line.png", 400)

Also rectangles.

g := globe.New()
g.DrawGraticule(10.0)
g.DrawLandBoundaries()
g.DrawRect(
	41.897209, 12.500285,
	55.782693, 37.615993,
	globe.Color(color.NRGBA{255, 0, 0, 255}),
)
g.CenterOn(48, 25)
g.SavePNG("rect.png", 400)

See examples and godoc for more.

License

globe is available under the ISC License.

globe's People

Contributors

mmcloughlin avatar

Watchers

James Cloos 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.