Changeset 33710 in osm


Ignore:
Timestamp:
2017-10-07T13:58:25+02:00 (7 years ago)
Author:
donvip
Message:

fix #josm15408 - plugin download_along is very slow when computing download area for complex multipolygon (patch by GerdP)

Location:
applications/editors/josm/plugins/download_along
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/download_along/build.xml

    r32730 r33710  
    44    <property name="commit.message" value="Changed the constructor signature of the plugin main class"/>
    55    <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
    6     <property name="plugin.main.version" value="10657"/>
     6    <property name="plugin.main.version" value="12643"/>
    77
    88        <!-- Configure these properties (replace "..." accordingly).
  • applications/editors/josm/plugins/download_along/src/org/openstreetmap/josm/plugin/download_along/DownloadAlong.java

    r30633 r33710  
    22package org.openstreetmap.josm.plugin.download_along;
    33
    4 import org.openstreetmap.josm.Main;
     4import org.openstreetmap.josm.gui.MainApplication;
    55import org.openstreetmap.josm.gui.MainMenu;
    66import org.openstreetmap.josm.plugins.Plugin;
     
    1111    public DownloadAlong(PluginInformation info) {
    1212        super(info);
    13         MainMenu.add(Main.main.menu.moreToolsMenu, new DownloadAlongWayAction());
     13        MainMenu.add(MainApplication.getMenu().moreToolsMenu, new DownloadAlongWayAction());
    1414    }
    1515}
  • applications/editors/josm/plugins/download_along/src/org/openstreetmap/josm/plugin/download_along/DownloadAlongWayAction.java

    r32946 r33710  
    77import java.awt.event.KeyEvent;
    88import java.awt.geom.Area;
     9import java.awt.geom.Path2D;
    910import java.awt.geom.Rectangle2D;
    1011import java.util.ArrayList;
     
    2324import org.openstreetmap.josm.gui.layer.gpx.DownloadAlongPanel;
    2425import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
     26import org.openstreetmap.josm.tools.Logging;
    2527import org.openstreetmap.josm.tools.Shortcut;
    2628
     
    8486        double buffer_x = buffer_y / scale;
    8587        double max_area = panel.getArea() / 10000.0 / scale;
    86         Area a = new Area();
     88        Path2D path = new Path2D.Double();
    8789        Rectangle2D r = new Rectangle2D.Double();
    8890
     
    101103                    Double d = c.greatCircleDistance(previous) / buffer_dist;
    102104                    int nbNodes = d.intValue();
    103                     Main.info(tr("{0} intermediate nodes to download.", nbNodes));
    104                     Main.info(tr("between {0} {1} and {2} {3}", c.lat(), c.lon(), previous.lat(),
     105                    Logging.info(tr("{0} intermediate nodes to download.", nbNodes));
     106                    Logging.info(tr("between {0} {1} and {2} {3}", c.lat(), c.lon(), previous.lat(),
    105107                            previous.lon()));
    106108                    for (int i = 1; i < nbNodes; i++) {
     
    108110                                + (i * (c.lat() - previous.lat()) / (nbNodes + 1)), previous.lon()
    109111                                + (i * (c.lon() - previous.lon()) / (nbNodes + 1))));
    110                         Main.info(tr("  adding {0} {1}", previous.lat()
     112                        Logging.info(tr("  adding {0} {1}", previous.lat()
    111113                                + (i * (c.lat() - previous.lat()) / (nbNodes + 1)), previous.lon()
    112114                                + (i * (c.lon() - previous.lon()) / (nbNodes + 1))));
     
    118120                        // we add a buffer around the point.
    119121                        r.setRect(d.lon() - buffer_x, d.lat() - buffer_y, 2 * buffer_x, 2 * buffer_y);
    120                         a.add(new Area(r));
     122                        path.append(r, false);
    121123                        previous = d;
    122124                    }
     
    125127            }
    126128        }
    127        
     129        Area a = new Area(path);
    128130        confirmAndDownloadAreas(a, max_area, panel.isDownloadOsmData(), panel.isDownloadGpxData(),
    129131                tr("Download from OSM along selected ways"), NullProgressMonitor.INSTANCE);
Note: See TracChangeset for help on using the changeset viewer.