Changeset 30283 in osm for applications/editors/josm/plugins/smed2/js57toosm/src
- Timestamp:
- 2014-02-15T16:22:45+01:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/smed2/js57toosm/src/js57toosm/Js57toosm.java
r30282 r30283 33 33 public static void main(String[] args) throws IOException { 34 34 35 in = new FileInputStream("/Users/mherring/boatsw/oseam/josm/plugins/smed2/js57toosm/tst.000"); 35 if (args.length < 1) { 36 System.err.println("Usage: java -jar js57toosm.jar S57_filename [types_filename]"); 37 System.exit(-1); 38 } 39 in = new FileInputStream(args[0]); 36 40 out = System.out; 41 ArrayList<Obj> types = new ArrayList<Obj>(); 42 if (args.length == 2) { 43 Scanner tin = new Scanner(new FileInputStream(args[1])); 44 while (tin.hasNext()) { 45 types.add(S57obj.enumType(tin.next())); 46 } 47 tin.close(); 48 } 49 37 50 map = new S57map(); 38 39 51 S57dat.rnum = 0; 40 52 … … 57 69 double minlat = 90, minlon = 180, maxlat = -90, maxlon = -180; 58 70 59 HashMap<Long, Boolean> done = newHashMap<Long, Boolean>();71 ArrayList<Long> done = new ArrayList<Long>(); 60 72 61 73 while (in.read(leader) == 24) { … … 221 233 Feature feature = map.index.get(id); 222 234 String type = S57obj.stringType(feature.type); 223 if (!type.isEmpty()) { 235 if (!type.isEmpty() && (types.isEmpty() || types.contains(feature.type))) { 224 236 if (feature.reln == Rflag.MASTER) { 225 237 if (feature.geom.prim == Pflag.POINT) { … … 228 240 Snode node; 229 241 while ((node = map.nodes.get(ref)) != null) { 230 if (!done.contains Key(ref)) {242 if (!done.contains(ref)) { 231 243 out.format(" <node id='%d' lat='%.8f' lon='%.8f' version='1'>%n", -ref, Math.toDegrees(node.lat), Math.toDegrees(node.lon)); 232 244 out.format(" <tag k='seamark:type' v=\"%s\"/>%n", type); … … 235 247 writeAtts(feature, type); 236 248 out.format(" </node>%n"); 237 done. put(ref, true);249 done.add(ref); 238 250 } 239 251 ref++; … … 247 259 Feature feature = map.index.get(id); 248 260 String type = S57obj.stringType(feature.type); 249 if (!type.isEmpty()) { 261 if (!type.isEmpty() && (types.isEmpty() || types.contains(feature.type))) { 250 262 if (feature.reln == Rflag.MASTER) { 251 263 if (feature.geom.prim == Pflag.LINE) { … … 258 270 long ref = git.nextRef(); 259 271 Snode node = map.nodes.get(ref); 260 if (!done.contains Key(ref)) {272 if (!done.contains(ref)) { 261 273 out.format(" <node id='%d' lat='%.8f' lon='%.8f' version='1'/>%n", -ref, Math.toDegrees(node.lat), Math.toDegrees(node.lon)); 262 done. put(ref, true);274 done.add(ref); 263 275 } 264 276 } … … 279 291 } 280 292 out.format(" </way>%n"); 281 done. put(way, true);293 done.add(way); 282 294 } 283 295 } else if (feature.geom.prim == Pflag.AREA) { … … 290 302 long ref = git.nextRef(); 291 303 Snode node = map.nodes.get(ref); 292 if (!done.contains Key(ref)) {304 if (!done.contains(ref)) { 293 305 out.format(" <node id='%d' lat='%.8f' lon='%.8f' version='1'/>%n", -ref, Math.toDegrees(node.lat), Math.toDegrees(node.lon)); 294 done. put(ref, true);306 done.add(ref); 295 307 } 296 308 } … … 302 314 while (git.hasEdge()) { 303 315 long way = git.nextEdge(); 304 if (!done.contains Key(way)) {316 if (!done.contains(way)) { 305 317 out.format(" <way id='%d' version='1'>%n", -way); 306 318 while (git.hasNode()) { … … 309 321 } 310 322 out.format(" </way>%n"); 311 done. put(way, true);323 done.add(way); 312 324 } 313 325 } … … 317 329 git = map.new GeomIterator(feature.geom); 318 330 int outers = feature.geom.refs.get(0).size; 319 if (feature.geom.inners != 0){320 int x=0;321 }322 331 while (git.hasComp()) { 323 332 git.nextComp();
Note:
See TracChangeset
for help on using the changeset viewer.