Skip to content

Instantly share code, notes, and snippets.

@also
Created September 26, 2011 17:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save also/1242797 to your computer and use it in GitHub Desktop.
Save also/1242797 to your computer and use it in GitHub Desktop.
TileMill provider for Unfolding
// TileMill provider for Unfolding (or modestmaps-processing?)
// requires Unfolding (http://unfoldingmaps.org/) and GLGraphics (http://glgraphics.sourceforge.net/)
// this is important. weird.
import processing.opengl.*;
import codeanticode.glgraphics.*;
import de.fhpotsdam.unfolding.core.*;
import de.fhpotsdam.unfolding.geo.*;
import de.fhpotsdam.unfolding.utils.*;
import de.fhpotsdam.unfolding.providers.AbstractMapTileProvider;
public class TileMillProvider extends AbstractMapTileProvider {
private String url;
private PApplet app;
public TileMillProvider(PApplet app, String url) {
super(new MercatorProjection(26, new Transformation(1.068070779e7f, 0.0f, 3.355443185e7f, 0.0f,
-1.068070890e7f, 3.355443057e7f)));
this.url = url;
this.app = app;
}
public int tileWidth() {
return 256;
}
public int tileHeight() {
return 256;
}
@Override
public PImage getTile(Coordinate coord) {
float gridSize = PApplet.pow(2, coord.zoom);
float negativeRow = gridSize - coord.row - 1;
return app.loadImage(url + "/" + (int) coord.zoom + "/" + (int) coord.column + "/" + (int) negativeRow + ".png");
}
}
private de.fhpotsdam.unfolding.Map map;
public void setup() {
size(800, 600, GLConstants.GLGRAPHICS);
map = new de.fhpotsdam.unfolding.Map(this, new TileMillProvider(this, "http://localhost:8889/1.0.0/control-room"));
MapUtils.createDefaultEventDispatcher(this, map);
map.setScaleRange(1, 8);
map.zoomToLevel(1);
map.setTweening(true);
}
void draw() {
background(100);
map.draw();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment