Changeset 27318 in osm


Ignore:
Timestamp:
2011-12-26T18:42:16+01:00 (13 years ago)
Author:
akks
Message:

'Utilsplugin2: open url patches'

Location:
applications/editors/josm/plugins/utilsplugin2
Files:
2 added
4 edited

Legend:

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

    r26990 r27318  
    3030<project name="utilsplugin2" default="dist" basedir=".">
    3131    <!-- enter the SVN commit message -->
    32     <property name="commit.message" value="Utilsplugin2: opening URL works without selected object"/>
     32    <property name="commit.message" value="Utilsplugin2: open url patches"/>
    3333    <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
    3434    <property name="plugin.main.version" value="4549"/>
  • applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/UtilsPlugin2.java

    r26792 r27318  
    4343    JMenuItem selModifiedWays;
    4444    JMenuItem selectHighway;
     45    JMenuItem selectAreaBoundary;
    4546   
    4647    JMenuItem selectURL;
     
    7980        undoSelection = MainMenu.add(selectionMenu, new UndoSelectionAction());
    8081        selectHighway = MainMenu.add(selectionMenu, new SelectHighwayAction());
     82        selectAreaBoundary = MainMenu.add(selectionMenu, new SelectBoundaryAction());
    8183       
    8284        selectURL = MainMenu.add(toolsMenu, new ChooseURLAction());
  • applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/selection/NodeWayUtils.java

    r26662 r27318  
    268268            }
    269269    }
    270 
    271270   
     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
    272344    static void addAllInsideMultipolygon(DataSet data, Relation rel, Set<Way> newWays, Set<Node> newNodes) {
    273345        if (!rel.isMultipolygon()) return;
  • applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/selection/SelectAllInsideAction.java

    r26694 r27318  
    3535    public void actionPerformed(ActionEvent e) {
    3636        long t=System.currentTimeMillis();
    37         Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected();
    3837        Set<Way> selectedWays = OsmPrimitive.getFilteredSet(getCurrentDataSet().getSelected(), Way.class);
    3938        Set<Relation> selectedRels = OsmPrimitive.getFilteredSet(getCurrentDataSet().getSelected(), Relation.class);
Note: See TracChangeset for help on using the changeset viewer.