Changeset 25266 in osm for applications/viewer/jmapviewer/src/org/openstreetmap/gui
- Timestamp:
- 2011-02-10T11:07:19+01:00 (14 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/ScanexTileSource.java
r25265 r25266 1 1 package org.openstreetmap.gui.jmapviewer; 2 2 3 import java.awt.Image; 4 import java.io.IOException; 5 import java.io.InputStream; 6 import java.net.URL; 7 import java.net.URLConnection; 8 import java.util.ArrayList; 9 import java.util.List; 10 import java.util.concurrent.Callable; 11 import java.util.concurrent.Executors; 12 import java.util.concurrent.Future; 3 public class ScanexTileSource extends OsmTileSource.AbstractOsmTileSource { 4 private static String API_KEY = "4018C5A9AECAD8868ED5DEB2E41D09F7"; 13 5 14 import javax.imageio.ImageIO; 6 private enum ScanexLayer { 7 IRS("irs", "/TileSender.ashx?ModeKey=tile&MapName=F7B8CF651682420FA1749D894C8AD0F6&LayerName=BAC78D764F0443BD9AF93E7A998C9F5B"), 8 SPOT("spot", "/TileSender.ashx?ModeKey=tile&MapName=F7B8CF651682420FA1749D894C8AD0F6&LayerName=F51CE95441284AF6B2FC319B609C7DEC"); 15 9 16 import org.xml.sax.Attributes; 17 import org.xml.sax.InputSource; 18 import org.xml.sax.SAXException; 19 import org.xml.sax.XMLReader; 20 import org.xml.sax.helpers.DefaultHandler; 21 import org.xml.sax.helpers.XMLReaderFactory; 10 private String name; 11 private String uri; 22 12 23 public class ScanexIRSTileSource extends OsmTileSource.AbstractOsmTileSource { 24 private static String API_KEY = "4018C5A9AECAD8868ED5DEB2E41D09F7"; 25 private static String BASE_URI = "/TileSender.ashx?ModeKey=tile&MapName=F7B8CF651682420FA1749D894C8AD0F6&LayerName=BAC78D764F0443BD9AF93E7A998C9F5B"; 13 ScanexLayer(String name, String uri) { 14 this.name = name; 15 this.uri = uri; 16 } 17 public String getName() { 18 return name; 19 } 20 public String getUri() { 21 return uri; 22 } 23 } 26 24 27 public ScanexIRSTileSource() { 28 super("IRS satellite imagery", "http://maps.kosmosnimki.ru"); 25 /* IRS by default */ 26 private ScanexLayer Layer = ScanexLayer.IRS; 27 28 public ScanexTileSource(String url) { 29 super("Scanex" + url, "http://maps.kosmosnimki.ru"); 30 31 for (ScanexLayer layer : ScanexLayer.values()) { 32 if (url.equalsIgnoreCase(layer.getName())) { 33 this.Layer = layer; 34 break; 35 } 36 } 29 37 } 30 38 … … 41 49 @Override 42 50 public String getTilePath(int zoom, int tilex, int tiley) { 43 51 int tmp = (int)Math.pow(2.0, zoom - 1); 44 52 45 46 53 tilex = tilex - tmp; 54 tiley = tmp - tiley - 1; 47 55 48 return BASE_URI+ "&apikey=" + API_KEY + "&x=" + tilex + "&y=" + tiley + "&z=" + zoom;56 return this.Layer.getUri() + "&apikey=" + API_KEY + "&x=" + tilex + "&y=" + tiley + "&z=" + zoom; 49 57 } 50 58 … … 62 70 double pow = Math.pow(Math.tan(Math.PI/4 + Math.asin(E * Math.sin(Math.toRadians(lat)))/2), E); 63 71 64 72 return (EQUATOR/2 - (RADIUS_E * Math.log(tmp/pow))) * Math.pow(2.0, zoom) / EQUATOR; 65 73 } 66 74 67 75 @Override 68 76 public double lonToTileX(double lon, int zoom) { 69 77 return (RADIUS_E * lon * Math.PI / (90*EQUATOR) + 1) * Math.pow(2.0, zoom - 1); 70 78 } 71 79 … … 77 85 @Override 78 86 public double tileYToLat(int y, int zoom) { 79 80 81 82 87 double lat = 0; 88 double minl = OsmMercator.MIN_LAT; 89 double maxl = OsmMercator.MAX_LAT; 90 double c; 83 91 84 85 86 87 88 89 90 91 92 93 92 for (int i=0; i < 60; i++) { 93 c = latToTileY(lat, zoom); 94 if (c < y) { 95 maxl = lat; 96 lat -= (lat - minl)/2; 97 } else { 98 minl = lat; 99 lat += (maxl - lat)/2; 100 } 101 } 94 102 95 103 return lat; 96 104 } 97 105
Note:
See TracChangeset
for help on using the changeset viewer.