You can subscribe to this list here.
| 2005 |
Jan
|
Feb
(19) |
Mar
(30) |
Apr
(28) |
May
|
Jun
|
Jul
(3) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|---|
|
From: Nicolas P. <nic...@us...> - 2005-07-09 19:22:43
|
Update of /cvsroot/hipgmap/gmap/com/trileet/gmap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18377/com/trileet/gmap Modified Files: TileSet.java Log Message: add teeny little display window of tile fetching status in bottom right corner, somehow it makes things feel 'faster' Index: TileSet.java =================================================================== RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/TileSet.java,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** TileSet.java 9 Jul 2005 19:06:18 -0000 1.28 --- TileSet.java 9 Jul 2005 19:22:33 -0000 1.29 *************** *** 487,494 **** // draw a little version of our tiles in the corner for cache debugging ! if (false){ ! int startX = 60; ! int startY = 20; ! int width = 10; for (int x = 0; x < getWidth(); x++) { for (int y = 0; y < getHeight(); y++) { --- 487,494 ---- // draw a little version of our tiles in the corner for cache debugging ! if (true){ ! int startX = 220; ! int startY = 120; ! int width = 5; for (int x = 0; x < getWidth(); x++) { for (int y = 0; y < getHeight(); y++) { *************** *** 509,523 **** int drawY = y * TILE_WIDTH - m_offsetY; ! if (drawX > -TILE_WIDTH && drawX < 240 ! && drawY > -TILE_WIDTH && drawY < 160) { ! p.setColor(Color.RED); ! } else { ! p.setColor(Color.BLACK); ! } ! p.drawRect(startX + x * width, startY + y * width, startX + (x+1) * width, startY + (y+1) * width); } } } } --- 509,523 ---- int drawY = y * TILE_WIDTH - m_offsetY; ! p.setColor(Color.BLACK); p.drawRect(startX + x * width, startY + y * width, startX + (x+1) * width, startY + (y+1) * width); } } + + // figure out where our current 'view' is.. + int topX = m_offsetX / 51; + int topY = m_offsetY / 51; + p.setColor(Color.RED); + p.drawRect(startX + topX, startY + topY, startX + topX + 5, startY + topY + 3); } } |
|
From: Nicolas P. <nic...@us...> - 2005-07-09 19:06:44
|
Update of /cvsroot/hipgmap/gmap/com/trileet/gmap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10888/com/trileet/gmap Modified Files: GMap.java Tile.java TileSet.java Log Message: Fix panning of new tiles. Index: Tile.java =================================================================== RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/Tile.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Tile.java 5 Jul 2005 23:50:14 -0000 1.10 --- Tile.java 9 Jul 2005 19:06:18 -0000 1.11 *************** *** 90,97 **** public static String makeURL(int x, int y, int zoom) { return "http://hipster.trileet.com/tmpimg/img.php?nocache=true&url=" + ! URLEncoder.encode("http://mt.google.com/mt?v=w2.4&x=" + x + "&y=" + y + "&zoom=" + zoom); ! // no direct request till Danger fixes their gateway ! // return "http://mt.google.com/mt?v=2.4&x=" + x + "&y=" + y + "&zoom=" ! // + zoom; } --- 90,94 ---- public static String makeURL(int x, int y, int zoom) { return "http://hipster.trileet.com/tmpimg/img.php?nocache=true&url=" + ! URLEncoder.encode("http://mt.google.com/mt?v=w2.4&x=" + x + "&y=" + y + "&zoom=" + zoom); } Index: GMap.java =================================================================== RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/GMap.java,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** GMap.java 23 Apr 2005 05:27:19 -0000 1.30 --- GMap.java 9 Jul 2005 19:06:18 -0000 1.31 *************** *** 20,26 **** * GMap * - * Test of cvs list. - * CVS Test - * * * @author <a href='ni...@tr...'>Nic Pottier</a> --- 20,23 ---- *************** *** 193,197 **** zoom = 4; } - System.out.println("SPAN: " + latSpan + " ZOOM: "+ zoom); s_mapWindow.setCenter(s_dirs.lat, s_dirs.lng, zoom); } --- 190,193 ---- Index: TileSet.java =================================================================== RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/TileSet.java,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** TileSet.java 5 Jul 2005 23:50:14 -0000 1.27 --- TileSet.java 9 Jul 2005 19:06:18 -0000 1.28 *************** *** 351,356 **** // Figure out our offset based on how much we moved ! m_offsetX = m_offsetX % TILE_WIDTH + TILE_WIDTH * 2; ! m_offsetY = m_offsetY % TILE_WIDTH + TILE_WIDTH * 2; setMapTilesByCenter(mapX, mapY, m_zoom); } --- 351,357 ---- // Figure out our offset based on how much we moved ! m_offsetX = m_offsetX % TILE_WIDTH + TILE_WIDTH; ! m_offsetY = m_offsetY % TILE_WIDTH + TILE_WIDTH; ! setMapTilesByCenter(mapX, mapY, m_zoom); } *************** *** 472,475 **** --- 473,477 ---- int m_hitY = -1; if (!displayPhoto) { + for (int x = 0; x < getWidth(); x++) { for (int y = 0; y < getHeight(); y++) { |
|
From: Adam B. <ab...@us...> - 2005-07-05 23:50:24
|
Update of /cvsroot/hipgmap/gmap/com/trileet/gmap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16325/com/trileet/gmap Modified Files: Tile.java TileSet.java Log Message: Began the update to the new 256x256 tiles and the Mercator projection. I looked up the formula on mathworld; I played around with the web app and the north/south cutoff on the new coordinate system seemed to be about +/- 3.141, so I took a guess that it was PI. Seems to work, more or less. - The mercator calculation with hipfloats is slow, so zoom in/out is sluggish. Perhaps a lookup table or other optimization is warranted. - I changed the tileset to be 3x3 rather than 5x5, since the tiles are huge. However, panning more than a tile's worth doesn't seem to work anymore. Can't figure out why. Nic, could you take a look? - Directions plotting is really slow, and the turn markers don't quite line up. That's all from me for now; if someone can polish it up and release a functional bundle on skdr, I'm sure our 800-some users would really appreciate it. Index: Tile.java =================================================================== RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/Tile.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Tile.java 23 Apr 2005 05:27:19 -0000 1.9 --- Tile.java 5 Jul 2005 23:50:14 -0000 1.10 *************** *** 23,27 **** public class Tile implements ImageCache.Listener { ! public static final int WIDTH = 128; // by default, the tile is empty --- 23,27 ---- public class Tile implements ImageCache.Listener { ! public static final int WIDTH = 256; // by default, the tile is empty *************** *** 90,96 **** public static String makeURL(int x, int y, int zoom) { return "http://hipster.trileet.com/tmpimg/img.php?nocache=true&url=" + ! URLEncoder.encode("http://mt.google.com/mt?v=.1&x=" + x + "&y=" + y + "&zoom=" + zoom); // no direct request till Danger fixes their gateway ! // return "http://mt.google.com/mt?v=.1&x=" + x + "&y=" + y + "&zoom=" // + zoom; } --- 90,96 ---- public static String makeURL(int x, int y, int zoom) { return "http://hipster.trileet.com/tmpimg/img.php?nocache=true&url=" + ! URLEncoder.encode("http://mt.google.com/mt?v=w2.4&x=" + x + "&y=" + y + "&zoom=" + zoom); // no direct request till Danger fixes their gateway ! // return "http://mt.google.com/mt?v=2.4&x=" + x + "&y=" + y + "&zoom=" // + zoom; } Index: TileSet.java =================================================================== RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/TileSet.java,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** TileSet.java 10 Apr 2005 23:16:05 -0000 1.26 --- TileSet.java 5 Jul 2005 23:50:14 -0000 1.27 *************** *** 19,23 **** * TileSet * ! * Aggregates a set of Tiles, which are google 128x128 GIF's * * @author <a href='ni...@tr...'>Nic Pottier</a> $Date$ --- 19,23 ---- * TileSet * ! * Aggregates a set of Tiles, which are google 256x256 GIF's * * @author <a href='ni...@tr...'>Nic Pottier</a> $Date$ *************** *** 38,42 **** */ public TileSet() { ! this(5,5); } --- 38,42 ---- */ public TileSet() { ! this(3,3); } *************** *** 53,58 **** // Get our pin bitmap m_pinBitmap = Application.getCurrentApp().getResources().getBitmap( ! Resources.ID_PIN); --- 53,59 ---- // Get our pin bitmap + m_pinBitmap = Application.getCurrentApp().getResources().getBitmap( ! Resources.ID_PIN); *************** *** 66,74 **** } ! public static final hipfloat X_OFFSET = new hipfloat("98.35"); ! public static final hipfloat Y_OFFSET = new hipfloat("39.5"); ! public static final hipfloat X_FACTOR = new hipfloat("0.77162458"); public void zoomOut() { --- 67,79 ---- } ! public static final hipfloat X_OFFSET = new hipfloat("180"); ! public static final hipfloat Y_OFFSET = new hipfloat("90"); ! public static final hipfloat X_FACTOR = new hipfloat("0.7111111"); ! ! public static final hipfloat Y_FACTOR = new hipfloat("0.5"); ! ! public static final hipfloat RAD_FACTOR = hipfloat.PI.div(new hipfloat("180")); public void zoomOut() { *************** *** 181,195 **** // we want to put our center smack dable in the middle of the screen ! // since we are a 5x5 grid and we lay our center _TILE_ in the middle of // that grid // if the center was in the center of that tile, we would have our top // left corner at: ! // y = (128 * 2.5) - 70 ! // x = (128 * 2.5) - 120 // However, since that isn't the case, we figure out what the offset for // our center tile // is and ajust accordingly ! int xRadius = getWidth() / 2; // = 2 ! int yRadius = getHeight() / 2;// = 2 m_offsetX = (TILE_WIDTH * xRadius) + mapXFloat.sub(mapXFloat.floor()).mul(TILE_WIDTH_FLOAT) --- 186,200 ---- // we want to put our center smack dable in the middle of the screen ! // since we are a 3x3 grid and we lay our center _TILE_ in the middle of // that grid // if the center was in the center of that tile, we would have our top // left corner at: ! // y = (256 * 1.5) - 70 ! // x = (256 * 1.5) - 120 // However, since that isn't the case, we figure out what the offset for // our center tile // is and ajust accordingly ! int xRadius = getWidth() / 2; // == 1 ! int yRadius = getHeight() / 2;// == 1 m_offsetX = (TILE_WIDTH * xRadius) + mapXFloat.sub(mapXFloat.floor()).mul(TILE_WIDTH_FLOAT) *************** *** 207,215 **** */ private void setMapTilesByCenter(int mapX, int mapY, int zoom) { ! /** Fine-tuned for the 5x5 tileset. **/ ImageCache.clearAllPriorityRequests(); ! int xRadius = getWidth() / 2; // = 2 ! int yRadius = getHeight() / 2;// = 2 // clear out our areas for our screen tiles --- 212,220 ---- */ private void setMapTilesByCenter(int mapX, int mapY, int zoom) { ! /** Fine-tuned for the 3x3 tileset. **/ ImageCache.clearAllPriorityRequests(); ! int xRadius = getWidth() / 2; // == 1 ! int yRadius = getHeight() / 2;// == 1 // clear out our areas for our screen tiles *************** *** 300,306 **** * as possible between east/west expansion and * north/south expansion. If you think you can do better, please improve it. */ ! int[] loadOrderX = {2,1,3,2,2,3,1,1,3,4,0,2,2,0,0,4,4,1,3,1,3,0,4,4,0}; ! int[] loadOrderY = {2,2,2,1,3,3,1,3,1,2,2,4,0,3,1,1,3,0,4,4,0,4,4,0,0}; int x,y; for (int i=0; i< loadOrderX.length;i++) { --- 305,322 ---- * as possible between east/west expansion and * north/south expansion. If you think you can do better, please improve it. + * + int[] loadOrderX = {2,1,3,2,2,3,1,1,3,4,0,2,2,0,0,4,4,1,3,1,3,0,4,4,0}; + int[] loadOrderY = {2,2,2,1,3,3,1,3,1,2,2,4,0,3,1,1,3,0,4,4,0,4,4,0,0}; */ ! /* ! * New order for 3x3, since the tiles are now 256x256: ! * ! * 6 3 9 ! * 5 1 4 ! * 7 2 8 ! */ ! int[] loadOrderX = {1,1,1,2,0,0,0,2,2}; ! int[] loadOrderY = {1,2,0,1,1,0,2,2,0}; ! int x,y; for (int i=0; i< loadOrderX.length;i++) { *************** *** 323,327 **** ImageCache.stopFetching(); ! /** Fine-tuned for the 5x5 tileset. **/ if (m_offsetX < TILE_WIDTH || m_offsetX > TILE_WIDTH * 2 || m_offsetY < TILE_WIDTH || m_offsetY > TILE_WIDTH * 2) { --- 339,343 ---- ImageCache.stopFetching(); ! /** Fine-tuned for the 3x3 tileset. **/ if (m_offsetX < TILE_WIDTH || m_offsetX > TILE_WIDTH * 2 || m_offsetY < TILE_WIDTH || m_offsetY > TILE_WIDTH * 2) { *************** *** 389,393 **** public static hipfloat getZoomFactor(int zoom) { if (zoomFactors[zoom] == null) { ! zoomFactors[zoom] = new hipfloat(1 << (10 - zoom)); } return zoomFactors[zoom]; --- 405,409 ---- public static hipfloat getZoomFactor(int zoom) { if (zoomFactors[zoom] == null) { ! zoomFactors[zoom] = new hipfloat(1 << (17 - zoom)); } return zoomFactors[zoom]; *************** *** 416,421 **** // now figure out our lat, the equation reversed is: ! // lat = -( mapY / 2^(10-zoom) - 39.5) ! return mapY.div(getZoomFactor(m_zoom)).sub(Y_OFFSET).neg(); } --- 432,440 ---- // now figure out our lat, the equation reversed is: ! // y = (2pi - ln(tan((90 + lat) / 2))) / 2pi * 2^(17 - zoom) ! // lat = (arctan(exp(pi - y / zoomfac * 2pi)) *2 - 90 ! return hipfloat.PI.sub(mapY.div(getZoomFactor(m_zoom)). ! mul(hipfloat.PI2)).exp().arctan().div(RAD_FACTOR). ! mul(hipfloat.TWO).sub(Y_OFFSET); } *************** *** 430,445 **** // now figure out our lat ! // lng = mapX / (2^(10-zoom) * .77162..) - 98.35 ! return mapX.div(getZoomFactor(m_zoom).mul(X_FACTOR)).sub(X_OFFSET); } ! // x = (lng + 98.35) * 2^(10 - zoom) * 0.77162458338772 public static hipfloat getX(hipfloat lng, int zoom) { ! return lng.add(X_OFFSET).mul(getZoomFactor(zoom)).mul(X_FACTOR); } ! // y = (39.5 - lat) * 2^(10 - zoom) public static hipfloat getY(hipfloat lat, int zoom) { ! return Y_OFFSET.sub(lat).mul(getZoomFactor(zoom)); } --- 449,467 ---- // now figure out our lat ! // lng = x * 256^2 / (180 * 2^(17-zoom)) - 180 ! return mapX.mul(TILE_WIDTH_FLOAT).div(X_FACTOR). ! div(getZoomFactor(m_zoom)).sub(X_OFFSET); } ! // x = (lng + 180) * 2^(17 - zoom) * 180 / 256 in pixels, not tiles public static hipfloat getX(hipfloat lng, int zoom) { ! return lng.add(X_OFFSET).mul(getZoomFactor(zoom)).mul(X_FACTOR).div(TILE_WIDTH_FLOAT); } ! // y = (pi - ln(tan((90 + lat) / 2))) / 2pi * 2^(17 - zoom) public static hipfloat getY(hipfloat lat, int zoom) { ! ! return hipfloat.PI.sub(lat.add(Y_OFFSET).div(hipfloat.TWO).mul(RAD_FACTOR).tan().ln()). ! div(hipfloat.PI2).mul(getZoomFactor(zoom)); } *************** *** 783,787 **** public static void main(String[] argv) { ! System.out.println(khToXOff("qtssqtssr")); } /** Our 2d array of tiles, first dimension is x, second is y */ --- 805,817 ---- public static void main(String[] argv) { ! // 37.871667,-122.271667 ! hipfloat mapY = new hipfloat("50617"); ! int zoom = 0; ! ! System.out.println(hipfloat.PI.sub(mapY.div(getZoomFactor(zoom)). ! mul(hipfloat.PI2)).exp().arctan().div(RAD_FACTOR). ! mul(hipfloat.TWO).sub(Y_OFFSET)); ! ! } /** Our 2d array of tiles, first dimension is x, second is y */ *************** *** 796,805 **** /** Size of the tiles (128) */ ! public static final int TILE_WIDTH = 128; public static final hipfloat TILE_WIDTH_FLOAT = new hipfloat(TILE_WIDTH); /** Our drawing offset for our tile set */ ! private int m_offsetX = TILE_WIDTH * 2; ! private int m_offsetY = TILE_WIDTH * 2; --- 826,835 ---- /** Size of the tiles (128) */ ! public static final int TILE_WIDTH = 256; public static final hipfloat TILE_WIDTH_FLOAT = new hipfloat(TILE_WIDTH); /** Our drawing offset for our tile set */ ! private int m_offsetX = TILE_WIDTH; ! private int m_offsetY = TILE_WIDTH; *************** *** 824,828 **** public static final int DISPLAY_ALL = 1; ! public static hipfloat[] zoomFactors = new hipfloat[15]; private boolean m_debug = false; --- 854,858 ---- public static final int DISPLAY_ALL = 1; ! public static hipfloat[] zoomFactors = new hipfloat[18]; private boolean m_debug = false; |
|
From: Nicolas P. <nic...@us...> - 2005-04-23 05:27:28
|
Update of /cvsroot/hipgmap/gmap/com/trileet/gmap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12644/com/trileet/gmap Modified Files: GMap.java ImageCache.java Tile.java Log Message: Dump danger's WAP proxy until they fix it. This makes GMap way slower as trileet has to do the translation. (and it appears HTTPConnection requests are much slower than usual right now) Not going to update on skdr as I'm hoping this is a temporary problem. Long term maybe we want to detect this and switch over within GMap, or at least provide it as a hidden option or somesuch. Index: Tile.java =================================================================== RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/Tile.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Tile.java 10 Apr 2005 20:45:33 -0000 1.8 --- Tile.java 23 Apr 2005 05:27:19 -0000 1.9 *************** *** 89,94 **** public static String makeURL(int x, int y, int zoom) { ! return "http://mt.google.com/mt?v=.1&x=" + x + "&y=" + y + "&zoom=" ! + zoom; } --- 89,97 ---- public static String makeURL(int x, int y, int zoom) { ! return "http://hipster.trileet.com/tmpimg/img.php?nocache=true&url=" + ! URLEncoder.encode("http://mt.google.com/mt?v=.1&x=" + x + "&y=" + y + "&zoom=" + zoom); ! // no direct request till Danger fixes their gateway ! // return "http://mt.google.com/mt?v=.1&x=" + x + "&y=" + y + "&zoom=" ! // + zoom; } Index: ImageCache.java =================================================================== RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/ImageCache.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** ImageCache.java 20 Apr 2005 14:14:19 -0000 1.15 --- ImageCache.java 23 Apr 2005 05:27:19 -0000 1.16 *************** *** 377,383 **** } ! // we expire after 8 seconds public boolean isExpired() { ! return System.currentTimeMillis() - requested > 8000; } --- 377,384 ---- } ! // we expire after 20 seconds, trileet is slow public boolean isExpired() { ! // change this back to 8 seconds when we can use the Danger proxies again ! return System.currentTimeMillis() - requested > 20000; } Index: GMap.java =================================================================== RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/GMap.java,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** GMap.java 23 Apr 2005 02:20:02 -0000 1.29 --- GMap.java 23 Apr 2005 05:27:19 -0000 1.30 *************** *** 249,254 **** if (request != null){ ! request.listener.handleResponse(request.url, transaction); ! s_listeners.remove(new Integer(id)); } } --- 249,254 ---- if (request != null){ ! request.listener.handleResponse(request.url, transaction); ! s_listeners.remove(new Integer(id)); } } *************** *** 267,271 **** System.out.println("REQUESTING: " + url); ! HTTPConnection.get(url, null, (short) 0, ++s_transactionId, !kh); s_listeners.put(new Integer(s_transactionId), new Request(url, listener)); return s_transactionId; --- 267,272 ---- System.out.println("REQUESTING: " + url); ! //HTTPConnection.get(url, null, (short) 0, ++s_transactionId, !kh); ! HTTPConnection.get(url, null, (short) 0, ++s_transactionId, false); s_listeners.put(new Integer(s_transactionId), new Request(url, listener)); return s_transactionId; |
|
From: Karl G. <kg...@us...> - 2005-04-23 02:20:10
|
Update of /cvsroot/hipgmap/gmap/com/trileet/gmap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12294/com/trileet/gmap Modified Files: GMap.java Log Message: tiny update which adds a little verbosity to error responses. Index: GMap.java =================================================================== RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/GMap.java,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** GMap.java 10 Apr 2005 20:45:33 -0000 1.28 --- GMap.java 23 Apr 2005 02:20:02 -0000 1.29 *************** *** 159,162 **** --- 159,166 ---- if (response == null || response.getResponse() != 200){ System.out.println("Failed getting query response."); + if (response != null) { + System.out.println("Response: " + response.getResponse() + + " " + response.getResponseMessage()); + } s_searchWindow.showHelp("Error getting response, try again."); return; |
|
From: Nicolas P. <nic...@us...> - 2005-04-20 16:59:58
|
Update of /cvsroot/hipgmap/gmap/locale/default/assets/default/color In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14137 Added Files: bigpin.png pin.png Log Message: Re-add as binary. --- NEW FILE: bigpin.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: pin.png --- (This appears to be a binary file; contents omitted.) |
|
From: Nicolas P. <nic...@us...> - 2005-04-20 16:59:11
|
Update of /cvsroot/hipgmap/gmap/locale/default/assets/default/color In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13191 Removed Files: bigpin.png pin.png Log Message: Remove ascii versions of pin and bigpin --- bigpin.png DELETED --- --- pin.png DELETED --- |
|
From: Karl G. <kg...@us...> - 2005-04-20 14:14:45
|
Update of /cvsroot/hipgmap/gmap/com/trileet/gmap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19934/com/trileet/gmap Modified Files: ImageCache.java MapWindow.java SearchWindow.java Log Message: moved back button function from eventDown to eventUp, so that keylock works correctly Index: MapWindow.java =================================================================== RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/MapWindow.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** MapWindow.java 10 Apr 2005 20:45:33 -0000 1.17 --- MapWindow.java 20 Apr 2005 14:14:20 -0000 1.18 *************** *** 81,84 **** --- 81,88 ---- m_tileSet.zoomIn(); } + else if (widget == Event.DEVICE_BUTTON_BACK + || widget == Event.DEVICE_BUTTON_CANCEL){ //kgutwin -- allow keylock + GMap.showSearchWindow(); + } else { return super.eventWidgetUp(widget, event); *************** *** 131,137 **** m_tileSet.toggleDisplay(); } - else if (widget == Event.DEVICE_BUTTON_BACK){ - GMap.showSearchWindow(); - } else { --- 135,138 ---- Index: ImageCache.java =================================================================== RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/ImageCache.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** ImageCache.java 10 Apr 2005 23:16:04 -0000 1.14 --- ImageCache.java 20 Apr 2005 14:14:19 -0000 1.15 *************** *** 4,7 **** --- 4,8 ---- import danger.ui.Bitmap; import danger.ui.ImageCodec; + import danger.ui.Color; import danger.app.Application; import danger.app.DataStore; *************** *** 509,513 **** try { image = Bitmap.newFromEncodedData(bytes); ! //image = Bitmap.convertToScreenColorSpace(image); } catch (Throwable t) { System.out.println("Unable to decode image: " + url + " error: " --- 510,514 ---- try { image = Bitmap.newFromEncodedData(bytes); ! image = Bitmap.convertToScreenColorSpace(image,Color.BLACK); } catch (Throwable t) { System.out.println("Unable to decode image: " + url + " error: " Index: SearchWindow.java =================================================================== RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/SearchWindow.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** SearchWindow.java 10 Apr 2005 20:45:33 -0000 1.18 --- SearchWindow.java 20 Apr 2005 14:14:20 -0000 1.19 *************** *** 246,250 **** * Called when buttons are pressed, on BACK, return to the launcher like a good app should. */ ! public boolean eventWidgetDown(int widget, Event event) { // If this is back or cancel, back out if (widget == Event.DEVICE_BUTTON_BACK --- 246,251 ---- * Called when buttons are pressed, on BACK, return to the launcher like a good app should. */ ! ! public boolean eventWidgetUp(int widget, Event event) { // If this is back or cancel, back out if (widget == Event.DEVICE_BUTTON_BACK *************** *** 254,258 **** } ! return super.eventWidgetDown(widget, event); } public boolean eventWidgetHeld(int widget, Event event) { --- 255,259 ---- } ! return super.eventWidgetUp(widget, event); } public boolean eventWidgetHeld(int widget, Event event) { |
|
From: Nicolas P. <nic...@us...> - 2005-04-10 23:16:35
|
Update of /cvsroot/hipgmap/gmap/com/trileet/gmap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28159/com/trileet/gmap Modified Files: ImageCache.java TileSet.java Log Message: Try to add request pausing when we are scrolling. Seems to work ok, but we still get slowed down by outstanding requests that come back. Index: ImageCache.java =================================================================== RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/ImageCache.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** ImageCache.java 10 Apr 2005 20:45:33 -0000 1.13 --- ImageCache.java 10 Apr 2005 23:16:04 -0000 1.14 *************** *** 213,216 **** --- 213,223 ---- } + + // Whether we are paused from currently requesting images + private static boolean s_paused = false; + + public static void stopFetching(){ s_paused = true; } + public static void startFetching(){ s_paused = false; synchronized(s_pending){ s_pending.notifyAll(); } } + /** * Thread that takes care of requesting images *************** *** 232,235 **** --- 239,249 ---- } } + + // while we are paused, hang out + while(s_paused){ + synchronized(s_pending){ + s_pending.wait(10000); + } + } // while we have 4 or more pending requests, wait for one to be over Index: TileSet.java =================================================================== RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/TileSet.java,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** TileSet.java 10 Apr 2005 20:45:33 -0000 1.25 --- TileSet.java 10 Apr 2005 23:16:05 -0000 1.26 *************** *** 316,319 **** --- 316,326 ---- // Checks our center, reordering our tile set accordingly if needed public void checkCenter() { + // called whenever we are moving + m_stopTimer.resetDelay(1000); + m_stopTimer.start(); + + // Turn off fetching + ImageCache.stopFetching(); + /** Fine-tuned for the 5x5 tileset. **/ if (m_offsetX < TILE_WIDTH || m_offsetX > TILE_WIDTH * 2 *************** *** 576,581 **** --- 583,590 ---- animateDeltaY = endY / numSteps; animateStepsLeft = numSteps; + // Do the first step now, so we don't have to wait 30 ms. animateStep(); + // Start up the repeating timer. animateTimer.start(); *************** *** 590,594 **** animateStepsLeft--; GMap.invalidateMap(); - } --- 599,602 ---- *************** *** 620,623 **** --- 628,637 ---- animateStep(); return true; + + } else if (e.data == STOP){ + // we stopped, trigger fetches again + m_stopTimer.stop(); + ImageCache.startFetching(); + return true; } else { return false; *************** *** 684,688 **** * When we convert the center of our map into a KH coordinate to * fetch the correct aerial photo tile, we will cut off the first ! * (18-zoom) characters and put them in the URL. The remaining * characters will tell us where, in the bitmap that gets * returned, is our point. --- 698,702 ---- * When we convert the center of our map into a KH coordinate to * fetch the correct aerial photo tile, we will cut off the first ! * (18-zoom) characters and put them in the URL. The remaing * characters will tell us where, in the bitmap that gets * returned, is our point. *************** *** 833,840 **** private boolean animateAlongPolyline; ! private danger.app.Timer animateTimer = new Timer(30, true, this, ANIMATE, ! null); public static final int ANIMATE = 1; public MapWindow parentMapWindow; --- 847,859 ---- private boolean animateAlongPolyline; ! private danger.app.Timer animateTimer = new Timer(30, true, this, ANIMATE, null); ! ! /** Stop timer, started everytime we start moving, when it ends then we know we can start ! * fetching tiles. ! */ ! private danger.app.Timer m_stopTimer = new Timer(500, true, this, STOP, null); public static final int ANIMATE = 1; + public static final int STOP = 2; public MapWindow parentMapWindow; |
Oh also added Titles to the windows and a full screen mode for the MapWindow. -Nic Nicolas Pottier wrote: > Update of /cvsroot/hipgmap/gmap/com/trileet/gmap > In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2670/com/trileet/gmap > > Modified Files: > DirectionWindow.java GMap.java ImageCache.java MapWindow.java > SearchWindow.java Tile.java TileSet.java > Log Message: > > Adam inspired me to look at how we could be faster with maps. > > We're now pretty wicked fast. > > Did some more optimization of ordering of tile fetching, we now fetch the tiles that have the most area on the screen first (in that order). Also tweaked the ImageCache quite a bit trying to find the best balance of requests and not blowing the connection with lots of queued messages. Anyways, it's much faster just grabbing stuff now. > > The downside is we're taxing the little cpu a lot more now, so scrolling isn't anywhere near as neato. Then again, you're not scrolling across white space most of the time now either. > > I know if we spend the time we can fix that and special case panning around to be much smarter and more efficient, but in the meantime this is a nice improvement. > > > > Index: MapWindow.java > =================================================================== > RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/MapWindow.java,v > retrieving revision 1.16 > retrieving revision 1.17 > diff -C2 -d -r1.16 -r1.17 > *** MapWindow.java 10 Apr 2005 10:23:48 -0000 1.16 > --- MapWindow.java 10 Apr 2005 20:45:33 -0000 1.17 > *************** > *** 27,30 **** > --- 27,32 ---- > > public MapWindow() { > + setTitle("GMap: Map"); > + > buildActionMenu(); > m_tileSet= new TileSet(); > > Index: DirectionWindow.java > =================================================================== > RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/DirectionWindow.java,v > retrieving revision 1.5 > retrieving revision 1.6 > diff -C2 -d -r1.5 -r1.6 > *** DirectionWindow.java 3 Apr 2005 11:21:52 -0000 1.5 > --- DirectionWindow.java 10 Apr 2005 20:45:25 -0000 1.6 > *************** > *** 23,26 **** > --- 23,28 ---- > > public DirectionWindow() { > + setTitle("GMap: Driving Directions"); > + > buildActionMenu(); > } > > Index: ImageCache.java > =================================================================== > RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/ImageCache.java,v > retrieving revision 1.12 > retrieving revision 1.13 > diff -C2 -d -r1.12 -r1.13 > *** ImageCache.java 10 Apr 2005 10:23:48 -0000 1.12 > --- ImageCache.java 10 Apr 2005 20:45:33 -0000 1.13 > *************** > *** 37,41 **** > */ > public class ImageCache implements ResponseListener, Runnable { > ! > /** > * Requests an image from our cache. Might return immediately with the > --- 37,41 ---- > */ > public class ImageCache implements ResponseListener, Runnable { > ! > /** > [...965 lines suppressed...] > private static ImageCache s_this; > ! > /** Our vector of recent images */ > private static Vector s_recentImages = new Vector(); > > ! /** Number of bitmaps we have in memory. **/ > ! private static int s_numBitmaps; > > ! private static final String DATASTORE_NAME = "GMapImageDataStore"; > > ! private static final int DATASTORE_VERSION = 4; > > ! /** Our data store */ > ! private static DataStore mDataStore; > ! > ! /** Our thread. */ > ! private static Thread s_thread; > ! > ! private static boolean s_running = true; > } > > Index: TileSet.java > =================================================================== > RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/TileSet.java,v > retrieving revision 1.24 > retrieving revision 1.25 > diff -C2 -d -r1.24 -r1.25 > *** TileSet.java 10 Apr 2005 10:23:48 -0000 1.24 > --- TileSet.java 10 Apr 2005 20:45:33 -0000 1.25 > *************** > *** 56,59 **** > --- 56,67 ---- > Resources.ID_PIN); > > + > + // at most there will be 9 screen tiles, build them up > + TileArea current = m_screenTiles; > + for(int i=0; i<9; i++){ > + current.next = new TileArea(0,0,0); > + current.next.previous = current; > + current = current.next; > + } > } > > *************** > *** 193,207 **** > setMapTilesByCenter(mapX, mapY, zoom); > } > /** > * This helper function ONLY manages which tiles point to which > * images, and what order they are loaded in. > */ > ! private void setMapTilesByCenter(int mapX, int mapY,int zoom) { > /** Fine-tuned for the 5x5 tileset. **/ > ! > ! ImageCache.clearAllPriorityRequests(); > > int xRadius = getWidth() / 2; // = 2 > int yRadius = getHeight() / 2;// = 2 > /** Cache on screen tiles first. Here's the order we ask the tiles in: > * 25 18 13 21 24 > --- 201,291 ---- > setMapTilesByCenter(mapX, mapY, zoom); > } > + > /** > * This helper function ONLY manages which tiles point to which > * images, and what order they are loaded in. > */ > ! private void setMapTilesByCenter(int mapX, int mapY, int zoom) { > /** Fine-tuned for the 5x5 tileset. **/ > ! ImageCache.clearAllPriorityRequests(); > > int xRadius = getWidth() / 2; // = 2 > int yRadius = getHeight() / 2;// = 2 > + > + // clear out our areas for our screen tiles > + TileArea current = m_screenTiles; > + while(current != null){ > + current.area = 0; > + current = current.next; > + } > + > + // figure out which tiles are on screen, prioritized by area > + for (int x = 0; x < getWidth(); x++) { > + for (int y = 0; y < getHeight(); y++) { > + > + int startX = x * TILE_WIDTH - m_offsetX; > + int startY = y * TILE_WIDTH - m_offsetY; > + > + if (startX > -TILE_WIDTH && startX < 240 > + && startY > -TILE_WIDTH && startY < 160) { > + // figure out how much of this tile will get drawn > + int width = (startX < 0) ? startX + TILE_WIDTH : (startX + TILE_WIDTH <= 240) ? TILE_WIDTH : 240 - startX; > + int height = (startY < 0) ? startY + TILE_WIDTH :(startY + TILE_WIDTH <= 160) ? TILE_WIDTH : 160 - startY; > + int area = width * height; > + > + // Add it to our linked list > + current = m_screenTiles; > + while(current.area > area){ > + current = current.next; > + } > + > + // Insert it here if this one is empty > + if (current.area == 0){ > + current.area = area; > + current.x = x; > + current.y = y; > + } > + // Otherwise, we need to grab one from the back and insert it here > + else { > + TileArea last = current; > + while(last.next != null){ > + last = last.next; > + } > + > + // Set it up as our new value > + last.area = area; > + last.x = x; > + last.y = y; > + > + // Clear it from where it was > + last.previous.next = null; > + > + // Insert it in the new spot > + last.next = current; > + last.previous = current.previous; > + if (last.previous != null){ > + last.previous.next = last; > + } > + current.previous = last; > + > + if (current == m_screenTiles){ > + m_screenTiles = last; > + } > + } > + } > + } > + } > + > + // First load our on screen tiles > + current = m_screenTiles; > + while(current != null && current.area > 0){ > + int x = current.x; > + int y = current.y; > + m_tiles[x][y].setTile(mapX - (xRadius - x), mapY - (yRadius - y), zoom, true); > + > + // onwards > + current = current.next; > + } > + > /** Cache on screen tiles first. Here's the order we ask the tiles in: > * 25 18 13 21 24 > *************** > *** 221,229 **** > int x,y; > for (int i=0; i< loadOrderX.length;i++) { > ! x = loadOrderX[i]; > ! y = loadOrderY[i]; > ! m_tiles[x][y].setTile(mapX - (xRadius - x), mapY > ! - (yRadius - y), zoom, > ! true); > } > > --- 305,312 ---- > int x,y; > for (int i=0; i< loadOrderX.length;i++) { > ! x = loadOrderX[i]; > ! y = loadOrderY[i]; > ! > ! m_tiles[x][y].setTile(mapX - (xRadius - x), mapY - (yRadius - y), zoom, true); > } > > *************** > *** 234,239 **** > public void checkCenter() { > /** Fine-tuned for the 5x5 tileset. **/ > ! if (m_offsetX < TILE_WIDTH/2 || m_offsetX > TILE_WIDTH * 3 > ! || m_offsetY < TILE_WIDTH/2 || m_offsetY > TILE_WIDTH * 3) { > // recenter based on where we are > int indexX = m_offsetX / TILE_WIDTH; > --- 317,323 ---- > public void checkCenter() { > /** Fine-tuned for the 5x5 tileset. **/ > ! if (m_offsetX < TILE_WIDTH || m_offsetX > TILE_WIDTH * 2 > ! || m_offsetY < TILE_WIDTH || m_offsetY > TILE_WIDTH * 2) { > ! > // recenter based on where we are > int indexX = m_offsetX / TILE_WIDTH; > *************** > *** 243,253 **** > int mapY = m_tiles[indexX][indexY].getY(); > > - > - > // Figure out our offset based on how much we moved > m_offsetX = m_offsetX % TILE_WIDTH + TILE_WIDTH * 2; > m_offsetY = m_offsetY % TILE_WIDTH + TILE_WIDTH * 2; > ! setMapTilesByCenter(mapX, mapY,m_zoom); > ! > } > if (displayPhoto) > --- 327,334 ---- > int mapY = m_tiles[indexX][indexY].getY(); > > // Figure out our offset based on how much we moved > m_offsetX = m_offsetX % TILE_WIDTH + TILE_WIDTH * 2; > m_offsetY = m_offsetY % TILE_WIDTH + TILE_WIDTH * 2; > ! setMapTilesByCenter(mapX, mapY, m_zoom); > } > if (displayPhoto) > *************** > *** 363,376 **** > if (!displayPhoto) { > for (int x = 0; x < getWidth(); x++) { > ! for (int y = 0; y < getHeight(); y++) { > ! int startX = x * TILE_WIDTH - m_offsetX; > ! int startY = y * TILE_WIDTH - m_offsetY; > > ! if (startX > -TILE_WIDTH && startX < 240 > ! && startY > -TILE_WIDTH && startY < 140) { > ! m_tiles[x][y].paint(p, startX, startY); > } > } > - } > } > else { > --- 444,493 ---- > if (!displayPhoto) { > for (int x = 0; x < getWidth(); x++) { > ! for (int y = 0; y < getHeight(); y++) { > ! int startX = x * TILE_WIDTH - m_offsetX; > ! int startY = y * TILE_WIDTH - m_offsetY; > > ! if (startX > -TILE_WIDTH && startX < 240 > ! && startY > -TILE_WIDTH && startY < 160) { > ! m_tiles[x][y].paint(p, startX, startY); > ! } > ! } > ! } > ! > ! // draw a little version of our tiles in the corner for cache debugging > ! if (false){ > ! int startX = 60; > ! int startY = 20; > ! int width = 10; > ! for (int x = 0; x < getWidth(); x++) { > ! for (int y = 0; y < getHeight(); y++) { > ! int stat = m_tiles[x][y].getImageStat(); > ! if (stat == 0){ > ! p.setColor(Color.GREEN); > ! } else if (stat == 1){ > ! p.setColor(Color.WHITE); > ! } else if (stat == 2){ > ! p.setColor(Color.YELLOW); > ! } else { > ! p.setColor(Color.RED); > ! } > ! p.fillRect(startX + x * width, startY + y * width, > ! startX + (x+1) * width, startY + (y+1) * width); > ! > ! int drawX = x * TILE_WIDTH - m_offsetX; > ! int drawY = y * TILE_WIDTH - m_offsetY; > ! > ! if (drawX > -TILE_WIDTH && drawX < 240 > ! && drawY > -TILE_WIDTH && drawY < 160) { > ! p.setColor(Color.RED); > ! } else { > ! p.setColor(Color.BLACK); > ! } > ! > ! p.drawRect(startX + x * width, startY + y * width, > ! startX + (x+1) * width, startY + (y+1) * width); > ! } > } > } > } > else { > *************** > *** 619,623 **** > } > public void quit() { > ! ImageCache.quit(); > } > public void debug() { > --- 736,740 ---- > } > public void quit() { > ! ImageCache.quit(); > } > public void debug() { > *************** > *** 727,729 **** > --- 844,860 ---- > int m_offsetXPhoto; > int m_offsetYPhoto; > + > + // Used for prioritizing which tiles to fetch > + class TileArea { > + TileArea(int x, int y, int area){ > + this.x = x; > + this.y = y; > + this.area = area; > + } > + > + int x, y, area; > + TileArea next = null; > + TileArea previous = null; > + } > + private TileArea m_screenTiles = new TileArea(0,0,0); > } > > Index: GMap.java > =================================================================== > RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/GMap.java,v > retrieving revision 1.27 > retrieving revision 1.28 > diff -C2 -d -r1.27 -r1.28 > *** GMap.java 10 Apr 2005 10:23:48 -0000 1.27 > --- GMap.java 10 Apr 2005 20:45:33 -0000 1.28 > *************** > *** 142,147 **** > s_searchWindow.handleVCard((IPCMessage)e.argument); > return true; > ! > ! > } > //System.out.println("Event: " + String.valueOf(e.type)); > --- 142,154 ---- > s_searchWindow.handleVCard((IPCMessage)e.argument); > return true; > ! > ! case FULLSCREEN: > ! // Toggle full screen on the map window > ! if (s_mapWindow.isFullScreen()){ > ! s_mapWindow.setFullScreen(false); > ! } else { > ! s_mapWindow.setFullScreen(true); > ! } > ! return true; > } > //System.out.println("Event: " + String.valueOf(e.type)); > *************** > *** 208,212 **** > locationIndex = result.indexOf("<location"); > } > ! > s_searchWindow.setHits(); > s_searchWindow.show(); > --- 215,219 ---- > locationIndex = result.indexOf("<location"); > } > ! > s_searchWindow.setHits(); > s_searchWindow.show(); > *************** > *** 308,313 **** > } > public void quit() { > ! s_mapWindow.quit(); > ! super.quit(); > } > > --- 315,320 ---- > } > public void quit() { > ! s_mapWindow.quit(); > ! super.quit(); > } > > > Index: Tile.java > =================================================================== > RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/Tile.java,v > retrieving revision 1.7 > retrieving revision 1.8 > diff -C2 -d -r1.7 -r1.8 > *** Tile.java 10 Apr 2005 10:23:48 -0000 1.7 > --- Tile.java 10 Apr 2005 20:45:33 -0000 1.8 > *************** > *** 22,26 **** > */ > public class Tile implements ImageCache.Listener { > ! > public static final int WIDTH = 128; > > --- 22,26 ---- > */ > public class Tile implements ImageCache.Listener { > ! > public static final int WIDTH = 128; > > *************** > *** 29,108 **** > } > > ! public void paint(Pen p, int x, int y) { > ! if (m_bitmap != null){ > ! p.drawBitmap(x, y, m_bitmap); > ! } else { > ! p.push(); > ! int stat = ImageCache.requestStatus(m_url); > ! if (stat == 1) { > ! p.setColor(Color.WHITE); > ! } else if (stat == 2) { > ! p.setColor(Color.YELLOW); > ! } > ! else { > ! p.setColor(Color.RED); > } > ! p.fillRect(x, y, x + WIDTH, y + WIDTH); > ! p.setColor(Color.BLACK); > ! p.drawRect(x, y, x + WIDTH, y + WIDTH); > ! p.drawText(x + 30, y + 30, "X: " + m_x + " Y: " + m_y); > ! p.drawText(x + 30, y + 50, "ZOOM: " + m_zoom); > ! p.pop(); > ! > ! } > > } > > public void setTile(int x, int y, int zoom) { > ! setTile( x, y, zoom, false); > } > public void setTile(int x, int y, int zoom, boolean priority) { > m_x = x; > m_y = y; > m_zoom = zoom; > ! > ! // clear out bitmap > ! m_bitmap = null; > ! > /** > ! // if our old url is not null and we still don't have a response from it, cancel that request > ! if (m_url != null && m_bitmap == null){ > ! ImageCache.cancelRequest(m_url); > ! } > ! **/ > > // go request the tile! > ! //m_url = "http://mt.google.com/mt%3Fv%3D.1%26x%3D" + m_x + "%26y%3D" + m_y + "%26zoom%3D" + m_zoom; > ! m_url = makeURL(x,y,zoom); > ! > ! //m_url = "http://hipster.trileet.com/tmpimg/img.php?url=" + m_url; > m_bitmap = ImageCache.requestImage(m_url, this, priority); > ! > // Invalidate our map > //GMap.invalidateMap(); > } > ! public static String makeURL(int x, int y, int zoom) { > ! return "http://mt.google.com/mt?v=.1&x=" + x + "&y=" + y + "&zoom=" + zoom; > ! } > ! public static String makePhotoURL(String khCoords, int zoom) { > ! return "http://hipster.trileet.com/tmpimg/img.php?url=" + > ! URLEncoder.encode("http://kh.google.com/kh?v=1&t=" + khCoords.substring(0,18-zoom)); > ! } > ! public void handleImage(String url, Bitmap image){ > // If this is our current url > ! if (url.equals(m_url)){ > // Set our bitmap > m_bitmap = image; > ! > // Invalidate our map > GMap.invalidateMap(); > } > //System.out.println("Tile.handleImage:"+url+((image==null)?" null":" notnull")); > ! } > > - public int getX(){ return m_x; } > - public int getY(){ return m_y; } > - public String getURL(){ return m_url; } > - > // our x for this tile's URL > private int m_x; > --- 29,131 ---- > } > > ! public void paint(Pen p, int x, int y) { > ! if (m_bitmap != null) { > ! p.drawBitmap(x, y, m_bitmap); > ! } else { > ! p.push(); > ! int stat = ImageCache.requestStatus(m_url); > ! if (stat == 1) { > ! p.setColor(Color.WHITE); > ! } else if (stat == 2) { > ! p.setColor(Color.YELLOW); > ! } else { > ! p.setColor(Color.RED); > ! } > ! p.fillRect(x, y, x + WIDTH, y + WIDTH); > ! p.setColor(Color.BLACK); > ! p.drawRect(x, y, x + WIDTH, y + WIDTH); > ! p.drawText(x + 30, y + 30, "X: " + m_x + " Y: " + m_y); > ! p.drawText(x + 30, y + 50, "ZOOM: " + m_zoom); > ! p.pop(); > } > ! } > > + public int getImageStat() { > + if (m_bitmap != null) { > + return 0; > + } else { > + return ImageCache.requestStatus(m_url); > + } > } > > public void setTile(int x, int y, int zoom) { > ! setTile(x, y, zoom, false); > } > + > public void setTile(int x, int y, int zoom, boolean priority) { > + // If this is not the same tile, then clear our bitmap > + if (m_x != x || m_y != y || m_zoom != zoom){ > + m_bitmap = null; > + } > + > m_x = x; > m_y = y; > m_zoom = zoom; > ! > /** > ! // if our old url is not null and we still don't have a response from it, cancel that request > ! if (m_url != null && m_bitmap == null){ > ! ImageCache.cancelRequest(m_url); > ! } > ! **/ > > // go request the tile! > ! m_url = makeURL(x, y, zoom); > m_bitmap = ImageCache.requestImage(m_url, this, priority); > ! > // Invalidate our map > //GMap.invalidateMap(); > } > ! > ! public static String makeURL(int x, int y, int zoom) { > ! return "http://mt.google.com/mt?v=.1&x=" + x + "&y=" + y + "&zoom=" > ! + zoom; > ! } > ! > ! public static String makePhotoURL(String khCoords, int zoom) { > ! return "http://hipster.trileet.com/tmpimg/img.php?url=" > ! + URLEncoder.encode("http://kh.google.com/kh?v=1&t=" > ! + khCoords.substring(0, 18 - zoom)); > ! } > ! > ! public void handleImage(String url, Bitmap image) { > // If this is our current url > ! if (url.equals(m_url)) { > ! // If we already had the image, comaplin > ! if (m_bitmap != null){ > ! System.out.println("WAISTED GET: " + url); > ! } > ! > // Set our bitmap > m_bitmap = image; > ! > // Invalidate our map > GMap.invalidateMap(); > } > //System.out.println("Tile.handleImage:"+url+((image==null)?" null":" notnull")); > ! } > ! > ! public int getX() { > ! return m_x; > ! } > ! > ! public int getY() { > ! return m_y; > ! } > ! > ! public String getURL() { > ! return m_url; > ! } > > // our x for this tile's URL > private int m_x; > *************** > *** 113,120 **** > // the zoom for this tile > private int m_zoom; > ! > // our image > private Bitmap m_bitmap; > ! > // our url > private String m_url; > --- 136,143 ---- > // the zoom for this tile > private int m_zoom; > ! > // our image > private Bitmap m_bitmap; > ! > // our url > private String m_url; > > Index: SearchWindow.java > =================================================================== > RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/SearchWindow.java,v > retrieving revision 1.17 > retrieving revision 1.18 > diff -C2 -d -r1.17 -r1.18 > *** SearchWindow.java 9 Apr 2005 21:56:48 -0000 1.17 > --- SearchWindow.java 10 Apr 2005 20:45:33 -0000 1.18 > *************** > *** 28,31 **** > --- 28,34 ---- > > public SearchWindow() { > + // Set our title > + setTitle("GMap: Search"); > + > // Search button first just for layout > Button searchButton = new Button("Search"); > > > > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real users. > Discover which products truly live up to the hype. Start reading now. > http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click > _______________________________________________ > Hipgmap-cvs mailing list > Hip...@li... > https://lists.sourceforge.net/lists/listinfo/hipgmap-cvs > |
|
From: Nicolas P. <nic...@us...> - 2005-04-10 20:46:07
|
Update of /cvsroot/hipgmap/gmap/com/trileet/gmap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2670/com/trileet/gmap Modified Files: DirectionWindow.java GMap.java ImageCache.java MapWindow.java SearchWindow.java Tile.java TileSet.java Log Message: Adam inspired me to look at how we could be faster with maps. We're now pretty wicked fast. Did some more optimization of ordering of tile fetching, we now fetch the tiles that have the most area on the screen first (in that order). Also tweaked the ImageCache quite a bit trying to find the best balance of requests and not blowing the connection with lots of queued messages. Anyways, it's much faster just grabbing stuff now. The downside is we're taxing the little cpu a lot more now, so scrolling isn't anywhere near as neato. Then again, you're not scrolling across white space most of the time now either. I know if we spend the time we can fix that and special case panning around to be much smarter and more efficient, but in the meantime this is a nice improvement. Index: MapWindow.java =================================================================== RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/MapWindow.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** MapWindow.java 10 Apr 2005 10:23:48 -0000 1.16 --- MapWindow.java 10 Apr 2005 20:45:33 -0000 1.17 *************** *** 27,30 **** --- 27,32 ---- public MapWindow() { + setTitle("GMap: Map"); + buildActionMenu(); m_tileSet= new TileSet(); Index: DirectionWindow.java =================================================================== RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/DirectionWindow.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** DirectionWindow.java 3 Apr 2005 11:21:52 -0000 1.5 --- DirectionWindow.java 10 Apr 2005 20:45:25 -0000 1.6 *************** *** 23,26 **** --- 23,28 ---- public DirectionWindow() { + setTitle("GMap: Driving Directions"); + buildActionMenu(); } Index: ImageCache.java =================================================================== RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/ImageCache.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** ImageCache.java 10 Apr 2005 10:23:48 -0000 1.12 --- ImageCache.java 10 Apr 2005 20:45:33 -0000 1.13 *************** *** 37,41 **** */ public class ImageCache implements ResponseListener, Runnable { ! /** * Requests an image from our cache. Might return immediately with the --- 37,41 ---- */ public class ImageCache implements ResponseListener, Runnable { ! /** [...965 lines suppressed...] private static ImageCache s_this; ! /** Our vector of recent images */ private static Vector s_recentImages = new Vector(); ! /** Number of bitmaps we have in memory. **/ ! private static int s_numBitmaps; ! private static final String DATASTORE_NAME = "GMapImageDataStore"; ! private static final int DATASTORE_VERSION = 4; ! /** Our data store */ ! private static DataStore mDataStore; ! ! /** Our thread. */ ! private static Thread s_thread; ! ! private static boolean s_running = true; } Index: TileSet.java =================================================================== RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/TileSet.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** TileSet.java 10 Apr 2005 10:23:48 -0000 1.24 --- TileSet.java 10 Apr 2005 20:45:33 -0000 1.25 *************** *** 56,59 **** --- 56,67 ---- Resources.ID_PIN); + + // at most there will be 9 screen tiles, build them up + TileArea current = m_screenTiles; + for(int i=0; i<9; i++){ + current.next = new TileArea(0,0,0); + current.next.previous = current; + current = current.next; + } } *************** *** 193,207 **** setMapTilesByCenter(mapX, mapY, zoom); } /** * This helper function ONLY manages which tiles point to which * images, and what order they are loaded in. */ ! private void setMapTilesByCenter(int mapX, int mapY,int zoom) { /** Fine-tuned for the 5x5 tileset. **/ ! ! ImageCache.clearAllPriorityRequests(); int xRadius = getWidth() / 2; // = 2 int yRadius = getHeight() / 2;// = 2 /** Cache on screen tiles first. Here's the order we ask the tiles in: * 25 18 13 21 24 --- 201,291 ---- setMapTilesByCenter(mapX, mapY, zoom); } + /** * This helper function ONLY manages which tiles point to which * images, and what order they are loaded in. */ ! private void setMapTilesByCenter(int mapX, int mapY, int zoom) { /** Fine-tuned for the 5x5 tileset. **/ ! ImageCache.clearAllPriorityRequests(); int xRadius = getWidth() / 2; // = 2 int yRadius = getHeight() / 2;// = 2 + + // clear out our areas for our screen tiles + TileArea current = m_screenTiles; + while(current != null){ + current.area = 0; + current = current.next; + } + + // figure out which tiles are on screen, prioritized by area + for (int x = 0; x < getWidth(); x++) { + for (int y = 0; y < getHeight(); y++) { + + int startX = x * TILE_WIDTH - m_offsetX; + int startY = y * TILE_WIDTH - m_offsetY; + + if (startX > -TILE_WIDTH && startX < 240 + && startY > -TILE_WIDTH && startY < 160) { + // figure out how much of this tile will get drawn + int width = (startX < 0) ? startX + TILE_WIDTH : (startX + TILE_WIDTH <= 240) ? TILE_WIDTH : 240 - startX; + int height = (startY < 0) ? startY + TILE_WIDTH :(startY + TILE_WIDTH <= 160) ? TILE_WIDTH : 160 - startY; + int area = width * height; + + // Add it to our linked list + current = m_screenTiles; + while(current.area > area){ + current = current.next; + } + + // Insert it here if this one is empty + if (current.area == 0){ + current.area = area; + current.x = x; + current.y = y; + } + // Otherwise, we need to grab one from the back and insert it here + else { + TileArea last = current; + while(last.next != null){ + last = last.next; + } + + // Set it up as our new value + last.area = area; + last.x = x; + last.y = y; + + // Clear it from where it was + last.previous.next = null; + + // Insert it in the new spot + last.next = current; + last.previous = current.previous; + if (last.previous != null){ + last.previous.next = last; + } + current.previous = last; + + if (current == m_screenTiles){ + m_screenTiles = last; + } + } + } + } + } + + // First load our on screen tiles + current = m_screenTiles; + while(current != null && current.area > 0){ + int x = current.x; + int y = current.y; + m_tiles[x][y].setTile(mapX - (xRadius - x), mapY - (yRadius - y), zoom, true); + + // onwards + current = current.next; + } + /** Cache on screen tiles first. Here's the order we ask the tiles in: * 25 18 13 21 24 *************** *** 221,229 **** int x,y; for (int i=0; i< loadOrderX.length;i++) { ! x = loadOrderX[i]; ! y = loadOrderY[i]; ! m_tiles[x][y].setTile(mapX - (xRadius - x), mapY ! - (yRadius - y), zoom, ! true); } --- 305,312 ---- int x,y; for (int i=0; i< loadOrderX.length;i++) { ! x = loadOrderX[i]; ! y = loadOrderY[i]; ! ! m_tiles[x][y].setTile(mapX - (xRadius - x), mapY - (yRadius - y), zoom, true); } *************** *** 234,239 **** public void checkCenter() { /** Fine-tuned for the 5x5 tileset. **/ ! if (m_offsetX < TILE_WIDTH/2 || m_offsetX > TILE_WIDTH * 3 ! || m_offsetY < TILE_WIDTH/2 || m_offsetY > TILE_WIDTH * 3) { // recenter based on where we are int indexX = m_offsetX / TILE_WIDTH; --- 317,323 ---- public void checkCenter() { /** Fine-tuned for the 5x5 tileset. **/ ! if (m_offsetX < TILE_WIDTH || m_offsetX > TILE_WIDTH * 2 ! || m_offsetY < TILE_WIDTH || m_offsetY > TILE_WIDTH * 2) { ! // recenter based on where we are int indexX = m_offsetX / TILE_WIDTH; *************** *** 243,253 **** int mapY = m_tiles[indexX][indexY].getY(); - - // Figure out our offset based on how much we moved m_offsetX = m_offsetX % TILE_WIDTH + TILE_WIDTH * 2; m_offsetY = m_offsetY % TILE_WIDTH + TILE_WIDTH * 2; ! setMapTilesByCenter(mapX, mapY,m_zoom); ! } if (displayPhoto) --- 327,334 ---- int mapY = m_tiles[indexX][indexY].getY(); // Figure out our offset based on how much we moved m_offsetX = m_offsetX % TILE_WIDTH + TILE_WIDTH * 2; m_offsetY = m_offsetY % TILE_WIDTH + TILE_WIDTH * 2; ! setMapTilesByCenter(mapX, mapY, m_zoom); } if (displayPhoto) *************** *** 363,376 **** if (!displayPhoto) { for (int x = 0; x < getWidth(); x++) { ! for (int y = 0; y < getHeight(); y++) { ! int startX = x * TILE_WIDTH - m_offsetX; ! int startY = y * TILE_WIDTH - m_offsetY; ! if (startX > -TILE_WIDTH && startX < 240 ! && startY > -TILE_WIDTH && startY < 140) { ! m_tiles[x][y].paint(p, startX, startY); } } - } } else { --- 444,493 ---- if (!displayPhoto) { for (int x = 0; x < getWidth(); x++) { ! for (int y = 0; y < getHeight(); y++) { ! int startX = x * TILE_WIDTH - m_offsetX; ! int startY = y * TILE_WIDTH - m_offsetY; ! if (startX > -TILE_WIDTH && startX < 240 ! && startY > -TILE_WIDTH && startY < 160) { ! m_tiles[x][y].paint(p, startX, startY); ! } ! } ! } ! ! // draw a little version of our tiles in the corner for cache debugging ! if (false){ ! int startX = 60; ! int startY = 20; ! int width = 10; ! for (int x = 0; x < getWidth(); x++) { ! for (int y = 0; y < getHeight(); y++) { ! int stat = m_tiles[x][y].getImageStat(); ! if (stat == 0){ ! p.setColor(Color.GREEN); ! } else if (stat == 1){ ! p.setColor(Color.WHITE); ! } else if (stat == 2){ ! p.setColor(Color.YELLOW); ! } else { ! p.setColor(Color.RED); ! } ! p.fillRect(startX + x * width, startY + y * width, ! startX + (x+1) * width, startY + (y+1) * width); ! ! int drawX = x * TILE_WIDTH - m_offsetX; ! int drawY = y * TILE_WIDTH - m_offsetY; ! ! if (drawX > -TILE_WIDTH && drawX < 240 ! && drawY > -TILE_WIDTH && drawY < 160) { ! p.setColor(Color.RED); ! } else { ! p.setColor(Color.BLACK); ! } ! ! p.drawRect(startX + x * width, startY + y * width, ! startX + (x+1) * width, startY + (y+1) * width); ! } } } } else { *************** *** 619,623 **** } public void quit() { ! ImageCache.quit(); } public void debug() { --- 736,740 ---- } public void quit() { ! ImageCache.quit(); } public void debug() { *************** *** 727,729 **** --- 844,860 ---- int m_offsetXPhoto; int m_offsetYPhoto; + + // Used for prioritizing which tiles to fetch + class TileArea { + TileArea(int x, int y, int area){ + this.x = x; + this.y = y; + this.area = area; + } + + int x, y, area; + TileArea next = null; + TileArea previous = null; + } + private TileArea m_screenTiles = new TileArea(0,0,0); } Index: GMap.java =================================================================== RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/GMap.java,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** GMap.java 10 Apr 2005 10:23:48 -0000 1.27 --- GMap.java 10 Apr 2005 20:45:33 -0000 1.28 *************** *** 142,147 **** s_searchWindow.handleVCard((IPCMessage)e.argument); return true; ! ! } //System.out.println("Event: " + String.valueOf(e.type)); --- 142,154 ---- s_searchWindow.handleVCard((IPCMessage)e.argument); return true; ! ! case FULLSCREEN: ! // Toggle full screen on the map window ! if (s_mapWindow.isFullScreen()){ ! s_mapWindow.setFullScreen(false); ! } else { ! s_mapWindow.setFullScreen(true); ! } ! return true; } //System.out.println("Event: " + String.valueOf(e.type)); *************** *** 208,212 **** locationIndex = result.indexOf("<location"); } ! s_searchWindow.setHits(); s_searchWindow.show(); --- 215,219 ---- locationIndex = result.indexOf("<location"); } ! s_searchWindow.setHits(); s_searchWindow.show(); *************** *** 308,313 **** } public void quit() { ! s_mapWindow.quit(); ! super.quit(); } --- 315,320 ---- } public void quit() { ! s_mapWindow.quit(); ! super.quit(); } Index: Tile.java =================================================================== RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/Tile.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Tile.java 10 Apr 2005 10:23:48 -0000 1.7 --- Tile.java 10 Apr 2005 20:45:33 -0000 1.8 *************** *** 22,26 **** */ public class Tile implements ImageCache.Listener { ! public static final int WIDTH = 128; --- 22,26 ---- */ public class Tile implements ImageCache.Listener { ! public static final int WIDTH = 128; *************** *** 29,108 **** } ! public void paint(Pen p, int x, int y) { ! if (m_bitmap != null){ ! p.drawBitmap(x, y, m_bitmap); ! } else { ! p.push(); ! int stat = ImageCache.requestStatus(m_url); ! if (stat == 1) { ! p.setColor(Color.WHITE); ! } else if (stat == 2) { ! p.setColor(Color.YELLOW); ! } ! else { ! p.setColor(Color.RED); } ! p.fillRect(x, y, x + WIDTH, y + WIDTH); ! p.setColor(Color.BLACK); ! p.drawRect(x, y, x + WIDTH, y + WIDTH); ! p.drawText(x + 30, y + 30, "X: " + m_x + " Y: " + m_y); ! p.drawText(x + 30, y + 50, "ZOOM: " + m_zoom); ! p.pop(); ! ! } } public void setTile(int x, int y, int zoom) { ! setTile( x, y, zoom, false); } public void setTile(int x, int y, int zoom, boolean priority) { m_x = x; m_y = y; m_zoom = zoom; ! ! // clear out bitmap ! m_bitmap = null; ! /** ! // if our old url is not null and we still don't have a response from it, cancel that request ! if (m_url != null && m_bitmap == null){ ! ImageCache.cancelRequest(m_url); ! } ! **/ // go request the tile! ! //m_url = "http://mt.google.com/mt%3Fv%3D.1%26x%3D" + m_x + "%26y%3D" + m_y + "%26zoom%3D" + m_zoom; ! m_url = makeURL(x,y,zoom); ! ! //m_url = "http://hipster.trileet.com/tmpimg/img.php?url=" + m_url; m_bitmap = ImageCache.requestImage(m_url, this, priority); ! // Invalidate our map //GMap.invalidateMap(); } ! public static String makeURL(int x, int y, int zoom) { ! return "http://mt.google.com/mt?v=.1&x=" + x + "&y=" + y + "&zoom=" + zoom; ! } ! public static String makePhotoURL(String khCoords, int zoom) { ! return "http://hipster.trileet.com/tmpimg/img.php?url=" + ! URLEncoder.encode("http://kh.google.com/kh?v=1&t=" + khCoords.substring(0,18-zoom)); ! } ! public void handleImage(String url, Bitmap image){ // If this is our current url ! if (url.equals(m_url)){ // Set our bitmap m_bitmap = image; ! // Invalidate our map GMap.invalidateMap(); } //System.out.println("Tile.handleImage:"+url+((image==null)?" null":" notnull")); ! } - public int getX(){ return m_x; } - public int getY(){ return m_y; } - public String getURL(){ return m_url; } - // our x for this tile's URL private int m_x; --- 29,131 ---- } ! public void paint(Pen p, int x, int y) { ! if (m_bitmap != null) { ! p.drawBitmap(x, y, m_bitmap); ! } else { ! p.push(); ! int stat = ImageCache.requestStatus(m_url); ! if (stat == 1) { ! p.setColor(Color.WHITE); ! } else if (stat == 2) { ! p.setColor(Color.YELLOW); ! } else { ! p.setColor(Color.RED); ! } ! p.fillRect(x, y, x + WIDTH, y + WIDTH); ! p.setColor(Color.BLACK); ! p.drawRect(x, y, x + WIDTH, y + WIDTH); ! p.drawText(x + 30, y + 30, "X: " + m_x + " Y: " + m_y); ! p.drawText(x + 30, y + 50, "ZOOM: " + m_zoom); ! p.pop(); } ! } + public int getImageStat() { + if (m_bitmap != null) { + return 0; + } else { + return ImageCache.requestStatus(m_url); + } } public void setTile(int x, int y, int zoom) { ! setTile(x, y, zoom, false); } + public void setTile(int x, int y, int zoom, boolean priority) { + // If this is not the same tile, then clear our bitmap + if (m_x != x || m_y != y || m_zoom != zoom){ + m_bitmap = null; + } + m_x = x; m_y = y; m_zoom = zoom; ! /** ! // if our old url is not null and we still don't have a response from it, cancel that request ! if (m_url != null && m_bitmap == null){ ! ImageCache.cancelRequest(m_url); ! } ! **/ // go request the tile! ! m_url = makeURL(x, y, zoom); m_bitmap = ImageCache.requestImage(m_url, this, priority); ! // Invalidate our map //GMap.invalidateMap(); } ! ! public static String makeURL(int x, int y, int zoom) { ! return "http://mt.google.com/mt?v=.1&x=" + x + "&y=" + y + "&zoom=" ! + zoom; ! } ! ! public static String makePhotoURL(String khCoords, int zoom) { ! return "http://hipster.trileet.com/tmpimg/img.php?url=" ! + URLEncoder.encode("http://kh.google.com/kh?v=1&t=" ! + khCoords.substring(0, 18 - zoom)); ! } ! ! public void handleImage(String url, Bitmap image) { // If this is our current url ! if (url.equals(m_url)) { ! // If we already had the image, comaplin ! if (m_bitmap != null){ ! System.out.println("WAISTED GET: " + url); ! } ! // Set our bitmap m_bitmap = image; ! // Invalidate our map GMap.invalidateMap(); } //System.out.println("Tile.handleImage:"+url+((image==null)?" null":" notnull")); ! } ! ! public int getX() { ! return m_x; ! } ! ! public int getY() { ! return m_y; ! } ! ! public String getURL() { ! return m_url; ! } // our x for this tile's URL private int m_x; *************** *** 113,120 **** // the zoom for this tile private int m_zoom; ! // our image private Bitmap m_bitmap; ! // our url private String m_url; --- 136,143 ---- // the zoom for this tile private int m_zoom; ! // our image private Bitmap m_bitmap; ! // our url private String m_url; Index: SearchWindow.java =================================================================== RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/SearchWindow.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** SearchWindow.java 9 Apr 2005 21:56:48 -0000 1.17 --- SearchWindow.java 10 Apr 2005 20:45:33 -0000 1.18 *************** *** 28,31 **** --- 28,34 ---- public SearchWindow() { + // Set our title + setTitle("GMap: Search"); + // Search button first just for layout Button searchButton = new Button("Search"); |
|
From: Nicolas P. <nic...@us...> - 2005-04-10 20:46:06
|
Update of /cvsroot/hipgmap/gmap/locale/en_US In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2670/locale/en_US Modified Files: GMap.rsrc Log Message: Adam inspired me to look at how we could be faster with maps. We're now pretty wicked fast. Did some more optimization of ordering of tile fetching, we now fetch the tiles that have the most area on the screen first (in that order). Also tweaked the ImageCache quite a bit trying to find the best balance of requests and not blowing the connection with lots of queued messages. Anyways, it's much faster just grabbing stuff now. The downside is we're taxing the little cpu a lot more now, so scrolling isn't anywhere near as neato. Then again, you're not scrolling across white space most of the time now either. I know if we spend the time we can fix that and special case panning around to be much smarter and more efficient, but in the meantime this is a nice improvement. Index: GMap.rsrc =================================================================== RCS file: /cvsroot/hipgmap/gmap/locale/en_US/GMap.rsrc,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** GMap.rsrc 10 Apr 2005 10:23:49 -0000 1.16 --- GMap.rsrc 10 Apr 2005 20:45:33 -0000 1.17 *************** *** 73,77 **** --- 73,79 ---- menuItem title="Search Near Here" id=kID_SearchMap event=SEARCH_MAP shortcut='n' menuItem title="Current Hit..." id=kID_hitsSubMenuMap subMenu=HITS_SUBMENU + divider menuItem title="Debug" id=kID_beug event=DEBUG shortcut='q' + menuItem title="Fullscreen" id=kID_fullscreen event=FULLSCREEN shortcut='z' endMenu |
|
From: Adam B. <ab...@us...> - 2005-04-10 10:23:59
|
Update of /cvsroot/hipgmap/gmap/com/trileet/gmap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1962/com/trileet/gmap Modified Files: GMap.java Hit.java ImageCache.java MapWindow.java Tile.java TileSet.java Log Message: Implemented an idea contributed by Karl Gutwin to let the user know when a tile has been queued or is pending (by white background or yellow background). If you see a tile with a red background, it has somehow fallen out of the queue (this shouldn't ever happen, and in fact now happens much less often than before). Generally messed with queuing and tile request order. Fixed several small bugs, and optimized things a bit, so that tile-fetching should seem just a hair more speedy than before. Not sure if it is a noticeable change though. Index: MapWindow.java =================================================================== RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/MapWindow.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** MapWindow.java 8 Apr 2005 17:35:58 -0000 1.15 --- MapWindow.java 10 Apr 2005 10:23:48 -0000 1.16 *************** *** 142,145 **** --- 142,147 ---- } public boolean receiveEvent(Event e) { + if (e.type>0) + System.out.println(e.type); switch (e.type) { case TOGGLE_PATH: Index: Hit.java =================================================================== RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/Hit.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Hit.java 4 Apr 2005 03:00:19 -0000 1.14 --- Hit.java 10 Apr 2005 10:23:48 -0000 1.15 *************** *** 7,11 **** import danger.ui.*; import danger.app.*; ! import danger.io.obex.VCardGenerator; import java.util.Vector; --- 7,11 ---- import danger.ui.*; import danger.app.*; ! // import danger.io.obex.VCardGenerator; // it's restricted, so why bother? import java.util.Vector; *************** *** 148,152 **** // url = "http://hipster.trileet.com/tmpimg/img.php?url=" + url; ! String url = Tile.makeURL(m_point.x.toint(), m_point.y.toint(), zoom); ImageCache.requestImage(url, null); } --- 148,152 ---- // url = "http://hipster.trileet.com/tmpimg/img.php?url=" + url; ! String url = Tile.makeURL(m_point.x.toint()-1, m_point.y.toint(), zoom); ImageCache.requestImage(url, null); } Index: ImageCache.java =================================================================== RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/ImageCache.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** ImageCache.java 8 Apr 2005 17:35:58 -0000 1.11 --- ImageCache.java 10 Apr 2005 10:23:48 -0000 1.12 *************** *** 94,107 **** } } - - // Otherwise, add this message to our queue - if (priority) { - s_queued.insertElementAt(new ImageRequest(url, listener),0); - } - else { - s_queued.addElement(new ImageRequest(url, listener)); - } synchronized(s_queued){ ! s_queued.notifyAll(); } return null; --- 94,106 ---- } } synchronized(s_queued){ ! if (priority) { ! s_queued.insertElementAt(new ImageRequest(url, listener),priorityIndex++); ! } ! else { ! s_queued.addElement(new ImageRequest(url, listener)); ! } ! ! s_queued.notifyAll(); } return null; *************** *** 116,119 **** --- 115,122 ---- */ public void handleResponse(String url, HTTPTransaction response){ + /** Don't bother with it if we somehow already have this url. **/ + if (s_cache.containsKey(url)) + return; + // if it's not valid, no-op if (response != null && response.getResponse() != 200){ *************** *** 122,126 **** byte[] bytes = response.getBytes(); boolean kh = false; ! if (url.substring(7,9).equals("kh")) { System.out.println("Got a kh response"); kh = true; --- 125,130 ---- byte[] bytes = response.getBytes(); boolean kh = false; ! if (url.substring(7,9).equals("kh") || ! (url.length()>61 && url.substring(59,61).equals("kh"))) { System.out.println("Got a kh response"); kh = true; *************** *** 154,161 **** --- 158,167 ---- s_cache.put(url, image); s_numBitmaps++; + System.out.println("Got: "+url+","+String.valueOf(s_numBitmaps)); // If our cache is over 90, trim it // TODO: Make maintainign cache size smarter if (s_numBitmaps > 90){ + System.out.println("ImageCache Trimming."); trimCache(); } *************** *** 191,194 **** --- 197,201 ---- */ public static void cancelRequest(String url){ + //System.out.println("Cancelling:" + url); synchronized(s_queued){ for(int i=0; i<s_queued.size(); i++){ *************** *** 198,201 **** --- 205,209 ---- if (request.url.equals(url)){ s_queued.removeElementAt(i); + if (i < priorityIndex) priorityIndex--; i--; } *************** *** 204,214 **** } /** * Clears all the queued requests, except for requests to data store. */ ! public static void clearAllRequests(){ synchronized(s_queued) { int i=0; ! while (i < s_queued.size()) { if (((ImageRequest)s_queued.elementAt(i)).store) { i++; --- 212,241 ---- } + public static int requestStatus(String url) { + if (url == null) + return 0; + if (s_pending.containsKey(url)) { + return 2; // pending + } + synchronized(s_queued) { + for (int i=0; i < s_queued.size(); i++) { + ImageRequest request = (ImageRequest) s_queued.elementAt(i); + + if (request.url.equals(url)) { + return 1; // queued + } + } + } + return 0; // not present + } + /** * Clears all the queued requests, except for requests to data store. */ ! public static void clearAllPriorityRequests(){ ! //System.out.println("ImageCache clearing all queued requests."); synchronized(s_queued) { int i=0; ! while ((i < priorityIndex) && (i < s_queued.size())) { if (((ImageRequest)s_queued.elementAt(i)).store) { i++; *************** *** 218,221 **** --- 245,249 ---- } } + priorityIndex=0; } } *************** *** 261,264 **** --- 289,293 ---- ImageRequest nextRequest = (ImageRequest) s_queued.elementAt(0); s_queued.removeElementAt(0); + if (0 < priorityIndex) priorityIndex--; // Fire the requeset off *************** *** 437,443 **** /** Our vector of queued requests (these have not yet been requested and might ! * get cancelled before we do request them) */ private static Vector s_queued = new Vector(); ! /** Static instance */ private static ImageCache s_this; --- 466,474 ---- /** Our vector of queued requests (these have not yet been requested and might ! * get cancelled before we do request them). */ private static Vector s_queued = new Vector(); ! /** An int to keep track of the tail of the "priority" subqueue. **/ ! private static int priorityIndex = 0; ! /** Static instance */ private static ImageCache s_this; *************** *** 450,456 **** private static final String DATASTORE_NAME = "GMapImageDataStore"; ! private static final int DATASTORE_TYPE_IMG_PTR = 2; ! private static final int DATASTORE_TYPE_IMG = 4; ! private static final int DATASTORE_VERSION = 3; /** Our data store */ --- 481,485 ---- private static final String DATASTORE_NAME = "GMapImageDataStore"; ! private static final int DATASTORE_VERSION = 4; /** Our data store */ Index: TileSet.java =================================================================== RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/TileSet.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** TileSet.java 8 Apr 2005 17:35:58 -0000 1.23 --- TileSet.java 10 Apr 2005 10:23:48 -0000 1.24 *************** *** 38,42 **** */ public TileSet() { ! this(5, 6); } --- 38,42 ---- */ public TileSet() { ! this(5,5); } *************** *** 72,76 **** public void zoomIn() { ! if (m_zoom > 1) { setCenter(getLat(), getLng(), --m_zoom); } --- 72,76 ---- public void zoomIn() { ! if (m_zoom > 0) { setCenter(getLat(), getLng(), --m_zoom); } *************** *** 161,166 **** // Set the center for our tile set public void setCenter(hipfloat latFloat, hipfloat lngFloat, int zoom) { - // clear all pending requests - ImageCache.clearAllRequests(); hipfloat mapXFloat = getX(lngFloat, zoom); --- 161,164 ---- *************** *** 173,198 **** int mapX = mapXFloat.floor().toint(); int mapY = mapYFloat.floor().toint(); - int xRadius = getWidth() / 2; - int yRadius = getHeight() / 2 + 1; - - // Cache on screen tiles first - for (int x = 2; x < 5; x++) { - for (int y = 2; y < 4; y++) { - m_tiles[x][y].setTile(mapX - (xRadius - x), mapY - - (yRadius - y), zoom, true); - } - } - - // Cache all our tiles - for (int x = 0; x < getWidth(); x++) { - for (int y = 0; y < getHeight(); y++) { - // Don't get ones we just cached - if (x < 2 || x >= 5 || y < 2 || y >= 5) { - m_tiles[x][y].setTile(mapX - (xRadius - x), mapY - - (yRadius - y), zoom, false); - } - } - } - // we want to put our center smack dable in the middle of the screen --- 171,174 ---- *************** *** 206,209 **** --- 182,187 ---- // our center tile // is and ajust accordingly + int xRadius = getWidth() / 2; // = 2 + int yRadius = getHeight() / 2;// = 2 m_offsetX = (TILE_WIDTH * xRadius) + mapXFloat.sub(mapXFloat.floor()).mul(TILE_WIDTH_FLOAT) *************** *** 212,230 **** + mapYFloat.sub(mapYFloat.floor()).mul(TILE_WIDTH_FLOAT) .toint() - 70; ! // Update our zoom ! m_zoom = zoom; ! /** ! * // If our zoom is different, update our hits for(int i=0; i<GMap.s_hits.size(); ! * i++){ ((Hit)GMap.s_hits.elementAt(i)).setZoom(m_zoom); } */ } // Checks our center, reordering our tile set accordingly if needed public void checkCenter() { ! if (m_offsetX < TILE_WIDTH || m_offsetX > TILE_WIDTH * 3 ! || m_offsetY < TILE_WIDTH || m_offsetY > TILE_WIDTH * 3) { ! // recenter based on where we are int indexX = m_offsetX / TILE_WIDTH; --- 190,239 ---- + mapYFloat.sub(mapYFloat.floor()).mul(TILE_WIDTH_FLOAT) .toint() - 70; + m_zoom=zoom; + setMapTilesByCenter(mapX, mapY, zoom); + } + /** + * This helper function ONLY manages which tiles point to which + * images, and what order they are loaded in. + */ + private void setMapTilesByCenter(int mapX, int mapY,int zoom) { + /** Fine-tuned for the 5x5 tileset. **/ ! ImageCache.clearAllPriorityRequests(); ! int xRadius = getWidth() / 2; // = 2 ! int yRadius = getHeight() / 2;// = 2 ! /** Cache on screen tiles first. Here's the order we ask the tiles in: ! * 25 18 13 21 24 ! * 15 07 04 09 16 ! * 11 02 01 03 10 ! * 14 08 05 06 17 ! * 22 20 12 19 23 ! * ! * This is meant to emphasize horizontal expansion ! * before vertical, because the screen is wider than ! * it is tall. However, it is meant to be as agnostic ! * as possible between east/west expansion and ! * north/south expansion. If you think you can do better, please improve it. */ + int[] loadOrderX = {2,1,3,2,2,3,1,1,3,4,0,2,2,0,0,4,4,1,3,1,3,0,4,4,0}; + int[] loadOrderY = {2,2,2,1,3,3,1,3,1,2,2,4,0,3,1,1,3,0,4,4,0,4,4,0,0}; + int x,y; + for (int i=0; i< loadOrderX.length;i++) { + x = loadOrderX[i]; + y = loadOrderY[i]; + m_tiles[x][y].setTile(mapX - (xRadius - x), mapY + - (yRadius - y), zoom, + true); + } + + GMap.invalidateMap(); } // Checks our center, reordering our tile set accordingly if needed public void checkCenter() { ! /** Fine-tuned for the 5x5 tileset. **/ ! if (m_offsetX < TILE_WIDTH/2 || m_offsetX > TILE_WIDTH * 3 ! || m_offsetY < TILE_WIDTH/2 || m_offsetY > TILE_WIDTH * 3) { // recenter based on where we are int indexX = m_offsetX / TILE_WIDTH; *************** *** 234,261 **** int mapY = m_tiles[indexX][indexY].getY(); ! int xRadius = (getWidth() / 2) - 1; ! int yRadius = (getHeight() / 2); ! for (int x = 0; x < getWidth(); x++) { ! for (int y = 0; y < getHeight(); y++) { ! // System.out.println("Setting: " + x + "," + y + " to: " + ! // (mapX - (xRadius - x)) + "," + (mapY - (yRadius - y))); ! m_tiles[x][y].setTile(mapX - (xRadius - x), mapY ! - (yRadius - y), m_zoom); ! } ! } // Figure out our offset based on how much we moved m_offsetX = m_offsetX % TILE_WIDTH + TILE_WIDTH * 2; m_offsetY = m_offsetY % TILE_WIDTH + TILE_WIDTH * 2; } - /** - String khCenter = Point.latLngToKH(getLat(),getLng()); - String khTail = khCenter.substring(18-m_zoom); - - System.out.println(khCenter); - System.out.println(khToXOff(khTail)); - System.out.println(khToYOff(khTail)); - **/ if (displayPhoto) enterPhotoMode(); --- 243,254 ---- int mapY = m_tiles[indexX][indexY].getY(); ! // Figure out our offset based on how much we moved m_offsetX = m_offsetX % TILE_WIDTH + TILE_WIDTH * 2; m_offsetY = m_offsetY % TILE_WIDTH + TILE_WIDTH * 2; + setMapTilesByCenter(mapX, mapY,m_zoom); } if (displayPhoto) enterPhotoMode(); *************** *** 557,560 **** --- 550,560 ---- displayPhoto = true; GMap.invalidateMap(); + /** + System.out.println(getLat()); + System.out.println(getLng()); + System.out.println(khCenter); + System.out.println(khTail); + System.out.println(m_offsetXPhoto); + **/ } public void exitPhotoMode() { *************** *** 575,582 **** * referring to. */ ! int khToXOff(String khTail) { int x = 0; for (int i=0; i <8; i++) { - x = x << 1; char c='t'; if (khTail.length()>i) --- 575,581 ---- * referring to. */ ! static int khToXOff(String khTail) { int x = 0; for (int i=0; i <8; i++) { char c='t'; if (khTail.length()>i) *************** *** 588,592 **** case 'r': case 's': ! x |= 1; break; default: --- 587,591 ---- case 'r': case 's': ! x |= (1<<(7-i)); break; default: *************** *** 597,604 **** return 120-x; } ! int khToYOff(String khTail) { int y = 0; for (int i=0; i <8; i++) { - y = y << 1; char c='t'; if (khTail.length()>i) --- 596,602 ---- return 120-x; } ! static int khToYOff(String khTail) { int y = 0; for (int i=0; i <8; i++) { char c='t'; if (khTail.length()>i) *************** *** 610,614 **** case 'r': case 'q': ! y |= 1; break; default: --- 608,612 ---- case 'r': case 'q': ! y |= (1<<(7-i)); break; default: *************** *** 653,656 **** --- 651,657 ---- } + public static void main(String[] argv) { + System.out.println(khToXOff("qtssqtssr")); + } /** Our 2d array of tiles, first dimension is x, second is y */ private Tile[][] m_tiles; *************** *** 661,685 **** /** Our width and height of our tile set */ private int m_width; - private int m_height; - /** Our center of our view */ - private hipfloat m_centerX; - - private hipfloat m_centerY; - - /** Our incremet to the right and left */ - private hipfloat m_incrementX; - - private hipfloat m_incrementY; - /** Size of the tiles (128) */ public static final int TILE_WIDTH = 128; - public static final hipfloat TILE_WIDTH_FLOAT = new hipfloat(TILE_WIDTH); /** Our drawing offset for our tile set */ private int m_offsetX = TILE_WIDTH * 2; - private int m_offsetY = TILE_WIDTH * 2; --- 662,673 ---- Index: GMap.java =================================================================== RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/GMap.java,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** GMap.java 8 Apr 2005 17:35:58 -0000 1.26 --- GMap.java 10 Apr 2005 10:23:48 -0000 1.27 *************** *** 52,56 **** --- 52,60 ---- */ public boolean receiveEvent(Event e) { + if (e.type>0) + System.out.println(e.type); switch (e.type) { + case SAVE_TILE: + return s_mapWindow.receiveEvent(e); case SEARCH: //getSearchDialog().show(); *************** *** 247,251 **** (url.length()>61 && url.substring(59,61).equals("kh")) ) { ! System.out.println("Got a kh response"); kh = true; } --- 251,255 ---- (url.length()>61 && url.substring(59,61).equals("kh")) ) { ! kh = true; } Index: Tile.java =================================================================== RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/Tile.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Tile.java 8 Apr 2005 17:35:58 -0000 1.6 --- Tile.java 10 Apr 2005 10:23:48 -0000 1.7 *************** *** 5,8 **** --- 5,9 ---- import danger.net.URLEncoder; import danger.ui.Bitmap; + import danger.ui.Color; /** *************** *** 21,25 **** */ public class Tile implements ImageCache.Listener { ! public static final int WIDTH = 128; --- 22,26 ---- */ public class Tile implements ImageCache.Listener { ! public static final int WIDTH = 128; *************** *** 28,39 **** } ! public void paint(Pen p, int x, int y) { ! if (m_bitmap != null){ ! p.drawBitmap(x, y, m_bitmap); ! } else { ! p.drawRect(x, y, x + WIDTH, y + WIDTH); ! p.drawText(x + 30, y + 30, "X: " + m_x + " Y: " + m_y); ! p.drawText(x + 30, y + 50, "ZOOM: " + m_zoom); } } --- 29,55 ---- } ! public void paint(Pen p, int x, int y) { ! if (m_bitmap != null){ ! p.drawBitmap(x, y, m_bitmap); ! } else { ! p.push(); ! int stat = ImageCache.requestStatus(m_url); ! if (stat == 1) { ! p.setColor(Color.WHITE); ! } else if (stat == 2) { ! p.setColor(Color.YELLOW); } + else { + p.setColor(Color.RED); + } + p.fillRect(x, y, x + WIDTH, y + WIDTH); + p.setColor(Color.BLACK); + p.drawRect(x, y, x + WIDTH, y + WIDTH); + p.drawText(x + 30, y + 30, "X: " + m_x + " Y: " + m_y); + p.drawText(x + 30, y + 50, "ZOOM: " + m_zoom); + p.pop(); + + } + } *************** *** 48,57 **** // clear out bitmap m_bitmap = null; ! // if our old url is not null and we still don't have a response from it, cancel that request if (m_url != null && m_bitmap == null){ ImageCache.cancelRequest(m_url); } ! // go request the tile! //m_url = "http://mt.google.com/mt%3Fv%3D.1%26x%3D" + m_x + "%26y%3D" + m_y + "%26zoom%3D" + m_zoom; --- 64,75 ---- // clear out bitmap m_bitmap = null; ! ! /** // if our old url is not null and we still don't have a response from it, cancel that request if (m_url != null && m_bitmap == null){ ImageCache.cancelRequest(m_url); } ! **/ ! // go request the tile! //m_url = "http://mt.google.com/mt%3Fv%3D.1%26x%3D" + m_x + "%26y%3D" + m_y + "%26zoom%3D" + m_zoom; *************** *** 62,66 **** // Invalidate our map ! GMap.invalidateMap(); } public static String makeURL(int x, int y, int zoom) { --- 80,84 ---- // Invalidate our map ! //GMap.invalidateMap(); } public static String makeURL(int x, int y, int zoom) { *************** *** 80,83 **** --- 98,102 ---- GMap.invalidateMap(); } + //System.out.println("Tile.handleImage:"+url+((image==null)?" null":" notnull")); } |
|
From: Adam B. <ab...@us...> - 2005-04-10 10:23:58
|
Update of /cvsroot/hipgmap/gmap/locale/en_US In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1962/locale/en_US Modified Files: GMap.rsrc Log Message: Implemented an idea contributed by Karl Gutwin to let the user know when a tile has been queued or is pending (by white background or yellow background). If you see a tile with a red background, it has somehow fallen out of the queue (this shouldn't ever happen, and in fact now happens much less often than before). Generally messed with queuing and tile request order. Fixed several small bugs, and optimized things a bit, so that tile-fetching should seem just a hair more speedy than before. Not sure if it is a noticeable change though. Index: GMap.rsrc =================================================================== RCS file: /cvsroot/hipgmap/gmap/locale/en_US/GMap.rsrc,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** GMap.rsrc 8 Apr 2005 17:41:18 -0000 1.15 --- GMap.rsrc 10 Apr 2005 10:23:49 -0000 1.16 *************** *** 70,74 **** menu MAP_MENU menuItem title="Toggle Path" id=kID_togglePath event=TOGGLE_PATH shortcut='p' ! menuItem title="Save Tile" id=kID_saveTile event=SAVE_TILE shortcut='s' menuItem title="Search Near Here" id=kID_SearchMap event=SEARCH_MAP shortcut='n' menuItem title="Current Hit..." id=kID_hitsSubMenuMap subMenu=HITS_SUBMENU --- 70,74 ---- menu MAP_MENU menuItem title="Toggle Path" id=kID_togglePath event=TOGGLE_PATH shortcut='p' ! menuItem title="Save Tile" id=kID_saveTile event=SAVE_TILE shortcut='a' menuItem title="Search Near Here" id=kID_SearchMap event=SEARCH_MAP shortcut='n' menuItem title="Current Hit..." id=kID_hitsSubMenuMap subMenu=HITS_SUBMENU |
|
From: Nicolas P. <nic...@us...> - 2005-04-09 21:56:56
|
Update of /cvsroot/hipgmap/gmap/com/trileet/gmap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9664/com/trileet/gmap Modified Files: HitBox.java SearchWindow.java Log Message: Make search results much prettier, ahh, the joys of bold. Index: HitBox.java =================================================================== RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/HitBox.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** HitBox.java 3 Apr 2005 11:21:53 -0000 1.10 --- HitBox.java 9 Apr 2005 21:56:48 -0000 1.11 *************** *** 2,5 **** --- 2,6 ---- import danger.ui.*; + import danger.util.LineBreaker; import danger.app.*; *************** *** 23,27 **** private int debug = 0; ! public HitBox(Hit h) { // Do all the usual StaticTextBox stuff first. super(); --- 24,32 ---- private int debug = 0; ! /** Horizontal and vertical margins for our text */ ! public static final int V_MARGIN = 4; ! public static final int H_MARGIN = 3; ! ! public HitBox(Hit h, int width) { // Do all the usual StaticTextBox stuff first. super(); *************** *** 32,60 **** // Set our default click to show the hit this.setEvent(new Event(Application.getCurrentApp(),SHOW_HIT,0,0,m_hit)); ! this.setAutoResize(true); ! String s = new String(); ! if (h.title.length() > 0) { ! if (s.length()>0) s+="\n"; ! s += h.title; ! } ! if (h.address1.length() > 0) { ! if (s.length()>0) s+="\n"; ! s += h.address1; ! } ! if (h.address2.length() > 0) { ! if (s.length()>0) s+="\n"; ! s += h.address2; ! } ! if (h.address3.length() > 0) { ! if (s.length()>0) s+="\n"; ! s += h.address3; ! } ! if (h.phone.length() > 0) { ! if (s.length()>0) s+="\n"; ! s += h.phone; ! } ! this.setText(s); ! } --- 37,56 ---- // Set our default click to show the hit this.setEvent(new Event(Application.getCurrentApp(),SHOW_HIT,0,0,m_hit)); + this.setAutoResize(false); ! setWidth(width); ! ! // height starts out being our top and bottom vertical margins ! int currentY = V_MARGIN * 2; ! Font bf = Font.findBoldSystemFont(); ! Font f = Font.findSystemFont(); ! ! currentY = paintLine(null, bf, m_hit.title, currentY); ! currentY = paintLine(null, f, m_hit.address1, currentY); ! currentY = paintLine(null, f, m_hit.address2, currentY); ! currentY = paintLine(null, f, m_hit.address3, currentY); ! currentY = paintLine(null, bf, m_hit.phone, currentY); ! ! setHeight(currentY); } *************** *** 62,74 **** p.push(); if (isFocused()) { ! this.setBackgroundColor(Color.BLUE); p.setColor(Color.WHITE); } else { ! this.setBackgroundColor(Color.WHITE); p.setColor(Color.BLACK); } ! super.paint(p); p.pop(); } void adjustContextMenuState(Menu menu) { --- 58,132 ---- p.push(); if (isFocused()) { ! p.setColor(Color.BLUE); ! p.fillRoundRect(0, 0, getWidth(), getHeight(), 3, 3); p.setColor(Color.WHITE); } else { ! p.setColor(Color.WHITE); ! p.fillRect(0, 0, getWidth(), getHeight()); p.setColor(Color.BLACK); } ! ! Font bf = Font.findBoldSystemFont(); ! Font f = Font.findSystemFont(); ! ! int currentY = bf.getAscent() + V_MARGIN; ! ! p.setFont(bf); ! currentY = paintLine(p, bf, m_hit.title, currentY); ! ! p.setFont(f); ! currentY = paintLine(p, f, m_hit.address1, currentY); ! currentY = paintLine(p, f, m_hit.address2, currentY); ! currentY = paintLine(p, f, m_hit.address3, currentY); ! ! p.setFont(bf); ! currentY = paintLine(p, bf, m_hit.phone, currentY); ! p.pop(); } + + /** + * Paints the passed in line, using linebreaks as necessary + * + * + * @param p The pen to draw to, optionally null if no painting is desired + * @param f The font to use + * @param line The line to paint + * @param currentY The current Y position to start at + * @return The new Y position to start drawing at + */ + private int paintLine(Pen p, Font f, String line, int currentY){ + // Nothing to do, move on + if (line.length() <= 0){ + return currentY; + } + + // Will this line fit? + int availWidth = getWidth() - H_MARGIN * 2; + + // If not, break it + if (f.getWidth(line) >= availWidth){ + LineBreaker breaker = new LineBreaker(line, f, availWidth); + int lastBreak = 0; + int currentBreak = 0; + while((currentBreak = breaker.nextLineBreak(lastBreak)) < line.length()){ + String segment = line.substring(lastBreak, currentBreak); + if (p != null) p.drawText(H_MARGIN, currentY, segment); + currentY += f.getAscent() + f.getDescent(); + lastBreak = currentBreak; + } + + String segment = line.substring(lastBreak); + if (p != null) p.drawText(H_MARGIN, currentY, segment); + currentY += f.getAscent() + f.getDescent(); + } + // Otherwise, draw it + else { + if (p != null) p.drawText(H_MARGIN, currentY, line); + currentY += f.getAscent() + f.getDescent(); + } + + return currentY; + } void adjustContextMenuState(Menu menu) { Index: SearchWindow.java =================================================================== RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/SearchWindow.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** SearchWindow.java 4 Apr 2005 03:00:19 -0000 1.16 --- SearchWindow.java 9 Apr 2005 21:56:48 -0000 1.17 *************** *** 69,83 **** if(false) { Vector hits = new Vector(); ! Hit hit = new Hit("test", new hipfloat(1), new hipfloat(1)); ! hit.address1 = "asdf"; hits.addElement(hit); ! hit = new Hit("Another test", new hipfloat(1), new hipfloat(1)); hits.addElement(hit); ! hit = new Hit("test3", new hipfloat(1), new hipfloat(1)); ! hit.address1 = "asdf"; ! hit.phone="8005551212"; hits.addElement(hit); ! hit = new Hit("test4", new hipfloat(1), new hipfloat(1)); ! hit.address1 = "aoeu"; hit.phone="8005551212"; hits.addElement(hit); --- 69,86 ---- if(false) { Vector hits = new Vector(); ! Hit hit = new Hit("Hit numero uno", new hipfloat(1), new hipfloat(1)); ! hit.address1 = "10100 ne 7th"; ! hit.address2 = "Santa Cruz, CA 12452"; ! hit.phone = "(235) 124-5323"; hits.addElement(hit); ! hit = new Hit("Hit Numero Deux", new hipfloat(1), new hipfloat(1)); hits.addElement(hit); ! hit = new Hit("Three Hits, I love counting Hits", new hipfloat(1), new hipfloat(1)); ! hit.address1 = "1400 Hit Ave"; ! hit.address2 = "Hollywood, CA 12532"; ! hit.phone="(800) 555-1212"; hits.addElement(hit); ! hit = new Hit("Four Hits, The fourth longer than the previous three, Four hits I say!", new hipfloat(1), new hipfloat(1)); ! hit.address1 = "More Addresses for the Fourth Hit"; hit.phone="8005551212"; hits.addElement(hit); *************** *** 89,96 **** setHits(); GMap.getMapWindow().setHits(); - //*/ } else { ! // Show our help cells showHelp(); } --- 92,98 ---- setHits(); GMap.getMapWindow().setHits(); } else { ! // Show our help cells showHelp(); } *************** *** 346,351 **** private void addHit(Hit h) { ! HitBox hb = new HitBox(h); ! hb.setSize(218, 10); m_results.addChild(hb); hb.setFont(Font.findFont("Bort9")); --- 348,352 ---- private void addHit(Hit h) { ! HitBox hb = new HitBox(h, 218); m_results.addChild(hb); hb.setFont(Font.findFont("Bort9")); *************** *** 354,379 **** m_currentY += hb.getHeight(); } public void handleVCard( IPCMessage ipcm) { ! String vcard = ipcm.findString("vcard"); ! StringBuffer munged = new StringBuffer(); ! /** Parse the VCard content and get the searchable address. ! * TODO: This needs a lot of improvement... ! **/ ! int i = vcard.indexOf("ADR;"); ! if (i<0) { ! return; } ! i = vcard.indexOf(":",i); ! int j; ! do { ! j = vcard.indexOf("\r\n",i); ! munged.append(vcard.substring(i+1,j)); ! i = j+2; ! } while (vcard.substring(j+2,j+3).equals(" ")); ! vcard = munged.toString(); ! vcard = vcard.replace(';',','); ! m_searchField.insert(vcard); ! ! } /** Our search field */ private TextField m_searchField; --- 355,382 ---- m_currentY += hb.getHeight(); } + public void handleVCard( IPCMessage ipcm) { ! String vcard = ipcm.findString("vcard"); ! StringBuffer munged = new StringBuffer(); ! /** ! * Parse the VCard content and get the searchable address. TODO: This ! * needs a lot of improvement... ! */ ! int i = vcard.indexOf("ADR;"); ! if (i < 0) { ! return; ! } ! i = vcard.indexOf(":", i); ! int j; ! do { ! j = vcard.indexOf("\r\n", i); ! munged.append(vcard.substring(i + 1, j)); ! i = j + 2; ! } while (vcard.substring(j + 2, j + 3).equals(" ")); ! vcard = munged.toString(); ! vcard = vcard.replace(';', ','); ! m_searchField.insert(vcard); } ! /** Our search field */ private TextField m_searchField; |
|
From: Adam B. <ab...@us...> - 2005-04-08 17:41:28
|
Update of /cvsroot/hipgmap/gmap/locale/en_US In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20069/locale/en_US Modified Files: GMap.rsrc Log Message: rsrc update to go with previous checkin. Index: GMap.rsrc =================================================================== RCS file: /cvsroot/hipgmap/gmap/locale/en_US/GMap.rsrc,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** GMap.rsrc 4 Apr 2005 03:00:20 -0000 1.14 --- GMap.rsrc 8 Apr 2005 17:41:18 -0000 1.15 *************** *** 70,84 **** menu MAP_MENU menuItem title="Toggle Path" id=kID_togglePath event=TOGGLE_PATH shortcut='p' ! menuItem title="Debug" id=kID_beug event=DEBUG shortcut='q' menuItem title="Search Near Here" id=kID_SearchMap event=SEARCH_MAP shortcut='n' menuItem title="Current Hit..." id=kID_hitsSubMenuMap subMenu=HITS_SUBMENU ! endMenu menu WINDOW_MENU ! menuItem title="Show Map" id=kID_showMap event=SHOW_MAP shortcut='m' ! menuItem title="Search" id=kID_search event=SEARCH shortcut='s' ! menuItem title="Show Directions" id=kID_showDirs event=SHOW_DIRS shortcut='d' ! menuItem title="Show Hits" id=kID_showHits event=SHOW_HITS shortcut='h' endMenu --- 70,84 ---- menu MAP_MENU menuItem title="Toggle Path" id=kID_togglePath event=TOGGLE_PATH shortcut='p' ! menuItem title="Save Tile" id=kID_saveTile event=SAVE_TILE shortcut='s' menuItem title="Search Near Here" id=kID_SearchMap event=SEARCH_MAP shortcut='n' menuItem title="Current Hit..." id=kID_hitsSubMenuMap subMenu=HITS_SUBMENU ! menuItem title="Debug" id=kID_beug event=DEBUG shortcut='q' endMenu menu WINDOW_MENU ! menuItem title="Search" id=kID_search event=SEARCH shortcut='1' ! menuItem title="Show Map" id=kID_showMap event=SHOW_MAP shortcut='2' ! menuItem title="Show Directions" id=kID_showDirs event=SHOW_DIRS shortcut='3' ! menuItem title="Show Hits" id=kID_showHits event=SHOW_HITS shortcut='4' endMenu |
|
From: Adam B. <ab...@us...> - 2005-04-08 17:36:10
|
Update of /cvsroot/hipgmap/gmap/com/trileet/gmap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16048 Modified Files: GMap.java ImageCache.java MapWindow.java Point.java Tile.java TileSet.java Log Message: A nearly functional photo routine. Pressing Menu+Q takes you into Photo mode, where your photo will be displayed instead of the map. The photo is also requested when you go into photo mode. It is NOT requested if you scroll off the photo--you have to go back to map mode (menu+q) and into photo mode again to make the request. This is to limit bandwidth-heavy requests of photos. Right now, it's set to use Nic's img.php script to convert the JPEGs to PNGs. However, the phone doesn't seem to be able to decode _those_ either. Index: Point.java =================================================================== RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/Point.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Point.java 8 Apr 2005 00:07:53 -0000 1.5 --- Point.java 8 Apr 2005 17:35:58 -0000 1.6 *************** *** 89,106 **** private static final hipfloat h180 = new hipfloat(180); private static final hipfloat h360 = new hipfloat(360); ! private static final hipfloat h2p18 = new hipfloat(1<<19); private static final char[] KHCHARS = {'t','q','s','r'}; /** ! * Returns a string of length 19. First char is t. Remaining * chars encode the given point. */ public static String latLngToKH(hipfloat lat, hipfloat lng) { ! int y = lat.add(h180).div(h360).mul(h2p18).toint(); ! int x = lng.add(h180).div(h360).mul(h2p18).toint(); ! char[] outArr = new char[19]; ! for (int i=0; i<19; i++) { ! int index = ((x & 1<<(19-i))>>(18-i)); ! index |= ((y & 1<<(19-i))>>(19-i)); outArr[i] = KHCHARS[index]; } --- 89,106 ---- private static final hipfloat h180 = new hipfloat(180); private static final hipfloat h360 = new hipfloat(360); ! private static final hipfloat h2p26 = new hipfloat(1<<27); private static final char[] KHCHARS = {'t','q','s','r'}; /** ! * Returns a string of length 27. First char is t. Remaining * chars encode the given point. */ public static String latLngToKH(hipfloat lat, hipfloat lng) { ! int y = lat.add(h180).div(h360).mul(h2p26).toint(); ! int x = lng.add(h180).div(h360).mul(h2p26).toint(); ! char[] outArr = new char[27]; ! for (int i=0; i<27; i++) { ! int index = ((x & 1<<(27-i))>>(26-i)); ! index |= ((y & 1<<(27-i))>>(27-i)); outArr[i] = KHCHARS[index]; } Index: ImageCache.java =================================================================== RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/ImageCache.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** ImageCache.java 8 Apr 2005 00:07:52 -0000 1.10 --- ImageCache.java 8 Apr 2005 17:35:58 -0000 1.11 *************** *** 125,130 **** System.out.println("Got a kh response"); kh = true; - /** System.out.println(bytes.length); for (int i=0; i<=32; i++) { System.out.print(Integer.toHexString((int)(bytes[i]))); --- 125,130 ---- System.out.println("Got a kh response"); kh = true; System.out.println(bytes.length); + /** for (int i=0; i<=32; i++) { System.out.print(Integer.toHexString((int)(bytes[i]))); Index: TileSet.java =================================================================== RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/TileSet.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** TileSet.java 8 Apr 2005 00:07:53 -0000 1.22 --- TileSet.java 8 Apr 2005 17:35:58 -0000 1.23 *************** *** 248,253 **** m_offsetX = m_offsetX % TILE_WIDTH + TILE_WIDTH * 2; m_offsetY = m_offsetY % TILE_WIDTH + TILE_WIDTH * 2; ! photoAvailable = ImageCache.hasImage(Tile.makePhotoURL(Point.latLngToKH(getLat(),getLng()),m_zoom)); } } --- 248,263 ---- m_offsetX = m_offsetX % TILE_WIDTH + TILE_WIDTH * 2; m_offsetY = m_offsetY % TILE_WIDTH + TILE_WIDTH * 2; ! } + /** + String khCenter = Point.latLngToKH(getLat(),getLng()); + String khTail = khCenter.substring(18-m_zoom); + + System.out.println(khCenter); + System.out.println(khToXOff(khTail)); + System.out.println(khToYOff(khTail)); + **/ + if (displayPhoto) + enterPhotoMode(); } *************** *** 354,411 **** // paints this tile set, given the offset from the center ! public void paint(Pen p) { ! if (!displayPhoto) { ! int m_hitX = -1; ! int m_hitY = -1; ! for (int x = 0; x < getWidth(); x++) { ! for (int y = 0; y < getHeight(); y++) { ! int startX = x * TILE_WIDTH - m_offsetX; ! int startY = y * TILE_WIDTH - m_offsetY; ! if (startX > -TILE_WIDTH && startX < 240 ! && startY > -TILE_WIDTH && startY < 140) { ! m_tiles[x][y].paint(p, startX, startY); ! } ! } } ! // draw our hits ! int startX = m_tiles[0][0].getX(); ! int startY = m_tiles[0][0].getY(); ! // draw our polyline. ! if (m_polyline != null && m_drawPoly) { ! m_polyline.paint(p, m_offsetX, m_offsetY, startX, startY, m_zoom); ! } ! ! for (int i = 0; i < GMap.s_hits.size(); i++) { ! Hit hit = (Hit) GMap.s_hits.elementAt(i); ! // if this is our current hit, skip it, we'll draw it last ! if (i != m_currentHit){ ! hit.paint(p, m_offsetX, m_offsetY, startX, startY, m_zoom, false); ! } ! } ! // draw our current hit ! if (m_currentHit >= 0 && m_currentHit < GMap.s_hits.size()){ ! Hit hit = (Hit) GMap.s_hits.elementAt(m_currentHit); ! hit.paint(p, m_offsetX, m_offsetY, startX, startY, m_zoom, (m_display == DISPLAY_ALL)); ! } ! } ! else { ! // Photo mode. ! String khCenter = Point.latLngToKH(getLat(),getLng()); ! Bitmap photo = ImageCache.requestImage(Tile.makePhotoURL(khCenter,m_zoom),null); ! if (photo == null) { ! System.out.println("Null photo!"); ! return; ! } ! String khTail = khCenter.substring(18-m_zoom); ! p.drawBitmap(khToXOff(khTail),khToYOff(khTail),photo); ! } } public int getHeight() { --- 364,421 ---- // paints this tile set, given the offset from the center ! public void paint(Pen p) { ! int m_hitX = -1; ! int m_hitY = -1; ! if (!displayPhoto) { ! for (int x = 0; x < getWidth(); x++) { ! for (int y = 0; y < getHeight(); y++) { ! int startX = x * TILE_WIDTH - m_offsetX; ! int startY = y * TILE_WIDTH - m_offsetY; ! if (startX > -TILE_WIDTH && startX < 240 ! && startY > -TILE_WIDTH && startY < 140) { ! m_tiles[x][y].paint(p, startX, startY); ! } } + } + } + else { + // Photo mode. + p.drawRect(m_offsetXPhoto,m_offsetYPhoto, + m_offsetXPhoto+256,m_offsetYPhoto+256); + if (m_photo != null) { + p.drawBitmap(m_offsetXPhoto,m_offsetYPhoto,m_photo); + } + else { + p.drawText(m_offsetXPhoto+128,m_offsetYPhoto+128,"Wait"); + } ! } ! // draw our hits ! int startX = m_tiles[0][0].getX(); ! int startY = m_tiles[0][0].getY(); ! ! // draw our polyline. ! if (m_polyline != null && m_drawPoly) { ! m_polyline.paint(p, m_offsetX, m_offsetY, startX, startY, m_zoom); ! } ! for (int i = 0; i < GMap.s_hits.size(); i++) { ! Hit hit = (Hit) GMap.s_hits.elementAt(i); ! // if this is our current hit, skip it, we'll draw it last ! if (i != m_currentHit){ ! hit.paint(p, m_offsetX, m_offsetY, startX, startY, m_zoom, false); } } + + // draw our current hit + if (m_currentHit >= 0 && m_currentHit < GMap.s_hits.size()){ + Hit hit = (Hit) GMap.s_hits.elementAt(m_currentHit); + hit.paint(p, m_offsetX, m_offsetY, startX, startY, m_zoom, (m_display == DISPLAY_ALL)); + } + } public int getHeight() { *************** *** 504,509 **** } } ! ! public void drill(int x, int y, int zoom, int lowestZoom) { /** * Assume the given map tile is of interest. We will --- 514,527 ---- } } ! public void drill() { ! /** ! * Drill the center tile and current zoom, down to 2. ! */ ! drill(m_tiles[getWidth()/2][getHeight()/2].getX(), ! m_tiles[getWidth()/2][getHeight()/2].getY(), ! m_zoom, ! 2); ! } ! private void drill(int x, int y, int zoom, int lowestZoom) { /** * Assume the given map tile is of interest. We will *************** *** 521,525 **** public void enterPhotoMode() { ! System.out.println("Photo mode on"); displayPhoto = true; GMap.invalidateMap(); --- 539,558 ---- public void enterPhotoMode() { ! // Mess with photo ! String khCenter = Point.latLngToKH(getLat(),getLng()); ! String photoURL = Tile.makePhotoURL(khCenter,m_zoom); ! if (ImageCache.hasImage(photoURL)) { ! m_photo = ImageCache.requestImage(photoURL,null); ! } ! else { ! m_photo = null; ! } ! String khTail = khCenter.substring(18-m_zoom); ! /** ! **/ ! m_offsetXPhoto = khToXOff(khTail); ! m_offsetYPhoto = khToYOff(khTail); ! ! displayPhoto = true; GMap.invalidateMap(); *************** *** 599,606 **** 2); **/ ! String tempurl = Tile.makePhotoURL(Point.latLngToKH(getLat(),getLng()),m_zoom); ! photoAvailable = ImageCache.hasImage(tempurl); System.out.println("Photo "+(photoAvailable?"yes":"no")); ! if (photoAvailable && !displayPhoto) { enterPhotoMode(); } --- 632,647 ---- 2); **/ ! boolean photoAvailable = (m_photo != null); System.out.println("Photo "+(photoAvailable?"yes":"no")); ! if (!photoAvailable) { ! String khCenter = Point.latLngToKH(getLat(),getLng()); ! String photoURL = Tile.makePhotoURL(khCenter,m_zoom); ! ! ImageCache.requestImage(photoURL, ! null, true); ! } ! if (!displayPhoto) { ! System.out.println("Photo mode on"); ! enterPhotoMode(); } *************** *** 608,615 **** exitPhotoMode(); } - else { - ImageCache.requestImage(tempurl, - null, true); - } m_debug = !m_debug; --- 649,652 ---- *************** *** 698,703 **** public MapWindow parentMapWindow; - public boolean photoAvailable = false; private boolean displayPhoto = false; int m_offsetXPhoto; int m_offsetYPhoto; --- 735,740 ---- public MapWindow parentMapWindow; private boolean displayPhoto = false; + private Bitmap m_photo; int m_offsetXPhoto; int m_offsetYPhoto; Index: GMap.java =================================================================== RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/GMap.java,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** GMap.java 8 Apr 2005 00:07:50 -0000 1.25 --- GMap.java 8 Apr 2005 17:35:58 -0000 1.26 *************** *** 243,247 **** public static int requestURL(String url, ResponseListener listener){ boolean kh = false; ! if (url.substring(7,9).equals("kh")) { System.out.println("Got a kh response"); kh = true; --- 243,250 ---- public static int requestURL(String url, ResponseListener listener){ boolean kh = false; ! //http://hipster.trileet.com/tmpimg/img.php?url=http%3A%2F%2Fkh ! if ((url.length()>9 && url.substring(7,9).equals("kh")) || ! (url.length()>61 && url.substring(59,61).equals("kh")) ! ) { System.out.println("Got a kh response"); kh = true; *************** *** 249,253 **** System.out.println("REQUESTING: " + url); ! HTTPConnection.get(url, null, (short) 0, ++s_transactionId, true);//!kh); s_listeners.put(new Integer(s_transactionId), new Request(url, listener)); return s_transactionId; --- 252,256 ---- System.out.println("REQUESTING: " + url); ! HTTPConnection.get(url, null, (short) 0, ++s_transactionId, !kh); s_listeners.put(new Integer(s_transactionId), new Request(url, listener)); return s_transactionId; Index: Tile.java =================================================================== RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/Tile.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Tile.java 7 Apr 2005 02:18:16 -0000 1.5 --- Tile.java 8 Apr 2005 17:35:58 -0000 1.6 *************** *** 3,6 **** --- 3,7 ---- import danger.ui.Pen; import danger.net.HTTPTransaction; + import danger.net.URLEncoder; import danger.ui.Bitmap; *************** *** 67,71 **** } public static String makePhotoURL(String khCoords, int zoom) { ! return "http://kh.google.com/kh?v=1&t=" + khCoords.substring(0,18-zoom); } public void handleImage(String url, Bitmap image){ --- 68,73 ---- } public static String makePhotoURL(String khCoords, int zoom) { ! return "http://hipster.trileet.com/tmpimg/img.php?url=" + ! URLEncoder.encode("http://kh.google.com/kh?v=1&t=" + khCoords.substring(0,18-zoom)); } public void handleImage(String url, Bitmap image){ Index: MapWindow.java =================================================================== RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/MapWindow.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** MapWindow.java 4 Apr 2005 03:00:19 -0000 1.14 --- MapWindow.java 8 Apr 2005 17:35:58 -0000 1.15 *************** *** 146,151 **** m_tileSet.toggleDrawPoly(); return true; ! } return super.receiveEvent(e); } --- 146,158 ---- m_tileSet.toggleDrawPoly(); return true; ! case DEBUG: ! debug(); ! return true; ! case SAVE_TILE: ! System.out.println("Drilling."); ! m_tileSet.drill(); ! return true; } + return super.receiveEvent(e); } |
|
From: Eric A. <eri...@gm...> - 2005-04-08 15:33:56
|
I think I personally would not want that much bandwidth to go to the satellite imagery. I think what would be more useful is to not download the chunks until the user requests them ,then alert the user when all the chunks visible on the screen are downloaded and then he/she can switch to thr satellite view. On Thu, 7 Apr 2005 6:21pm, Adam Bliss wrote: > Update of /cvsroot/hipgmap/gmap/com/trileet/gmap > In directory > sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10307/com/trileet/gmap > > Modified Files: > GMap.java ImageCache.java Point.java TileSet.java > Log Message: > This is still VERY rough, but I have shown how to compute the correct > offset at which to display the photo. This does not work, because we > are still passing the WAP flag to the HTTPRequest, which causes the > 256x256 JPEG to be resized. If we request without the WAP flag, the > photo will not display at all (I have posted to the UI form on > developer.danger.com about this.) > > Now, the big question... do we want to alter the tileset to support > the two different tile-widths and coordinate-systems, and have GMap > maintain two independent tilesets loading tiles from different > sources, and have a button to swap between them? This would give the > closest experience to the web application, but I feel the photo tiles > are too slow-loading to proceed in this way. > > > > Index: Point.java > =================================================================== > RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/Point.java,v > retrieving revision 1.4 > retrieving revision 1.5 > diff -C2 -d -r1.4 -r1.5 > *** Point.java 6 Apr 2005 23:39:42 -0000 1.4 > --- Point.java 8 Apr 2005 00:07:53 -0000 1.5 > *************** > *** 91,99 **** > private static final hipfloat h2p18 = new hipfloat(1<<19); > private static final char[] KHCHARS = {'t','q','s','r'}; > public static String latLngToKH(hipfloat lat, hipfloat lng) { > int y = lat.add(h180).div(h360).mul(h2p18).toint(); > int x = lng.add(h180).div(h360).mul(h2p18).toint(); > > ! char[] outArr = new char[20]; > for (int i=0; i<19; i++) { > int index = ((x & 1<<(19-i))>>(18-i)); > --- 91,103 ---- > private static final hipfloat h2p18 = new hipfloat(1<<19); > private static final char[] KHCHARS = {'t','q','s','r'}; > + /** > + * Returns a string of length 19. First char is t. Remaining > + * chars encode the given point. > + */ > public static String latLngToKH(hipfloat lat, hipfloat lng) { > int y = lat.add(h180).div(h360).mul(h2p18).toint(); > int x = lng.add(h180).div(h360).mul(h2p18).toint(); > > ! char[] outArr = new char[19]; > for (int i=0; i<19; i++) { > int index = ((x & 1<<(19-i))>>(18-i)); > > Index: ImageCache.java > =================================================================== > RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/ImageCache.java,v > retrieving revision 1.9 > retrieving revision 1.10 > diff -C2 -d -r1.9 -r1.10 > *** ImageCache.java 7 Apr 2005 02:18:16 -0000 1.9 > --- ImageCache.java 8 Apr 2005 00:07:52 -0000 1.10 > *************** > *** 120,134 **** > return; > } > boolean kh = false; > if (url.substring(7,9).equals("kh")) { > System.out.println("Got a kh response"); > kh = true; > } > // Build the image > Bitmap image= null; > try { > ! //image = Bitmap.newFromPNGData(response.getBytes()); > ! image = kh?ImageCodec.decodeJPEG(response.getBytes()) : > ! ImageCodec.decodePNG(response.getBytes()); > } catch (Throwable t) { > System.out.println("Unable to decode image: " + url + " error: " + > t.getMessage()); > --- 120,141 ---- > return; > } > + byte[] bytes = response.getBytes(); > boolean kh = false; > if (url.substring(7,9).equals("kh")) { > System.out.println("Got a kh response"); > kh = true; > + /** > + System.out.println(bytes.length); > + for (int i=0; i<=32; i++) { > + System.out.print(Integer.toHexString((int)(bytes[i]))); > + } > + **/ > + > } > // Build the image > Bitmap image= null; > try { > ! image = Bitmap.newFromEncodedData(bytes); > ! //image = Bitmap.convertToScreenColorSpace(image); > } catch (Throwable t) { > System.out.println("Unable to decode image: " + url + " error: " + > t.getMessage()); > *************** > *** 138,142 **** > System.out.println("ImageCodec gave null:"); > for (int i=0; i<=32; i++) { > ! System.out.print(Integer.toHexString((int)(response.getBytes()[i]))); > } > > --- 145,149 ---- > System.out.println("ImageCodec gave null:"); > for (int i=0; i<=32; i++) { > ! System.out.print(Integer.toHexString((int)(bytes[i]))); > } > > *************** > *** 174,186 **** > // Store the PNG data to the datastore if asked > if (request.store) { > ! saveToDataStore(url, response.getBytes()); > } > } > - if (hasImage(url)) { > - System.out.println("Got it."); > - } > - else { > - System.out.println("Don't got it."); > - } > } > > --- 181,187 ---- > // Store the PNG data to the datastore if asked > if (request.store) { > ! saveToDataStore(url, bytes); > } > } > } > > > Index: GMap.java > =================================================================== > RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/GMap.java,v > retrieving revision 1.24 > retrieving revision 1.25 > diff -C2 -d -r1.24 -r1.25 > *** GMap.java 7 Apr 2005 02:18:16 -0000 1.24 > --- GMap.java 8 Apr 2005 00:07:50 -0000 1.25 > *************** > *** 84,87 **** > --- 84,88 ---- > > s_searchWindow.dirsFrom(((Hit)e.argument).getSearchableAddress()); > return true; > + > case SHOW_DRIVE: > s_searchWindow.hide(); > *************** > *** 89,95 **** > s_directionWindow.show(); > return true; > ! case SEARCH_MAP: > ! s_searchWindow.show(); > ! s_searchWindow.searchNear(s_mapWindow.getCoords()); > return true; > case SHOW_DIRS: > --- 90,97 ---- > s_directionWindow.show(); > return true; > ! case SHOW_MAP: > ! s_searchWindow.hide(); > ! s_directionWindow.hide(); > ! s_mapWindow.show(); > return true; > case SHOW_DIRS: > *************** > *** 99,102 **** > --- 101,109 ---- > s_searchWindow.show(); > return true; > + > + case SEARCH_MAP: > + s_searchWindow.show(); > + s_searchWindow.searchNear(s_mapWindow.getCoords()); > + return true; > case SHOW_SAVED_HITS: > s_searchWindow.show(); > *************** > *** 235,240 **** > > public static int requestURL(String url, ResponseListener listener){ > System.out.println("REQUESTING: " + url); > ! HTTPConnection.get(url, null, (short) 0, ++s_transactionId, true); > s_listeners.put(new Integer(s_transactionId), new Request(url, > listener)); > return s_transactionId; > --- 242,253 ---- > > public static int requestURL(String url, ResponseListener listener){ > + boolean kh = false; > + if (url.substring(7,9).equals("kh")) { > + System.out.println("Got a kh response"); > + kh = true; > + } > + > System.out.println("REQUESTING: " + url); > ! HTTPConnection.get(url, null, (short) 0, ++s_transactionId, > true);//!kh); > s_listeners.put(new Integer(s_transactionId), new Request(url, > listener)); > return s_transactionId; > > Index: TileSet.java > =================================================================== > RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/TileSet.java,v > retrieving revision 1.21 > retrieving revision 1.22 > diff -C2 -d -r1.21 -r1.22 > *** TileSet.java 7 Apr 2005 02:18:16 -0000 1.21 > --- TileSet.java 8 Apr 2005 00:07:53 -0000 1.22 > *************** > *** 397,407 **** > else { > // Photo mode. > ! Bitmap photo = > ImageCache.requestImage(Tile.makePhotoURL(Point.latLngToKH(getLat(),getLng()),m_zoom),null); > if (photo == null) { > System.out.println("Null photo!"); > return; > } > ! //todo: find offset > ! p.drawBitmap(0,0,photo); > > } > --- 397,408 ---- > else { > // Photo mode. > ! String khCenter = Point.latLngToKH(getLat(),getLng()); > ! Bitmap photo = > ImageCache.requestImage(Tile.makePhotoURL(khCenter,m_zoom),null); > if (photo == null) { > System.out.println("Null photo!"); > return; > } > ! String khTail = khCenter.substring(18-m_zoom); > ! p.drawBitmap(khToXOff(khTail),khToYOff(khTail),photo); > > } > *************** > *** 530,534 **** > > } > ! > public void quit() { > ImageCache.quit(); > --- 531,590 ---- > > } > ! /** > ! * When we convert the center of our map into a KH coordinate to > ! * fetch the correct aerial photo tile, we will cut off the first > ! * (18-zoom) characters and put them in the URL. The remaining > ! * characters will tell us where, in the bitmap that gets > ! * returned, is our point. > ! * > ! * Since the photo image is 256 pixels across, the first 8 > ! * characters of the KH tail tell us exactly which pixel we are > ! * referring to. > ! */ > ! int khToXOff(String khTail) { > ! int x = 0; > ! for (int i=0; i <8; i++) { > ! x = x << 1; > ! char c='t'; > ! if (khTail.length()>i) > ! c = khTail.charAt(i); > ! switch (c) { > ! case 'q': > ! case 't': > ! break; > ! case 'r': > ! case 's': > ! x |= 1; > ! break; > ! default: > ! throw new IllegalArgumentException("Bad KH String:" + khTail); > ! } > ! > ! } > ! return 120-x; > ! } > ! int khToYOff(String khTail) { > ! int y = 0; > ! for (int i=0; i <8; i++) { > ! y = y << 1; > ! char c='t'; > ! if (khTail.length()>i) > ! c = khTail.charAt(i); > ! switch (c) { > ! case 's': > ! case 't': > ! break; > ! case 'r': > ! case 'q': > ! y |= 1; > ! break; > ! default: > ! throw new IllegalArgumentException("Bad KH String:" + khTail); > ! } > ! > ! } > ! return y-186; > ! > ! } > public void quit() { > ImageCache.quit(); > *************** > *** 644,647 **** > public boolean photoAvailable = false; > private boolean displayPhoto = false; > ! > } > --- 700,704 ---- > public boolean photoAvailable = false; > private boolean displayPhoto = false; > ! int m_offsetXPhoto; > ! int m_offsetYPhoto; > } > > > > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real > users. > Discover which products truly live up to the hype. Start reading now. > http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click > _______________________________________________ > Hipgmap-cvs mailing list > Hip...@li... > https://lists.sourceforge.net/lists/listinfo/hipgmap-cvs |
|
From: Adam B. <ab...@us...> - 2005-04-08 00:08:03
|
Update of /cvsroot/hipgmap/gmap/com/trileet/gmap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10307/com/trileet/gmap Modified Files: GMap.java ImageCache.java Point.java TileSet.java Log Message: This is still VERY rough, but I have shown how to compute the correct offset at which to display the photo. This does not work, because we are still passing the WAP flag to the HTTPRequest, which causes the 256x256 JPEG to be resized. If we request without the WAP flag, the photo will not display at all (I have posted to the UI form on developer.danger.com about this.) Now, the big question... do we want to alter the tileset to support the two different tile-widths and coordinate-systems, and have GMap maintain two independent tilesets loading tiles from different sources, and have a button to swap between them? This would give the closest experience to the web application, but I feel the photo tiles are too slow-loading to proceed in this way. Index: Point.java =================================================================== RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/Point.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Point.java 6 Apr 2005 23:39:42 -0000 1.4 --- Point.java 8 Apr 2005 00:07:53 -0000 1.5 *************** *** 91,99 **** private static final hipfloat h2p18 = new hipfloat(1<<19); private static final char[] KHCHARS = {'t','q','s','r'}; public static String latLngToKH(hipfloat lat, hipfloat lng) { int y = lat.add(h180).div(h360).mul(h2p18).toint(); int x = lng.add(h180).div(h360).mul(h2p18).toint(); ! char[] outArr = new char[20]; for (int i=0; i<19; i++) { int index = ((x & 1<<(19-i))>>(18-i)); --- 91,103 ---- private static final hipfloat h2p18 = new hipfloat(1<<19); private static final char[] KHCHARS = {'t','q','s','r'}; + /** + * Returns a string of length 19. First char is t. Remaining + * chars encode the given point. + */ public static String latLngToKH(hipfloat lat, hipfloat lng) { int y = lat.add(h180).div(h360).mul(h2p18).toint(); int x = lng.add(h180).div(h360).mul(h2p18).toint(); ! char[] outArr = new char[19]; for (int i=0; i<19; i++) { int index = ((x & 1<<(19-i))>>(18-i)); Index: ImageCache.java =================================================================== RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/ImageCache.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** ImageCache.java 7 Apr 2005 02:18:16 -0000 1.9 --- ImageCache.java 8 Apr 2005 00:07:52 -0000 1.10 *************** *** 120,134 **** return; } boolean kh = false; if (url.substring(7,9).equals("kh")) { System.out.println("Got a kh response"); kh = true; } // Build the image Bitmap image= null; try { ! //image = Bitmap.newFromPNGData(response.getBytes()); ! image = kh?ImageCodec.decodeJPEG(response.getBytes()) : ! ImageCodec.decodePNG(response.getBytes()); } catch (Throwable t) { System.out.println("Unable to decode image: " + url + " error: " + t.getMessage()); --- 120,141 ---- return; } + byte[] bytes = response.getBytes(); boolean kh = false; if (url.substring(7,9).equals("kh")) { System.out.println("Got a kh response"); kh = true; + /** + System.out.println(bytes.length); + for (int i=0; i<=32; i++) { + System.out.print(Integer.toHexString((int)(bytes[i]))); + } + **/ + } // Build the image Bitmap image= null; try { ! image = Bitmap.newFromEncodedData(bytes); ! //image = Bitmap.convertToScreenColorSpace(image); } catch (Throwable t) { System.out.println("Unable to decode image: " + url + " error: " + t.getMessage()); *************** *** 138,142 **** System.out.println("ImageCodec gave null:"); for (int i=0; i<=32; i++) { ! System.out.print(Integer.toHexString((int)(response.getBytes()[i]))); } --- 145,149 ---- System.out.println("ImageCodec gave null:"); for (int i=0; i<=32; i++) { ! System.out.print(Integer.toHexString((int)(bytes[i]))); } *************** *** 174,186 **** // Store the PNG data to the datastore if asked if (request.store) { ! saveToDataStore(url, response.getBytes()); } } - if (hasImage(url)) { - System.out.println("Got it."); - } - else { - System.out.println("Don't got it."); - } } --- 181,187 ---- // Store the PNG data to the datastore if asked if (request.store) { ! saveToDataStore(url, bytes); } } } Index: GMap.java =================================================================== RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/GMap.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** GMap.java 7 Apr 2005 02:18:16 -0000 1.24 --- GMap.java 8 Apr 2005 00:07:50 -0000 1.25 *************** *** 84,87 **** --- 84,88 ---- s_searchWindow.dirsFrom(((Hit)e.argument).getSearchableAddress()); return true; + case SHOW_DRIVE: s_searchWindow.hide(); *************** *** 89,95 **** s_directionWindow.show(); return true; ! case SEARCH_MAP: ! s_searchWindow.show(); ! s_searchWindow.searchNear(s_mapWindow.getCoords()); return true; case SHOW_DIRS: --- 90,97 ---- s_directionWindow.show(); return true; ! case SHOW_MAP: ! s_searchWindow.hide(); ! s_directionWindow.hide(); ! s_mapWindow.show(); return true; case SHOW_DIRS: *************** *** 99,102 **** --- 101,109 ---- s_searchWindow.show(); return true; + + case SEARCH_MAP: + s_searchWindow.show(); + s_searchWindow.searchNear(s_mapWindow.getCoords()); + return true; case SHOW_SAVED_HITS: s_searchWindow.show(); *************** *** 235,240 **** public static int requestURL(String url, ResponseListener listener){ System.out.println("REQUESTING: " + url); ! HTTPConnection.get(url, null, (short) 0, ++s_transactionId, true); s_listeners.put(new Integer(s_transactionId), new Request(url, listener)); return s_transactionId; --- 242,253 ---- public static int requestURL(String url, ResponseListener listener){ + boolean kh = false; + if (url.substring(7,9).equals("kh")) { + System.out.println("Got a kh response"); + kh = true; + } + System.out.println("REQUESTING: " + url); ! HTTPConnection.get(url, null, (short) 0, ++s_transactionId, true);//!kh); s_listeners.put(new Integer(s_transactionId), new Request(url, listener)); return s_transactionId; Index: TileSet.java =================================================================== RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/TileSet.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** TileSet.java 7 Apr 2005 02:18:16 -0000 1.21 --- TileSet.java 8 Apr 2005 00:07:53 -0000 1.22 *************** *** 397,407 **** else { // Photo mode. ! Bitmap photo = ImageCache.requestImage(Tile.makePhotoURL(Point.latLngToKH(getLat(),getLng()),m_zoom),null); if (photo == null) { System.out.println("Null photo!"); return; } ! //todo: find offset ! p.drawBitmap(0,0,photo); } --- 397,408 ---- else { // Photo mode. ! String khCenter = Point.latLngToKH(getLat(),getLng()); ! Bitmap photo = ImageCache.requestImage(Tile.makePhotoURL(khCenter,m_zoom),null); if (photo == null) { System.out.println("Null photo!"); return; } ! String khTail = khCenter.substring(18-m_zoom); ! p.drawBitmap(khToXOff(khTail),khToYOff(khTail),photo); } *************** *** 530,534 **** } ! public void quit() { ImageCache.quit(); --- 531,590 ---- } ! /** ! * When we convert the center of our map into a KH coordinate to ! * fetch the correct aerial photo tile, we will cut off the first ! * (18-zoom) characters and put them in the URL. The remaining ! * characters will tell us where, in the bitmap that gets ! * returned, is our point. ! * ! * Since the photo image is 256 pixels across, the first 8 ! * characters of the KH tail tell us exactly which pixel we are ! * referring to. ! */ ! int khToXOff(String khTail) { ! int x = 0; ! for (int i=0; i <8; i++) { ! x = x << 1; ! char c='t'; ! if (khTail.length()>i) ! c = khTail.charAt(i); ! switch (c) { ! case 'q': ! case 't': ! break; ! case 'r': ! case 's': ! x |= 1; ! break; ! default: ! throw new IllegalArgumentException("Bad KH String:" + khTail); ! } ! ! } ! return 120-x; ! } ! int khToYOff(String khTail) { ! int y = 0; ! for (int i=0; i <8; i++) { ! y = y << 1; ! char c='t'; ! if (khTail.length()>i) ! c = khTail.charAt(i); ! switch (c) { ! case 's': ! case 't': ! break; ! case 'r': ! case 'q': ! y |= 1; ! break; ! default: ! throw new IllegalArgumentException("Bad KH String:" + khTail); ! } ! ! } ! return y-186; ! ! } public void quit() { ImageCache.quit(); *************** *** 644,647 **** public boolean photoAvailable = false; private boolean displayPhoto = false; ! } --- 700,704 ---- public boolean photoAvailable = false; private boolean displayPhoto = false; ! int m_offsetXPhoto; ! int m_offsetYPhoto; } |
|
From: Adam B. <ab...@us...> - 2005-04-07 02:18:26
|
Update of /cvsroot/hipgmap/gmap/com/trileet/gmap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3623/com/trileet/gmap Modified Files: GMap.java ImageCache.java Tile.java TileSet.java Log Message: A _very_ rough beginning on the aerial photo images. Press menu+q once to request an aerial image for your current location. SysLog will let you know when it comes in. Press menu+q again when your photo is available, and it will be displayed. No guarantee where you will be *in* that photo, and the photo doesn't scroll. Menu+q again to return to regular map mode. Heading out to dinner now; expect more work on this soon, but feel free to jump in yourself. Index: Tile.java =================================================================== RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/Tile.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Tile.java 29 Mar 2005 22:50:30 -0000 1.4 --- Tile.java 7 Apr 2005 02:18:16 -0000 1.5 *************** *** 66,70 **** return "http://mt.google.com/mt?v=.1&x=" + x + "&y=" + y + "&zoom=" + zoom; } ! public void handleImage(String url, Bitmap image){ // If this is our current url --- 66,72 ---- return "http://mt.google.com/mt?v=.1&x=" + x + "&y=" + y + "&zoom=" + zoom; } ! public static String makePhotoURL(String khCoords, int zoom) { ! return "http://kh.google.com/kh?v=1&t=" + khCoords.substring(0,18-zoom); ! } public void handleImage(String url, Bitmap image){ // If this is our current url Index: ImageCache.java =================================================================== RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/ImageCache.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ImageCache.java 4 Apr 2005 03:00:19 -0000 1.8 --- ImageCache.java 7 Apr 2005 02:18:16 -0000 1.9 *************** *** 49,52 **** --- 49,56 ---- return requestImage(url, listener, false); } + + public static boolean hasImage(String url) { + return s_cache.containsKey(url); + } /** * Requests an image from our cache. Might return immediately with the *************** *** 116,132 **** return; } ! // Build the image Bitmap image= null; try { //image = Bitmap.newFromPNGData(response.getBytes()); ! image = ImageCodec.decodePNG(response.getBytes()); } catch (Throwable t) { System.out.println("Unable to decode image: " + url + " error: " + t.getMessage()); } // Put the image in our cache ! s_cache.put(url, image); ! s_numBitmaps++; // If our cache is over 90, trim it --- 120,150 ---- return; } ! boolean kh = false; ! if (url.substring(7,9).equals("kh")) { ! System.out.println("Got a kh response"); ! kh = true; ! } // Build the image Bitmap image= null; try { //image = Bitmap.newFromPNGData(response.getBytes()); ! image = kh?ImageCodec.decodeJPEG(response.getBytes()) : ! ImageCodec.decodePNG(response.getBytes()); } catch (Throwable t) { System.out.println("Unable to decode image: " + url + " error: " + t.getMessage()); } + if (image == null) { + System.out.println("ImageCodec gave null:"); + for (int i=0; i<=32; i++) { + System.out.print(Integer.toHexString((int)(response.getBytes()[i]))); + } + + System.out.println(); + return; + } // Put the image in our cache ! s_cache.put(url, image); ! s_numBitmaps++; // If our cache is over 90, trim it *************** *** 159,162 **** --- 177,186 ---- } } + if (hasImage(url)) { + System.out.println("Got it."); + } + else { + System.out.println("Don't got it."); + } } Index: GMap.java =================================================================== RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/GMap.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** GMap.java 4 Apr 2005 03:00:18 -0000 1.23 --- GMap.java 7 Apr 2005 02:18:16 -0000 1.24 *************** *** 134,138 **** } ! System.out.println("Event: " + String.valueOf(e.type)); return (super.receiveEvent(e)); } --- 134,138 ---- } ! //System.out.println("Event: " + String.valueOf(e.type)); return (super.receiveEvent(e)); } Index: TileSet.java =================================================================== RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/TileSet.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** TileSet.java 4 Apr 2005 03:00:20 -0000 1.20 --- TileSet.java 7 Apr 2005 02:18:16 -0000 1.21 *************** *** 248,251 **** --- 248,252 ---- m_offsetX = m_offsetX % TILE_WIDTH + TILE_WIDTH * 2; m_offsetY = m_offsetY % TILE_WIDTH + TILE_WIDTH * 2; + photoAvailable = ImageCache.hasImage(Tile.makePhotoURL(Point.latLngToKH(getLat(),getLng()),m_zoom)); } } *************** *** 354,357 **** --- 355,359 ---- // paints this tile set, given the offset from the center public void paint(Pen p) { + if (!displayPhoto) { int m_hitX = -1; int m_hitY = -1; *************** *** 392,395 **** --- 394,409 ---- hit.paint(p, m_offsetX, m_offsetY, startX, startY, m_zoom, (m_display == DISPLAY_ALL)); } + } + else { + // Photo mode. + Bitmap photo = ImageCache.requestImage(Tile.makePhotoURL(Point.latLngToKH(getLat(),getLng()),m_zoom),null); + if (photo == null) { + System.out.println("Null photo!"); + return; + } + //todo: find offset + p.drawBitmap(0,0,photo); + + } } *************** *** 504,507 **** --- 518,534 ---- } } + + public void enterPhotoMode() { + System.out.println("Photo mode on"); + displayPhoto = true; + GMap.invalidateMap(); + } + public void exitPhotoMode() { + System.out.println("Photo mode off"); + displayPhoto = false; + GMap.invalidateMap(); + + } + public void quit() { ImageCache.quit(); *************** *** 509,519 **** public void debug() { // m_polyline.debug(); - System.out.println("debug " + (m_debug ? "on" : "off")); drill(m_tiles[getWidth()/2][getHeight()/2].getX(), m_tiles[getWidth()/2][getHeight()/2].getY(), m_zoom, 2); ! checkCenter(); m_debug = !m_debug; } --- 536,560 ---- public void debug() { // m_polyline.debug(); System.out.println("debug " + (m_debug ? "on" : "off")); + /** drill(m_tiles[getWidth()/2][getHeight()/2].getX(), m_tiles[getWidth()/2][getHeight()/2].getY(), m_zoom, 2); ! **/ ! String tempurl = Tile.makePhotoURL(Point.latLngToKH(getLat(),getLng()),m_zoom); ! photoAvailable = ImageCache.hasImage(tempurl); ! System.out.println("Photo "+(photoAvailable?"yes":"no")); ! if (photoAvailable && !displayPhoto) { ! enterPhotoMode(); ! } ! else if (displayPhoto) { ! exitPhotoMode(); ! } ! else { ! ImageCache.requestImage(tempurl, ! null, true); ! } ! m_debug = !m_debug; } *************** *** 600,602 **** --- 641,647 ---- public MapWindow parentMapWindow; + + public boolean photoAvailable = false; + private boolean displayPhoto = false; + } |
|
From: Adam B. <ab...@us...> - 2005-04-06 23:39:51
|
Update of /cvsroot/hipgmap/gmap/com/trileet/gmap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15703 Modified Files: Point.java Log Message: You can now ask a Point for its KeyHole (KH) coordinates. See the wiki for discussions of this. Next I'm going to start playing with some of the Photo tiles.... Index: Point.java =================================================================== RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/Point.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Point.java 3 Apr 2005 11:21:53 -0000 1.3 --- Point.java 6 Apr 2005 23:39:42 -0000 1.4 *************** *** 81,91 **** } public static void main(String[] argv) { // A little test routine ! Point p = new Point(3256000,-11824000); ! System.out.println(p.toString()); ! Point q = fromString(p.toString()); ! System.out.println(q.toString()); ! System.out.println(q.lat.toString()); } } --- 81,115 ---- } + /** + * We can convert the point's lat/lng to KeyHole (KH) coordinates. + * See Eric's writeup of the KH system on the wiki, and my + * explanation of the algorithm on the talk:Satellite page. + */ + + private static final hipfloat h180 = new hipfloat(180); + private static final hipfloat h360 = new hipfloat(360); + private static final hipfloat h2p18 = new hipfloat(1<<19); + private static final char[] KHCHARS = {'t','q','s','r'}; + public static String latLngToKH(hipfloat lat, hipfloat lng) { + int y = lat.add(h180).div(h360).mul(h2p18).toint(); + int x = lng.add(h180).div(h360).mul(h2p18).toint(); + + char[] outArr = new char[20]; + for (int i=0; i<19; i++) { + int index = ((x & 1<<(19-i))>>(18-i)); + index |= ((y & 1<<(19-i))>>(19-i)); + outArr[i] = KHCHARS[index]; + } + return new String(outArr); + //return String.valueOf(x) + " " + String.valueOf(y); + } + public String getKH() { + return latLngToKH(this.lat,this.lng); + } + public static void main(String[] argv) { // A little test routine ! Point p = new Point(3787206,-12227688); ! System.out.println(p.getKH()); } } |
|
From: Eric A. <eri...@gm...> - 2005-04-06 18:57:52
|
Hmm, it's not going to be easy. The tiles are 256x256 and their coordinate system is totally wacked out. Instead of x,y coordinates, they divide the world up into a hierarchy of quadrants. I added a page on the wiki about it http://gmap.trileet.com/wiki/index.php/Satellite It's my first whack, feel free to add to it. Any ideas on how we could implement this? Preferrably other than ripping off however google does it... On Apr 5, 2005 8:51 AM, Nicolas Pottier <nic...@ya...> wrote: > > Tiles will likely be considerably larger, but probably worth trying to plug > it in: > http://maps.google.com/maps?q=seattle,wa&spn=0.232773,0.249939&t=k&hl=en > > -Nic > > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real users. > Discover which products truly live up to the hype. Start reading now. > http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click > _______________________________________________ > Hipgmap-cvs mailing list > Hip...@li... > https://lists.sourceforge.net/lists/listinfo/hipgmap-cvs > |
|
From: Nicolas P. <nic...@ya...> - 2005-04-05 15:49:46
|
Tiles will likely be considerably larger, but probably worth trying to plug it in: http://maps.google.com/maps?q=seattle,wa&spn=0.232773,0.249939&t=k&hl=en -Nic |
|
From: Adam B. <ab...@us...> - 2005-04-04 03:00:29
|
Update of /cvsroot/hipgmap/gmap/locale/en_US In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9883/locale/en_US Modified Files: GMap.rsrc Log Message: Summary of yesterday and today's edits: * Messed with the menus some more. Events are now handled a bit better. * Directions and Hits are now kept statically in the GMap object. * You can hold down the scrollwheel on a hit to access its context menu. * Saved hits now fully functional * Reduced redundant datastore-saving of image tiles * Added direction-reversing * Make the ImageCache thread stop on quit (still needs work.) Index: GMap.rsrc =================================================================== RCS file: /cvsroot/hipgmap/gmap/locale/en_US/GMap.rsrc,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** GMap.rsrc 3 Apr 2005 11:21:53 -0000 1.13 --- GMap.rsrc 4 Apr 2005 03:00:20 -0000 1.14 *************** *** 72,76 **** menuItem title="Debug" id=kID_beug event=DEBUG shortcut='q' menuItem title="Search Near Here" id=kID_SearchMap event=SEARCH_MAP shortcut='n' ! menuItem title="Current Hit..." id=kID_hitsSubMenu subMenu=HITS_SUBMENU endMenu --- 72,76 ---- menuItem title="Debug" id=kID_beug event=DEBUG shortcut='q' menuItem title="Search Near Here" id=kID_SearchMap event=SEARCH_MAP shortcut='n' ! menuItem title="Current Hit..." id=kID_hitsSubMenuMap subMenu=HITS_SUBMENU endMenu *************** *** 87,91 **** menuItem title="Insert Contact" id=kID_getContact event=GET_CONTACT shortcut='i' menuItem title="Saved Hits" id=kID_savedHits event=SHOW_SAVED_HITS shortcut='k' ! menuItem title="This Hit..." id=kID_hitsSubMenu subMenu=HITS_SUBMENU endMenu --- 87,91 ---- menuItem title="Insert Contact" id=kID_getContact event=GET_CONTACT shortcut='i' menuItem title="Saved Hits" id=kID_savedHits event=SHOW_SAVED_HITS shortcut='k' ! menuItem title="This Hit..." id=kID_hitsSubMenuSearch subMenu=HITS_SUBMENU endMenu |
|
From: Adam B. <ab...@us...> - 2005-04-04 03:00:29
|
Update of /cvsroot/hipgmap/gmap/com/trileet/gmap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9883/com/trileet/gmap Modified Files: GMap.java Hit.java ImageCache.java MapWindow.java SearchWindow.java TileSet.java Log Message: Summary of yesterday and today's edits: * Messed with the menus some more. Events are now handled a bit better. * Directions and Hits are now kept statically in the GMap object. * You can hold down the scrollwheel on a hit to access its context menu. * Saved hits now fully functional * Reduced redundant datastore-saving of image tiles * Added direction-reversing * Make the ImageCache thread stop on quit (still needs work.) Index: MapWindow.java =================================================================== RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/MapWindow.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** MapWindow.java 3 Apr 2005 11:21:53 -0000 1.13 --- MapWindow.java 4 Apr 2005 03:00:19 -0000 1.14 *************** *** 157,161 **** m_tileSet.debug(); } ! // Our tile set private TileSet m_tileSet; --- 157,161 ---- m_tileSet.debug(); } ! public void quit() {m_tileSet.quit();} // Our tile set private TileSet m_tileSet; Index: ImageCache.java =================================================================== RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/ImageCache.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ImageCache.java 3 Apr 2005 11:21:53 -0000 1.7 --- ImageCache.java 4 Apr 2005 03:00:19 -0000 1.8 *************** *** 200,204 **** */ public void run(){ ! while(1 == 1){ try{ // our process is like so: --- 200,204 ---- */ public void run(){ ! while(s_running){ try{ // our process is like so: *************** *** 285,289 **** loadFromDataStore(); // start our thread ! new Thread(this).start(); } --- 285,290 ---- loadFromDataStore(); // start our thread ! s_thread = new Thread(this); ! s_thread.start(); } *************** *** 395,398 **** --- 396,404 ---- } + public static void quit() { + s_running=false; + //TODO: interrupt here? + + } public static void main(String[] argv) { *************** *** 426,428 **** --- 432,437 ---- private static DataStore mDataStore; + /** Our thread. */ + private static Thread s_thread; + private static boolean s_running=true; } Index: TileSet.java =================================================================== RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/TileSet.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** TileSet.java 3 Apr 2005 11:21:53 -0000 1.19 --- TileSet.java 4 Apr 2005 03:00:20 -0000 1.20 *************** *** 98,102 **** } public void adjustContextMenu(Menu menu) { ! MenuItem contextItem = menu.getItemWithID(kID_hitsSubMenu); if (m_currentHit <0) { contextItem.disable(); --- 98,102 ---- } public void adjustContextMenu(Menu menu) { ! MenuItem contextItem = menu.getItemWithIDOrNull(kID_hitsSubMenuMap); if (m_currentHit <0) { contextItem.disable(); *************** *** 504,508 **** } } ! public void debug() { // m_polyline.debug(); --- 504,510 ---- } } ! public void quit() { ! ImageCache.quit(); ! } public void debug() { // m_polyline.debug(); Index: GMap.java =================================================================== RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/GMap.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** GMap.java 3 Apr 2005 11:21:52 -0000 1.22 --- GMap.java 4 Apr 2005 03:00:18 -0000 1.23 *************** *** 57,60 **** --- 57,64 ---- s_searchWindow.show(); return true; + case REV_DIRS: + s_searchWindow.indicateSearching(); + e.argument = s_dirs.reverseQuery(); + // fall through to NEW_SEARCH case NEW_SEARCH: String search = (String) e.argument; *************** *** 114,118 **** m_networkUp=true; break; ! //TODO: these last two should be handled by searchwindow itself. case GET_CONTACT: --- 118,123 ---- m_networkUp=true; break; ! case SystemEventIds.APPLICATION_QUIT: ! quit(); //TODO: these last two should be handled by searchwindow itself. case GET_CONTACT: *************** *** 127,132 **** return true; } ! return (super.receiveEvent(e)); } --- 132,138 ---- return true; + } ! System.out.println("Event: " + String.valueOf(e.type)); return (super.receiveEvent(e)); } *************** *** 281,284 **** --- 287,294 ---- m_lastWindow = getFrontScreenWindow(); } + public void quit() { + s_mapWindow.quit(); + super.quit(); + } public static void invalidateMap(){ Index: Hit.java =================================================================== RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/Hit.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Hit.java 3 Apr 2005 11:21:52 -0000 1.13 --- Hit.java 4 Apr 2005 03:00:19 -0000 1.14 *************** *** 42,45 **** --- 42,48 ---- // our pin bitmap private static Bitmap s_pinBitmap; + static { + loadBitmaps(); + } private static Bitmap s_topLeft; *************** *** 151,155 **** public void paint(Pen p, int offsetX, int offsetY, int mapX, int mapY, int zoom, boolean drawInfo) { ! // Figure out where this hit would get drawn int tileX = m_point.getPaintX(offsetX, mapX, zoom); --- 154,164 ---- public void paint(Pen p, int offsetX, int offsetY, int mapX, int mapY, int zoom, boolean drawInfo) { ! if (m_point == null) { ! System.out.println("mpoint is null!"); ! return; ! } ! if (s_pinBitmap == null) { ! System.out.println("No bitmap!"); ! } // Figure out where this hit would get drawn int tileX = m_point.getPaintX(offsetX, mapX, zoom); *************** *** 161,165 **** p.drawBitmap(tileX - (s_pinBitmap.getWidth() / 2), tileY - s_pinBitmap.getHeight(), s_pinBitmap); - if (drawInfo) { int width = Math.max(Math.max(Math.max(Math.max(bf.getWidth(title), --- 170,173 ---- *************** *** 369,372 **** --- 377,381 ---- /** Unflatten. **/ public Hit (byte[] abyte) { + loadBitmaps(); DataRecord dr = new DataRecord(abyte,1); //type = (short) dr.getShort(0,0); Index: SearchWindow.java =================================================================== RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/SearchWindow.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** SearchWindow.java 3 Apr 2005 11:21:53 -0000 1.15 --- SearchWindow.java 4 Apr 2005 03:00:19 -0000 1.16 *************** *** 142,149 **** } ! // Say we are searching ! clearResultsView(); ! addRow(" ... searching ...", Font ! .findItalicSystemFont()); // Send the event up to our app --- 142,146 ---- } ! indicateSearching(); // Send the event up to our app *************** *** 158,164 **** return super.receiveEvent(e); } ! public void adjustActionMenuState(Menu menu) { ! MenuItem contextItem = menu.getItemWithID(kID_hitsSubMenu); if (m_results.getFocusedChild() instanceof HitBox) { contextItem.enable(); --- 155,169 ---- return super.receiveEvent(e); } ! public void indicateSearching() { ! // Say we are searching ! clearResultsView(); ! addRow(" ... searching ...", Font ! .findItalicSystemFont()); ! } public void adjustActionMenuState(Menu menu) { ! MenuItem contextItem = menu.getItemWithIDOrNull(kID_hitsSubMenuSearch); ! if (contextItem == null) { ! return; ! } if (m_results.getFocusedChild() instanceof HitBox) { contextItem.enable(); *************** *** 246,249 **** --- 251,270 ---- return super.eventWidgetDown(widget, event); } + public boolean eventWidgetHeld(int widget, Event event) { + /** If the scrollwheel is held, display the context menu. + * Hacked out by analogy to the ContactBrowser. + **/ + if (widget == Event.DEVICE_WHEEL_BUTTON && + m_results.getFocusedChild() instanceof HitBox) { + Menu m = new Menu(""); + ((HitBox)m_results.getFocusedChild()).adjustContextMenuState(m); + m.setWindow(this); + //m.setPosition(0,0); + m.enterMenu(true); + return true; + } + return super.eventWidgetHeld(widget,event); + } + /** *************** *** 335,338 **** --- 356,360 ---- public void handleVCard( IPCMessage ipcm) { String vcard = ipcm.findString("vcard"); + StringBuffer munged = new StringBuffer(); /** Parse the VCard content and get the searchable address. * TODO: This needs a lot of improvement... *************** *** 343,355 **** } i = vcard.indexOf(":",i); ! int j = vcard.indexOf("\r\n",i); ! vcard = vcard.substring(i+1,j); //TODO: should support spanning multiple lines... something like the below while loop vcard = vcard.replace(';',','); m_searchField.insert(vcard); ! /** ! while (vcard.subString(j+2,j+3).equals(" ")) { ! ! } ! **/ } /** Our search field */ --- 365,378 ---- } i = vcard.indexOf(":",i); ! int j; ! do { ! j = vcard.indexOf("\r\n",i); ! munged.append(vcard.substring(i+1,j)); ! i = j+2; ! } while (vcard.substring(j+2,j+3).equals(" ")); ! vcard = munged.toString(); vcard = vcard.replace(';',','); m_searchField.insert(vcard); ! } /** Our search field */ |