Changeset 29156 in osm for applications/editors
- Timestamp:
- 2013-01-03T13:37:21+01:00 (12 years ago)
- Location:
- applications/editors/josm/plugins/smed2/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/smed2/src/seamap/Map.java
r29153 r29156 39 39 public class Feature { 40 40 public Fflag flag; 41 public ArrayList<Long>refs;41 public long refs; 42 42 public Obj type; 43 43 public EnumMap<Att, AttItem> atts; … … 45 45 46 46 Feature() { 47 clean();48 }49 50 void clean() {51 47 flag = Fflag.UNKN; 52 refs = new ArrayList<Long>();48 refs = 0; 53 49 type = Obj.UNKOBJ; 54 50 atts = new EnumMap<Att, AttItem>(Att.class); … … 70 66 public HashMap<Long, ArrayList<Long>> ways; 71 67 public HashMap<Long, ArrayList<Long>> mpolys; 72 public ArrayList<Feature> features;68 public HashMap<Long, Feature> features; 73 69 74 70 private Feature feature; 71 private ArrayList<Long> list; 75 72 76 73 public Map() { … … 79 76 mpolys = new HashMap<Long, ArrayList<Long>>(); 80 77 feature = new Feature(); 81 features = new ArrayList<Feature>(); 82 features.add(feature); 78 features = new HashMap<Long, Feature>(); 83 79 } 84 80 85 81 public void addNode(long id, double lat, double lon) { 86 82 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; 93 86 } 94 87 95 88 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; 107 94 } 108 95 109 96 public void addMpoly(long id) { 110 mpolys.put(id, new ArrayList<Long>()); 97 list = new ArrayList<Long>(); 98 mpolys.put(id, list); 111 99 } 112 100 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 } 115 119 } 116 120 -
applications/editors/josm/plugins/smed2/src/smed2/Smed2Action.java
r29153 r29156 41 41 @Override 42 42 public void dataChanged(DataChangedEvent e) { 43 reMap();43 // reMap(); 44 44 } 45 45 46 46 @Override 47 47 public void nodeMoved(NodeMovedEvent e) { 48 reMap();48 // reMap(); 49 49 } 50 50 51 51 @Override 52 52 public void otherDatasetChange(AbstractDatasetChangedEvent e) { 53 reMap();53 // reMap(); 54 54 } 55 55 56 56 @Override 57 57 public void primitivesAdded(PrimitivesAddedEvent e) { 58 reMap();58 // reMap(); 59 59 } 60 60 61 61 @Override 62 62 public void primitivesRemoved(PrimitivesRemovedEvent e) { 63 reMap();63 // reMap(); 64 64 } 65 65 66 66 @Override 67 67 public void relationMembersChanged(RelationMembersChangedEvent e) { 68 reMap();68 // reMap(); 69 69 } 70 70 71 71 @Override 72 72 public void tagsChanged(TagsChangedEvent e) { 73 reMap();73 // reMap(); 74 74 } 75 75 76 76 @Override 77 77 public void wayNodesChanged(WayNodesChangedEvent e) { 78 reMap();78 // reMap(); 79 79 } 80 80 }; … … 119 119 panelS57.setVisible(false); 120 120 frame.add(panelS57); 121 //System.out.println("hello");121 // System.out.println("hello"); 122 122 rendering = ImageryLayer.create(new ImageryInfo("OpenSeaMap")); 123 123 Main.main.addLayer(rendering); … … 144 144 data = newLayer.data.allPrimitives(); 145 145 reMap(); 146 146 } else { 147 147 data = null; 148 148 map = null; … … 155 155 156 156 } 157 157 158 158 void reMap() { 159 159 map = new Map(); 160 160 for (OsmPrimitive osm : data) { 161 if (osm instanceof Node) { 162 map.addNode(((Node)osm).getId(), ((Node)osm).getCoor().lat(), ((Node)osm).getCoor().lon()); 163 } else if (osm instanceof Way) { 164 map.addWay(((Way)osm).getId()); 165 for (Node node : ((Way)osm).getNodes()) { 166 map.addToWay(((Way)osm).getUniqueId(), node.getUniqueId()); 161 System.out.println(osm); 162 if ((osm instanceof Node) || (osm instanceof Way)) { 163 if (osm instanceof Node) { 164 map.addNode(((Node) osm).getUniqueId(), ((Node) osm).getCoor().lat(), ((Node) osm).getCoor().lon()); 165 } else { 166 map.addWay(((Way) osm).getUniqueId()); 167 for (Node node : ((Way) osm).getNodes()) { 168 map.addToWay((node.getUniqueId())); 169 } 170 } 171 for (Entry<String, String> entry : osm.getKeys().entrySet()) { 172 map.addTag(entry.getKey(), entry.getValue()); 173 } 174 map.tagsDone(); 175 } else if ((osm instanceof Relation) && ((Relation) osm).isMultipolygon()) { 176 map.addMpoly(((Relation) osm).getUniqueId()); 177 for (RelationMember mem : ((Relation) osm).getMembers()) { 178 if (mem.getType() == OsmPrimitiveType.WAY) 179 map.addToMpoly(mem.getUniqueId(), (mem.getRole().equals("outer"))); 167 180 } 168 181 } 169 for (Entry<String, String> entry : osm.getKeys().entrySet()) {170 map.addTag(entry.getKey(), entry.getValue());171 }172 182 } 173 174 183 } 175 184
Note:
See TracChangeset
for help on using the changeset viewer.