Ignore:
Timestamp:
2013-12-08T20:52:05+01:00 (12 years ago)
Author:
malcolmh
Message:

save

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/smed2/src/seamap/SeaMap.java

    r29995 r30119  
    2222
    2323        public enum Nflag {
    24                 ANON, ISOL, CONN
    25         }
    26 
    27         public class Snode {
    28                 public double lat;
    29                 public double lon;
    30                 public Nflag flg;
     24                ANON,   // Edge inner nodes
     25                ISOL,   // Node not part of Edge
     26                CONN    // Edge first and last nodes
     27        }
     28
     29        public class Snode {    // All coordinates in map
     30                public double lat;      // Latitude
     31                public double lon;      // Longitude
     32                public Nflag flg;               // Role of node
    3133
    3234                public Snode() {
     
    3537                        lon = 0;
    3638                }
    37 
    3839                public Snode(double ilat, double ilon) {
    3940                        flg = Nflag.ANON;
     
    4142                        lon = ilon;
    4243                }
    43 
    4444                public Snode(double ilat, double ilon, Nflag iflg) {
    4545                        lat = ilat;
     
    4949        }
    5050
    51         public class Edge {
    52                 public boolean forward;
    53                 public long first;
    54                 public long last;
    55                 public ArrayList<Long> nodes;
     51        public class Edge {             // A polyline segment
     52                public long first;      // First CONN node
     53                public long last;               // Last CONN node
     54                public ArrayList<Long> nodes; // Inner ANON nodes
    5655
    5756                public Edge() {
    58                         forward = true;
    5957                        first = 0;
    6058                        last = 0;
     
    6361        }
    6462
    65         public class Side {
    66                 Edge edge;
    67                 boolean forward;
     63        public class Side {     // An edge as used in a line or area feature
     64                Edge edge;                              // Side is formed by this Edge...
     65                boolean forward;        // ... in this direction
    6866
    6967                public Side(Edge iedge, boolean ifwd) {
     
    7371        }
    7472
    75         public class Bound {
    76                 public boolean outer;
    77                 ArrayList<Side> sides;
     73        public class Bound { // A single closed area
     74                public boolean outer;           // Role
     75                ArrayList<Side> sides;  // Sides that make up this area
    7876
    7977                public Bound() {
     
    8179                        sides = new ArrayList<Side>();
    8280                }
    83 
    8481                public Bound(Side iside, boolean irole) {
    8582                        outer = irole;
     
    8986        }
    9087
    91         public class Area extends ArrayList<Bound> {
     88        public class Area extends ArrayList<Bound> {    // The collection of bounds for an area.
    9289                public Area() {
    9390                        super();
     
    389386                        nodes.get(edge.first).flg = Nflag.CONN;
    390387                        nodes.get(edge.last).flg = Nflag.CONN;
    391                         Bound ebound = (new Bound(new Side(edge, edge.forward), true));
     388                        Bound ebound = (new Bound(new Side(edge, true), true));
    392389                        feature.length = calcLength(ebound);
    393390                        if (edge.first == edge.last) {
     
    410407                                        long node1 = edge.first;
    411408                                        long node2 = edge.last;
    412                                         bound = new Bound(new Side(edge, edge.forward), (role == outers));
     409                                        bound = new Bound(new Side(edge, true), (role == outers));
    413410                                        if (node1 != node2) {
    414411                                                for (ListIterator<Long> it = role.listIterator(0); it.hasNext();) {
     
    551548                                } else {
    552549                                        double arc = (Math.acos(Math.cos(lon - llon) * Math.cos(lat - llat)));
    553                                         slat += (lat * arc);
    554                                         slon += (lon * arc);
     550                                        slat += ((lat + llat) / 2 * arc);
     551                                        slon += ((lon + llon) / 2 * arc);
    555552                                        sarc += arc;
    556553                                }
Note: See TracChangeset for help on using the changeset viewer.