Changeset 30279 in osm for applications/editors/josm/plugins
- Timestamp:
- 2014-02-14T19:48:40+01:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/smed2/js57toosm/src/js57toosm/Js57toosm.java
r30269 r30279 11 11 12 12 import java.io.*; 13 import java.util.Iterator; 13 14 import java.util.Map; 14 15 16 import s57.S57map.Prim; 15 17 import s57.S57obj; 16 18 import s57.S57att; … … 47 49 int pos; 48 50 boolean inFeature = false; 49 51 50 52 double comf = 1; 51 53 double somf = 1; … … 155 157 S57dat.setField(record, fields + pos, S57field.VRPT, len); 156 158 do { 157 name= (Long) S57dat.getSubf(S57subf.NAME) << 16;159 long conn = (Long) S57dat.getSubf(S57subf.NAME) << 16; 158 160 int topi = ((Long) S57dat.getSubf(S57subf.TOPI)).intValue(); 159 map.addConn( name, topi);161 map.addConn(conn, topi); 160 162 S57dat.getSubf(S57subf.MASK); 161 163 } while (S57dat.more()); … … 208 210 map.endFile(); 209 211 in.close(); 210 212 211 213 out.println("<?xml version='1.0' encoding='UTF-8'?>"); 212 214 out.println("<osm version='0.6' generator='js57toosm'>"); 213 out.println("<bounds minlat='" + minlat +"' minlon='" + minlon + "' maxlat='" + maxlat + "' maxlon='" + maxlon + "'/>"); 214 215 out.println("<bounds minlat='" + minlat + "' minlon='" + minlon + "' maxlat='" + maxlat + "' maxlon='" + maxlon + "'/>"); 216 215 217 for (long id : map.index.keySet()) { 216 218 Feature feature = map.index.get(id); … … 236 238 } 237 239 } 238 239 //int i = 256;240 240 for (long id : map.index.keySet()) { 241 //if (i-- == 0) break;242 241 Feature feature = map.index.get(id); 243 242 String type = S57obj.stringType(feature.type); 244 243 if (!type.isEmpty()) { 245 244 if (feature.reln == Rflag.MASTER) { 246 if ( (feature.geom.prim == Pflag.LINE) || ((feature.geom.prim == Pflag.AREA) && (feature.geom.outers == 1) && (feature.geom.inners == 0))) {245 if (feature.geom.prim == Pflag.LINE) { 247 246 GeomIterator git = map.new GeomIterator(feature.geom); 248 while (git.hasMore()) { 249 git.getMore(); 250 while (git.hasNext()) { 251 long ref = git.nextRef(); 252 Snode node = map.nodes.get(ref); 253 if (node != null) { 254 out.format(" <node id='%d' lat='%.8f' lon='%.8f' version='1'/>%n", -ref, Math.toDegrees(node.lat), Math.toDegrees(node.lon)); 255 map.nodes.remove(ref); 247 while (git.hasComp()) { 248 git.nextComp(); 249 while (git.hasEdge()) { 250 git.nextEdge(); 251 while (git.hasNode()) { 252 long ref = git.nextRef(); 253 Snode node = map.nodes.get(ref); 254 if (node != null) { 255 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); 257 } 256 258 } 257 259 } 258 260 } 259 261 git = map.new GeomIterator(feature.geom); 260 while (git.has More()) {261 long way = git. getMore();262 while (git.hasComp()) { 263 long way = git.nextComp(); 262 264 out.format(" <way id='%d' version='1'>%n", -way); 263 while (git.hasNext()) { 264 long ref = git.nextRef(); 265 out.format(" <nd ref='%d'/>%n", -ref); 266 } 267 out.format(" <tag k='seamark:type' v=\"%s\"/>%n", type); 268 writeAtts(feature, type); 265 while (git.hasEdge()) { 266 git.nextEdge(); 267 while (git.hasNode()) { 268 long ref = git.nextRef(); 269 out.format(" <nd ref='%d'/>%n", -ref); 270 } 271 out.format(" <tag k='seamark:type' v=\"%s\"/>%n", type); 272 writeAtts(feature, type); 273 } 269 274 out.format(" </way>%n"); 270 275 } 271 276 } else if (feature.geom.prim == Pflag.AREA) { 272 277 GeomIterator git = map.new GeomIterator(feature.geom); 278 while (git.hasComp()) { 279 git.nextComp(); 280 while (git.hasEdge()) { 281 git.nextEdge(); 282 while (git.hasNode()) { 283 long ref = git.nextRef(); 284 Snode node = map.nodes.get(ref); 285 if (node != null) { 286 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); 288 } 289 } 290 } 291 } 292 git = map.new GeomIterator(feature.geom); 293 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"); 304 } 305 out.format(" <relation id='%d' version='1'>%n", -map.ref++); 306 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); 313 } 314 } 315 out.format(" <tag k='seamark:type' v=\"%s\"/>%n", type); 316 writeAtts(feature, type); 317 out.format(" </relation>%n"); 273 318 } 274 319 }
Note:
See TracChangeset
for help on using the changeset viewer.