Package org.openstreetmap.josm.actions.downloadtasks

Examples of org.openstreetmap.josm.actions.downloadtasks.DownloadOsmTask


        }
    }

    @Override
    protected void handleRequest() throws RequestHandlerErrorException {
        DownloadTask osmTask = new DownloadOsmTask();
        try {
            boolean newLayer = isLoadInNewLayer();

            if (command.equals(myCommand)) {
                if (!PermissionPrefWithDefault.LOAD_DATA.isAllowed()) {
                    Main.info("RemoteControl: download forbidden by preferences");
                } else {
                    Area toDownload = null;
                    if (!newLayer) {
                        // find out whether some data has already been downloaded
                        Area present = null;
                        DataSet ds = Main.main.getCurrentDataSet();
                        if (ds != null) {
                            present = ds.getDataSourceArea();
                        }
                        if (present != null && !present.isEmpty()) {
                            toDownload = new Area(new Rectangle2D.Double(minlon,minlat,maxlon-minlon,maxlat-minlat));
                            toDownload.subtract(present);
                            if (!toDownload.isEmpty()) {
                                // the result might not be a rectangle (L shaped etc)
                                Rectangle2D downloadBounds = toDownload.getBounds2D();
                                minlat = downloadBounds.getMinY();
                                minlon = downloadBounds.getMinX();
                                maxlat = downloadBounds.getMaxY();
                                maxlon = downloadBounds.getMaxX();
                            }
                        }
                    }
                    if (toDownload != null && toDownload.isEmpty()) {
                        Main.info("RemoteControl: no download necessary");
                    } else {
                        Future<?> future = osmTask.download(newLayer, new Bounds(minlat,minlon,maxlat,maxlon), null /* let the task manage the progress monitor */);
                        Main.worker.submit(new PostDownloadHandler(osmTask, future));
                    }
                }
            }
        } catch (Exception ex) {
View Full Code Here


        // Find download tasks for the given URL
        suitableDownloadTasks = Main.main.menu.openLocation.findDownloadTasks(urlString);
        if (suitableDownloadTasks.isEmpty()) {
            // It should maybe be better to reject the request in that case ?
            // For compatibility reasons with older instances of JOSM, arbitrary choice of DownloadOsmTask
            suitableDownloadTasks.add(new DownloadOsmTask());
        }
    }
View Full Code Here

        dialog.setVisible(true);
        if (! dialog.isCanceled()) {
            dialog.rememberSettings();
            Bounds area = dialog.getSelectedDownloadArea();
            if (dialog.isDownloadOsmData()) {
                DownloadOsmTask task = new DownloadOsmTask();
                Future<?> future = task.download(dialog.isNewLayerRequired(), area, null);
                Main.worker.submit(new PostDownloadHandler(task, future));
            }
            if (dialog.isDownloadGpxData()) {
                DownloadGpsTask task = new DownloadGpsTask();
                Future<?> future = task.download(dialog.isNewLayerRequired(),area, null);
                Main.worker.submit(new PostDownloadHandler(task, future));
            }
        }
    }
View Full Code Here

     * @param b The bounds value
     * @see #downloadFromParamBounds(boolean, String)
     * @see #downloadFromParamHttp
     */
    private static void downloadFromParamBounds(final boolean rawGps, Bounds b) {
        DownloadTask task = rawGps ? new DownloadGpsTask() : new DownloadOsmTask();
        // asynchronously launch the download task ...
        Future<?> future = task.download(true, b, null);
        // ... and the continuation when the download is finished (this will wait for the download to finish)
        Main.worker.execute(new PostDownloadHandler(task, future));
    }
View Full Code Here

TOP

Related Classes of org.openstreetmap.josm.actions.downloadtasks.DownloadOsmTask

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.