|
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; + } |