Changeset 30230 in osm
- Timestamp:
- 2014-01-26T19:10:19+01:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/smed2/js57toosm/src/js57toosm/Js57toosm.java
r30226 r30230 15 15 import s57.S57obj; 16 16 import s57.S57att; 17 import s57.S57obj.Obj; 17 18 import s57.S57att.*; 18 19 import s57.S57val; … … 51 52 long name = 0; 52 53 S57map.Nflag nflag = Nflag.ANON; 53 S57map.Pflag p rim= S57map.Pflag.NOSP;54 S57map.Pflag pflag = S57map.Pflag.NOSP; 54 55 long objl = 0; 55 56 double minlat = 90, minlon = 180, maxlat = -90, maxlon = -180; … … 88 89 switch ((int)((long)S57dat.getSubf(record, fields + pos, S57field.FRID, S57subf.PRIM))) { 89 90 case 1: 90 p rim= S57map.Pflag.POINT;91 pflag = S57map.Pflag.POINT; 91 92 break; 92 93 case 2: 93 p rim= S57map.Pflag.LINE;94 pflag = S57map.Pflag.LINE; 94 95 break; 95 96 case 3: 96 p rim= S57map.Pflag.AREA;97 pflag = S57map.Pflag.AREA; 97 98 break; 98 99 default: 99 p rim= S57map.Pflag.NOSP;100 pflag = S57map.Pflag.NOSP; 100 101 } 101 102 objl = (long)S57dat.getSubf(S57subf.OBJL); … … 103 104 case "FOID": 104 105 name = (long) S57dat.getSubf(record, fields + pos, S57field.FOID, S57subf.LNAM); 105 map.newFeature(name, p rim, objl);106 map.newFeature(name, pflag, objl); 106 107 break; 107 108 case "ATTF": … … 210 211 if (feature.reln != Rflag.SLAVE) { 211 212 if (feature.geom.prim == Pflag.POINT) { 212 long ref = feature.geom.elems.get(0).id; 213 Snode node = map.nodes.get(ref); 214 String type = S57obj.stringType(feature.type); 215 out.format(" <node id='%d' lat='%f' lon='%f' version='1'>%n", -ref, Math.toDegrees(node.lat), Math.toDegrees(node.lon)); 216 out.format(" <tag k='seamark:type' v=\"%s\"/>%n", type); 217 writeAtts(feature, type); 218 out.format(" </node>%n"); 219 map.nodes.remove(ref); 213 for (Prim prim : feature.geom.elems) { 214 long ref = prim.id; 215 Snode node = map.nodes.get(ref); 216 out.format(" <node id='%d' lat='%f' lon='%f' version='1'>%n", -ref, Math.toDegrees(node.lat), Math.toDegrees(node.lon)); 217 String type = S57obj.stringType(feature.type); 218 out.format(" <tag k='seamark:type' v=\"%s\"/>%n", type); 219 if ((feature.type == Obj.SOUNDG) && (node.flg == S57map.Nflag.DPTH)) 220 out.format(" <tag k='seamark:sounding:depth' v='%.1f'/>%n", ((Dnode)node).val); 221 writeAtts(feature, type); 222 out.format(" </node>%n"); 223 map.nodes.remove(ref); 224 } 220 225 } 221 226 } … … 225 230 Feature feature = map.index.get(id); 226 231 if (feature.reln != Rflag.SLAVE) { 227 if ( feature.geom.prim == Pflag.LINE) {232 if ((feature.geom.prim == Pflag.LINE) || ((feature.geom.prim == Pflag.AREA) && (feature.geom.outers == 1) && (feature.geom.inners == 0))) { 228 233 GeomIterator git = map.new GeomIterator(feature.geom); 229 234 while (git.hasMore()) { 230 git. more();235 git.getMore(); 231 236 while (git.hasNext()) { 232 237 long ref = git.nextRef(); … … 238 243 } 239 244 } 240 out.format(" <way id='%d' version='1'>%n", -id);241 245 git = map.new GeomIterator(feature.geom); 242 246 while (git.hasMore()) { 243 git.more(); 247 long way = git.getMore(); 248 out.format(" <way id='%d' version='1'>%n", -way); 244 249 while (git.hasNext()) { 245 250 long ref = git.nextRef(); 246 251 out.format(" <nd ref='%d'/>%n", -ref); 247 252 } 248 } 249 String type = S57obj.stringType(feature.type); 250 out.format(" <tag k='seamark:type' v=\"%s\"/>%n", type); 251 writeAtts(feature, type); 252 out.format(" </way>%n"); 253 } 254 } 255 } 256 /* for (long id : map.nodes.keySet()) { 257 Snode node = map.nodes.get(id); 258 if (node.flg == S57map.Nflag.DPTH) { 259 out.format(" <node id='%d' lat='%f' lon='%f' version='1'>%n", -id, Math.toDegrees(node.lat), Math.toDegrees(node.lon)); 260 out.format(" <tag k='seamark:type' v='sounding'/>%n"); 261 out.format(" <tag k='seamark:sounding:depth' v='%.1f'/>%n", ((Dnode)node).val); 262 out.format(" </node>%n"); 263 map.nodes.remove(id); 264 } 265 } 266 267 for (long id : map.edges.keySet()) { 268 Edge edge = map.edges.get(id); 269 out.format(" <way id='%d' version='1'>%n", -id); 270 out.format(" <nd ref='%d'/>%n", -edge.first); 271 for (long anon : edge.nodes) { 272 out.format(" <nd ref='%d'/>%n", -anon); 273 } 274 out.format(" <nd ref='%d'/>%n", -edge.last); 275 out.format(" </way>%n"); 276 } 277 */ 253 String type = S57obj.stringType(feature.type); 254 out.format(" <tag k='seamark:type' v=\"%s\"/>%n", type); 255 writeAtts(feature, type); 256 out.format(" </way>%n"); 257 } 258 } else if (feature.geom.prim == Pflag.AREA) { 259 260 } 261 } 262 } 278 263 out.println("</osm>\n"); 279 264 }
Note:
See TracChangeset
for help on using the changeset viewer.