Skip to content

Instantly share code, notes, and snippets.

@RandomEtc
Created March 5, 2011 00:18
Show Gist options
  • Save RandomEtc/855959 to your computer and use it in GitHub Desktop.
Save RandomEtc/855959 to your computer and use it in GitHub Desktop.
A Modest Maps provider for OpenStreetMap in Processing
import processing.core.*;
import com.modestmaps.core.*;
import com.modestmaps.geo.*;
public class OpenStreetMapProvider extends AbstractMapProvider {
public String[] subdomains = new String[] { "", "a.", "b.", "c." };
public OpenStreetMapProvider() {
super(new MercatorProjection(26, new Transformation(1.068070779e7f, 0.0f, 3.355443185e7f, 0.0f, -1.068070890e7f, 3.355443057e7f)));
}
public int tileWidth() {
return 256;
}
public int tileHeight() {
return 256;
}
public String[] getTileUrls(Coordinate coordinate) {
String img = (int)coordinate.zoom + "/" + (int)coordinate.column + "/" + (int)coordinate.row + ".png";
String url = "http://" + subdomains[(int)random(0, 4)] + "tile.openstreetmap.org/" + img;
return new String[] { url };
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment