Changeset 7251 in josm
- Timestamp:
- 2014-06-17T22:23:01+02:00 (11 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/io/remotecontrol/handler
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/ImageryHandler.java
r7005 r7251 126 126 @Override 127 127 public String getUsage() { 128 return "adds an imagery layer (e.g. WMS, TMS) )";128 return "adds an imagery layer (e.g. WMS, TMS)"; 129 129 } 130 130 -
trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/LoadAndZoomHandler.java
r7005 r7251 6 6 import java.awt.geom.Area; 7 7 import java.awt.geom.Rectangle2D; 8 import java.util.Collection; 9 import java.util.Collections; 8 10 import java.util.HashSet; 9 11 import java.util.Set; … … 15 17 import org.openstreetmap.josm.actions.downloadtasks.DownloadTask; 16 18 import org.openstreetmap.josm.actions.downloadtasks.PostDownloadHandler; 19 import org.openstreetmap.josm.actions.search.SearchCompiler; 17 20 import org.openstreetmap.josm.data.Bounds; 18 21 import org.openstreetmap.josm.data.coor.LatLon; … … 70 73 @Override 71 74 public String[] getOptionalParams() { 72 return new String[] {"new_layer", "addtags", "select", "zoom_mode", "changeset_comment", "changeset_source"}; 75 return new String[] {"new_layer", "addtags", "select", "zoom_mode", "changeset_comment", "changeset_source", "search"}; 73 76 } 74 77 … … 91 94 } else { 92 95 return new String[] { 93 "/zoom?left=8.19&right=8.20&top=48.605&bottom=48.590&select=node413602999"}; 96 "/zoom?left=8.19&right=8.20&top=48.605&bottom=48.590&select=node413602999", 97 "/zoom?left=8.19&right=8.20&top=48.605&bottom=48.590&search=highway+OR+railway", 98 }; 94 99 } 95 100 } … … 163 168 Set<OsmPrimitive> newSel = new HashSet<>(); 164 169 DataSet ds = Main.main.getCurrentDataSet(); 165 if(ds == null) // e.g. download failed 170 if (ds == null) // e.g. download failed 166 171 return; 167 172 for (SimplePrimitiveId id : toSelect) { … … 173 178 toSelect.clear(); 174 179 ds.setSelected(newSel); 175 if (PermissionPrefWithDefault.CHANGE_VIEWPORT.isAllowed()) { 176 // zoom_mode=(download|selection), defaults to selection 177 if (!"download".equals(args.get("zoom_mode")) && !newSel.isEmpty()) { 178 AutoScaleAction.autoScale("selection"); 179 } else { 180 zoom(bbox); 181 } 182 } 180 zoom(newSel, bbox); 183 181 if (Main.isDisplayingMapView() && Main.map.relationListDialog != null) { 184 182 Main.map.relationListDialog.selectRelations(null); // unselect all relations to fix #7342 … … 188 186 } 189 187 }); 190 } else if (PermissionPrefWithDefault.CHANGE_VIEWPORT.isAllowed()) { 188 } else if (args.containsKey("search") && PermissionPrefWithDefault.CHANGE_SELECTION.isAllowed()) { 189 try { 190 final DataSet ds = Main.main.getCurrentDataSet(); 191 final SearchCompiler.Match search = SearchCompiler.compile(args.get("search"), false, false); 192 final Collection<OsmPrimitive> filteredPrimitives = Utils.filter(ds.allPrimitives(), search); 193 ds.setSelected(filteredPrimitives); 194 zoom(filteredPrimitives, bbox); 195 } catch (SearchCompiler.ParseError ex) { 196 Main.error(ex); 197 throw new RequestHandlerErrorException(ex); 198 } 199 } else { 191 200 // after downloading, zoom to downloaded area. 192 zoom(bbox); 201 zoom(Collections.<OsmPrimitive>emptySet(), bbox); 193 202 } 194 203 … … 213 222 } 214 223 215 protected void zoom(final Bounds bounds) { 216 // make sure this isn't called unless there *is* a MapView 217 if (Main.isDisplayingMapView()) { 224 protected void zoom(Collection<OsmPrimitive> primitives, final Bounds bbox) { 225 if (!PermissionPrefWithDefault.CHANGE_VIEWPORT.isAllowed()) { 226 return; 227 } 228 // zoom_mode=(download|selection), defaults to selection 229 if (!"download".equals(args.get("zoom_mode")) && !primitives.isEmpty()) { 230 AutoScaleAction.autoScale("selection"); 231 } else if (Main.isDisplayingMapView()) { 232 // make sure this isn't called unless there *is* a MapView 218 233 GuiHelper.executeByMainWorkerInEDT(new Runnable() { 219 234 @Override 220 235 public void run() { 221 BoundingXYVisitor bbox = new BoundingXYVisitor(); 222 bbox.visit(b ounds);223 Main.map.mapView.recalculateCenterScale(bbox); 236 BoundingXYVisitor bbox1 = new BoundingXYVisitor(); 237 bbox1.visit(bbox); 238 Main.map.mapView.recalculateCenterScale(bbox1); 224 239 } 225 240 });
Note:
See TracChangeset
for help on using the changeset viewer.