- Timestamp:
- 2016-01-01T18:52:02+01:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/OverpassDownloadAction.java
r8932 r9241 60 60 61 61 /** 62 * The {@link StringProperty property} of the currently selected Overpass server. 63 * 64 * @since 9241 65 */ 66 public static final StringProperty OVERPASS_SERVER = new StringProperty("download.overpass.server", "http://overpass-api.de/api/"); 67 68 /** 62 69 * Constructs a new {@code OverpassDownloadAction}. 63 70 */ … … 121 128 private JosmTextArea overpassQuery; 122 129 private static OverpassDownloadDialog instance; 123 private static final StringProperty OVERPASS_SERVER = new StringProperty("download.overpass.server", "http://overpass-api.de/api/");124 130 private static final CollectionProperty OVERPASS_SERVER_HISTORY = new CollectionProperty("download.overpass.servers", 125 131 Arrays.asList("http://overpass-api.de/api/", "http://overpass.osm.rambler.ru/cgi/")); -
trunk/src/org/openstreetmap/josm/actions/UpdateSelectionAction.java
r8510 r9241 39 39 */ 40 40 public static void handlePrimitiveGoneException(long id, OsmPrimitiveType type) { 41 MultiFetchServerObjectReader reader = new MultiFetchServerObjectReader();41 MultiFetchServerObjectReader reader = MultiFetchServerObjectReader.create(); 42 42 reader.append(getCurrentDataSet(), id, type); 43 43 try { -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadReferrersTask.java
r8510 r9241 220 220 nodes.removeAll(targetLayer.data.getNodes()); 221 221 if (!nodes.isEmpty()) { 222 reader = new MultiFetchServerObjectReader();222 reader = MultiFetchServerObjectReader.create(); 223 223 ((MultiFetchServerObjectReader) reader).append(nodes); 224 224 DataSet wayNodes = reader.parseOsm(progressMonitor.createSubTaskMonitor(1, false)); -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/DownloadRelationMemberTask.java
r9078 r9241 117 117 synchronized (this) { 118 118 if (canceled) return; 119 objectReader = new MultiFetchServerObjectReader();119 objectReader = MultiFetchServerObjectReader.create(); 120 120 } 121 121 objectReader.append(children); -
trunk/src/org/openstreetmap/josm/gui/io/DownloadPrimitivesTask.java
r8510 r9241 141 141 synchronized (this) { 142 142 if (canceled) return; 143 multiObjectReader = new MultiFetchServerObjectReader();143 multiObjectReader = MultiFetchServerObjectReader.create(); 144 144 } 145 145 initMultiFetchReader(multiObjectReader); -
trunk/src/org/openstreetmap/josm/gui/io/UpdatePrimitivesTask.java
r9078 r9241 128 128 synchronized (this) { 129 129 if (canceled) return; 130 multiObjectReader = new MultiFetchServerObjectReader();130 multiObjectReader = MultiFetchServerObjectReader.create(); 131 131 } 132 132 initMultiFetchReaderWithNodes(multiObjectReader); -
trunk/src/org/openstreetmap/josm/io/MultiFetchServerObjectReader.java
r9231 r9241 10 10 import java.util.ArrayList; 11 11 import java.util.Collection; 12 import java.util.Collections; 12 13 import java.util.HashSet; 13 14 import java.util.Iterator; … … 74 75 * Constructs a {@code MultiFetchServerObjectReader}. 75 76 */ 76 p ublicMultiFetchServerObjectReader() {77 protected MultiFetchServerObjectReader() { 77 78 nodes = new LinkedHashSet<>(); 78 79 ways = new LinkedHashSet<>(); … … 80 81 this.outputDataSet = new DataSet(); 81 82 this.missingPrimitives = new LinkedHashSet<>(); 83 } 84 85 /** 86 * Creates a new instance of {@link MultiFetchServerObjectReader} or {@link MultiFetchOverpassObjectReader} 87 * depending on the {@code download.overpass.for-multi-fetch} preference. 88 * 89 * @return a new instance 90 * @since 9241 91 */ 92 public static MultiFetchServerObjectReader create() { 93 return create(Main.pref.getBoolean("download.overpass.for-multi-fetch", false)); 94 } 95 96 /** 97 * Creates a new instance of {@link MultiFetchServerObjectReader} or {@link MultiFetchOverpassObjectReader} 98 * depending on the {@code fromMirror} parameter. 99 * 100 * @param fromMirror {@code false} for {@link MultiFetchServerObjectReader}, {@code true} for {@link MultiFetchOverpassObjectReader} 101 * @return a new instance 102 * @since 9241 103 */ 104 static MultiFetchServerObjectReader create(final boolean fromMirror) { 105 if (fromMirror) { 106 return new MultiFetchOverpassObjectReader(); 107 } else { 108 return new MultiFetchServerObjectReader(); 109 } 82 110 } 83 111 … … 240 268 * @return the request string 241 269 */ 242 protected static String buildRequestString(OsmPrimitiveType type, Set<Long> idPackage) { 243 StringBuilder sb = new StringBuilder(); 244 sb.append(type.getAPIName()).append("s?") 245 .append(type.getAPIName()).append("s="); 246 247 Iterator<Long> it = idPackage.iterator(); 248 for (int i = 0; i < idPackage.size(); i++) { 249 sb.append(it.next()); 250 if (i < idPackage.size()-1) { 251 sb.append(','); 252 } 253 } 254 return sb.toString(); 255 } 256 257 /** 258 * builds the Multi Get request string for a single id and a given {@link OsmPrimitiveType}. 259 * 260 * @param type The primitive type. Must be one of {@link OsmPrimitiveType#NODE NODE}, {@link OsmPrimitiveType#WAY WAY}, 261 * {@link OsmPrimitiveType#RELATION RELATION} 262 * @param id the id 263 * @return the request string 264 */ 265 protected static String buildRequestString(OsmPrimitiveType type, long id) { 266 StringBuilder sb = new StringBuilder(); 267 sb.append(type.getAPIName()).append("s?") 268 .append(type.getAPIName()).append("s=") 269 .append(id); 270 return sb.toString(); 270 protected String buildRequestString(final OsmPrimitiveType type, Set<Long> idPackage) { 271 return type.getAPIName() + "s?" + type.getAPIName() + "s=" + Utils.join(",", idPackage); 272 } 273 274 @Override 275 protected String getBaseUrl() { 276 return super.getBaseUrl(); 271 277 } 272 278 … … 304 310 protected void fetchPrimitives(Set<Long> ids, OsmPrimitiveType type, ProgressMonitor progressMonitor) throws OsmTransferException { 305 311 String msg = ""; 306 String baseUrl = OsmApi.getOsmApi().getBaseUrl();312 final String baseUrl = getBaseUrl(); 307 313 switch (type) { 308 314 case NODE: msg = tr("Fetching a package of nodes from ''{0}''", baseUrl); break; … … 429 435 * @see FetchResult 430 436 */ 431 protected staticclass Fetcher extends OsmServerReader implements Callable<FetchResult> {437 protected class Fetcher extends OsmServerReader implements Callable<FetchResult> { 432 438 433 439 private final Set<Long> pkg; … … 477 483 } 478 484 } 485 } 486 487 @Override 488 protected String getBaseUrl() { 489 return MultiFetchServerObjectReader.this.getBaseUrl(); 479 490 } 480 491 … … 520 531 */ 521 532 protected DataSet singleGetId(OsmPrimitiveType type, long id, ProgressMonitor progressMonitor) throws OsmTransferException { 522 String request = buildRequestString(type, id);533 String request = buildRequestString(type, Collections.singleton(id)); 523 534 DataSet result = null; 524 535 try (InputStream in = getInputStream(request, NullProgressMonitor.INSTANCE)) {
Note:
See TracChangeset
for help on using the changeset viewer.