Ignore:
Timestamp:
2013-01-03T13:37:21+01:00 (12 years ago)
Author:
malcolmh
Message:

save

File:
1 edited

Legend:

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

    r29153 r29156  
    3939        public class Feature {
    4040                public Fflag flag;
    41                 public ArrayList<Long> refs;
     41                public long refs;
    4242                public Obj type;
    4343                public EnumMap<Att, AttItem> atts;
     
    4545
    4646                Feature() {
    47                         clean();
    48                 }
    49                
    50                 void clean() {
    5147                        flag = Fflag.UNKN;
    52                         refs = new ArrayList<Long>();
     48                        refs = 0;
    5349                        type = Obj.UNKOBJ;
    5450                        atts = new EnumMap<Att, AttItem>(Att.class);
     
    7066        public HashMap<Long, ArrayList<Long>> ways;
    7167        public HashMap<Long, ArrayList<Long>> mpolys;
    72         public ArrayList<Feature> features;
     68        public HashMap<Long, Feature> features;
    7369
    7470        private Feature feature;
     71        private ArrayList<Long> list;
    7572
    7673        public Map() {
     
    7976                mpolys = new HashMap<Long, ArrayList<Long>>();
    8077                feature = new Feature();
    81                 features = new ArrayList<Feature>();
    82                 features.add(feature);
     78                features = new HashMap<Long, Feature>();
    8379        }
    8480
    8581        public void addNode(long id, double lat, double lon) {
    8682                nodes.put(id, new Coord(lat, lon));
    87                 if (feature.type == Obj.UNKOBJ) {
    88                         feature.clean();
    89                 } else {
    90                         feature = new Feature();
    91                         features.add(feature);
    92                 }
     83                feature = new Feature();
     84                feature.refs = id;
     85                feature.flag = Fflag.NODE;
    9386        }
    9487
    9588        public void addWay(long id) {
    96                 ways.put(id, new ArrayList<Long>());
    97                 if (feature.type == Obj.UNKOBJ) {
    98                         feature.clean();
    99                 } else {
    100                         feature = new Feature();
    101                         features.add(feature);
    102                 }
    103         }
    104 
    105         public void addToWay(long way, long node) {
    106                 ways.get(way).add(node);
     89                list = new ArrayList<Long>();
     90                ways.put(id, list);
     91                feature = new Feature();
     92                feature.refs = id;
     93                feature.flag = Fflag.WAY;
    10794        }
    10895
    10996        public void addMpoly(long id) {
    110                 mpolys.put(id, new ArrayList<Long>());
     97                list = new ArrayList<Long>();
     98                mpolys.put(id, list);
    11199        }
    112100
    113         public void addToMpoly(long id, long way) {
    114                 mpolys.get(id).add(way);
     101        public void addToWay(long node) {
     102                list.add(node);
     103        }
     104
     105        public void addToMpoly(long way, boolean outer) {
     106                if (outer)
     107                        list.add(0, way);
     108                else
     109                        list.add(way);
     110        }
     111
     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))) {
     115                                feature.flag = Fflag.AREA;
     116                        }
     117                        features.put(feature.refs, feature);
     118                }
    115119        }
    116120
Note: See TracChangeset for help on using the changeset viewer.