Changeset 25326 in osm for applications/viewer
- Timestamp:
- 2011-02-15T16:34:25+01:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/BingAerialTileSource.java
r25314 r25326 57 57 58 58 @Override 59 public void startElement(String uri, String stripped, String tagName, 60 Attributes attrs) throws SAXException { 61 if("ImageryProvider".equals(tagName)) { 59 public void startElement(String uri, String stripped, String tagName, Attributes attrs) throws SAXException { 60 if ("ImageryProvider".equals(tagName)) { 62 61 curr = new Attribution(); 63 } else if ("CoverageArea".equals(tagName)) {62 } else if ("CoverageArea".equals(tagName)) { 64 63 inCoverage = true; 65 64 } … … 67 66 68 67 @Override 69 public void characters(char[] ch, int start, int length) 70 throws SAXException { 68 public void characters(char[] ch, int start, int length) throws SAXException { 71 69 string = new String(ch, start, length); 72 70 } 73 71 74 72 @Override 75 public void endElement(String uri, String stripped, String tagName) 76 throws SAXException { 77 if("ImageryProvider".equals(tagName)) { 73 public void endElement(String uri, String stripped, String tagName) throws SAXException { 74 if ("ImageryProvider".equals(tagName)) { 78 75 attributions.add(curr); 79 } else if ("Attribution".equals(tagName)) {76 } else if ("Attribution".equals(tagName)) { 80 77 curr.attribution = string; 81 } else if (inCoverage && "ZoomMin".equals(tagName)) {78 } else if (inCoverage && "ZoomMin".equals(tagName)) { 82 79 curr.minZoom = Integer.parseInt(string); 83 } else if (inCoverage && "ZoomMax".equals(tagName)) {80 } else if (inCoverage && "ZoomMax".equals(tagName)) { 84 81 curr.maxZoom = Integer.parseInt(string); 85 } else if (inCoverage && "SouthLatitude".equals(tagName)) {82 } else if (inCoverage && "SouthLatitude".equals(tagName)) { 86 83 southLat = Double.parseDouble(string); 87 } else if (inCoverage && "NorthLatitude".equals(tagName)) {84 } else if (inCoverage && "NorthLatitude".equals(tagName)) { 88 85 northLat = Double.parseDouble(string); 89 } else if (inCoverage && "EastLongitude".equals(tagName)) {86 } else if (inCoverage && "EastLongitude".equals(tagName)) { 90 87 eastLon = Double.parseDouble(string); 91 } else if (inCoverage && "WestLongitude".equals(tagName)) {88 } else if (inCoverage && "WestLongitude".equals(tagName)) { 92 89 westLon = Double.parseDouble(string); 93 } else if ("BoundingBox".equals(tagName)) {90 } else if ("BoundingBox".equals(tagName)) { 94 91 curr.min = new Coordinate(southLat, westLon); 95 92 curr.max = new Coordinate(northLat, eastLon); 96 } else if ("CoverageArea".equals(tagName)) {93 } else if ("CoverageArea".equals(tagName)) { 97 94 inCoverage = false; 98 95 } … … 103 100 private List<Attribution> loadAttributionText() { 104 101 try { 105 URL u = new URL("http://dev.virtualearth.net/REST/v1/Imagery/Metadata/Aerial/0,0?zl=1&mapVersion=v1&key="+API_KEY+"&include=ImageryProviders&output=xml"); 102 URL u = new URL("http://dev.virtualearth.net/REST/v1/Imagery/Metadata/Aerial/0,0?zl=1&mapVersion=v1&key=" 103 + API_KEY + "&include=ImageryProviders&output=xml"); 106 104 URLConnection conn = u.openConnection(); 107 105 108 106 // This is not JOSM! Do not use anything other than standard JRE classes within this package! 109 107 // See package.html for details 110 108 //conn.setConnectTimeout(Main.pref.getInteger("imagery.bing.load-attribution-text.timeout", 4000)); 111 109 112 110 InputStream stream = conn.getInputStream(); 113 111 114 112 XMLReader parser = XMLReaderFactory.createXMLReader(); 115 113 AttrHandler handler = new AttrHandler(); 116 114 parser.setContentHandler(handler); 117 115 parser.parse(new InputSource(stream)); 118 System.err.println("Added " + handler.attributions.size() + " attributions.");116 //System.err.println("Added " + handler.attributions.size() + " attributions."); 119 117 return handler.attributions; 120 118 } catch (IOException e) { … … 134 132 @Override 135 133 public String getExtension() { 136 return ("jpeg");134 return ("jpeg"); 137 135 } 138 136 … … 189 187 StringBuilder a = new StringBuilder(); 190 188 for (Attribution attr : attributions.get()) { 191 if(zoom <= attr.maxZoom && zoom >= attr.minZoom) { 192 if(topLeft.getLon() < attr.max.getLon() 193 && botRight.getLon() > attr.min.getLon() 194 && topLeft.getLat() > attr.min.getLat() 195 && botRight.getLat() < attr.max.getLat()) { 189 if (zoom <= attr.maxZoom && zoom >= attr.minZoom) { 190 if (topLeft.getLon() < attr.max.getLon() && botRight.getLon() > attr.min.getLon() 191 && topLeft.getLat() > attr.min.getLat() && botRight.getLat() < attr.max.getLat()) { 196 192 a.append(attr.attribution); 197 193 a.append(" "); … … 208 204 static String computeQuadTree(int zoom, int tilex, int tiley) { 209 205 StringBuilder k = new StringBuilder(); 210 for (int i = zoom; i > 0; i--) {206 for (int i = zoom; i > 0; i--) { 211 207 char digit = 48; 212 208 int mask = 1 << (i - 1);
Note:
See TracChangeset
for help on using the changeset viewer.