patchwork

an assorted collection of randomness and non-essential remarks
Have at least one original repos where PHP is the dominant language The walrus is no stranger to variety. Use at least 4 different languages throughout all your repos Fork and commit to someone's open source project in need Have a project valued enough to be forked by someone else Have at least three original repos where Ruby is the dominant language Have at least one original repo where Ruby is the dominant language Have at least one original repo where some form of shell script is the dominant language
Endorse tarakanbg on Coderwall Powered by Obtvse

GCMapper: A Ruby gem for generating Great Circle maps

Yet another gem release announcement: this time it's GCMapper, a library for easy generation of Great Circle Map images between 2 or more airports. The gem provides an API for constructing the image URLs, the maps themselves are pulled from gcmap.com.

Here's a quote from the documentation:

The .gcmap method can be applied to a string (or variable containing a string), representing a valid route between 2 or more airports (ICAO or IATA codes), connected with dashes, like this: EGLL-LOWI or LFST-LSZH-LBSF.

The resulting image size and look can be customized by passing an optional hash of arguments to the .gcmap method. Customizable attributes include width, height and terrain (toggle satellite terrain overlay). These options can be combined in any way or omitted entirely.

Here are some examples:

Loading gist...

Finally, here's an example of how to use the gem in a Rails application:

In your controller:

@route = "egll-lowi"

In your view:

<%= image_tag @route.gcmap(:width => "600") %>

Notes:

  • the route string can be constructed from either ICAO or IATA airport codes; both types are recognized
  • the route string is not case sensitive, so for example lgav-lqsa will be recognized as well
  • layover routes that chain multiple airports (more than 2) are also supported
  • default image parameters are: width 720px, width: 360px, terrain not shown
  • when passing the width and height hash options the values can be put in quotes or not, either way works

As usual, the packaged gem is available on rubygems and the source code and documentation are on github.

Back to Blog