Changeset 4183 in josm for trunk/src/org/openstreetmap/josm/io
- Timestamp:
- 2011-06-29T10:06:35+02:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/imagery/WMSGrabber.java
r4172 r4183 18 18 import java.text.DecimalFormatSymbols; 19 19 import java.text.NumberFormat; 20 import java.util.ArrayList; 20 21 import java.util.Locale; 21 22 import java.util.regex.Matcher; … … 73 74 int wi, int ht) throws MalformedURLException { 74 75 String myProj = Main.getProjection().toCode(); 75 if(Main.getProjection() instanceof Mercator) // don't use mercator code directly 76 String srs = ""; 77 boolean useepsg = false; 78 try 79 { 80 Matcher m = Pattern.compile(".*srs=([a-z0-9:]+).*").matcher(baseURL.toUpperCase()); 81 if(m.matches()) 82 { 83 if(m.group(1).equals("EPSG:4326") && Main.getProjection() instanceof Mercator) 84 useepsg = true; 85 } else if(Main.getProjection() instanceof Mercator) { 86 useepsg = true; 87 srs ="&srs=EPSG:4326"; 88 } else { 89 srs ="&srs="+myProj; 90 } 91 } 92 catch(Exception ex) 93 { 94 } 95 96 if(useepsg) // don't use mercator code directly 76 97 { 77 98 LatLon sw = Main.getProjection().eastNorth2latlon(new EastNorth(w, s)); … … 101 122 } else { 102 123 str += "bbox=" + bbox 103 + getProjection(baseURL, false)124 + srs 104 125 + "&width=" + wi + "&height=" + ht; 105 126 if (!(baseURL.endsWith("&") || baseURL.endsWith("?"))) { … … 112 133 } 113 134 114 static public String getProjection(String baseURL, Boolean warn)135 static public ArrayList<String> getServerProjections(String baseURL, Boolean warn) 115 136 { 116 String projname = Main.getProjection().toCode(); 117 if(Main.getProjection() instanceof Mercator) { 118 projname = "EPSG:4326"; 119 } 120 String res = ""; 137 ArrayList<String> serverProjections = new ArrayList<String>(); 121 138 try 122 139 { 123 Matcher m = Pattern.compile(".*srs=([a-z0-9:]+).*").matcher(baseURL.to LowerCase());140 Matcher m = Pattern.compile(".*srs=([a-z0-9:]+).*").matcher(baseURL.toUpperCase()); 124 141 if(m.matches()) 125 142 { 126 projname = projname.toLowerCase(); 127 if(!projname.equals(m.group(1)) && warn) 128 { 129 JOptionPane.showMessageDialog(Main.parent, 130 tr("The projection ''{0}'' in URL and current projection ''{1}'' mismatch.\n" 131 + "This may lead to wrong coordinates.", 132 m.group(1), projname), 133 tr("Warning"), 134 JOptionPane.WARNING_MESSAGE); 135 } 136 } else { 137 res ="&srs="+projname; 138 } 143 serverProjections.add(m.group(1)); 144 if(m.group(1).equals("EPSG:4326")) 145 serverProjections.add(new Mercator().toCode()); 146 } 147 /* TODO: here should be an "else" code checking server capabilities */ 139 148 } 140 149 catch(Exception e) 141 150 { 142 151 } 143 return res; 152 if(serverProjections.isEmpty()) 153 return null; 154 if(warn) 155 { 156 String myProj = Main.getProjection().toCode().toUpperCase(); 157 if(!serverProjections.contains(myProj)) 158 { 159 JOptionPane.showMessageDialog(Main.parent, 160 tr("The projection ''{0}'' in URL and current projection ''{1}'' mismatch.\n" 161 + "This may lead to wrong coordinates.", 162 serverProjections.get(0), myProj), 163 tr("Warning"), 164 JOptionPane.WARNING_MESSAGE); 165 } 166 } 167 return serverProjections; 144 168 } 145 169
Note:
See TracChangeset
for help on using the changeset viewer.