Changeset 24942 in osm


Ignore:
Timestamp:
2011-01-02T12:45:06+01:00 (14 years ago)
Author:
oliverw
Message:

Zoom to selected item in incomplete address list.

Location:
applications/editors/josm/plugins/FixAddresses
Files:
4 edited

Legend:

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

    r24232 r24942  
    9090                <attribute name="Author" value="Oliver Wieland"/>
    9191                <attribute name="Plugin-Class" value="org.openstreetmap.josm.plugins.fixAddresses.FixAddressesPlugin"/>
    92                 <attribute name="Plugin-Date" value="14.11.2010"/>
     92                <attribute name="Plugin-Date" value="02.01.2011"/>
    9393                <attribute name="Plugin-Description" value="Finds and fixes invalid street addresses in a comfortable way."/>
    9494                <attribute name="de_Plugin-Description" value="Findet ungültige Addressen und bietet Unterstützung zur deren Korrektur."/>
  • applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/OsmUtils.java

    r24941 r24942  
    1717import java.util.Locale;
    1818
     19import org.openstreetmap.josm.Main;
     20import org.openstreetmap.josm.data.Bounds;
    1921import org.openstreetmap.josm.data.coor.LatLon;
    2022import org.openstreetmap.josm.data.osm.Node;
     
    2325import org.openstreetmap.josm.data.osm.RelationMember;
    2426import org.openstreetmap.josm.data.osm.Way;
     27import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
    2528import org.openstreetmap.josm.tools.CheckParameterUtil;
    2629import org.openstreetmap.josm.tools.Pair;
    2730
     31// TODO: Auto-generated Javadoc
    2832/**
    2933 * The Class OsmUtils provides some utilities not provided by the OSM data framework.
    3034 */
    3135public class OsmUtils {
     36       
     37        /**
     38         * Instantiates a new osm utils.
     39         */
    3240        private OsmUtils() {}
    3341       
     42        /** The cached locale. */
    3443        private static String cachedLocale = null;
    3544       
     
    196205                return cachedLocale;
    197206        }
     207       
     208        /**
     209         * Zooms to the given addresses.
     210         *
     211         * @param addressList the address list
     212         */
     213        public static void zoomAddresses(List<OSMAddress> addressList) {
     214                CheckParameterUtil.ensureParameterNotNull(addressList, "addressList");
     215               
     216                if (Main.map == null && Main.map.mapView == null) return; // nothing to do
     217                       
     218                // compute bounding box
     219                BoundingXYVisitor bbox = new BoundingXYVisitor();
     220        for (OSMAddress source : addressList) {
     221                OsmPrimitive osm = source.getOsmObject();
     222                Bounds b = new Bounds(osm.getBBox().getTopLeft(), osm.getBBox().getBottomRight());
     223            bbox.visit(b);
     224        }
     225       
     226        // zoom to calculated bounding box       
     227        Main.map.mapView.zoomTo(bbox.getBounds());
     228        }
    198229
    199230        /**
     
    205236         */
    206237        private static void applyDerivedValue(OSMAddress address, Way w, String tag) {
     238                CheckParameterUtil.ensureParameterNotNull(address, "address");
     239                CheckParameterUtil.ensureParameterNotNull(w, "way");
     240               
    207241                if (!address.hasTag(tag) && TagUtils.hasTag(w, tag)) {                                         
    208242                        address.setDerivedValue(tag, w.get(tag));
  • applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/gui/IncompleteAddressesDialog.java

    r24940 r24942  
    4141import org.openstreetmap.josm.plugins.fixAddresses.IAddressEditContainerListener;
    4242import org.openstreetmap.josm.plugins.fixAddresses.IOSMEntity;
     43import org.openstreetmap.josm.plugins.fixAddresses.OsmUtils;
    4344import org.openstreetmap.josm.plugins.fixAddresses.gui.actions.AbstractAddressEditAction;
    4445import org.openstreetmap.josm.plugins.fixAddresses.gui.actions.ApplyAllGuessesAction;
     
    204205                for (AbstractAddressEditAction action : actions) {
    205206                        action.setEvent(event);
    206                 }               
     207                }       
     208               
     209                OsmUtils.zoomAddresses(event.getSelectedIncompleteAddresses());
    207210        }
    208211
  • applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/gui/IncompleteAddressesTableModel.java

    r24231 r24942  
    142142       
    143143
     144        /* (non-Javadoc)
     145         * @see org.openstreetmap.josm.plugins.fixAddresses.gui.AddressEditTableModel#sortByColumn(int, boolean)
     146         */
    144147        @Override
    145148        protected void sortByColumn(int column, boolean ascending) {
Note: See TracChangeset for help on using the changeset viewer.