Changeset 4375 in josm


Ignore:
Timestamp:
2011-08-28T14:24:35+02:00 (13 years ago)
Author:
simon04
Message:

fix #2750 - add inView, allinView to search

Location:
trunk/src/org/openstreetmap/josm/actions/search
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/search/SearchAction.java

    r4373 r4375  
    230230        descriptionText.appendItem(tr("<b>parent <i>expr</i></b> - all parents of objects matching the expression"));
    231231        descriptionText.appendItem(tr("<b>(all)inDownloadedArea</b> - objects (and all its way nodes / relation members) in downloaded area"));
     232        descriptionText.appendItem(tr("<b>(all)inView</b> - objects (and all its way nodes / relation members) in current view"));
    232233        descriptionText.appendItem(tr("Use <b>|</b> or <b>OR</b> to combine with logical or"));
    233234        descriptionText.appendItem(tr("Use <b>\"</b> to quote operators (e.g. if key contains <b>:</b>)")
  • trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java

    r4372 r4375  
    1616import org.openstreetmap.josm.actions.search.PushbackTokenizer.Range;
    1717import org.openstreetmap.josm.actions.search.PushbackTokenizer.Token;
     18import org.openstreetmap.josm.data.Bounds;
    1819import org.openstreetmap.josm.data.osm.Node;
    1920import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    724725
    725726    /**
    726      * Matches data in source area ("downloaded area").
     727     * Matches data within bounds.
    727728     */
    728     private static class InDataSourceArea extends Match {
    729 
    730         private final java.awt.geom.Area dataSourceArea = Main.main.getCurrentDataSet().getDataSourceArea();
    731         private final boolean all;
     729    private abstract static class InArea extends Match {
     730
     731        protected abstract Bounds getBounds();
     732        protected final boolean all;
     733        protected final Bounds bounds;
    732734
    733735        /**
    734736         * @param all if true, all way nodes or relation members have to be within source area;if false, one suffices.
    735737         */
    736         public InDataSourceArea(boolean all) {
     738        public InArea(boolean all) {
    737739            this.all = all;
     740            this.bounds = getBounds();
    738741        }
    739742
     
    743746                return false;
    744747            } else if (osm instanceof Node) {
    745                 return dataSourceArea.contains(((Node) osm).getCoor());
     748                return bounds.contains(((Node) osm).getCoor());
    746749            } else if (osm instanceof Way) {
    747750                Collection<Node> nodes = ((Way) osm).getNodes();
     
    753756                return false;
    754757            }
     758        }
     759    }
     760
     761    /**
     762     * Matches data in source area ("downloaded area").
     763     */
     764    private static class InDataSourceArea extends InArea {
     765
     766        public InDataSourceArea(boolean all) {
     767            super(all);
     768        }
     769
     770        @Override
     771        protected Bounds getBounds() {
     772            return new Bounds(Main.main.getCurrentDataSet().getDataSourceArea().getBounds2D());
     773        }
     774    }
     775
     776    /**
     777     * Matches data in current map view.
     778     */
     779    private static class InView extends InArea {
     780
     781        public InView(boolean all) {
     782            super(all);
     783        }
     784
     785        @Override
     786        protected Bounds getBounds() {
     787            return Main.map.mapView.getRealBounds();
    755788        }
    756789    }
     
    857890            else if ("allinDownloadedArea".equals(key))
    858891                return new InDataSourceArea(true);
     892            else if ("inView".equals(key))
     893                return new InView(false);
     894            else if ("allinView".equals(key))
     895                return new InView(true);
    859896            else
    860897                return new Any(key, regexSearch, caseSensitive);
Note: See TracChangeset for help on using the changeset viewer.