Changeset 499
- Timestamp:
- 02/18/08 21:11:41 (7 months ago)
- Files:
-
- trunk/processing/sketches/modest_maps/modest_maps.pde (modified) (1 diff)
- trunk/processing/sketches/modest_maps_interactive/code/modestmaps.jar (modified) (previous)
- trunk/processing/sketches/modest_maps_interactive/modest_maps_interactive.pde (modified) (8 diffs)
- trunk/processing/sketches/modest_maps_interactive_test/modest_maps_interactive_test.pde (modified) (4 diffs)
- trunk/processing/sketches/modest_maps_lib/atkinson.pde (added)
- trunk/processing/sketches/modest_maps_lib/code/modestmaps.jar (modified) (previous)
- trunk/processing/sketches/modest_maps_lib/modest_maps_lib.pde (modified) (2 diffs)
- trunk/processing/sketches/modest_maps_lib/tests.pde (modified) (2 diffs)
- trunk/processing/src/com/modestmaps/providers/Yahoo.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/processing/sketches/modest_maps/modest_maps.pde
r489 r499 1 2 // 3 // This is a standalone port of the Python version of Modest Maps, 4 // based off the version from around 13th February 2008. 5 // 6 // It works, but I won't be fixing bugs. It's all been ported to 7 // .java files and will shortly be released as a library. 8 // 9 // 1 10 2 11 void setup() { trunk/processing/sketches/modest_maps_interactive/modest_maps_interactive.pde
r497 r499 1 1 2 // 3 // This is a test of the interactive Modest Maps library for Processing 4 // the modestmaps.jar in the code folder of this sketch might not be 5 // entirely up to date - you have been warned! 6 // 7 8 // this is the only bit that's needed to show a map: 2 9 InteractiveMap map; 3 10 11 // buttons take x,y and width,height: 4 12 ZoomButton out = new ZoomButton(5,5,14,14,false); 5 13 ZoomButton in = new ZoomButton(22,5,14,14,true); … … 9 17 PanButton right = new PanButton(22,41,14,14,RIGHT); 10 18 19 // all the buttons in one place, for looping: 11 20 Button[] buttons = { in, out, up, down, left, right }; 12 21 13 float startTx, endTx;14 float startTy, endTy;15 float startSc, endSc;16 17 int startTime;18 int duration;19 20 22 void setup() { 21 size( screen.width/2, screen.height/2);23 size(600, 400); 22 24 smooth(); 23 25 26 // create a new map, optionally specify a provider 27 map = new InteractiveMap(this, new Microsoft.HybridProvider()); 28 29 // set the initial location and zoom level to London: 30 map.setCenterZoom(new Location(51.500, -0.126), 11); 31 // zoom 0 is the whole world, 19 is street level 32 // (try some out, or use getlatlon.com to search for more) 33 34 // set a default font for labels 35 PFont font = createFont("Helvetica", 12); 36 textFont(font, 12); 37 38 // enable the mouse wheel, for zooming 24 39 addMouseWheelListener(new java.awt.event.MouseWheelListener() { 25 40 public void mouseWheelMoved(java.awt.event.MouseWheelEvent evt) { … … 28 43 }); 29 44 30 map = new InteractiveMap(this);31 32 // London from getlatlon.com, thanks Simon!33 map.setCenterZoom(new Location(51.500152, -0.126236), 11);34 35 textFont(createFont("Helvetica", 12), 12);36 37 startTime = millis() + 1000;38 duration = 5000;39 45 } 40 46 … … 42 48 background(0); 43 49 50 // draw the map: 44 51 map.draw(); 52 // (that's it! really... everything else is interactions now) 45 53 54 // draw all the buttons and check for mouse-over 46 55 boolean hand = false; 47 56 for (int i = 0; i < buttons.length; i++) { … … 50 59 } 51 60 61 // if we're over a button, use the finger pointer 62 // otherwise use the cross 63 // (I wish Java had the open/closed hand for "move" cursors) 52 64 cursor(hand ? HAND : CROSS); 53 65 66 // see if the arrow keys or +/- keys are pressed: 67 // (also check space and z, to reset or round zoom levels) 54 68 if (keyPressed) { 55 69 if (key == CODED) { … … 83 97 } 84 98 99 // grab the lat/lon location under the mouse point: 85 100 Location location = map.pointLocation(mouseX, mouseY); 86 101 102 // draw the mouse location, bottom left: 87 103 fill(0); 88 104 noStroke(); 89 rect(5, height-5-g.textSize, textWidth(location.toString()), g.textSize+textDescent()); 105 rect(5, height-5-g.textSize, textWidth("mouse: " + location), g.textSize+textDescent()); 106 fill(255,255,0); 107 textAlign(LEFT, BOTTOM); 108 text("mouse: " + location, 5, height-5); 90 109 91 fill(255); 92 textAlign(LEFT, BOTTOM); 93 text(location.toString(), 5, height-5); 94 110 // grab the center 111 location = map.pointLocation(width/2, height/2); 112 113 // draw the center location, bottom right: 114 fill(0); 115 noStroke(); 116 float rw = textWidth("map: " + location); 117 rect(width-5-rw, height-5-g.textSize, rw, g.textSize+textDescent()); 118 fill(255,255,0); 119 textAlign(RIGHT, BOTTOM); 120 text("map: " + location, width-5, height-5); 95 121 } 96 122 123 // see if we're over any buttons, otherwise tell the map to drag 97 124 void mouseDragged() { 98 125 boolean hand = false; … … 106 133 } 107 134 135 // zoom in or out: 108 136 void mouseWheel(int delta) { 109 137 if (delta > 0) { … … 115 143 } 116 144 145 // see if we're over any buttons, and respond accordingly: 117 146 void mouseClicked() { 118 147 if (in.mouseOver()) { trunk/processing/sketches/modest_maps_interactive_test/modest_maps_interactive_test.pde
r491 r499 1 2 // 3 // This was a test for a matrix-math-based continuous pan/zoom set-up for 4 // Modest Maps, which works, and has subsequently been turned into a library. 5 // 6 // There may be bugs in this sketch, and they won't be fixed. 7 // 8 // I didn't get around to doing rotations. 9 // 1 10 2 11 // pan, zoom and rotate … … 8 17 size(screen.width/2, screen.height/2, P3D); 9 18 10 tx = -128 + width/2;11 ty = -128 + height/2;19 tx = -128; 20 ty = -128; 12 21 13 22 PFont f = createFont("Helvetica",16); … … 50 59 51 60 // find the biggest box the screen would fit in, aligned with the map: 52 float screenMinX = -tx;53 float screenMinY = -ty;54 float screenMaxX = width -tx;55 float screenMaxY = height -ty;61 float screenMinX = 0; 62 float screenMinY = 0; 63 float screenMaxX = width; 64 float screenMaxY = height; 56 65 println("screen: " + nf(screenMinX,1,3) + " " + nf(screenMinY,1,3) + " : " + nf(screenMaxX,1,3) + " " + nf(screenMaxY,1,3)); 57 66 // TODO align this box! … … 104 113 else if (key == ' ') { 105 114 sc = 1.0; 106 tx = 0;107 ty = 0;115 tx = -128; 116 ty = -128; 108 117 a = 0; 109 118 } trunk/processing/sketches/modest_maps_lib/modest_maps_lib.pde
r491 r499 1 2 // 3 // This is a test of the static Modest Maps library for Processing 4 // the modestmaps.jar in the code folder of this sketch might not be 5 // entirely up to date - you have been warned! 6 // 7 // The tests are useful, and seem to pass. 8 // 9 // The Atkinson dithering is fun too, but slow. 10 // 1 11 2 12 void setup() { 3 size(screen.width , screen.height);13 size(screen.width/2, screen.height/2); 4 14 if (!runTests(false)) { 5 15 println("one or more tests failed"); … … 11 21 void draw() { 12 22 13 MMap m = new MMap(this, new Microsoft.AerialProvider(), new Point2f(width*2, height*2), new Location(51.5, -0.137), 12);23 StaticMap m = new StaticMap(this, new Microsoft.AerialProvider(), new Point2f(width/2, height/2), new Location(51.5, -0.137), 12); 14 24 15 //PImage img = m.draw(true);25 PImage img = m.draw(true); 16 26 17 27 // img.save("data/map.png"); 18 28 19 PImage img = loadImage("map.png");29 // PImage img = loadImage("map.png"); 20 30 21 img = atkinsonDither(img);31 // img = atkinsonDither(img); 22 32 23 img.save("data/dither.png");33 // img.save("data/dither.png"); 24 34 25 println("done");35 // println("done"); 26 36 27 //image(img,0,0);37 image(img,0,0); 28 38 } trunk/processing/sketches/modest_maps_lib/tests.pde
r489 r499 22 22 boolean passed = true; 23 23 24 MMap m = new MMap(this, new Google.RoadProvider(), new Point2f(600, 600), new Coordinate(3165, 1313, 13), new Point2f(-144, -94));25 Point2f p = m.locationPoint (new Location(37.804274, -122.262940));24 StaticMap m = new StaticMap(this, new Google.RoadProvider(), new Point2f(600, 600), new Coordinate(3165, 1313, 13), new Point2f(-144, -94)); 25 Point2f p = m.locationPoint2f(new Location(37.804274, -122.262940)); 26 26 passed = passed && p.toString().equals("(370.688, 342.438)"); 27 27 if (!quiet) println(passed); … … 161 161 */ 162 162 163 Coordinate c = Tiles.fromMicrosoftRoad("0");163 Coordinate c = Microsoft.fromMicrosoftRoad("0"); 164 164 println(c.column == 0.0 && c.row == 0.0 && c.zoom == 1.0); 165 Coordinate d = Tiles.fromMicrosoftRoad("0230102122203031");165 Coordinate d = Microsoft.fromMicrosoftRoad("0230102122203031"); 166 166 println(d.column == 25322.0 && d.row == 10507.0 && d.zoom == 16.0); 167 Coordinate e = Tiles.fromMicrosoftRoad("0230102033330212");167 Coordinate e = Microsoft.fromMicrosoftRoad("0230102033330212"); 168 168 println(e.column == 25333.0 && e.row == 10482.0 && e.zoom == 16.0); 169 169 170 println( "0".equals( Tiles.toMicrosoftRoad(0, 0, 1) ) );171 println( "0230102122203031".equals( Tiles.toMicrosoftRoad(10507, 25322, 16) ) );172 println( "0230102033330212".equals( Tiles.toMicrosoftRoad(10482, 25333, 16) ) );173 174 c = Tiles.fromMicrosoftAerial("0");170 println( "0".equals( Microsoft.toMicrosoftRoad(0, 0, 1) ) ); 171 println( "0230102122203031".equals(Microsoft.toMicrosoftRoad(10507, 25322, 16) ) ); 172 println( "0230102033330212".equals(Microsoft.toMicrosoftRoad(10482, 25333, 16) ) ); 173 174 c = Microsoft.fromMicrosoftAerial("0"); 175 175 println(c.column == 0.0 && c.row == 0.0 && c.zoom == 1.0); 176 d = Tiles.fromMicrosoftAerial("0230102122203031");176 d = Microsoft.fromMicrosoftAerial("0230102122203031"); 177 177 println(d.column == 25322.0 && d.row == 10507.0 && d.zoom == 16.0); 178 e = Tiles.fromMicrosoftAerial("0230102033330212");178 e = Microsoft.fromMicrosoftAerial("0230102033330212"); 179 179 println(e.column == 25333.0 && e.row == 10482.0 && e.zoom == 16.0); 180 180 181 println( "0".equals( Tiles.toMicrosoftAerial(0, 0, 1) ) );182 println( "0230102122203031".equals( Tiles.toMicrosoftAerial(10507, 25322, 16) ) );183 println( "0230102033330212".equals( Tiles.toMicrosoftAerial(10482, 25333, 16) ) );181 println( "0".equals( Microsoft.toMicrosoftAerial(0, 0, 1) ) ); 182 println( "0230102122203031".equals(Microsoft.toMicrosoftAerial(10507, 25322, 16) ) ); 183 println( "0230102033330212".equals(Microsoft.toMicrosoftAerial(10482, 25333, 16) ) ); 184 184 185 185 } trunk/processing/src/com/modestmaps/providers/Yahoo.java
r498 r499 60 60 public static Coordinate toYahoo(Coordinate coord) { 61 61 // Return x, y, z for Yahoo tile column, row, zoom. 62 return new Coordinate( coord.row, (int)PApplet.pow(2, coord.zoom - 1) - coord.row - 1, 18 - coord.zoom);62 return new Coordinate((int)PApplet.pow(2, coord.zoom - 1) - coord.row - 1, coord.column, 18 - coord.zoom); 63 63 } 64 64
