Changeset 3826 in josm for trunk/src/org
- Timestamp:
- 2011-01-28T00:49:15+01:00 (14 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/AddImageryLayerAction.java
r3733 r3826 31 31 @Override 32 32 protected void updateEnabledState() { 33 setEnabled(info.getImageryType() == ImageryType.TMS 34 || info.getImageryType() == ImageryType.BING 35 || (Main.map != null && Main.map.mapView != null 36 && !Main.map.mapView.getAllLayers().isEmpty())); 33 // never enable blacklisted entries. 34 if (info.isBlacklisted()) { 35 setEnabled(false); 36 } else if (info.getImageryType() == ImageryType.TMS || info.getImageryType() == ImageryType.BING) { 37 setEnabled(true); 38 } else if (Main.map != null && Main.map.mapView != null && !Main.map.mapView.getAllLayers().isEmpty()) { 39 setEnabled(true); 40 } else { 41 setEnabled(false); 42 } 37 43 } 38 44 } -
trunk/src/org/openstreetmap/josm/data/imagery/ImageryInfo.java
r3720 r3826 6 6 7 7 /** 8 * Class that stores info about a WMS server.8 * Class that stores info about an image background layer. 9 9 * 10 10 * @author Frederik Ramm <frederik@remote.org> 11 11 */ 12 12 public class ImageryInfo implements Comparable<ImageryInfo> { 13 13 14 public enum ImageryType { 14 15 WMS("wms"), … … 26 27 } 27 28 29 private final static String[] BLACKLIST_REGEXES = { 30 // These entries are for Google tile servers (names and IPV4 numbers) 31 ".*\\.google\\.com/.*", 32 ".*209\\.85\\.2\\d\\d.*", 33 ".*209\\.85\\.1[3-9]\\d.*", 34 ".*209\\.85\\.12[89].*" 35 }; 36 28 37 String name; 29 String url =null;38 String url = null; 30 39 String cookies = null; 31 40 public final String eulaAcceptanceRequired; … … 33 42 double pixelPerDegree = 0.0; 34 43 int maxZoom = 0; 44 private boolean blacklisted = false; 35 45 36 46 public ImageryInfo(String name) { … … 41 51 public ImageryInfo(String name, String url) { 42 52 this.name=name; 43 setU RL(url);53 setUrl(url); 44 54 this.eulaAcceptanceRequired = null; 45 55 } … … 47 57 public ImageryInfo(String name, String url, String eulaAcceptanceRequired) { 48 58 this.name=name; 49 setU RL(url);59 setUrl(url); 50 60 this.eulaAcceptanceRequired = eulaAcceptanceRequired; 51 61 } … … 53 63 public ImageryInfo(String name, String url, String eulaAcceptanceRequired, String cookies) { 54 64 this.name=name; 55 setU RL(url);65 setUrl(url); 56 66 this.cookies=cookies; 57 67 this.eulaAcceptanceRequired = eulaAcceptanceRequired; … … 60 70 public ImageryInfo(String name, String url, String cookies, double pixelPerDegree) { 61 71 this.name=name; 62 setU RL(url);72 setUrl(url); 63 73 this.cookies=cookies; 64 74 this.pixelPerDegree=pixelPerDegree; … … 71 81 String e4 = null; 72 82 if(url != null && !url.isEmpty()) { 73 e2 = getFullU RL();83 e2 = getFullUrl(); 74 84 } 75 85 if(cookies != null && !cookies.isEmpty()) { … … 110 120 this.name=array.get(0); 111 121 if(array.size() >= 2) { 112 setU RL(array.get(1));122 setUrl(array.get(1)); 113 123 } 114 124 if(array.size() >= 3) { … … 160 170 } 161 171 162 public void setURL(String url) { 172 public void setUrl(String url) { 173 174 // determine if URL is on blacklist and flag accordingly. 175 blacklisted = false; 176 for (String blacklistRegex : BLACKLIST_REGEXES) { 177 if (url.matches(blacklistRegex)) { 178 blacklisted = true; 179 System.err.println("layer '" + name + "' uses blacklisted URL"); 180 break; 181 } 182 } 183 163 184 for (ImageryType type : ImageryType.values()) { 164 185 if (url.startsWith(type.getUrlString() + ":")) { … … 182 203 } 183 204 184 public String getU RL() {205 public String getUrl() { 185 206 return this.url; 186 207 } … … 198 219 } 199 220 200 public String getFullU RL() {221 public String getFullUrl() { 201 222 return imageryType.getUrlString() + ":" + url; 202 223 } … … 229 250 return url != null && url.contains("{") && url.contains("}"); 230 251 } 252 253 public boolean isBlacklisted() { 254 return blacklisted; 255 } 231 256 } -
trunk/src/org/openstreetmap/josm/data/imagery/ImageryLayerInfo.java
r3737 r3826 20 20 21 21 public class ImageryLayerInfo { 22 22 23 public static final ImageryLayerInfo instance = new ImageryLayerInfo(); 23 24 ArrayList<ImageryInfo> layers = new ArrayList<ImageryInfo>(); 24 25 ArrayList<ImageryInfo> defaultLayers = new ArrayList<ImageryInfo>(); 25 private final static String[] DEFAULT_LAYER_SITES 26 = { "http://josm.openstreetmap.de/maps"}; 26 27 private final static String[] DEFAULT_LAYER_SITES = { 28 "http://josm.openstreetmap.de/maps" 29 }; 27 30 28 31 public void load() { … … 32 35 for(Collection<String> c : Main.pref.getArray("imagery.layers", 33 36 Collections.<Collection<String>>emptySet())) { 34 layers.add(new ImageryInfo(c));37 add(new ImageryInfo(c)); 35 38 } 36 39 … … 60 63 String url = val[2]; 61 64 String eulaAcceptanceRequired = null; 65 62 66 if (val.length == 4) { 63 67 // 4th parameter optional for license agreement (EULA) 64 68 eulaAcceptanceRequired = val[3]; 65 69 } 70 66 71 defaultLayers.add(new ImageryInfo(name, url, eulaAcceptanceRequired)); 67 72 68 if (force) {73 if (force) { 69 74 defaultsSave.add(url); 70 if (!defaults.contains(url)) {71 for (ImageryInfo i : layers) {72 if ((i.getImageryType() == ImageryType.WMS && url.equals(i.getU RL()))73 || url.equals(i.getFullU RL())) {75 if (!defaults.contains(url)) { 76 for (ImageryInfo i : layers) { 77 if ((i.getImageryType() == ImageryType.WMS && url.equals(i.getUrl())) 78 || url.equals(i.getFullUrl())) { 74 79 force = false; 75 80 } 76 81 } 77 if (force) {78 layers.add(new ImageryInfo(name, url));82 if (force) { 83 add(new ImageryInfo(name, url)); 79 84 } 80 85 } -
trunk/src/org/openstreetmap/josm/gui/bbox/SlippyMapBBoxChooser.java
r3777 r3826 99 99 List<TileSource> sources = new ArrayList<TileSource>(); 100 100 for (ImageryInfo info : ImageryLayerInfo.instance.getLayers()) { 101 if (existingSlippyMapUrls.contains(info.getU RL())) {101 if (existingSlippyMapUrls.contains(info.getUrl())) { 102 102 continue; 103 103 } -
trunk/src/org/openstreetmap/josm/gui/layer/TMSLayer.java
r3787 r3826 232 232 public static TileSource getTileSource(ImageryInfo info) { 233 233 if (info.getImageryType() == ImageryType.TMS) { 234 if(ImageryInfo.isUrlWithPatterns(info.getU RL()))235 return new TemplatedTMSTileSource(info.getName(), info.getU RL(), info.getMaxZoom());234 if(ImageryInfo.isUrlWithPatterns(info.getUrl())) 235 return new TemplatedTMSTileSource(info.getName(), info.getUrl(), info.getMaxZoom()); 236 236 else 237 return new TMSTileSource(info.getName(),info.getU RL(), info.getMaxZoom());237 return new TMSTileSource(info.getName(),info.getUrl(), info.getMaxZoom()); 238 238 } else if (info.getImageryType() == ImageryType.BING) 239 239 return new BingAerialTileSource(); -
trunk/src/org/openstreetmap/josm/gui/layer/WMSLayer.java
r3809 r3826 124 124 resolution = mv.getDist100PixelText(); 125 125 126 if(info.getU RL() != null) {127 WMSGrabber.getProjection(info.getU RL(), true);126 if(info.getUrl() != null) { 127 WMSGrabber.getProjection(info.getUrl(), true); 128 128 startGrabberThreads(); 129 if(info.getImageryType() == ImageryType.WMS && !ImageryInfo.isUrlWithPatterns(info.getU RL())) {130 if (!(info.getU RL().endsWith("&") || info.getURL().endsWith("?"))) {131 if (!confirmMalformedUrl(info.getU RL())) {132 System.out.println(tr("Warning: WMS layer deactivated because of malformed base url ''{0}''", info.getU RL()));129 if(info.getImageryType() == ImageryType.WMS && !ImageryInfo.isUrlWithPatterns(info.getUrl())) { 130 if (!(info.getUrl().endsWith("&") || info.getUrl().endsWith("?"))) { 131 if (!confirmMalformedUrl(info.getUrl())) { 132 System.out.println(tr("Warning: WMS layer deactivated because of malformed base url ''{0}''", info.getUrl())); 133 133 usesInvalidUrl = true; 134 134 setName(getName() + tr("(deactivated)")); … … 200 200 201 201 @Override public void paint(Graphics2D g, final MapView mv, Bounds b) { 202 if(info.getU RL() == null || (usesInvalidUrl && !isInvalidUrlConfirmed)) return;202 if(info.getUrl() == null || (usesInvalidUrl && !isInvalidUrlConfirmed)) return; 203 203 204 204 settingsChanged = false; … … 628 628 oos.writeDouble(info.getPixelPerDegree()); 629 629 oos.writeObject(info.getName()); 630 oos.writeObject(info.getFullU RL());630 oos.writeObject(info.getFullUrl()); 631 631 oos.writeObject(images); 632 632 oos.close(); … … 667 667 info.setPixelPerDegree(ois.readDouble()); 668 668 doSetName((String)ois.readObject()); 669 info.setU RL((String) ois.readObject());669 info.setUrl((String) ois.readObject()); 670 670 images = (GeorefImage[][])ois.readObject(); 671 671 ois.close(); … … 680 680 settingsChanged = true; 681 681 mv.repaint(); 682 if(info.getU RL() != null)682 if(info.getUrl() != null) 683 683 { 684 684 startGrabberThreads(); -
trunk/src/org/openstreetmap/josm/gui/preferences/ImageryPreference.java
r3816 r3826 587 587 return info.getName(); 588 588 case 1: 589 return info.getFullU RL();589 return info.getFullUrl(); 590 590 case 2: 591 591 return (info.getImageryType() == ImageryType.WMS || info.getImageryType() == ImageryType.HTML) ? … … 605 605 break; 606 606 case 1: 607 info.setU RL((String)o);607 info.setUrl((String)o); 608 608 break; 609 609 case 2: … … 654 654 return info.getName(); 655 655 case 1: 656 return info.getFullU RL();656 return info.getFullUrl(); 657 657 } 658 658 return null; -
trunk/src/org/openstreetmap/josm/gui/preferences/ImagerySettingsMigration.java
r3720 r3826 128 128 HashSet<String> existingUrls = new HashSet<String>(); 129 129 for (ImageryInfo info : layerInfo.getLayers()) { 130 existingUrls.add(info.getFullU RL());130 existingUrls.add(info.getFullUrl()); 131 131 } 132 132 for(Collection<String> c : Main.pref.getArray("wmslayers", 133 133 Collections.<Collection<String>>emptySet())) { 134 134 ImageryInfo info = new ImageryInfo(c); 135 if (!existingUrls.contains(info.getFullU RL())) {135 if (!existingUrls.contains(info.getFullUrl())) { 136 136 layerInfo.add(info); 137 137 } -
trunk/src/org/openstreetmap/josm/io/imagery/WMSGrabber.java
r3808 r3826 43 43 public WMSGrabber(MapView mv, WMSLayer layer) { 44 44 super(mv, layer); 45 this.baseURL = layer.getInfo().getU RL();45 this.baseURL = layer.getInfo().getUrl(); 46 46 /* URL containing placeholders? */ 47 47 urlWithPatterns = ImageryInfo.isUrlWithPatterns(baseURL);
Note:
See TracChangeset
for help on using the changeset viewer.