Changeset 31731 in osm for applications/editors/josm/plugins/seachart/src/s57
- Timestamp:
- 2015-11-05T13:43:10+01:00 (9 years ago)
- Location:
- applications/editors/josm/plugins/seachart/src/s57
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/seachart/src/s57/S57att.java
r31704 r31731 86 86 AttIENC.put(Att.LC_DR1, 18022); AttIENC.put(Att.LC_DR2, 18023); AttIENC.put(Att.LC_SP1, 18024); AttIENC.put(Att.LC_SP2, 18025); AttIENC.put(Att.LC_WD1, 18026); 87 87 AttIENC.put(Att.LC_WD2, 18027); AttIENC.put(Att.SHPTYP, 33066); AttIENC.put(Att.UPDMSG, 40000); AttIENC.put(Att.BNKWTW, 17999); 88 }89 90 private static final HashMap<Integer, Att> S57Att = new HashMap<Integer, Att>();91 static {92 for (Map.Entry<Att, Integer> entry : AttS57.entrySet()) {93 S57Att.put(entry.getValue(), entry.getKey());94 }95 for (Map.Entry<Att, Integer> entry : AttIENC.entrySet()) {96 S57Att.put(entry.getValue(), entry.getKey());97 }98 88 } 99 89 … … 354 344 } 355 345 356 public static Att decodeAttribute(long attribute) { // Convert S57 attribute code to SCM attribute enumeration 357 Att att = S57Att.get((int)attribute); 358 return (att != null) ? att : Att.UNKATT; 346 public static Att decodeAttribute(long attl) { // Convert S57 attribute code to SCM attribute enumeration 347 for (Att att : AttS57.keySet()) { 348 if (AttS57.get(att) == attl) return att; 349 } 350 for (Att att : AttIENC.keySet()) { 351 if (AttIENC.get(att) == attl) return att; 352 } 353 return Att.UNKATT; 359 354 } 360 355 -
applications/editors/josm/plugins/seachart/src/s57/S57dat.java
r31722 r31731 54 54 convs.put(S57subf.LFIL, new S57conv(0,0)); convs.put(S57subf.VOLM, new S57conv(0,0)); convs.put(S57subf.IMPL, new S57conv(3,0)); 55 55 convs.put(S57subf.SLAT, new S57conv(0,0)); convs.put(S57subf.WLON, new S57conv(0,0)); convs.put(S57subf.NLAT, new S57conv(0,0)); 56 convs.put(S57subf.ELON, new S57conv(0,0)); convs.put(S57subf.CRCS, new S57conv(0,0)); convs.put(S57subf.NAM1, new S57conv(12, 40));57 convs.put(S57subf.NAM2, new S57conv(12, 40)); convs.put(S57subf.OORA, new S57conv(1,1)); convs.put(S57subf.OAAC, new S57conv(6,0));56 convs.put(S57subf.ELON, new S57conv(0,0)); convs.put(S57subf.CRCS, new S57conv(0,0)); convs.put(S57subf.NAM1, new S57conv(12,5)); 57 convs.put(S57subf.NAM2, new S57conv(12,5)); convs.put(S57subf.OORA, new S57conv(1,1)); convs.put(S57subf.OAAC, new S57conv(6,0)); 58 58 convs.put(S57subf.OACO, new S57conv(5,2)); convs.put(S57subf.OALL, new S57conv(0,0)); convs.put(S57subf.OATY, new S57conv(1,1)); 59 59 convs.put(S57subf.DEFN, new S57conv(0,0)); convs.put(S57subf.AUTH, new S57conv(2,2)); convs.put(S57subf.RFTP, new S57conv(2,1)); … … 65 65 convs.put(S57subf.FIDN, new S57conv(10,4)); convs.put(S57subf.FIDS, new S57conv(5,2)); convs.put(S57subf.ATTL, new S57conv(5,2)); 66 66 convs.put(S57subf.ATVL, new S57conv(0,0)); convs.put(S57subf.FFUI, new S57conv(1,1)); convs.put(S57subf.FFIX, new S57conv(0,2)); 67 convs.put(S57subf.NFPT, new S57conv(0,2)); convs.put(S57subf.LNAM, new S57conv(17, 64)); convs.put(S57subf.RIND, new S57conv(0,1));67 convs.put(S57subf.NFPT, new S57conv(0,2)); convs.put(S57subf.LNAM, new S57conv(17,8)); convs.put(S57subf.RIND, new S57conv(0,1)); 68 68 convs.put(S57subf.FSUI, new S57conv(1,1)); convs.put(S57subf.FSIX, new S57conv(0,2)); convs.put(S57subf.NSPT, new S57conv(0,2)); 69 convs.put(S57subf.NAME, new S57conv(12, 40)); convs.put(S57subf.ORNT, new S57conv(1,1)); convs.put(S57subf.USAG, new S57conv(1,1));69 convs.put(S57subf.NAME, new S57conv(12,5)); convs.put(S57subf.ORNT, new S57conv(1,1)); convs.put(S57subf.USAG, new S57conv(1,1)); 70 70 convs.put(S57subf.MASK, new S57conv(1,1)); convs.put(S57subf.VPUI, new S57conv(1,1)); convs.put(S57subf.VPIX, new S57conv(0,2)); 71 71 convs.put(S57subf.NVPT, new S57conv(0,2)); convs.put(S57subf.TOPI, new S57conv(1,1)); convs.put(S57subf.CCUI, new S57conv(1,1)); … … 138 138 fields.put(S57field.ARCC, S57arcc); fields.put(S57field.AR2D, S57ar2d); fields.put(S57field.EL2D, S57el2d); fields.put(S57field.CT2D, S57ct2d); 139 139 } 140 141 public enum S57record { DS, DP, DH, DA, CD, CR, ID, IO, IS, FE, VS, VI, VC, VE }142 143 private static ArrayList<S57field> S57ds = new ArrayList<S57field>(Arrays.asList(S57field.I8RI, S57field.DSID, S57field.DSSI ));144 private static ArrayList<S57field> S57dp = new ArrayList<S57field>(Arrays.asList(S57field.I8RI, S57field.DSPM, S57field.DSPR, S57field.DSRC ));145 private static ArrayList<S57field> S57dh = new ArrayList<S57field>(Arrays.asList(S57field.I8RI, S57field.DSHT ));146 private static ArrayList<S57field> S57da = new ArrayList<S57field>(Arrays.asList(S57field.I8RI, S57field.DSAC ));147 private static ArrayList<S57field> S57cd = new ArrayList<S57field>(Arrays.asList(S57field.I8RI, S57field.CATD ));148 private static ArrayList<S57field> S57cr = new ArrayList<S57field>(Arrays.asList(S57field.I8RI, S57field.CATX ));149 private static ArrayList<S57field> S57id = new ArrayList<S57field>(Arrays.asList(S57field.I8RI, S57field.DDDF, S57field.DDDR ));150 private static ArrayList<S57field> S57io = new ArrayList<S57field>(Arrays.asList(S57field.I8RI, S57field.DDDI, null, S57field.DDOM, S57field.DDRF, null ));151 private static ArrayList<S57field> S57is = new ArrayList<S57field>(Arrays.asList(S57field.I8RI, S57field.DDSI, S57field.DDSC ));152 private static ArrayList<S57field> S57fe = new ArrayList<S57field>(Arrays.asList(S57field.I8RI, S57field.FRID, S57field.FOID, null, S57field.ATTF, null,153 null, S57field.NATF, null, null, S57field.FFPT, null, null, S57field.FSPT, null ));154 private static ArrayList<S57field> S57vs = new ArrayList<S57field>(Arrays.asList(S57field.I8RI, S57field.VRID, null, S57field.SG3D, null));155 private static ArrayList<S57field> S57vi = new ArrayList<S57field>(Arrays.asList(S57field.I8RI, S57field.VRID, S57field.SG2D));156 private static ArrayList<S57field> S57vc = new ArrayList<S57field>(Arrays.asList(S57field.I8RI, S57field.VRID, S57field.SG2D));157 private static ArrayList<S57field> S57ve = new ArrayList<S57field>(Arrays.asList(S57field.I8RI, S57field.VRID, null, S57field.VRPT, null, null, S57field.SG3D, null));158 159 private static final EnumMap<S57record, ArrayList<S57field>> records = new EnumMap<S57record, ArrayList<S57field>>(S57record.class);160 static {161 records.put(S57record.DS, S57ds); records.put(S57record.DP, S57dp); records.put(S57record.DH, S57dh); records.put(S57record.DA, S57da); records.put(S57record.CD, S57cd);162 records.put(S57record.CR, S57cr); records.put(S57record.ID, S57id); records.put(S57record.IO, S57io); records.put(S57record.IS, S57is); records.put(S57record.FE, S57fe);163 records.put(S57record.VS, S57vs); records.put(S57record.VI, S57vi); records.put(S57record.VC, S57vc); records.put(S57record.VE, S57ve);164 }165 166 private static final EnumMap<S57record, Integer> rcnms = new EnumMap<S57record, Integer>(S57record.class);167 static {168 rcnms.put(S57record.DS, 10); rcnms.put(S57record.DP, 20); rcnms.put(S57record.DH, 30); rcnms.put(S57record.DA, 40); rcnms.put(S57record.CD, 50);169 rcnms.put(S57record.CR, 60); rcnms.put(S57record.ID, 70); rcnms.put(S57record.IO, 80); rcnms.put(S57record.IS, 90); rcnms.put(S57record.FE, 100);170 rcnms.put(S57record.VS, 110); rcnms.put(S57record.VI, 110); rcnms.put(S57record.VC, 120); rcnms.put(S57record.VE, 130);171 }172 140 173 141 private static byte[] leader = {'0', '0', '0', '0', '0', ' ', 'D', ' ', ' ', ' ', ' ', ' ', '0', '0', '0', '0', '0', ' ', ' ', ' ', '0', '0', '0', '4'}; … … 293 261 294 262 public static byte[] encSubf(S57subf subf, Object val) { 295 if (val instanceof S57record) val = rcnms.get(val);296 263 S57conv conv = convs.get(subf); 297 264 if (conv.bin == 0) { … … 332 299 lval = (long) val; 333 300 } 334 if (f < 8) { 335 buffer = new byte[f]; 336 for (int i = 0; i < f; i++) { 337 buffer[i] = (byte) (lval & 0xff); 338 lval >>= 8; 339 } 340 } else { 341 f /= 8; 342 buffer = new byte[f]; 343 for (int i = f-1; i >= 0; i--) { 344 buffer[i] = (byte) (lval & 0xff); 345 lval >>= 8; 346 } 301 buffer = new byte[f]; 302 for (int i = 0; i < f; i++) { 303 buffer[i] = (byte) (lval & 0xff); 304 lval >>= 8; 347 305 } 348 306 } … … 361 319 } 362 320 363 public static byte[] encRecord(Object...params) { 321 public static class Fparams { 322 public S57field field; 323 public Object[] params; 324 public Fparams(S57field f, Object[] p) { 325 field = f; 326 params = p; 327 } 328 }; 329 330 public static byte[] encRecord(int i8rn, ArrayList<Fparams> fparams) { 364 331 ArrayList<Index> index = new ArrayList<Index>(); 365 offset = 0; 366 int maxlen = 0; 367 ArrayList<S57field> record = records.get(params[1]); 368 byte[] buf = new byte[0]; 369 int ip = 0; 370 for (S57field field : record) { 371 for (S57subf subf : fields.get(field)) { 372 byte[] next = encSubf(subf, params[ip++]); 373 buf = Arrays.copyOf(buf, (buf.length + next.length)); 374 System.arraycopy(next, 0, buf, (buf.length - next.length), next.length); 375 if (ip >= params.length) 376 break; 332 int offset = 3; 333 int maxlen = 3; 334 byte[] buf = encSubf(S57subf.I8RN, i8rn); 335 buf = Arrays.copyOf(buf, 3); 336 buf[2] = 0x1e; 337 index.add(new Index("0001".getBytes(), 3, 0)); 338 for (Fparams sfparams : fparams) { 339 for (int ip = 0; ip < sfparams.params.length; ) { 340 for (S57subf subf : fields.get(sfparams.field)) { 341 byte[] next = encSubf(subf, sfparams.params[ip++]); 342 buf = Arrays.copyOf(buf, (buf.length + next.length)); 343 System.arraycopy(next, 0, buf, (buf.length - next.length), next.length); 344 } 377 345 } 378 346 buf = Arrays.copyOf(buf, (buf.length + 1)); 379 347 buf[buf.length-1] = 0x1e; 380 348 int flen = buf.length - offset; 381 if (field == S57field.I8RI) { 382 index.add(new Index("0001".getBytes(), flen, offset)); 383 } else { 384 index.add(new Index(field.toString().getBytes(), flen, offset)); 385 } 349 index.add(new Index(sfparams.field.toString().getBytes(), flen, offset)); 386 350 maxlen = (flen > maxlen) ? flen : maxlen; 387 351 offset += flen; -
applications/editors/josm/plugins/seachart/src/s57/S57enc.java
r31722 r31731 11 11 12 12 import java.io.UnsupportedEncodingException; 13 import java.nio.ByteBuffer; 14 import java.text.SimpleDateFormat; 15 import java.util.ArrayList; 16 import java.util.Arrays; 17 import java.util.Calendar; 13 18 import java.util.HashMap; 14 19 import java.util.Map; 15 20 import java.util.Map.Entry; 21 import java.util.zip.CRC32; 22 23 import s57.S57obj.*; 24 import s57.S57val.AttVal; 25 import s57.S57att.Att; 16 26 import s57.S57dat.*; 17 27 import s57.S57map.*; 18 28 19 29 public class S57enc { // S57 ENC file generation 20 21 private static byte[] header = { 22 // Record 0 23 '0', '1', '9', '5', '9', '3', 'L', 'E', '1', ' ', '0', '9', '0', '0', '2', '4', '5', ' ', '!', ' ', '3', '4', '0', '4', // Leader 24 '0', '0', '0', '0', '1', '6', '7', '0', '0', '0', '0', '0', '0', '0', '1', '0', '4', '3', '0', '1', '6', '7', // Directory 25 'D', 'S', 'I', 'D', '1', '6', '5', '0', '2', '1', '0', 'D', 'S', 'S', 'I', '1', '1', '3', '0', '3', '7', '5', 26 'D', 'S', 'P', 'M', '1', '3', '0', '0', '4', '8', '8', 'F', 'R', 'I', 'D', '1', '0', '0', '0', '6', '1', '8', 27 'F', 'O', 'I', 'D', '0', '7', '0', '0', '7', '1', '8', 'A', 'T', 'T', 'F', '0', '5', '9', '0', '7', '8', '8', 28 'N', 'A', 'T', 'F', '0', '6', '8', '0', '8', '4', '7', 'F', 'F', 'P', 'C', '0', '9', '0', '0', '9', '1', '5', 29 'F', 'F', 'P', 'T', '0', '8', '6', '1', '0', '0', '5', 'F', 'S', 'P', 'C', '0', '9', '0', '1', '0', '9', '1', 30 'F', 'S', 'P', 'T', '0', '8', '9', '1', '1', '8', '1', 'V', 'R', 'I', 'D', '0', '7', '8', '1', '2', '7', '0', 31 'A', 'T', 'T', 'V', '0', '5', '8', '1', '3', '4', '8', 'V', 'R', 'P', 'C', '0', '7', '1', '1', '4', '0', '6', 32 'V', 'R', 'P', 'T', '0', '7', '6', '1', '4', '7', '7', 'S', 'G', 'C', 'C', '0', '6', '0', '1', '5', '5', '3', 33 'S', 'G', '2', 'D', '0', '4', '8', '1', '6', '1', '3', 'S', 'G', '3', 'D', '0', '5', '3', '1', '6', '6', '1', 0x1e, 34 // File control field 35 '0', '0', '0', '0', ';', '&', ' ', ' ', ' ', 36 //*** 254 37 '0', 'S', '0', '0', '0', '0', '0', '0', '.', '0', '0', '0', 0x1f, // Filename 38 '0', '0', '0', '1', 'D', 'S', 'I', 'D', 'D', 'S', 'I', 'D', 'D', 'S', 'S', 'I', '0', '0', '0', '1', 'D', 'S', 'P', 'M', 39 '0', '0', '0', '1', 'F', 'R', 'I', 'D', 'F', 'R', 'I', 'D', 'F', 'O', 'I', 'D', 'F', 'R', 'I', 'D', 'A', 'T', 'T', 'F', 40 'F', 'R', 'I', 'D', 'N', 'A', 'T', 'F', 'F', 'R', 'I', 'D', 'F', 'F', 'P', 'C', 'F', 'R', 'I', 'D', 'F', 'F', 'P', 'T', 41 'F', 'R', 'I', 'D', 'F', 'S', 'P', 'C', 'F', 'R', 'I', 'D', 'F', 'S', 'P', 'T', '0', '0', '0', '1', 'V', 'R', 'I', 'D', 42 'V', 'R', 'I', 'D', 'A', 'T', 'T', 'V', 'V', 'R', 'I', 'D', 'V', 'R', 'P', 'C', 'V', 'R', 'I', 'D', 'V', 'R', 'P', 'T', 43 'V', 'R', 'I', 'D', 'S', 'G', 'C', 'C', 'V', 'R', 'I', 'D', 'S', 'G', '2', 'D', 'V', 'R', 'I', 'D', 'S', 'G', '3', 'D', 0x1e, 44 // Record identifier fields 45 '0', '5', '0', '0', ';', '&', ' ', ' ', ' ', 'I', 'S', 'O', ' ', '8', '2', '1', '1', ' ', 'R', 'e', 'c', 'o', 'r', 'd', 46 ' ', 'I', 'd', 'e', 'n', 't', 'i', 'f', 'i', 'e', 'r', 0x1f, 0x1f, '(', 'b', '1', '2', ')', 0x1e, 47 '1', '6', '0', '0', ';', '&', ' ', ' ', ' ', 'D', 'a', 't', 'a', ' ', 'S', 'e', 't', ' ', 'I', 'd', 'e', 'n', 't', 'i', 'f', 48 'i', 'c', 'a', 't', 'i', 'o', 'n', ' ', 'F', 'i', 'e', 'l', 'd', 0x1f, 'R', 'C', 'N', 'M', '!', 'R', 'C', 'I', 'D', '!', 'E', 49 'X', 'P', 'P', '!', 'I', 'N', 'T', 'U', '!', 'D', 'S', 'N', 'M', '!', 'E', 'D', 'T', 'N', '!', 'U', 'P', 'D', 'N', '!', 'U', 50 'A', 'D', 'T', '!', 'I', 'S', 'D', 'T', '!', 'S', 'T', 'E', 'D', '!', 'P', 'R', 'S', 'P', '!', 'P', 'S', 'D', 'N', '!', 'P', 51 'R', 'E', 'D', '!', 'P', 'R', 'O', 'F', '!', 'A', 'G', 'E', 'N', '!', 'C', 'O', 'M', 'T', 0x1f, '(', 'b', '1', '1', ',', 'b', 52 '1', '4', ',', '2', 'b', '1', '1', ',', '3', 'A', ',', '2', 'A', '(', '8', ')', ',', 'R', '(', '4', ')', ',', 'b', '1', '1', 30 31 private static final byte[] header = { 32 '0', '1', '5', '7', '6', '3', 'L', 'E', '1', ' ', '0', '9', '0', '0', '2', '0', '1', ' ', '!', ' ', '3', '4', '0', '4', // Leader 33 '0', '0', '0', '0', '1', '2', '3', '0', '0', '0', '0', '0', '0', '0', '1', '0', '4', '7', '0', '1', '2', '3', 34 'D', 'S', 'I', 'D', '1', '5', '9', '0', '1', '7', '0', 'D', 'S', 'S', 'I', '1', '1', '3', '0', '3', '2', '9', 35 'D', 'S', 'P', 'M', '1', '3', '0', '0', '4', '4', '2', 'F', 'R', 'I', 'D', '1', '0', '0', '0', '5', '7', '2', 36 'F', 'O', 'I', 'D', '0', '7', '0', '0', '6', '7', '2', 'A', 'T', 'T', 'F', '0', '5', '9', '0', '7', '4', '2', 37 'N', 'A', 'T', 'F', '0', '6', '8', '0', '8', '0', '1', 'F', 'F', 'P', 'T', '0', '8', '6', '0', '8', '6', '9', 38 'F', 'S', 'P', 'T', '0', '9', '0', '0', '9', '5', '5', 'V', 'R', 'I', 'D', '0', '7', '8', '1', '0', '4', '5', 39 'A', 'T', 'T', 'V', '0', '5', '8', '1', '1', '2', '3', 'V', 'R', 'P', 'T', '0', '7', '6', '1', '1', '8', '1', 40 'S', 'G', '2', 'D', '0', '4', '8', '1', '2', '5', '7', 'S', 'G', '3', 'D', '0', '7', '0', '1', '3', '0', '5', 0x1e, 41 // File control field 42 '0', '0', '0', '0', ';', '&', ' ', ' ', ' ', 0x1f, 43 '0', '0', '0', '1', 'D', 'S', 'I', 'D', 'D', 'S', 'I', 'D', 'D', 'S', 'S', 'I', '0', '0', '0', '1', 'D', 'S', 'P', 'M', 44 '0', '0', '0', '1', 'F', 'R', 'I', 'D', 'F', 'R', 'I', 'D', 'F', 'O', 'I', 'D', 'F', 'R', 'I', 'D', 'A', 'T', 'T', 'F', 45 'F', 'R', 'I', 'D', 'N', 'A', 'T', 'F', 'F', 'R', 'I', 'D', 'F', 'F', 'P', 'T', 'F', 'R', 'I', 'D', 'F', 'S', 'P', 'T', 46 '0', '0', '0', '1', 'V', 'R', 'I', 'D', 'V', 'R', 'I', 'D', 'A', 'T', 'T', 'V', 'V', 'R', 'I', 'D', 'V', 'R', 'P', 'T', 47 'V', 'R', 'I', 'D', 'S', 'G', '2', 'D', 'V', 'R', 'I', 'D', 'S', 'G', '3', 'D', 0x1e, 48 // Record identifier fields 49 '0', '5', '0', '0', ';', '&', ' ', ' ', ' ', 'I', 'S', 'O', '/', 'I', 'E', 'C', ' ', '8', '2', '1', '1', ' ', 50 'R', 'e', 'c', 'o', 'r', 'd', ' ', 'I', 'd', 'e', 'n', 't', 'i', 'f', 'i', 'e', 'r', 0x1f, 0x1f, '(', 'b', '1', '2', ')', 0x1e, 51 '1', '6', '0', '0', ';', '&', ' ', ' ', ' ', 'D', 'a', 't', 'a', ' ', 'S', 'e', 't', ' ', 'I', 'd', 'e', 'n', 't', 'i', 52 'f', 'i', 'c', 'a', 't', 'i', 'o', 'n', 0x1f, 'R', 'C', 'N', 'M', '!', 'R', 'C', 'I', 'D', '!', 'E', 'X', 'P', 'P', '!', 53 'I', 'N', 'T', 'U', '!', 'D', 'S', 'N', 'M', '!', 'E', 'D', 'T', 'N', '!', 'U', 'P', 'D', 'N', '!', 'U', 'A', 'D', 'T', 54 '!', 'I', 'S', 'D', 'T', '!', 'S', 'T', 'E', 'D', '!', 'P', 'R', 'S', 'P', '!', 'P', 'S', 'D', 'N', '!', 'P', 'R', 'E', 55 'D', '!', 'P', 'R', 'O', 'F', '!', 'A', 'G', 'E', 'N', '!', 'C', 'O', 'M', 'T', 0x1f, '(', 'b', '1', '1', ',', 'b', '1', 56 '4', ',', '2', 'b', '1', '1', ',', '3', 'A', ',', '2', 'A', '(', '8', ')', ',', 'R', '(', '4', ')', ',', 'b', '1', '1', 53 57 ',', '2', 'A', ',', 'b', '1', '1', ',', 'b', '1', '2', ',', 'A', ')', 0x1e, 54 '1', '6', '0', '0', ';', '&', ' ', ' ', ' ', 'D', 'a', 't', 'a', ' ', ' S', 'e', 't', ' ', 'S', 't', 'r', 'u', 'c', 't', 'u',55 ' r', 'e', ' ', 'I', 'n', 'f', 'o', 'r', 'm', 'a', 't', 'i', 'o', 'n', ' ', 'F', 'i', 'e', 'l', 'd', 0x1f, 'D', 'S', 'T', 'R',56 ' !', 'A', 'A', 'L', 'L', '!', 'N', 'A', 'L', 'L', '!', 'N', 'O', 'M', 'R', '!', 'N', 'O', 'C', 'R', '!', 'N', 'O', 'G', 'R',57 '!', 'N', 'O', ' L', 'R', '!', 'N', 'O', 'I', 'N', '!', 'N', 'O', 'C', 'N', '!', 'N', 'O', 'E', 'D', '!', 'N', 'O', 'F', 'A', 0x1f,58 ' (', '3', 'b', '1', '1', ',', '8', 'b', '1', '4', ')', 0x1e,59 '1', '6', '0', '0', ';', '&', ' ', ' ', ' ', 'D', 'a', 't', 'a', ' ', ' S', 'e', 't', ' ', 'P', 'a', 'r', 'a', 'm', 'e', 't',60 ' e', 'r', ' ', 'F', 'i', 'e', 'l', 'd', 0x1f, 'R', 'C', 'N', 'M', '!', 'R', 'C', 'I', 'D', '!', 'H', 'D', 'A', 'T', '!', 'V',61 ' D', 'A', 'T', '!', 'S', 'D', 'A', 'T', '!', 'C', 'S', 'C', 'L', '!', 'D', 'U', 'N', 'I', '!', 'H', 'U', 'N', 'I', '!', 'P',62 ' U', 'N', 'I', '!', 'C', 'O', 'U', 'N', '!', 'C', 'O', 'M', 'F', '!', 'S', 'O', 'M', 'F', '!', 'C', 'O', 'M', 'T', 0x1f,63 ' (', 'b', '1', '1', ',', 'b', '1', '4', ',', '3', 'b', '1', '1', ',', 'b', '1', '4', ',', '4', 'b', '1', '1', ',', '2', 'b',64 '1', ' 4', ',', 'A', ')', 0x1e,65 '1', '6', '0', '0', ';', '&', ' ', ' ', ' ', 'F', 'e', 'a', 't', 'u', 'r', 'e', ' ', ' R', 'e', 'c', 'o', 'r', 'd', ' ', 'I',66 'd', 'e', 'n', 't', 'i', 'f', 'i', 'e', 'r', ' ', ' F', 'i', 'e', 'l', 'd', 0x1f, 'R', 'C', 'N', 'M', '!', 'R', 'C', 'I', 'D',58 '1', '6', '0', '0', ';', '&', ' ', ' ', ' ', 'D', 'a', 't', 'a', ' ', 's', 'e', 't', ' ', 's', 't', 'r', 'u', 'c', 't', 59 'u', 'r', 'e', ' ', 'i', 'n', 'f', 'o', 'r', 'm', 'a', 't', 'i', 'o', 'n', ' ', 'f', 'i', 'e', 'l', 'd', 0x1f, 60 'D', 'S', 'T', 'R', '!', 'A', 'A', 'L', 'L', '!', 'N', 'A', 'L', 'L', '!', 'N', 'O', 'M', 'R', '!', 'N', 'O', 'C', 'R', 61 '!', 'N', 'O', 'G', 'R', '!', 'N', 'O', 'L', 'R', '!', 'N', 'O', 'I', 'N', '!', 'N', 'O', 'C', 'N', '!', 'N', 'O', 'E', 62 'D', '!', 'N', 'O', 'F', 'A', 0x1f, '(', '3', 'b', '1', '1', ',', '8', 'b', '1', '4', ')', 0x1e, 63 '1', '6', '0', '0', ';', '&', ' ', ' ', ' ', 'D', 'a', 't', 'a', ' ', 's', 'e', 't', ' ', 'p', 'a', 'r', 'a', 'm', 'e', 64 't', 'e', 'r', ' ', 'f', 'i', 'e', 'l', 'd', 0x1f, 'R', 'C', 'N', 'M', '!', 'R', 'C', 'I', 'D', '!', 'H', 'D', 'A', 'T', 65 '!', 'V', 'D', 'A', 'T', '!', 'S', 'D', 'A', 'T', '!', 'C', 'S', 'C', 'L', '!', 'D', 'U', 'N', 'I', '!', 'H', 'U', 'N', 66 'I', '!', 'P', 'U', 'N', 'I', '!', 'C', 'O', 'U', 'N', '!', 'C', 'O', 'M', 'F', '!', 'S', 'O', 'M', 'F', '!', 'C', 'O', 67 'M', 'T', 0x1f, '(', 'b', '1', '1', ',', 'b', '1', '4', ',', '3', 'b', '1', '1', ',', 'b', '1', '4', ',', '4', 'b', '1', 68 '1', ',', '2', 'b', '1', '4', ',', 'A', ')', 0x1e, 69 '1', '6', '0', '0', ';', '&', ' ', ' ', ' ', 'F', 'e', 'a', 't', 'u', 'r', 'e', ' ', 'r', 'e', 'c', 'o', 'r', 'd', ' ', 'i', 70 'd', 'e', 'n', 't', 'i', 'f', 'i', 'e', 'r', ' ', 'f', 'i', 'e', 'l', 'd', 0x1f, 'R', 'C', 'N', 'M', '!', 'R', 'C', 'I', 'D', 67 71 '!', 'P', 'R', 'I', 'M', '!', 'G', 'R', 'U', 'P', '!', 'O', 'B', 'J', 'L', '!', 'R', 'V', 'E', 'R', '!', 'R', 'U', 'I', 'N', 0x1f, 68 72 '(', 'b', '1', '1', ',', 'b', '1', '4', ',', '2', 'b', '1', '1', ',', '2', 'b', '1', '2', ',', 'b', '1', '1', ')', 0x1e, 69 '1', '6', '0', '0', ';', '&', ' ', ' ', ' ', 'F', 'e', 'a', 't', 'u', 'r', 'e', ' ', ' O', 'b', 'j', 'e', 'c', 't', ' ', 'I',70 'd', 'e', 'n', 't', 'i', 'f', 'i', 'e', 'r', ' ', ' F', 'i', 'e', 'l', 'd', 0x1f, 'A', 'G', 'E', 'N', '!', 'F', 'I', 'D', 'N',73 '1', '6', '0', '0', ';', '&', ' ', ' ', ' ', 'F', 'e', 'a', 't', 'u', 'r', 'e', ' ', 'o', 'b', 'j', 'e', 'c', 't', ' ', 'i', 74 'd', 'e', 'n', 't', 'i', 'f', 'i', 'e', 'r', ' ', 'f', 'i', 'e', 'l', 'd', 0x1f, 'A', 'G', 'E', 'N', '!', 'F', 'I', 'D', 'N', 71 75 '!', 'F', 'I', 'D', 'S', 0x1f, '(', 'b', '1', '2', ',', 'b', '1', '4', ',', 'b', '1', '2', ')', 0x1e, 72 '2', '6', '0', '0', ';', '&', '-', 'A', ' ', 'F', 'e', 'a', 't', 'u', 'r', 'e', ' ', ' R', 'e', 'c', 'o', 'r', 'd', ' ', 'A',73 't', 't', 'r', 'i', 'b', 'u', 't', 'e', ' ', ' F', 'i', 'e', 'l', 'd', 0x1f, '*', 'A', 'T', 'T', 'L', '!', 'A', 'T', 'V', 'L', 0x1f,76 '2', '6', '0', '0', ';', '&', '-', 'A', ' ', 'F', 'e', 'a', 't', 'u', 'r', 'e', ' ', 'r', 'e', 'c', 'o', 'r', 'd', ' ', 'a', 77 't', 't', 'r', 'i', 'b', 'u', 't', 'e', ' ', 'f', 'i', 'e', 'l', 'd', 0x1f, '*', 'A', 'T', 'T', 'L', '!', 'A', 'T', 'V', 'L', 0x1f, 74 78 '(', 'b', '1', '2', ',', 'A', ')', 0x1e, 75 '2', '6', '0', '0', ';', '&', '-', 'A', ' ', 'F', 'e', 'a', 't', 'u', 'r', 'e', ' ', 'R', 'e', 'c', 'o', 'r', 'd', ' ', 'N', 76 'a', 't', 'i', 'o', 'n', 'a', 'l', ' ', 'A', 't', 't', 'r', 'i', 'b', 'u', 't', 'e', ' ', 'F', 'i', 'e', 'l', 'd', 0x1f, 77 '*', 'A', 'T', 'T', 'L', '!', 'A', 'T', 'V', 'L', 0x1f, '(', 'b', '1', '2', ',', 'A', ')', 0x1e, 78 '1', '6', '0', '0', ';', '&', ' ', ' ', ' ', 'F', 'e', 'a', 't', 'u', 'r', 'e', ' ', 'R', 'e', 'c', 'o', 'r', 'd', ' ', 'T', 79 'o', ' ', 'F', 'e', 'a', 't', 'u', 'r', 'e', ' ', 'O', 'b', 'j', 'e', 'c', 't', ' ', 'P', 'o', 'i', 'n', 't', 'e', 'r', ' ', 80 'C', 'o', 'n', 't', 'r', 'o', 'l', ' ', 'F', 'i', 'e', 'l', 'd', 0x1f, 'F', 'F', 'U', 'I', '!', 'F', 'F', 'I', 'X', '!', 'N', 81 'F', 'P', 'T', 0x1f, '(', 'b', '1', '1', ',', '2', 'b', '1', '2', ')', 0x1e, 82 '2', '0', '0', '0', ';', '&', ' ', ' ', ' ', 'F', 'e', 'a', 't', 'u', 'r', 'e', ' ', 'R', 'e', 'c', 'o', 'r', 'd', ' ', 'T', 83 'o', ' ', 'F', 'e', 'a', 't', 'u', 'r', 'e', ' ', 'O', 'b', 'j', 'e', 'c', 't', ' ', 'P', 'o', 'i', 'n', 't', 'e', 'r', ' ', 84 'F', 'i', 'e', 'l', 'd', 0x1f, '*', 'L', 'N', 'A', 'M', '!', 'R', 'I', 'N', 'D', '!', 'C', 'O', 'M', 'T', 0x1f, '(', 'B', '(', 85 '6', '4', ')', ',', 'b', '1', '1', ',', 'A', ')', 0x1e, 86 '1', '6', '0', '0', ';', '&', ' ', ' ', ' ', 'F', 'e', 'a', 't', 'u', 'r', 'e', ' ', 'R', 'e', 'c', 'o', 'r', 'd', ' ', 'T', 87 'o', ' ', 'S', 'p', 'a', 't', 'i', 'a', 'l', ' ', 'R', 'e', 'c', 'o', 'r', 'd', ' ', 'P', 'o', 'i', 'n', 't', 'e', 'r', ' ', 88 'C', 'o', 'n', 't', 'r', 'o', 'l', ' ', 'F', 'i', 'e', 'l', 'd', 0x1f, 'F', 'S', 'U', 'I', '!', 'F', 'S', 'I', 'X', '!', 'N', 89 'S', 'P', 'T', 0x1f, '(', 'b', '1', '1', ',', '2', 'b', '1', '2', ')', 0x1e, 90 '2', '0', '0', '0', ';', '&', ' ', ' ', ' ', 'F', 'e', 'a', 't', 'u', 'r', 'e', ' ', 'R', 'e', 'c', 'o', 'r', 'd', ' ', 'T', 91 'o', ' ', 'S', 'p', 'a', 't', 'i', 'a', 'l', ' ', 'R', 'e', 'c', 'o', 'r', ' ', 'P', 'o', 'i', 'n', 't', 'e', 'r', ' ', 'F', 92 'i', 'e', 'l', 'd', 0x1f, '*', 'N', 'A', 'M', 'E', '!', 'O', 'R', 'N', 'T', '!', 'U', 'S', 'A', 'G', '!', 'M', 'A', 'S', 'K', 0x1f, 79 '2', '6', '0', '0', ';', '&', '-', 'A', ' ', 'F', 'e', 'a', 't', 'u', 'r', 'e', ' ', 'r', 'e', 'c', 'o', 'r', 'd', ' ', 'n', 'a', 80 't', 'i', 'o', 'n', 'a', 'l', ' ', 'a', 't', 't', 'r', 'i', 'b', 'u', 't', 'e', ' ', 'f', 'i', 'e', 'l', 'd', 0x1f, '*', 'A', 'T', 81 'T', 'L', '!', 'A', 'T', 'V', 'L', 0x1f, '(', 'b', '1', '2', ',', 'A', ')', 0x1e, 82 '2', '6', '0', '0', ';', '&', ' ', ' ', ' ', 'F', 'e', 'a', 't', 'u', 'r', 'e', ' ', 'r', 'e', 'c', 'o', 'r', 'd', ' ', 't', 'o', 83 ' ', 'f', 'e', 'a', 't', 'u', 'r', 'e', ' ', 'o', 'b', 'j', 'e', 'c', 't', ' ', 'p', 'o', 'i', 'n', 't', 'e', 'r', ' ', 'f', 'i', 84 'e', 'l', 'd', 0x1f, '*', 'L', 'N', 'A', 'M', '!', 'R', 'I', 'N', 'D', '!', 'C', 'O', 'M', 'T', 0x1f, '(', 'B', '(', '6', '4', 85 ')', ',', 'b', '1', '1', ',', 'A', ')', 0x1e, 86 '2', '6', '0', '0', ';', '&', ' ', ' ', ' ', 'F', 'e', 'a', 't', 'u', 'r', 'e', ' ', 'r', 'e', 'c', 'o', 'r', 'd', ' ', 't', 'o', 87 ' ', 's', 'p', 'a', 't', 'i', 'a', 'l', ' ', 'r', 'e', 'c', 'o', 'r', 'd', ' ', 'p', 'o', 'i', 'n', 't', 'e', 'r', ' ', 'f', 'i', 88 'e', 'l', 'd', 0x1f, '*', 'N', 'A', 'M', 'E', '!', 'O', 'R', 'N', 'T', '!', 'U', 'S', 'A', 'G', '!', 'M', 'A', 'S', 'K', 0x1f, 93 89 '(', 'B', '(', '4', '0', ')', ',', '3', 'b', '1', '1', ')', 0x1e, 94 '1', '6', '0', '0', ';', '&', ' ', ' ', ' ', 'V', 'e', 'c', 't', 'o', 'r', ' ', 'R', 'e', 'c', 'o', 'r', 'd', ' ', 'I', 'd', 95 'e', 'n', 't', 'i', 'f', 'i', 'e', 'r', ' ', 'F', 'i', 'e', 'l', 'd', 0x1f, 'R', 'C', 'N', 'M', '!', 'R', 'C', 'I', 'D', '!', 96 'R', 'V', 'E', 'R', '!', 'R', 'U', 'I', 'N', 0x1f, '(', 'b', '1', '1', ',', 'b', '1', '4', ',', 'b', '1', '2', ',', 'b', '1', 97 '1', ')', 0x1e, 98 '2', '6', '0', '0', ';', '&', ' ', ' ', ' ', 'V', 'e', 'c', 't', 'o', 'r', ' ', 'R', 'e', 'c', 'o', 'r', 'd', ' ', 'A', 't', 99 't', 'r', 'i', 'b', 'u', 't', 'e', ' ', 'F', 'i', 'e', 'l', 'd', 0x1f, '*', 'A', 'T', 'T', 'L', '!', 'A', 'T', 'V', 'L', 0x1f, 100 '(', 'b', '1', '2', ',', 'A', ')', 0x1e, 101 '1', '6', '0', '0', ';', '&', ' ', ' ', ' ', 'V', 'e', 'c', 't', 'o', 'r', ' ', 'R', 'e', 'c', 'o', 'r', 'd', ' ', 'P', 'o', 102 'i', 'n', 't', 'e', 'r', ' ', 'C', 'o', 'n', 't', 'r', 'o', 'l', ' ', 'F', 'i', 'e', 'l', 's', 0x1f, 'V', 'P', 'U', 'I', '!', 103 'V', 'P', 'I', 'X', '!', 'N', 'V', 'P', 'T', 0x1f, '(', 'b', '1', '1', ',', '2', 'b', '1', '2', ')', 0x1e, 104 '2', '0', '0', '0', ';', '&', ' ', ' ', ' ', 'V', 'e', 'c', 't', 'o', 'r', ' ', 'R', 'e', 'c', 'o', 'r', 'd', ' ', 'P', 'o', 105 'i', 'n', 't', 'e', 'r', ' ', 'F', 'i', 'e', 'l', 'd', 0x1f, '*', 'N', 'A', 'M', 'E', '!', 'O', 'R', 'N', 'T', '!', 'U', 'S', 106 'A', 'G', '!', 'T', 'O', 'P', 'I', '!', 'M', 'A', 'S', 'K', 0x1f, '(', 'B', '(', '4', '0', ')', ',', '4', 'b', '1', '1', ')', 107 0x1e, 108 '1', '6', '0', '0', ';', '&', ' ', ' ', ' ', 'C', 'o', 'o', 'r', 'd', 'i', 'n', 'a', 't', 'e', ' ', 'C', 'o', 'n', 't', 'r', 109 'o', 'l', ' ', 'F', 'i', 'e', 'l', 'd', 0x1f, 'C', 'C', 'U', 'I', '!', 'C', 'C', 'I', 'X', '!', 'C', 'C', 'N', 'C', 0x1f, '(', 110 'b', '1', '1', ',', '2', 'b', '1', '2', ')', 0x1e, 111 '2', '2', '0', '0', ';', '&', ' ', ' ', ' ', '2', '-', 'D', ' ', 'C', 'o', 'o', 'r', 'd', 'i', 'n', 'a', 't', 'e', ' ', 'F', 112 'i', 'e', 'l', 'd', 0x1f, '*', 'Y', 'C', 'O', 'O', '!', 'X', 'C', 'O', 'O', 0x1f, '(', '2', 'b', '2', '4', ')', 113 0x1e, 114 '2', '2', '0', '0', ';', '&', ' ', ' ', ' ', '3', '-', 'D', ' ', 'C', 'o', 'o', 'r', 'd', 'i', 'n', 'a', 't', 'e', ' ', 'F', 115 'i', 'e', 'l', 'd', 0x1f, '*', 'Y', 'C', 'O', 'O', '!', 'X', 'C', 'O', 'O', '!', 'V', 'E', '3', 'D', 0x1f, '(', '3', 'b', '2', 116 '4', ')', 0x1e, 117 118 // Record 1 119 '0', '0', '1', '6', '7', ' ', 'D', ' ', ' ', ' ', ' ', ' ', '0', '0', '0', '4', '9', ' ', ' ', ' ', '2', '2', '0', '4', // Leader 120 // Directory 121 '0', '0', '0', '1', '0', '3', '0', '0', 'D', 'S', 'I', 'D', '7', '9', '0', '3', 'D', 'S', 'S', 'I', '3', '6', '8', '2', 0x1e, 122 '1', '0', 0x1e, // Field 0001 123 // Field DSID 124 0x0a, 0x01, 0x00, 0x00, 0x00, 0x01, 125 //*** 2017 126 0x00, '0', 'S', '0', '0', '0', '0', '0', '0', '.', '0', '0', '0', 0x1f, // INTU & Filename 127 '1', 0x1f, '0', 0x1f, 128 //*** 2035 129 '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', // Date x2 (from system) 130 '0', '3', '.', '1', 0x14, 0x1f, 0x1f, 0x01, 0x26, 0x0f, 'G', 'e', 'n', 'e', 'r', 'a', 't', 'e', 'd', ' ', 'b', 'y', ' ', 131 'O', 'p', 'e', 'n', 'S', 'e', 'a', 'M', 'a', 'p', '.', 'o', 'r', 'g', 0x1f, 0x1e, 132 // Field DSSI 133 0x02, 0x01, 0x02, 134 //*** 2093 135 0x00, 0x00, 0x00, 0x00, // # of meta records (from metas counter) 136 0x00, 0x00, 0x00, 0x00, 137 0x00, 0x00, 0x00, 0x00, // # of geo records (from geos counter) 138 0x00, 0x00, 0x00, 0x00, 139 0x00, 0x00, 0x00, 0x00, // # of isolated node records (from isols counter) 140 0x00, 0x00, 0x00, 0x00, // # of connected node records (from conns counter) 141 0x00, 0x00, 0x00, 0x00, // # of edge records (from edges counter) 142 0x00, 0x00, 0x00, 0x00, 0x1e, 143 144 // Record 2 145 '0', '0', '0', '6', '8', ' ', 'D', ' ', ' ', ' ', ' ', ' ', '0', '0', '0', '3', '9', ' ', ' ', ' ', '2', '1', '0', '4', 146 '0', '0', '0', '1', '0', '3', '0', 'D', 'S', 'P', 'M', '2', '6', '3', 0x1e, 147 // Field 0001 148 0x02, 0x00, 0x1e, 149 // Field DSPM 150 0x14, 0x01, 0x00, 0x00, 0x00, 0x02, 0x17, 0x17, 151 //*** 2176 152 0x00, 0x00, 0x00, 0x00, // Scale (from meta list) 153 0x01, // Depth units (from meta list) 154 0x01, // Height units (from meta list) 155 0x01, 0x01, 156 (byte)0x80, (byte)0x96, (byte)0x98, 0x00, // COMF=10000000 157 0x0a, // SOMF=10 158 0x00, 0x00, 0x00, 0x1f, 0x1e 90 '1', '6', '0', '0', ';', '&', ' ', ' ', ' ', 'V', 'e', 'c', 't', 'o', 'r', ' ', 'r', 'e', 'c', 'o', 'r', 'd', ' ', 'i', 'd', 'e', 91 'n', 't', 'i', 'f', 'i', 'e', 'r', ' ', 'f', 'i', 'e', 'l', 'd', 0x1f, 'R', 'C', 'N', 'M', '!', 'R', 'C', 'I', 'D', '!', 'R', 'V', 92 'E', 'R', '!', 'R', 'U', 'I', 'N', 0x1f, '(', 'b', '1', '1', ',', 'b', '1', '4', ',', 'b', '1', '2', ',', 'b', '1', '1', ')', 0x1e, 93 '2', '6', '0', '0', ';', '&', ' ', ' ', ' ', 'V', 'e', 'c', 't', 'o', 'r', ' ', 'r', 'e', 'c', 'o', 'r', 'd', ' ', 'a', 't', 't', 94 'r', 'i', 'b', 'u', 't', 'e', ' ', 'f', 'i', 'e', 'l', 'd', 0x1f, '*', 'A', 'T', 'T', 'L', '!', 'A', 'T', 'V', 'L', 0x1f, '(', 'b', 95 '1', '2', ',', 'A', ')', 0x1e, 96 '2', '6', '0', '0', ';', '&', ' ', ' ', ' ', 'V', 'e', 'c', 't', 'o', 'r', ' ', 'r', 'e', 'c', 'o', 'r', 'd', ' ', 'p', 'o', 'i', 97 'n', 't', 'e', 'r', ' ', 'f', 'i', 'e', 'l', 'd', 0x1f, '*', 'N', 'A', 'M', 'E', '!', 'O', 'R', 'N', 'T', '!', 'U', 'S', 'A', 'G', 98 '!', 'T', 'O', 'P', 'I', '!', 'M', 'A', 'S', 'K', 0x1f, '(', 'B', '(', '4', '0', ')', ',', '4', 'b', '1', '1', ')', 0x1e, 99 '2', '6', '0', '0', ';', '&', ' ', ' ', ' ', '2', '-', 'D', ' ', 'c', 'o', 'o', 'r', 'd', 'i', 'n', 'a', 't', 'e', ' ', 'f', 'i', 100 'e', 'l', 'd', 0x1f, '*', 'Y', 'C', 'O', 'O', '!', 'X', 'C', 'O', 'O', 0x1f, '(', '2', 'b', '2', '4', ')', 0x1e, 101 '2', '6', '0', '0', ';', '&', ' ', ' ', ' ', '3', '-', 'D', ' ', 'c', 'o', 'o', 'r', 'd', 'i', 'n', 'a', 't', 'e', ' ', '(', 's', 102 'o', 'u', 'n', 'd', 'i', 'n', 'g', ' ', 'a', 'r', 'r', 'a', 'y', ')', ' ', 'f', 'i', 'e', 'l', 'd', 0x1f, '*', 'Y', 'C', 'O', 'O', 103 '!', 'X', 'C', 'O', 'O', '!', 'V', 'E', '3', 'D', 0x1f, '(', '3', 'b', '2', '4', ')', 0x1e 159 104 }; 160 105 161 106 static final double COMF=10000000; 162 107 static final double SOMF=10; 108 109 static int agen = 3878; 110 static int cscl = 10000; 163 111 164 112 static int idx; … … 168 116 static int metas; 169 117 static int geos; 170 static int rcid; 118 static int edges; 119 120 static long hash(long val) { 121 byte[] bval = ByteBuffer.allocate(Long.SIZE).putLong(val).array(); 122 CRC32 crc = new CRC32(); 123 crc.update(bval); 124 return crc.getValue(); 125 } 171 126 172 127 public static int encodeChart(S57map map, HashMap<String, String> meta, byte[] buf) throws IndexOutOfBoundsException, UnsupportedEncodingException { 173 128 174 /* 175 * Encoding order: 176 * 1. Copy records 0-3 & fill in meta attributes. 177 * 2. Depth isolated nodes. 178 * 3. All other isolated nodes. 179 * 4. Connected nodes. 180 * 5. Edges. 181 * 6. Meta objects. 182 * 7. Geo objects. 183 */ 184 185 recs = rcid = 3; 186 isols = conns = metas = geos = 0; 187 for (idx = 0; idx < header.length; idx++) { 188 buf[idx] = header[idx]; 189 } 190 // byte[] file = S57dat.encSubf(S57subf.FILE, meta.get("FILE")); 191 129 byte[] record; 130 ArrayList<Fparams> fields; 131 132 String date = new SimpleDateFormat("yyyyMMdd").format(Calendar.getInstance().getTime()); 133 ArrayList<Fparams> ds = new ArrayList<Fparams>(); 134 ds.add(new Fparams(S57field.DSID, new Object[]{ 10, 1, 1, 4, "0S000000.000", 1, 0, date, date, "03.1", 1, "ENC", "", 1, agen, "Generated by OpenSeaMap.org" })); 135 ds.add(new Fparams(S57field.DSSI, new Object[]{ 2, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0 })); 136 ArrayList<Fparams> dp = new ArrayList<Fparams>(); 137 dp.add(new Fparams(S57field.DSPM, new Object[]{ 20, 2, 2, 23, 23, cscl, 1, 1, 1, 1, 10000000, 10, "" })); 138 139 isols = conns = metas = geos = edges = 0; 140 System.arraycopy(header, 0, buf, 0, header.length); 141 idx = header.length; 142 record = S57dat.encRecord(1, ds); 143 System.arraycopy(record, 0, buf, idx, record.length); 144 idx += record.length; 145 record = S57dat.encRecord(2, dp); 146 System.arraycopy(record, 0, buf, idx, record.length); 147 idx += record.length; 148 recs = 3; 149 150 // Depths 151 Object[] depths = new Object[0]; 152 for (Map.Entry<Long, S57map.Snode> entry : map.nodes.entrySet()) { 153 S57map.Snode node = entry.getValue(); 154 if (node.flg == Nflag.DPTH) { 155 Object[] dval = new Object[]{ (Math.toDegrees(node.lat) * COMF), (Math.toDegrees(node.lon) * COMF), (node.val * SOMF) }; 156 depths = Arrays.copyOf(depths, (depths.length + dval.length)); 157 System.arraycopy(dval, 0, depths, (depths.length - dval.length), dval.length); 158 } 159 } 160 if (depths.length > 0) { 161 fields = new ArrayList<Fparams>(); 162 fields.add(new Fparams(S57field.VRID, new Object[]{ 110, -2, 1, 1 })); 163 fields.add(new Fparams(S57field.SG3D, depths)); 164 record = S57dat.encRecord(recs++, fields); 165 System.arraycopy(record, 0, buf, idx, record.length); 166 idx += record.length; 167 isols++; 168 } 169 170 // Isolated nodes 192 171 for (Map.Entry<Long, S57map.Snode> entry : map.nodes.entrySet()) { 193 172 S57map.Snode node = entry.getValue(); 194 173 if (node.flg == Nflag.ISOL) { 195 byte[] record = S57dat.encRecord(recs++, S57record.VI, rcid++, 1, 1, (Math.toDegrees(node.lat) * COMF), (Math.toDegrees(node.lon) * COMF)); 174 fields = new ArrayList<Fparams>(); 175 fields.add(new Fparams(S57field.VRID, new Object[]{ 110, hash(entry.getKey()), 1, 1 })); 176 fields.add(new Fparams(S57field.SG2D, new Object[]{ (Math.toDegrees(node.lat) * COMF), (Math.toDegrees(node.lon) * COMF) })); 177 record = S57dat.encRecord(recs++, fields); 196 178 System.arraycopy(record, 0, buf, idx, record.length); 197 179 idx += record.length; 198 180 isols++; 199 recs++; 200 } 201 } 202 181 } 182 } 183 184 // Connected nodes 185 for (Map.Entry<Long, S57map.Snode> entry : map.nodes.entrySet()) { 186 S57map.Snode node = entry.getValue(); 187 if (node.flg == Nflag.CONN) { 188 fields = new ArrayList<Fparams>(); 189 fields.add(new Fparams(S57field.VRID, new Object[]{ 120, hash(entry.getKey()), 1, 1 })); 190 fields.add(new Fparams(S57field.SG2D, new Object[]{ (Math.toDegrees(node.lat) * COMF), (Math.toDegrees(node.lon) * COMF) })); 191 record = S57dat.encRecord(recs++, fields); 192 System.arraycopy(record, 0, buf, idx, record.length); 193 idx += record.length; 194 conns++; 195 } 196 } 197 198 // Edges 199 for (Map.Entry<Long, S57map.Edge> entry : map.edges.entrySet()) { 200 S57map.Edge edge = entry.getValue(); 201 fields = new ArrayList<Fparams>(); 202 fields.add(new Fparams(S57field.VRID, new Object[]{ 130, hash(entry.getKey()), 1, 1 })); 203 fields.add(new Fparams(S57field.VRPT, new Object[]{ (((hash(edge.first) & 0xffffffff) << 8) + 120l), 255, 255, 1, 255, (((hash(edge.last) & 0xffffffff) << 8) + 120l), 255, 255, 2, 255 })); 204 Object[] nodes = new Object[0]; 205 for (long ref : edge.nodes) { 206 Object[] nval = new Object[]{ (Math.toDegrees(map.nodes.get(ref).lat) * COMF), (Math.toDegrees(map.nodes.get(ref).lon) * COMF) }; 207 nodes = Arrays.copyOf(nodes, (nodes.length + nval.length)); 208 System.arraycopy(nval, 0, nodes, (nodes.length - nval.length), nval.length); 209 } 210 if (nodes.length > 0) { 211 fields.add(new Fparams(S57field.SG2D, nodes)); 212 } 213 record = S57dat.encRecord(recs++, fields); 214 System.arraycopy(record, 0, buf, idx, record.length); 215 idx += record.length; 216 edges++; 217 } 218 219 // Meta & Geo objects 220 for (Entry<Obj, ArrayList<Feature>> entry : map.features.entrySet()) { 221 Obj obj = entry.getKey(); 222 for (Feature feature : entry.getValue()) { 223 int prim = feature.geom.prim.ordinal(); 224 prim = (prim == 0) ? 255 : prim; 225 int grup = ((obj == Obj.DEPARE) || (obj == Obj.DRGARE) || (obj == Obj.FLODOC) || (obj == Obj.HULKES) || (obj == Obj.LNDARE) || (obj == Obj.PONTON) || (obj == Obj.UNSARE)) ? 1 : 2; 226 227 ArrayList<Fparams> geom = new ArrayList<Fparams>(); 228 int outers = feature.geom.outers; 229 for (Prim elem : feature.geom.elems) { 230 if (feature.geom.prim == Pflag.POINT) { 231 geom.add(new Fparams(S57field.FSPT, new Object[] { ((hash(elem.id) << 8) + ((map.nodes.get(elem.id).flg == Nflag.CONN) ? 120l : 110l)), 255, 255, 255 })); 232 } else { 233 geom.add(new Fparams(S57field.FSPT, new Object[] { ((hash(elem.id) << 8) + 130l), (elem.forward ? 1 : 2), ((outers-- > 0) ? 1 : 2), 2 })); 234 } 235 } 236 237 ArrayList<ArrayList<Fparams>> objects = new ArrayList<ArrayList<Fparams>>(); 238 ArrayList<Long> slaves = new ArrayList<Long>(); 239 long slaveid = feature.id & 0x01ffffffffffffffl; 240 for (Entry<Obj, ObjTab> objs : feature.objs.entrySet()) { 241 Obj objobj = objs.getKey(); 242 for (Entry<Integer, AttMap> object : objs.getValue().entrySet()) { 243 ArrayList<Fparams> objatts = new ArrayList<Fparams>(); 244 boolean master = (feature.type == objobj) && ((object.getKey() == 0) || (object.getKey() == 1)); 245 long id = hash(master ? feature.id : slaveid); 246 objatts.add(new Fparams(S57field.FRID, new Object[] { 100, id, prim, grup, S57obj.encodeType(objobj), 1, 1 })); 247 objatts.add(new Fparams(S57field.FOID, new Object[] { agen, id, 1 })); 248 Object[] attf = new Object[0]; 249 Object[] natf = new Object[0]; 250 for (Entry<Att, AttVal<?>> att : object.getValue().entrySet()) { 251 if (!((obj == Obj.SOUNDG) && (att.getKey() == Att.VALSOU))) { 252 long attl = S57att.encodeAttribute(att.getKey()); 253 Object[] next = new Object[] { attl, S57val.encodeValue(att.getValue(), att.getKey()) }; 254 if ((attl < 300) || (attl > 304)) { 255 attf = Arrays.copyOf(attf, (attf.length + next.length)); 256 System.arraycopy(next, 0, attf, (attf.length - next.length), next.length); 257 } else { 258 natf = Arrays.copyOf(natf, (natf.length + next.length)); 259 System.arraycopy(next, 0, natf, (natf.length - next.length), next.length); 260 } 261 } 262 } 263 if (attf.length > 0) { 264 objatts.add(new Fparams(S57field.ATTF, attf)); 265 } 266 if (natf.length > 0) { 267 objatts.add(new Fparams(S57field.NATF, attf)); 268 } 269 if (master) { 270 objects.add(objatts); 271 } else { 272 slaves.add(id); 273 objects.add(0, objatts); 274 slaveid += 0x0100000000000000l; 275 } 276 } 277 } 278 279 if (!slaves.isEmpty()) { 280 ArrayList<Fparams> refs = new ArrayList<Fparams>(); 281 Object[] params = new Object[0]; 282 while (!slaves.isEmpty()) { 283 long id = slaves.remove(0); 284 Object[] next = new Object[]{ (long)((((id & 0xffffffff) + 0x100000000l) << 16) + (agen & 0xffff)) , 2, "" }; 285 params = Arrays.copyOf(params, (params.length + next.length)); 286 System.arraycopy(next, 0, params, (params.length - next.length), next.length); 287 } 288 refs.add(new Fparams(S57field.FFPT, params)); 289 objects.get(objects.size() - 1).addAll(refs); 290 } 291 292 for (ArrayList<Fparams> object : objects) { 293 object.addAll(geom); 294 record = S57dat.encRecord(recs++, object); 295 System.arraycopy(record, 0, buf, idx, record.length); 296 idx += record.length; 297 if ((obj == Obj.M_COVR) || (obj == Obj.M_NSYS)) { 298 metas++; 299 } else { 300 geos++; 301 } 302 } 303 } 304 } 305 306 // Re-write DSID/DSSI with final totals 307 ds = new ArrayList<Fparams>(); 308 ds.add(new Fparams(S57field.DSID, new Object[]{ 10, 1, 1, 4, "0S000000.000", 1, 0, date, date, "03.1", 1, "ENC", "", 1, agen, "Generated by OpenSeaMap.org" })); 309 ds.add(new Fparams(S57field.DSSI, new Object[]{ 2, 1, 2, metas, 0, geos, 0, isols, conns, edges, 0 })); 310 record = S57dat.encRecord(1, ds); 311 System.arraycopy(record, 0, buf, header.length, record.length); 312 203 313 return idx; 204 314 } -
applications/editors/josm/plugins/seachart/src/s57/S57map.java
r31722 r31731 47 47 public double lon; // Longitude in radians 48 48 public Nflag flg; // Role of node 49 public double val; // Optional value 49 50 50 51 public Snode() { … … 52 53 lat = 0; 53 54 lon = 0; 55 val = 0; 54 56 } 55 57 public Snode(double ilat, double ilon) { … … 57 59 lat = ilat; 58 60 lon = ilon; 61 val = 0; 59 62 } 60 63 public Snode(double ilat, double ilon, Nflag iflg) { … … 62 65 lon = ilon; 63 66 flg = iflg; 64 }65 }66 67 public class Dnode extends Snode { // All depth soundings68 public double val; // Sounding value69 70 public Dnode() {71 flg = Nflag.DPTH;72 lat = 0;73 lon = 0;74 67 val = 0; 75 68 } 76 public Dnode(double ilat, double ilon, double ival) {69 public Snode(double ilat, double ilon, double ival) { 77 70 flg = Nflag.DPTH; 78 71 lat = ilat; … … 81 74 } 82 75 } 83 76 84 77 public class Edge { // A polyline segment 85 78 public long first; // First CONN node … … 207 200 208 201 public class Feature { 202 public long id; // Ref for this feature 209 203 public Rflag reln; // Relationship status 210 204 public Geom geom; // Geometry data … … 215 209 216 210 Feature() { 211 id = 0; 217 212 reln = Rflag.UNKN; 218 213 geom = new Geom(Pflag.NOSP); … … 261 256 262 257 public void newNode(long id, double lat, double lon, double depth) { 263 nodes.put(id, new Dnode(Math.toRadians(lat), Math.toRadians(lon), depth));258 nodes.put(id, new Snode(Math.toRadians(lat), Math.toRadians(lon), depth)); 264 259 } 265 260 … … 271 266 if (obj == Obj.BOYWTW) 272 267 obj = Obj.BOYLAT; 273 if (obj == Obj.C_AGGR)274 feature.reln = Rflag.UNKN;275 268 feature.geom = new Geom(p); 276 269 feature.type = obj; 277 270 if (obj != Obj.UNKOBJ) { 278 271 index.put(id, feature); 272 feature.id = id; 279 273 } 280 274 } … … 378 372 nodes.put(id, node); 379 373 feature = new Feature(); 374 feature.id = id; 380 375 feature.reln = Rflag.UNKN; 381 376 feature.geom.prim = Pflag.POINT; … … 387 382 public void addEdge(long id) { 388 383 feature = new Feature(); 384 feature.id = id; 389 385 feature.reln = Rflag.UNKN; 390 386 feature.geom.prim = Pflag.LINE; … … 408 404 public void addArea(long id) { 409 405 feature = new Feature(); 406 feature.id = id; 410 407 feature.reln = Rflag.UNKN; 411 408 feature.geom.prim = Pflag.AREA; … … 445 442 } 446 443 AttVal<?> attval = S57val.convertValue(val, att); 447 if (attval.val != null) 444 if (attval.val != null) { 445 if (att == Att.VALSOU) { 446 Snode node = nodes.get(feature.geom.elems.get(0).id); 447 node.val = (double) attval.val; 448 } 448 449 atts.put(att, attval); 450 } 449 451 } else { 450 452 if (subkeys[1].equals("type")) { … … 461 463 objs.put(0, atts); 462 464 } 465 if ((obj == Obj.SOUNDG) && (feature.geom.prim == Pflag.POINT)) { 466 Snode node = nodes.get(feature.geom.elems.get(0).id); 467 node.flg = Nflag.DPTH; 468 } 463 469 } else { 464 470 Att att = S57att.enumAttribute(subkeys[1], Obj.UNKOBJ); … … 485 491 case POINT: 486 492 Snode node = nodes.get(id); 487 if ( node.flg != Nflag.CONN) {493 if ((node.flg != Nflag.CONN) && (node.flg != Nflag.DPTH) && (!feature.objs.isEmpty())) { 488 494 node.flg = Nflag.ISOL; 489 495 } -
applications/editors/josm/plugins/seachart/src/s57/S57obj.java
r31704 r31731 15 15 16 16 public enum Obj { 17 UNKOBJ, AIRARE, ACHBRT, ACHARE, BCNCAR, BCNISD, BCNLAT, BCNSAW, BCNSPP, BERTHS, BRIDGE, BUISGL, BUAARE, BOYCAR, BOYINB, BOYISD,18 BOY LAT, BOYSAW, BOYSPP, CBLARE, CBLOHD, CBLSUB, CANALS, CTSARE, CAUSWY, CTNARE, CHKPNT, CGUSTA, COALNE, CONZNE, COSARE, CTRPNT,19 CO NVYR, CRANES, CURENT, CUSZNE, DAMCON, DAYMAR, DWRTCL, DWRTPT, DEPARE, DEPCNT, DISMAR, DOCARE, DRGARE, DRYDOC, DMPGRD, DYKCON,20 EXEZNE, FAIRWY, FNCLNE, FERYRT, FSHZNE, FSHFAC, FSHGRD, FLODOC, FOGSIG, FORSTC, FRPARE, GATCON, GRIDRN, HRBARE, HRBFAC, HULKES,21 ICEARE, ICNARE, ISTZNE, LAKARE, LNDARE, LNDELV, LNDRGN, LNDMRK, LIGHTS, LITFLT, LITVES, LOCMAG, LOKBSN, LOGPON, MAGVAR, MARCUL,22 M IPARE, MORFAC, MPAARE, NAVLNE, OBSTRN, OFSPLF, OSPARE, OILBAR, PILPNT, PILBOP, PIPARE, PIPOHD, PIPSOL, PONTON, PRCARE, PRDARE,23 P YLONS, RADLNE, RADRNG, RADRFL, RADSTA, RTPBCN, RDOCAL, RDOSTA, RAILWY, RAPIDS, RCRTCL, RECTRC, RCTLPT, RSCSTA, RESARE, RETRFL,24 R IVERS, ROADWY, RUNWAY, SNDWAV, SEAARE, SPLARE, SBDARE, SLCONS, SISTAT, SISTAW, SILTNK, SLOTOP, SLOGRD, SMCFAC, SOUNDG, SPRING,25 S TSLNE, SUBTLN, SWPARE, TESARE, TS_PRH, TS_PNH, TS_PAD, TS_TIS, T_HMON, T_NHMN, T_TIMS, TIDEWY, TOPMAR, TSELNE, TSSBND, TSSCRS,26 TSS LPT, TSSRON, TSEZNE, TUNNEL, TWRTPT, UWTROC, UNSARE, VEGATN, WATTUR, WATFAL, WEDKLP, WRECKS, TS_FEB, NOTMRK, WTWAXS, WTWPRF,27 BRGARE, BUNSTA, COMARE, HRBBSN, LOKARE, LKBSPT, PRTARE, BCNWTW, BOYWTW, REFDMP, RTPLPT, TERMNL, TRNBSN, WTWARE, WTWGAG, TISDGE,28 VEHTRF, EXCNST, LG_SDM, LG_VSP, LITMIN, LITMAJ, C_AGGR, M_COVR, M_NSYS17 UNKOBJ, M_COVR, M_NSYS, AIRARE, ACHBRT, ACHARE, BCNCAR, BCNISD, BCNLAT, BCNSAW, BCNSPP, BERTHS, BRIDGE, BUISGL, BUAARE, BOYCAR, 18 BOYINB, BOYISD, BOYLAT, BOYSAW, BOYSPP, CBLARE, CBLOHD, CBLSUB, CANALS, CTSARE, CAUSWY, CTNARE, CHKPNT, CGUSTA, COALNE, CONZNE, 19 COSARE, CTRPNT, CONVYR, CRANES, CURENT, CUSZNE, DAMCON, DAYMAR, DWRTCL, DWRTPT, DEPARE, DEPCNT, DISMAR, DOCARE, DRGARE, DRYDOC, 20 DMPGRD, DYKCON, EXEZNE, FAIRWY, FNCLNE, FERYRT, FSHZNE, FSHFAC, FSHGRD, FLODOC, FOGSIG, FORSTC, FRPARE, GATCON, GRIDRN, HRBARE, 21 HRBFAC, HULKES, ICEARE, ICNARE, ISTZNE, LAKARE, LNDARE, LNDELV, LNDRGN, LNDMRK, LIGHTS, LITFLT, LITVES, LOCMAG, LOKBSN, LOGPON, 22 MAGVAR, MARCUL, MIPARE, MORFAC, MPAARE, NAVLNE, OBSTRN, OFSPLF, OSPARE, OILBAR, PILPNT, PILBOP, PIPARE, PIPOHD, PIPSOL, PONTON, 23 PRCARE, PRDARE, PYLONS, RADLNE, RADRNG, RADRFL, RADSTA, RTPBCN, RDOCAL, RDOSTA, RAILWY, RAPIDS, RCRTCL, RECTRC, RCTLPT, RSCSTA, 24 RESARE, RETRFL, RIVERS, ROADWY, RUNWAY, SNDWAV, SEAARE, SPLARE, SBDARE, SLCONS, SISTAT, SISTAW, SILTNK, SLOTOP, SLOGRD, SMCFAC, 25 SOUNDG, SPRING, STSLNE, SUBTLN, SWPARE, TESARE, TS_PRH, TS_PNH, TS_PAD, TS_TIS, T_HMON, T_NHMN, T_TIMS, TIDEWY, TOPMAR, TSELNE, 26 TSSBND, TSSCRS, TSSLPT, TSSRON, TSEZNE, TUNNEL, TWRTPT, UWTROC, UNSARE, VEGATN, WATTUR, WATFAL, WEDKLP, WRECKS, TS_FEB, NOTMRK, 27 WTWAXS, WTWPRF, BRGARE, BUNSTA, COMARE, HRBBSN, LOKARE, LKBSPT, PRTARE, BCNWTW, BOYWTW, REFDMP, RTPLPT, TERMNL, TRNBSN, WTWARE, 28 WTWGAG, TISDGE, VEHTRF, EXCNST, LG_SDM, LG_VSP, LITMIN, LITMAJ 29 29 } 30 30 … … 63 63 ObjS57.put(Obj.TUNNEL,151); ObjS57.put(Obj.TWRTPT,152); ObjS57.put(Obj.UWTROC,153); ObjS57.put(Obj.UNSARE,154); ObjS57.put(Obj.VEGATN,155); 64 64 ObjS57.put(Obj.WATTUR,156); ObjS57.put(Obj.WATFAL,157); ObjS57.put(Obj.WEDKLP,158); ObjS57.put(Obj.WRECKS,159); ObjS57.put(Obj.TS_FEB,160); 65 ObjS57.put(Obj.MPAARE,199); ObjS57.put(Obj. C_AGGR,400); ObjS57.put(Obj.M_COVR,302); ObjS57.put(Obj.M_NSYS,306);65 ObjS57.put(Obj.MPAARE,199); ObjS57.put(Obj.M_COVR,302); ObjS57.put(Obj.M_NSYS,306); ObjS57.put(Obj.LITMAJ,74); ObjS57.put(Obj.LITMIN,90); 66 66 } 67 67 … … 82 82 } 83 83 84 private static final HashMap<Integer, Obj> S57Obj = new HashMap<Integer, Obj>();85 static {86 for (Map.Entry<Obj, Integer> entry : ObjS57.entrySet()) {87 S57Obj.put(entry.getValue(), entry.getKey());88 }89 for (Map.Entry<Obj, Integer> entry : ObjIENC.entrySet()) {90 S57Obj.put(entry.getValue(), entry.getKey());91 }92 }93 94 84 private static final EnumMap<Obj, String> ObjStr = new EnumMap<Obj, String>(Obj.class); 95 85 static { … … 139 129 ObjStr.put(Obj.TRNBSN, "turning_basin"); ObjStr.put(Obj.WTWARE, "waterway_area"); ObjStr.put(Obj.WTWGAG, "waterway_gauge"); ObjStr.put(Obj.TISDGE, "time_schedule"); 140 130 ObjStr.put(Obj.VEHTRF, "vehicle_transfer"); ObjStr.put(Obj.EXCNST, "exceptional_structure"); ObjStr.put(Obj.MPAARE, "protected_area"); 141 ObjStr.put(Obj.LITMAJ, "light_major"); ObjStr.put(Obj.LITMIN, "light_minor"); ObjStr.put(Obj.M_COVR, "coverage"); ObjStr.put(Obj.M_NSYS, " navigational_system");131 ObjStr.put(Obj.LITMAJ, "light_major"); ObjStr.put(Obj.LITMIN, "light_minor"); ObjStr.put(Obj.M_COVR, "coverage"); ObjStr.put(Obj.M_NSYS, "system"); 142 132 } 143 133 … … 151 141 152 142 public static Obj decodeType(long objl) { // Convert S57 feature code to SCM object enumeration 153 Obj obj = S57Obj.get((int)objl); 154 return (obj != null) ? obj : Obj.UNKOBJ; 143 for (Obj obj : ObjS57.keySet()) { 144 if (ObjS57.get(obj) == objl) return obj; 145 } 146 for (Obj obj : ObjIENC.keySet()) { 147 if (ObjIENC.get(obj) == objl) return obj; 148 } 149 return Obj.UNKOBJ; 155 150 } 156 151 -
applications/editors/josm/plugins/seachart/src/s57/S57val.java
r31704 r31731 1150 1150 } 1151 1151 1152 public static Integer encodeValue(String val, Att att) { // Convert OSM attribute value string to S57 attribute value 1153 EnumMap<?, ?> map = keys.get(att).map; 1154 for (Object item : map.keySet()) { 1155 if (((S57enum)map.get(item)).val.equals(val)) 1156 return ((S57enum)map.get(item)).atvl; 1157 } 1158 return 0; 1159 } 1160 1161 public static String stringValue(AttVal<?> attval, Att att) { // Convert SCM value object to OSM attribute value string 1152 public static String encodeValue(AttVal<?> attval, Att att) { // Convert SCM attribute value to S57 attribute value string 1153 if (attval != null) { 1154 String str = stringValue(attval, att); 1155 if ((attval.conv == Conv.E) || (attval.conv == Conv.L)) { 1156 String[] vals = str.split(";"); 1157 str = ""; 1158 for (String val : vals) { 1159 if (!str.isEmpty()) str += ","; 1160 EnumMap<?, ?> map = keys.get(att).map; 1161 for (Object item : map.keySet()) { 1162 if (((S57enum)map.get(item)).val.equals(val)) 1163 str += ((S57enum)map.get(item)).atvl.toString(); 1164 } 1165 } 1166 } 1167 return str; 1168 } 1169 return ""; 1170 } 1171 1172 public static String stringValue(AttVal<?> attval, Att att) { // Convert SCM attribute value to OSM attribute value string 1162 1173 if (attval != null) { 1163 1174 switch (attval.conv) {
Note:
See TracChangeset
for help on using the changeset viewer.