Ignore:
Timestamp:
2009-08-03T21:18:50+02:00 (15 years ago)
Author:
jttt
Message:

Way refactoring - rewritten another parts of code to the new nodes api

File:
1 edited

Legend:

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

    r1862 r1898  
    1212
    1313import javax.swing.JOptionPane;
    14 import javax.swing.text.html.Option;
    1514
    1615import org.openstreetmap.josm.Main;
     
    9695            // Otherwise, two segments could be turned into same direction and intersection would fail.
    9796            // Or changes of shape would be too serious.
    98             for (int i1=0; i1 < way.nodes.size()-1; i1++) {
    99                 int i2 = (i1+1) % (way.nodes.size()-1);
    100                 int i3 = (i1+2) % (way.nodes.size()-1);
    101                 double angle1  =Math.abs(way.nodes.get(i1).getEastNorth().heading(way.nodes.get(i2).getEastNorth()));
    102                 double angle2 = Math.abs(way.nodes.get(i2).getEastNorth().heading(way.nodes.get(i3).getEastNorth()));
     97            for (int i1=0; i1 < way.getNodesCount()-1; i1++) {
     98                int i2 = (i1+1) % (way.getNodesCount()-1);
     99                int i3 = (i1+2) % (way.getNodesCount()-1);
     100                double angle1  =Math.abs(way.getNode(i1).getEastNorth().heading(way.getNode(i2).getEastNorth()));
     101                double angle2 = Math.abs(way.getNode(i2).getEastNorth().heading(way.getNode(i3).getEastNorth()));
    103102                double delta = Math.abs(angle2 - angle1);
    104103                while(delta > Math.PI) {
     
    162161
    163162            Way way = (Way)osm;
    164             int nodes = way.nodes.size();
     163            int nodes = way.getNodesCount();
    165164            int sides = nodes - 1;
    166165            // Copy necessary data into a more suitable data structure
    167166            EastNorth en[] = new EastNorth[sides];
    168167            for (int i=0; i < sides; i++) {
    169                 en[i] = new EastNorth(way.nodes.get(i).getEastNorth().east(), way.nodes.get(i).getEastNorth().north());
     168                en[i] = new EastNorth(way.getNode(i).getEastNorth().east(), way.getNode(i).getEastNorth().north());
    170169            }
    171170
     
    178177                double weights[] = new double[sides];
    179178                for (int i=0; i < sides; i++) {
    180                     headings[i] = normalize_angle(way.nodes.get(i).getEastNorth().heading(way.nodes.get(i+1).getEastNorth()));
    181                     weights[i] = way.nodes.get(i).getEastNorth().distance(way.nodes.get(i+1).getEastNorth());
     179                    headings[i] = normalize_angle(way.getNode(i).getEastNorth().heading(way.getNode(i+1).getEastNorth()));
     180                    weights[i] = way.getNode(i).getEastNorth().distance(way.getNode(i+1).getEastNorth());
    182181                }
    183182
     
    270269                        B.north() + q * (A.north() - B.north()));
    271270
    272                 Node n = way.nodes.get(i2);
     271                Node n = way.getNode(i2);
    273272
    274273                LatLon ill = Main.proj.eastNorth2latlon(intersection);
Note: See TracChangeset for help on using the changeset viewer.