- Timestamp:
- 2013-03-19T01:43:29+01:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java
r5730 r5782 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.awt.geom.Area;7 6 import java.io.IOException; 7 import java.io.UnsupportedEncodingException; 8 8 import java.net.URL; 9 import java.net.URLEncoder; 9 10 import java.util.Collection; 10 11 import java.util.concurrent.Future; 11 12 import java.util.regex.Matcher; 12 13 import java.util.regex.Pattern; 13 14 import org.xml.sax.SAXException;15 14 16 15 import org.openstreetmap.josm.Main; … … 30 29 import org.openstreetmap.josm.io.OsmTransferCanceledException; 31 30 import org.openstreetmap.josm.io.OsmTransferException; 31 import org.xml.sax.SAXException; 32 32 33 33 /** … … 116 116 } 117 117 118 protected final String encodePartialUrl(String url, String safePart) { 119 if (url != null && safePart != null) { 120 int pos = url.indexOf(safePart); 121 if (pos > -1) { 122 pos += safePart.length(); 123 try { 124 return url.substring(0, pos) + URLEncoder.encode(url.substring(pos), "UTF-8").replaceAll("\\+", "%20"); 125 } catch (UnsupportedEncodingException e) { 126 e.printStackTrace(); 127 } 128 } 129 } 130 return url; 131 } 132 118 133 /** 119 134 * Loads a given URL from the OSM Server … … 122 137 */ 123 138 public Future<?> loadUrl(boolean new_layer, String url, ProgressMonitor progressMonitor) { 139 if (url.matches(PATTERN_OVERPASS_API_URL)) { 140 url = encodePartialUrl(url, "/interpreter?data="); // encode only the part after the = sign 141 142 } else if (url.matches(PATTERN_OVERPASS_API_XAPI_URL)) { 143 url = encodePartialUrl(url, "/xapi?"); // encode only the part after the ? sign 144 } 124 145 downloadTask = new DownloadTask(new_layer, 125 146 new OsmServerLocationReader(url),
Note:
See TracChangeset
for help on using the changeset viewer.