Changeset 18780 in josm for trunk/src/org/openstreetmap/josm/io
- Timestamp:
- 2023-07-26T17:37:57+02:00 (20 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/imagery/WMSImagery.java
r18211 r18780 12 12 import java.nio.file.InvalidPathException; 13 13 import java.util.ArrayList; 14 import java.util.Arrays; 14 15 import java.util.Collection; 15 16 import java.util.Collections; … … 36 37 import org.openstreetmap.josm.data.projection.Projection; 37 38 import org.openstreetmap.josm.data.projection.Projections; 39 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 40 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 38 41 import org.openstreetmap.josm.io.CachedFile; 39 42 import org.openstreetmap.josm.tools.Logging; … … 151 154 */ 152 155 public WMSImagery(String url, Map<String, String> headers) throws IOException, WMSGetCapabilitiesException { 156 this(url, headers, NullProgressMonitor.INSTANCE); 157 } 158 159 /** 160 * Make getCapabilities request towards given URL using headers 161 * @param url service url 162 * @param headers HTTP headers to be sent with request 163 * @param monitor Feedback for which URL we are currently trying, the integer is the <i>total number of urls</i> we are going to try 164 * @throws IOException when connection error when fetching get capabilities document 165 * @throws WMSGetCapabilitiesException when there are errors when parsing get capabilities document 166 * @throws InvalidPathException if a Path object cannot be constructed for the capabilities cached file 167 * @since xxx 168 */ 169 public WMSImagery(String url, Map<String, String> headers, ProgressMonitor monitor) 170 throws IOException, WMSGetCapabilitiesException { 153 171 if (headers != null) { 154 172 this.headers.putAll(headers); … … 157 175 IOException savedExc = null; 158 176 String workingAddress = null; 177 final String[] baseAdditions = { 178 normalizeUrl(url), 179 url, 180 url + CAPABILITIES_QUERY_STRING, 181 }; 182 final String[] versionAdditions = {"", "&VERSION=1.3.0", "&VERSION=1.1.1"}; 183 final int totalNumberOfUrlsToTry = baseAdditions.length * versionAdditions.length; 184 monitor.setTicksCount(totalNumberOfUrlsToTry); 159 185 url_search: 160 for (String z: new String[]{ 161 normalizeUrl(url), 162 url, 163 url + CAPABILITIES_QUERY_STRING, 164 }) { 165 for (String ver: new String[]{"", "&VERSION=1.3.0", "&VERSION=1.1.1"}) { 186 for (String z : baseAdditions) { 187 for (String ver : versionAdditions) { 188 if (monitor.isCanceled()) { 189 break url_search; 190 } 166 191 try { 192 monitor.setCustomText(z + ver); 193 monitor.worked(1); 167 194 attemptGetCapabilities(z + ver); 168 195 workingAddress = z; … … 193 220 } 194 221 } 195 196 222 if (savedExc != null) { 197 223 throw savedExc; … … 616 642 617 643 private static Bounds parseBBox(Projection conv, String miny, String minx, String maxy, String maxx) { 618 if (miny == null || minx == null || maxy == null || maxx == null) { 644 if (miny == null || minx == null || maxy == null || maxx == null || Arrays.asList(miny, minx, maxy, maxx).contains("nan")) { 619 645 return null; 620 646 }
Note:
See TracChangeset
for help on using the changeset viewer.