public class DownloadOsmTask extends AbstractDownloadTask<DataSet>
| Modifier and Type | Class and Description |
|---|---|
static class |
DownloadOsmTask.AbstractInternalTask
Superclass of internal download task.
|
protected class |
DownloadOsmTask.DownloadTask |
| Modifier and Type | Field and Description |
|---|---|
protected Bounds |
currentBounds |
protected DownloadOsmTask.DownloadTask |
downloadTask |
protected java.lang.String |
newLayerName |
private static java.lang.String |
NO_DATA_FOUND |
protected static java.lang.String |
OVERPASS_INTERPRETER_DATA |
protected boolean |
warnAboutEmptyArea
This allows subclasses to ignore this warning
|
downloadedData, zoomAfterDownload| Constructor and Description |
|---|
DownloadOsmTask() |
| Modifier and Type | Method and Description |
|---|---|
void |
cancel()
Cancels the asynchronous download task.
|
protected java.util.concurrent.Future<?> |
download(DownloadOsmTask.DownloadTask downloadTask,
Bounds downloadArea) |
java.util.concurrent.Future<?> |
download(DownloadParams settings,
Bounds downloadArea,
ProgressMonitor progressMonitor)
Asynchronously launches the download task for a given bounding box.
|
java.util.concurrent.Future<?> |
download(OsmServerReader reader,
DownloadParams settings,
Bounds downloadArea,
ProgressMonitor progressMonitor)
Asynchronously launches the download task for a given bounding box.
|
protected void |
extractOsmFilename(DownloadParams settings,
java.lang.String pattern,
java.lang.String url) |
java.lang.String |
getConfirmationMessage(java.net.URL url)
Replies the HTML-formatted confirmation message to be shown to user when the given URL needs to be confirmed before loading.
|
ProjectionBounds |
getDownloadProjectionBounds()
Returns the projection bounds of downloaded data.
|
protected OsmServerReader |
getOsmServerReader(java.lang.String url) |
java.lang.String[] |
getPatterns()
Returns regular expressions that match the URLs
|
java.lang.String |
getTitle()
Returns human-readable description of the task
|
boolean |
isSafeForRemotecontrolRequests()
Check / decide if the task is safe for remotecontrol.
|
java.util.concurrent.Future<?> |
loadUrl(DownloadParams settings,
java.lang.String url,
ProgressMonitor progressMonitor)
Loads a given URL from the OSM Server
|
protected java.lang.String |
modifyUrlBeforeLoad(java.lang.String url)
This allows subclasses to perform operations on the URL before
loadUrl(org.openstreetmap.josm.actions.downloadtasks.DownloadParams, java.lang.String, org.openstreetmap.josm.gui.progress.ProgressMonitor) is performed. |
protected java.util.Collection<OsmPrimitive> |
searchPotentiallyDeletedPrimitives(DataSet ds) |
acceptsDocumentationSummary, acceptsUrl, acceptsUrl, getDownloadedData, getErrorObjects, isCanceled, isFailed, patterns, rememberDownloadedData, rememberErrorMessage, rememberException, setCanceled, setFailed, setZoomAfterDownload, toStringprotected Bounds currentBounds
protected DownloadOsmTask.DownloadTask downloadTask
protected java.lang.String newLayerName
protected boolean warnAboutEmptyArea
protected static final java.lang.String OVERPASS_INTERPRETER_DATA
private static final java.lang.String NO_DATA_FOUND
public DownloadOsmTask()
public java.lang.String[] getPatterns()
DownloadTaskgetPatterns in interface DownloadTaskgetPatterns in class AbstractDownloadTask<DataSet>public java.lang.String getTitle()
DownloadTaskgetTitle in interface DownloadTaskgetTitle in class AbstractDownloadTask<DataSet>public java.util.concurrent.Future<?> download(DownloadParams settings, Bounds downloadArea, ProgressMonitor progressMonitor)
DownloadTaskprogressMonitor to null, if the task should create, open, and close a progress monitor.
Set progressMonitor to NullProgressMonitor.INSTANCE if progress information is to
be discarded.
You can wait for the asynchronous download task to finish by synchronizing on the returned
Future, but make sure not to freeze up JOSM. Example:
Future<?> future = task.download(...);
// DON'T run this on the Swing EDT or JOSM will freeze
future.get(); // waits for the dowload task to complete
The following example uses a pattern which is better suited if a task is launched from
the Swing EDT:
final Future<?> future = task.download(...);
Runnable runAfterTask = new Runnable() {
public void run() {
// this is not strictly necessary because of the type of executor service
// Main.worker is initialized with, but it doesn't harm either
//
future.get(); // wait for the download task to complete
doSomethingAfterTheTaskCompleted();
}
}
MainApplication.worker.submit(runAfterTask);
settings - download settingsdownloadArea - the area to downloadprogressMonitor - the progressMonitorpublic java.util.concurrent.Future<?> download(OsmServerReader reader, DownloadParams settings, Bounds downloadArea, ProgressMonitor progressMonitor)
progressMonitor to null, if the task should create, open, and close a progress monitor.
Set progressMonitor to NullProgressMonitor.INSTANCE if progress information is to
be discarded.
You can wait for the asynchronous download task to finish by synchronizing on the returned
Future, but make sure not to freeze up JOSM. Example:
Future<?> future = task.download(...);
// DON'T run this on the Swing EDT or JOSM will freeze
future.get(); // waits for the dowload task to complete
The following example uses a pattern which is better suited if a task is launched from
the Swing EDT:
final Future<?> future = task.download(...);
Runnable runAfterTask = new Runnable() {
public void run() {
// this is not strictly necessary because of the type of executor service
// Main.worker is initialized with, but it doesn't harm either
//
future.get(); // wait for the download task to complete
doSomethingAfterTheTaskCompleted();
}
}
MainApplication.worker.submit(runAfterTask);
reader - the reader used to parse OSM data (see OsmServerReader.parseOsm(org.openstreetmap.josm.gui.progress.ProgressMonitor))settings - download settingsdownloadArea - the area to downloadprogressMonitor - the progressMonitorprotected java.util.concurrent.Future<?> download(DownloadOsmTask.DownloadTask downloadTask, Bounds downloadArea)
protected java.lang.String modifyUrlBeforeLoad(java.lang.String url)
loadUrl(org.openstreetmap.josm.actions.downloadtasks.DownloadParams, java.lang.String, org.openstreetmap.josm.gui.progress.ProgressMonitor) is performed.url - the original URLpublic java.util.concurrent.Future<?> loadUrl(DownloadParams settings, java.lang.String url, ProgressMonitor progressMonitor)
settings - download settingsurl - The URL as StringprogressMonitor - the progressMonitorDownloadTask.download(DownloadParams, Bounds, ProgressMonitor)protected OsmServerReader getOsmServerReader(java.lang.String url)
protected final void extractOsmFilename(DownloadParams settings, java.lang.String pattern, java.lang.String url)
public void cancel()
DownloadTaskpublic boolean isSafeForRemotecontrolRequests()
AbstractDownloadTaskisSafeForRemotecontrolRequests in class AbstractDownloadTask<DataSet>public ProjectionBounds getDownloadProjectionBounds()
AbstractDownloadTaskgetDownloadProjectionBounds in class AbstractDownloadTask<DataSet>nullprotected java.util.Collection<OsmPrimitive> searchPotentiallyDeletedPrimitives(DataSet ds)
public java.lang.String getConfirmationMessage(java.net.URL url)
DownloadTaskurl - The URL to be confirmed