Changeset 30282 in osm for applications
- Timestamp:
- 2014-02-15T13:01:07+01:00 (11 years ago)
- Location:
- applications/editors/josm/plugins/smed2
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/smed2/js57toosm/src/js57toosm/Js57toosm.java
r30279 r30282 11 11 12 12 import java.io.*; 13 import java.util.Iterator; 14 import java.util.Map; 13 import java.util.*; 15 14 16 15 import s57.S57map.Prim; 17 16 import s57.S57obj; 17 import s57.S57obj.*; 18 18 import s57.S57att; 19 import s57.S57obj.Obj;20 19 import s57.S57att.*; 21 20 import s57.S57val; … … 57 56 long objl = 0; 58 57 double minlat = 90, minlon = 180, maxlat = -90, maxlon = -180; 58 59 HashMap<Long, Boolean> done = new HashMap<Long, Boolean>(); 59 60 60 61 while (in.read(leader) == 24) { … … 113 114 long attl = (long) S57dat.getSubf(S57subf.ATTL); 114 115 String atvl = (String) S57dat.getSubf(S57subf.ATVL); 115 map.newAtt(attl, atvl); 116 if (!atvl.isEmpty()) { 117 map.newAtt(attl, atvl); 118 } 116 119 } while (S57dat.more()); 117 120 break; … … 225 228 Snode node; 226 229 while ((node = map.nodes.get(ref)) != null) { 227 out.format(" <node id='%d' lat='%.8f' lon='%.8f' version='1'>%n", -ref, Math.toDegrees(node.lat), Math.toDegrees(node.lon)); 228 out.format(" <tag k='seamark:type' v=\"%s\"/>%n", type); 229 if ((feature.type == Obj.SOUNDG) && (node.flg == S57map.Nflag.DPTH)) 230 out.format(" <tag k='seamark:sounding:depth' v='%.1f'/>%n", ((Dnode) node).val); 231 writeAtts(feature, type); 232 out.format(" </node>%n"); 233 map.nodes.remove(ref++); 230 if (!done.containsKey(ref)) { 231 out.format(" <node id='%d' lat='%.8f' lon='%.8f' version='1'>%n", -ref, Math.toDegrees(node.lat), Math.toDegrees(node.lon)); 232 out.format(" <tag k='seamark:type' v=\"%s\"/>%n", type); 233 if ((feature.type == Obj.SOUNDG) && (node.flg == S57map.Nflag.DPTH)) 234 out.format(" <tag k='seamark:sounding:depth' v='%.1f'/>%n", ((Dnode) node).val); 235 writeAtts(feature, type); 236 out.format(" </node>%n"); 237 done.put(ref, true); 238 } 239 ref++; 234 240 } 235 241 } … … 252 258 long ref = git.nextRef(); 253 259 Snode node = map.nodes.get(ref); 254 if ( node != null) {260 if (!done.containsKey(ref)) { 255 261 out.format(" <node id='%d' lat='%.8f' lon='%.8f' version='1'/>%n", -ref, Math.toDegrees(node.lat), Math.toDegrees(node.lon)); 256 map.nodes.remove(ref);262 done.put(ref, true); 257 263 } 258 264 } … … 273 279 } 274 280 out.format(" </way>%n"); 281 done.put(way, true); 275 282 } 276 283 } else if (feature.geom.prim == Pflag.AREA) { … … 283 290 long ref = git.nextRef(); 284 291 Snode node = map.nodes.get(ref); 285 if ( node != null) {292 if (!done.containsKey(ref)) { 286 293 out.format(" <node id='%d' lat='%.8f' lon='%.8f' version='1'/>%n", -ref, Math.toDegrees(node.lat), Math.toDegrees(node.lon)); 287 map.nodes.remove(ref);294 done.put(ref, true); 288 295 } 289 296 } … … 292 299 git = map.new GeomIterator(feature.geom); 293 300 while (git.hasComp()) { 294 long way = git.nextComp(); 295 out.format(" <way id='%d' version='1'>%n", -way); 296 while (git.hasEdge()) { 297 git.nextEdge(); 298 while (git.hasNode()) { 299 long ref = git.nextRef(); 300 out.format(" <nd ref='%d'/>%n", -ref); 301 } 302 } 303 out.format(" </way>%n"); 301 git.nextComp(); 302 while (git.hasEdge()) { 303 long way = git.nextEdge(); 304 if (!done.containsKey(way)) { 305 out.format(" <way id='%d' version='1'>%n", -way); 306 while (git.hasNode()) { 307 long ref = git.nextRef(true); 308 out.format(" <nd ref='%d'/>%n", -ref); 309 } 310 out.format(" </way>%n"); 311 done.put(way, true); 312 } 313 } 304 314 } 305 315 out.format(" <relation id='%d' version='1'>%n", -map.ref++); 306 316 out.format(" <tag k='type' v='multipolygon'/>%n"); 307 int i = 0; 308 for (Comp comp : feature.geom.refs) { 309 if (i++ < feature.geom.outers) { 310 out.format(" <member type='way' ref='%d' role='outer'/>%n", -comp.ref); 311 } else { 312 out.format(" <member type='way' ref='%d' role='inner'/>%n", -comp.ref); 317 git = map.new GeomIterator(feature.geom); 318 int outers = feature.geom.refs.get(0).size; 319 if (feature.geom.inners != 0){ 320 int x=0; 321 } 322 while (git.hasComp()) { 323 git.nextComp(); 324 while (git.hasEdge()) { 325 long way = git.nextEdge(); 326 if (outers-- > 0) { 327 out.format(" <member type='way' ref='%d' role='outer'/>%n", -way); 328 } else { 329 out.format(" <member type='way' ref='%d' role='inner'/>%n", -way); 330 } 313 331 } 314 332 } -
applications/editors/josm/plugins/smed2/src/s57/S57map.java
r30280 r30282 316 316 feature.geom.refs.add(comp); 317 317 ListIterator<S57map.Prim> ite = feature.geom.elems.listIterator(); 318 long first = 0; 318 319 while (ite.hasNext()) { 319 320 Prim prim = ite.next(); 320 if (prim.outer) { 321 comp.size++; 322 321 Edge edge = edges.get(prim.id); 322 if (!prim.outer) { 323 if (first == 0) { 324 feature.geom.inners++; 325 comp = new Comp(ref++, 0); 326 feature.geom.refs.add(comp); 327 first = edge.first; 328 } else { 329 if (edge.last == first) { 330 first = 0; 331 } 332 } 323 333 } 334 comp.size++; 324 335 } 325 336 } … … 609 620 } 610 621 611 public long nextRef( ) {622 public long nextRef(boolean all) { 612 623 long ref = eit.nextRef(); 613 if ( ref == lastref) {624 if (!all && (ref == lastref)) { 614 625 ref = eit.nextRef(); 615 626 } 616 627 lastref = ref; 617 628 return ref; 629 } 630 631 public long nextRef() { 632 return nextRef(false); 618 633 } 619 634 -
applications/editors/josm/plugins/smed2/src/s57/S57obj.java
r30269 r30282 131 131 ObjStr.put(Obj.TS_FEB, "tidal_stream"); ObjStr.put(Obj.NOTMRK, "notice"); ObjStr.put(Obj.WTWAXS, "waterway_axis"); ObjStr.put(Obj.WTWPRF, "waterway_profile"); 132 132 ObjStr.put(Obj.BRGARE, "bridge_area"); ObjStr.put(Obj.BUNSTA, "bunker_station"); ObjStr.put(Obj.COMARE, "communication_area"); ObjStr.put(Obj.HRBBSN, "harbour_basin"); 133 ObjStr.put(Obj.LOKARE, "lock_area"); ObjStr.put(Obj.LKBSPT, "lock_basin_part"); ObjStr.put(Obj.PRTARE, "port_area"); ObjStr.put(Obj.BCNWTW, "beacon_ waterway");134 ObjStr.put(Obj.BOYWTW, "buoy_ waterway"); ObjStr.put(Obj.REFDMP, "refuse_dump"); ObjStr.put(Obj.RTPLPT, "route_planning_point"); ObjStr.put(Obj.TERMNL, "terminal");133 ObjStr.put(Obj.LOKARE, "lock_area"); ObjStr.put(Obj.LKBSPT, "lock_basin_part"); ObjStr.put(Obj.PRTARE, "port_area"); ObjStr.put(Obj.BCNWTW, "beacon_lateral"); 134 ObjStr.put(Obj.BOYWTW, "buoy_lateral"); ObjStr.put(Obj.REFDMP, "refuse_dump"); ObjStr.put(Obj.RTPLPT, "route_planning_point"); ObjStr.put(Obj.TERMNL, "terminal"); 135 135 ObjStr.put(Obj.TRNBSN, "turning_basin"); ObjStr.put(Obj.WTWARE, "waterway_area"); ObjStr.put(Obj.WTWGAG, "waterway_gauge"); ObjStr.put(Obj.TISDGE, "time_schedule"); 136 136 ObjStr.put(Obj.VEHTRF, "vehicle_transfer"); ObjStr.put(Obj.EXCNST, "exceptional_structure");
Note:
See TracChangeset
for help on using the changeset viewer.