Changeset 30285 in osm for applications/editors/josm/plugins/smed2/src/s57
- Timestamp:
- 2014-02-17T14:27:01+01:00 (11 years ago)
- Location:
- applications/editors/josm/plugins/smed2/src/s57
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/smed2/src/s57/S57att.java
r30269 r30285 1 /* Copyright 2014 Malcolm Herring 2 * 3 * This is free software: you can redistribute it and/or modify 4 * it under the terms of the GNU General Public License as published by 5 * the Free Software Foundation, version 3 of the License. 6 * 7 * For a copy of the GNU General Public License, see <http://www.gnu.org/licenses/>. 8 */ 9 1 10 package s57; 2 11 -
applications/editors/josm/plugins/smed2/src/s57/S57dat.java
r30284 r30285 1 /* Copyright 2014 Malcolm Herring 2 * 3 * This is free software: you can redistribute it and/or modify 4 * it under the terms of the GNU General Public License as published by 5 * the Free Software Foundation, version 3 of the License. 6 * 7 * For a copy of the GNU General Public License, see <http://www.gnu.org/licenses/>. 8 */ 9 1 10 package s57; 2 11 12 import java.io.UnsupportedEncodingException; 3 13 import java.util.ArrayList; 4 14 import java.util.Arrays; … … 165 175 private static int index; 166 176 private static S57field field; 177 private static String aall = "US-ASCII"; 178 private static String nall = "US-ASCII"; 167 179 public static int rnum; 168 180 … … 219 231 if (conv.bin == 0) { 220 232 String str = ""; 233 int i = 0; 221 234 if (conv.asc == 0) { 222 while (buffer[offset] != 0x1f) { 223 str += (char)(buffer[offset++]); 224 } 225 offset++; 235 for (i=0; buffer[offset+i] != 0x1f; i++) {} 236 try { 237 String charset = ""; 238 if (field == S57field.ATTF) charset = aall; 239 else if (field == S57field.NATF) charset = nall; 240 else charset = "US-ASCII"; 241 str = new String(buffer, offset, i, charset); 242 } catch (UnsupportedEncodingException e) { 243 e.printStackTrace(); 244 } 245 offset += i + 1; 226 246 } else { 227 247 str = new String(buffer, offset, conv.asc); … … 239 259 } 240 260 offset += Math.abs(conv.bin); 261 if ((subf == S57subf.AALL) || (subf == S57subf.NALL)) { 262 String charset = ""; 263 switch ((int)val) { 264 case 0: 265 charset = "US-ASCII"; 266 break; 267 case 1: 268 charset = "ISO-8859-1"; 269 break; 270 case 2: 271 charset = "UTF-16LE"; 272 break; 273 } 274 if (subf == S57subf.NALL) { 275 nall = charset; 276 } else { 277 aall = charset; 278 } 279 } 241 280 return val; 242 281 } else { -
applications/editors/josm/plugins/smed2/src/s57/S57dec.java
r30284 r30285 1 /* Copyright 201 3Malcolm Herring1 /* Copyright 2014 Malcolm Herring 2 2 * 3 3 * This is free software: you can redistribute it and/or modify … … 65 65 } 66 66 break; 67 case DSSI: 68 S57dat.getSubf(record, fields + pos, S57field.DSSI, S57subf.AALL); 69 S57dat.getSubf(S57subf.NALL); 70 break; 67 71 case DSPM: 68 72 comf = (double) (Long) S57dat.getSubf(record, fields + pos, S57field.DSPM, S57subf.COMF); -
applications/editors/josm/plugins/smed2/src/s57/S57map.java
r30284 r30285 1 /* Copyright 201 3Malcolm Herring1 /* Copyright 2014 Malcolm Herring 2 2 * 3 3 * This is free software: you can redistribute it and/or modify … … 93 93 94 94 public enum Rflag { 95 UNKN, AGGR,MASTER, SLAVE95 UNKN, MASTER, SLAVE 96 96 } 97 97 … … 120 120 public ObjMap() { 121 121 super(Obj.class); 122 }123 }124 125 public class Aggr {126 public RelTab rels;127 public long par;128 public Aggr() {129 rels = new RelTab();130 par = 0;131 122 } 132 123 } … … 218 209 public Obj type; // Feature type 219 210 public AttMap atts; // Feature attributes 220 public Aggr aggr;// Related objects211 public RelTab rels; // Related objects 221 212 public ObjMap objs; // Slave object attributes 222 213 … … 224 215 reln = Rflag.UNKN; 225 216 geom = new Geom(Pflag.NOSP); 226 type = Obj. C_AGGR;217 type = Obj.UNKOBJ; 227 218 atts = new AttMap(); 228 aggr= newAggr();219 rels = new RelTab(); 229 220 objs = new ObjMap(); 230 221 } … … 271 262 obj = Obj.BOYLAT; 272 263 if (obj == Obj.C_AGGR) 273 feature.reln = Rflag. AGGR;264 feature.reln = Rflag.UNKN; 274 265 feature.geom = new Geom(p); 275 266 feature.type = obj; … … 280 271 281 272 public void newObj(long id, int rind) { 282 Rflag r = Rflag. AGGR;273 Rflag r = Rflag.UNKN; 283 274 switch (rind) { 284 275 case 1: … … 292 283 break; 293 284 } 294 feature. aggr.rels.add(new Reln(id, r));285 feature.rels.add(new Reln(id, r)); 295 286 } 296 287 … … 354 345 for (long id : index.keySet()) { 355 346 Feature feature = index.get(id); 356 for (Reln reln : feature. aggr.rels) {347 for (Reln reln : feature.rels) { 357 348 Feature rel = index.get(reln.id); 358 349 if (cmpGeoms(feature.geom, rel.geom)) { 359 350 switch (reln.reln) { 360 case MASTER:361 feature.reln = Rflag.AGGR;362 break;363 351 case SLAVE: 364 352 feature.reln = Rflag.MASTER; … … 388 376 for (long id : index.keySet()) { 389 377 Feature feature = index.get(id); 390 for (Reln reln : feature. aggr.rels) {378 for (Reln reln : feature.rels) { 391 379 Feature rel = index.get(reln.id); 392 380 if (rel.reln == Rflag.SLAVE) { … … 408 396 nodes.put(id, node); 409 397 feature = new Feature(); 410 feature.reln = Rflag. AGGR;398 feature.reln = Rflag.UNKN; 411 399 feature.geom.prim = Pflag.POINT; 412 400 feature.geom.elems.add(new Prim(id)); … … 416 404 public void addEdge(long id) { 417 405 feature = new Feature(); 418 feature.reln = Rflag. AGGR;406 feature.reln = Rflag.UNKN; 419 407 feature.geom.prim = Pflag.LINE; 420 408 feature.geom.elems.add(new Prim(id)); … … 436 424 public void addArea(long id) { 437 425 feature = new Feature(); 438 feature.reln = Rflag. AGGR;426 feature.reln = Rflag.UNKN; 439 427 feature.geom.prim = Pflag.AREA; 440 428 feature.geom.elems.add(new Prim(id)); … … 447 435 448 436 public void addTag(String key, String val) { 437 feature.reln = Rflag.MASTER; 449 438 String subkeys[] = key.split(":"); 450 439 if ((subkeys.length > 1) && subkeys[0].equals("seamark")) { … … 461 450 att = S57att.enumAttribute(subkeys[2], obj); 462 451 } 463 ObjTab items = feature.objs.get(obj); 464 if (items == null) { 465 items = new ObjTab(); 466 feature.objs.put(obj, items); 467 Feature type = new Feature(); 468 type.reln = Rflag.SLAVE; 469 type.type = obj; 470 type.geom = feature.geom; 471 } 472 // AttMap atts = items.get(idx); 473 // if (atts == null) { 474 // atts = new AttMap(); 475 // items.put(idx, atts); 476 // } 477 // AttVal<?> attval = S57val.convertValue(val, att); 478 // if (attval.val != null) 479 // atts.put(att, attval); 452 ObjTab objs = feature.objs.get(obj); 453 if (objs == null) { 454 objs = new ObjTab(); 455 feature.objs.put(obj, objs); 456 } 457 AttMap atts = objs.get(idx); 458 if (atts == null) { 459 atts = new AttMap(); 460 objs.put(idx, atts); 461 } 462 AttVal<?> attval = S57val.convertValue(val, att); 463 if (attval.val != null) 464 atts.put(att, attval); 480 465 } else { 481 466 if (subkeys[1].equals("type")) { 482 467 obj = S57obj.enumType(val); 483 if (feature.objs.get(feature.type) == null) { 484 feature.objs.put(feature.type, new ObjTab()); 485 Feature type = new Feature(); 486 type.reln = Rflag.MASTER; 487 type.type = obj; 488 type.geom = feature.geom; 468 feature.type = obj; 469 ObjTab objs = feature.objs.get(obj); 470 if (objs == null) { 471 objs = new ObjTab(); 472 feature.objs.put(obj, objs); 473 } 474 AttMap atts = objs.get(0); 475 if (atts == null) { 476 atts = new AttMap(); 477 objs.put(0, atts); 489 478 } 490 479 } else { -
applications/editors/josm/plugins/smed2/src/s57/S57obj.java
r30283 r30285 1 /* Copyright 2014 Malcolm Herring 2 * 3 * This is free software: you can redistribute it and/or modify 4 * it under the terms of the GNU General Public License as published by 5 * the Free Software Foundation, version 3 of the License. 6 * 7 * For a copy of the GNU General Public License, see <http://www.gnu.org/licenses/>. 8 */ 9 1 10 package s57; 2 11 -
applications/editors/josm/plugins/smed2/src/s57/S57val.java
r30231 r30285 1 /* Copyright 2014 Malcolm Herring 2 * 3 * This is free software: you can redistribute it and/or modify 4 * it under the terms of the GNU General Public License as published by 5 * the Free Software Foundation, version 3 of the License. 6 * 7 * For a copy of the GNU General Public License, see <http://www.gnu.org/licenses/>. 8 */ 9 1 10 package s57; 2 11
Note:
See TracChangeset
for help on using the changeset viewer.