Ignore:
Timestamp:
2013-01-08T21:26:40+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

    r29174 r29184  
    1515
    1616import s57.S57att;
    17 import s57.S57att.*;
     17import s57.S57att.Att;
    1818import s57.S57obj;
    1919import s57.S57obj.*;
     
    3737        }
    3838
     39        public class AttMap extends EnumMap<Att, AttItem> {
     40                private static final long serialVersionUID = 1L;
     41                public AttMap() {
     42                        super(Att.class);
     43                }
     44        }
     45       
     46        public class ObjTab extends HashMap<Integer, AttMap> {
     47                private static final long serialVersionUID = 1L;
     48                public ObjTab() {
     49                        super();
     50                }
     51        }
     52       
     53        public class ObjMap extends EnumMap<Obj, ObjTab> {
     54                private static final long serialVersionUID = 1L;
     55                public ObjMap() {
     56                        super(Obj.class);
     57                }
     58        }
     59       
     60        public class NodeTab extends HashMap<Long, Coord> {
     61                private static final long serialVersionUID = 1L;
     62                public NodeTab() {
     63                        super();
     64                }
     65        }
     66       
     67        public class WayTab extends HashMap<Long, ArrayList<Long>> {
     68                private static final long serialVersionUID = 1L;
     69                public WayTab() {
     70                        super();
     71                }
     72        }
     73       
     74        public class FtrMap extends EnumMap<Obj, ArrayList<Feature>> {
     75                private static final long serialVersionUID = 1L;
     76                public FtrMap() {
     77                        super(Obj.class);
     78                }
     79        }
     80       
     81        public class FtrTab extends HashMap<Long, Feature> {
     82                private static final long serialVersionUID = 1L;
     83                public FtrTab() {
     84                        super();
     85                }
     86        }
     87       
    3988        public class Feature {
    4089                public Fflag flag;
    4190                public long refs;
    4291                public Obj type;
    43                 public EnumMap<Att, AttItem> atts;
    44                 public EnumMap<Obj, HashMap<Integer, EnumMap<Att, AttItem>>> objs;
     92                public AttMap atts;
     93                public ObjMap objs;
    4594
    4695                Feature() {
     
    4897                        refs = 0;
    4998                        type = Obj.UNKOBJ;
    50                         atts = new EnumMap<Att, AttItem>(Att.class);
    51                         objs = new EnumMap<Obj, HashMap<Integer, EnumMap<Att, AttItem>>>(Obj.class);
     99                        atts = new AttMap();
     100                        objs = new ObjMap();
    52101                }
    53102        }
     
    57106                public double lon;
    58107
    59                 Coord(double ilat, double ilon) {
     108                public Coord(double ilat, double ilon) {
    60109                        lat = ilat;
    61110                        lon = ilon;
     
    63112        }
    64113
    65         public HashMap<Long, Coord> nodes;
    66         public HashMap<Long, ArrayList<Long>> ways;
    67         public HashMap<Long, ArrayList<Long>> mpolys;
    68         public EnumMap<Obj, ArrayList<Feature>> features;
     114        public NodeTab nodes;
     115        public WayTab ways;
     116        public WayTab mpolys;
     117        public FtrMap features;
     118        public FtrTab index;
    69119
    70120        private Feature feature;
     
    72122
    73123        public SeaMap() {
    74                 nodes = new HashMap<Long, Coord>();
    75                 ways = new HashMap<Long, ArrayList<Long>>();
    76                 mpolys = new HashMap<Long, ArrayList<Long>>();
     124                nodes = new NodeTab();
     125                ways = new WayTab();
     126                mpolys = new WayTab();
    77127                feature = new Feature();
    78                 features = new EnumMap<Obj, ArrayList<Feature>>(Obj.class);
     128                features = new FtrMap();
     129                index = new FtrTab();
    79130        }
    80131
     
    84135                feature.refs = id;
    85136                feature.flag = Fflag.NODE;
     137        }
     138
     139        public void moveNode(long id, double lat, double lon) {
     140                nodes.put(id, new Coord(lat, lon));
    86141        }
    87142
     
    110165        }
    111166
    112         public void tagsDone() {
    113                 if (feature.type != Obj.UNKOBJ) {
    114                         if ((feature.flag == Fflag.WAY) && (list.size() > 0) && (list.get(0) == list.get(list.size() - 1))) {
     167        public void tagsDone(long id) {
     168                if ((feature.type != Obj.UNKOBJ) && !((feature.flag == Fflag.WAY) && (list.size() < 2))) {
     169                        index.put(id, feature);
     170                        if ((feature.flag == Fflag.WAY) && (list.size() > 0) && (list.get(0).equals(list.get(list.size() - 1)))) {
    115171                                feature.flag = Fflag.AREA;
    116172                        }
     
    137193                                        att = S57att.enumAttribute(subkeys[2], obj);
    138194                                }
    139                                 HashMap<Integer, EnumMap<Att, AttItem>> items = feature.objs.get(obj);
     195                                ObjTab items = feature.objs.get(obj);
    140196                                if (items == null) {
    141                                         items = new HashMap<Integer, EnumMap<Att, AttItem>>();
     197                                        items = new ObjTab();
    142198                                        feature.objs.put(obj, items);
    143199                                }
    144                                 EnumMap<Att, AttItem> atts = items.get(idx);
     200                                AttMap atts = items.get(idx);
    145201                                if (atts == null) {
    146                                         atts = new EnumMap<Att, AttItem>(Att.class);
     202                                        atts = new AttMap();
    147203                                        items.put(idx, atts);
    148204                                }
Note: See TracChangeset for help on using the changeset viewer.