Changeset 27318 in osm for applications/editors/josm/plugins/utilsplugin2/src
- Timestamp:
- 2011-12-26T18:42:16+01:00 (13 years ago)
- Location:
- applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/UtilsPlugin2.java
r26792 r27318 43 43 JMenuItem selModifiedWays; 44 44 JMenuItem selectHighway; 45 JMenuItem selectAreaBoundary; 45 46 46 47 JMenuItem selectURL; … … 79 80 undoSelection = MainMenu.add(selectionMenu, new UndoSelectionAction()); 80 81 selectHighway = MainMenu.add(selectionMenu, new SelectHighwayAction()); 82 selectAreaBoundary = MainMenu.add(selectionMenu, new SelectBoundaryAction()); 81 83 82 84 selectURL = MainMenu.add(toolsMenu, new ChooseURLAction()); -
applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/selection/NodeWayUtils.java
r26662 r27318 268 268 } 269 269 } 270 271 270 271 static boolean addAreaBoundary(Way firstWay, Set<Way> newWays, boolean goingLeft) { 272 Way w=firstWay; 273 Node curNode = w.lastNode(); 274 Node prevNode = w.getNode(w.getNodes().size()-2); 275 Set<Way> newestWays = new HashSet<Way>(); 276 while(true) { 277 278 Node nextNode, endNode, otherEnd, preLast; 279 Way nextWay; 280 281 EastNorth en; 282 double startHeading,bestAngle; 283 284 en = curNode.getEastNorth(); 285 startHeading = prevNode.getEastNorth().heading( en ); 286 287 bestAngle = goingLeft ? -1e5 : 1e5 ; 288 otherEnd=null; nextWay=null; 289 290 for (OsmPrimitive ref : curNode.getReferrers()) { 291 if (ref instanceof Way && ref!=w && ref.isSelectable()) { 292 // 293 Way w2 = (Way) ref; 294 // -----[prevNode]-(curNode)-[nextNode]------[preLast]-(endNode) 295 // w | w2 296 if (w2.getNodesCount()<2 || w2.isClosed()) continue; 297 298 299 if (curNode == w2.firstNode()) { 300 nextNode = w2.getNode(1); 301 preLast = w2.getNode(w2.getNodesCount()-2); 302 endNode = w2.lastNode(); 303 } // forward direction 304 else if (curNode == w2.lastNode()) { 305 nextNode = w2.getNode(w2.getNodesCount()-2); 306 preLast = w2.getNode(1); 307 endNode = w2.firstNode(); 308 } // backward direction 309 else continue; // we came to some way middle node 310 311 double angle = startHeading -Math.PI - en.heading(nextNode.getEastNorth()); 312 while (angle<0) angle+=2*Math.PI; 313 314 if (angle < bestAngle ^ goingLeft) { 315 bestAngle = angle; 316 otherEnd = endNode; 317 prevNode = preLast; 318 nextWay = w2; 319 } 320 } 321 } 322 if (firstWay == nextWay ) { 323 //we came to starting way, but not not the right end 324 if (otherEnd==firstWay.firstNode()) return false; 325 newWays.addAll(newestWays); 326 return true; // correct loop found 327 } 328 if (newestWays.contains(nextWay)) { 329 // P - like loop found 330 return false; 331 } 332 if (nextWay != null) { 333 newestWays.add(nextWay); 334 curNode = otherEnd; 335 w = nextWay; 336 // next way found, continuing 337 } else { 338 // no closed loop found 339 return false; 340 } 341 } 342 } 343 272 344 static void addAllInsideMultipolygon(DataSet data, Relation rel, Set<Way> newWays, Set<Node> newNodes) { 273 345 if (!rel.isMultipolygon()) return; -
applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/selection/SelectAllInsideAction.java
r26694 r27318 35 35 public void actionPerformed(ActionEvent e) { 36 36 long t=System.currentTimeMillis(); 37 Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected();38 37 Set<Way> selectedWays = OsmPrimitive.getFilteredSet(getCurrentDataSet().getSelected(), Way.class); 39 38 Set<Relation> selectedRels = OsmPrimitive.getFilteredSet(getCurrentDataSet().getSelected(), Relation.class);
Note:
See TracChangeset
for help on using the changeset viewer.