The S2 Geometry Library is a spherical geometry library originally made by Google, released under the Apache License (Version 2.0), which is very useful for manipulating regions on the sphere (commonly on Earth) and indexing geographic data. I use it in several of my personal toy projects, both on desktop and on Android.

Use the Fork, Luke

Sadly, it is/was hosted on Google Code, but Google Code is closing. The project has had no activity since 2011 and looks abandoned, so I had little hope to see it migrate somewhere else. Too bad for such a useful project!

But the beauty of Free and Open Source Software is that anyone is free to fork the code to fit his needs. And that’s what I did.

I’ve put the sources on Github, who hopefully won’t close in the near future. I have changed the build system to use Gradle instead of Ant, but the core of the library hasn’t changed.

The continuous integration is provided by Travis CI.

The binaries are published on Bintray, so using them in your Gradle or Maven build is dead easy.

For Gradle, add the following repository in your build.gradle:

repositories {
  maven {
    url ""

Then reference the artifact you need:

dependencies {
  compile ''

If you’re using Maven, add the repository in your settings.xml:

<?xml version="1.0" encoding="UTF-8" ?>
<settings xsi:schemaLocation=''
xmlns='' xmlns:xsi=''>

Then add the dependency in your pom.xml:


(I suspect the Maven developers are paid by the hard disk manufacturers to have such verbose file formats.)

Did I mention the fact that this library works perfectly well on Android? Because it does.

Gosh, I love Open Source!