Changeset 30183 in osm for applications
- Timestamp:
- 2014-01-05T14:28:30+01:00 (11 years ago)
- Location:
- applications/editors/josm/plugins/smed2/src/s57
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/smed2/src/s57/S57dat.java
r30153 r30183 18 18 } 19 19 20 p rivate enum S57subf {RCNM, RCID, EXPP, INTU, DSNM, EDTN, UPDN, UADT, ISDT, STED, PRSP, PSDN, PRED, PROF, AGEN, COMT, DSTR, AALL, NALL, NOMR, NOCR, NOGR, NOLR, NOIN, NOCN,20 public enum S57subf { I8RN, RCNM, RCID, EXPP, INTU, DSNM, EDTN, UPDN, UADT, ISDT, STED, PRSP, PSDN, PRED, PROF, AGEN, COMT, DSTR, AALL, NALL, NOMR, NOCR, NOGR, NOLR, NOIN, NOCN, 21 21 NOED, NOFA, HDAT, VDAT, SDAT, CSCL, DUNI, HUNI, PUNI, COUN, COMF, SOMF, PROJ, PRP1, PRP2, PRP3, PRP4, FEAS, FNOR, FPMF, RPID, RYCO, RXCO, CURP, RXVL, RYVL, PRCO, ESDT, 22 22 LSDT, DCRT, CODT, PACC, HACC, SACC, FILE, LFIL, VOLM, IMPL, SLAT, WLON, NLAT, ELON, CRCS, NAM1, NAM2, OORA, OAAC, OACO, OALL, OATY, DEFN, AUTH, RFTP, RFVL, ATLB, ATDO, … … 26 26 private static final EnumMap<S57subf, S57conv> convs = new EnumMap<S57subf, S57conv>(S57subf.class); 27 27 static { 28 convs.put(S57subf.I8RN, new S57conv(5,2,Dom.INT)); 28 29 convs.put(S57subf.RCNM, new S57conv(2,1,Dom.AN)); convs.put(S57subf.RCID, new S57conv(10,4,Dom.INT)); convs.put(S57subf.EXPP, new S57conv(1,1,Dom.AN)); 29 30 convs.put(S57subf.INTU, new S57conv(1,1,Dom.INT)); convs.put(S57subf.DSNM, new S57conv(0,0,Dom.BT)); convs.put(S57subf.EDTN, new S57conv(0,0,Dom.BT)); … … 71 72 } 72 73 73 public enum S57field { DSID, DSSI, DSPM, DSPR, DSRC, DSHT, DSAC, CATD, CATX, DDDF, DDDR, DDDI, DDOM, DDRF, DDSI, DDSC,74 public enum S57field { I8RI, DSID, DSSI, DSPM, DSPR, DSRC, DSHT, DSAC, CATD, CATX, DDDF, DDDR, DDDI, DDOM, DDRF, DDSI, DDSC, 74 75 FRID, FOID, ATTF, NATF, FFPC, FFPT, FSPC, FSPT, VRID, ATTV, VRPC, VRPT, SGCC, SG2D, SG3D, ARCC, AR2D, EL2D, CT2D } 75 76 77 private static ArrayList<S57subf> S57i8ri = new ArrayList<S57subf>(Arrays.asList(S57subf.I8RN)); 76 78 private static ArrayList<S57subf> S57dsid = new ArrayList<S57subf>(Arrays.asList(S57subf.RCNM, S57subf.RCID, S57subf.EXPP, S57subf.INTU, S57subf.DSNM, S57subf.EDTN, S57subf.UPDN, 77 79 S57subf.UADT, S57subf.ISDT, S57subf.STED, S57subf.PRSP, S57subf.PSDN, S57subf.PRED, S57subf.PROF, S57subf.AGEN, S57subf.COMT)); … … 119 121 private static final EnumMap<S57field, ArrayList<S57subf>> fields = new EnumMap<S57field, ArrayList<S57subf>>(S57field.class); 120 122 static { 121 fields.put(S57field.DSID, S57dsid); fields.put(S57field.DSSI, S57dssi); fields.put(S57field.DSID, S57dspm); fields.put(S57field.DSID, S57dspr); 122 fields.put(S57field.DSID, S57dsrc); fields.put(S57field.DSID, S57dsht); fields.put(S57field.DSID, S57dsac); fields.put(S57field.DSID, S57catd); 123 fields.put(S57field.DSID, S57catx); fields.put(S57field.DSID, S57dddf); fields.put(S57field.DSID, S57dddr); fields.put(S57field.DSID, S57dddi); 124 fields.put(S57field.DSID, S57ddom); fields.put(S57field.DSID, S57ddrf); fields.put(S57field.DSID, S57ddsi); fields.put(S57field.DSID, S57ddsc); 125 fields.put(S57field.DSID, S57frid); fields.put(S57field.DSID, S57foid); fields.put(S57field.DSID, S57attf); fields.put(S57field.DSID, S57natf); 126 fields.put(S57field.DSID, S57ffpc); fields.put(S57field.DSID, S57ffpt); fields.put(S57field.DSID, S57fspc); fields.put(S57field.DSID, S57fspt); 127 fields.put(S57field.DSID, S57vrid); fields.put(S57field.DSID, S57attv); fields.put(S57field.DSID, S57vrpc); fields.put(S57field.DSID, S57vrpt); 128 fields.put(S57field.DSID, S57sgcc); fields.put(S57field.DSID, S57sg2d); fields.put(S57field.DSID, S57sg3d); fields.put(S57field.DSID, S57arcc); 129 fields.put(S57field.DSID, S57ar2d); fields.put(S57field.DSID, S57el2d); fields.put(S57field.DSID, S57ct2d); 123 fields.put(S57field.I8RI, S57i8ri); 124 fields.put(S57field.DSID, S57dsid); fields.put(S57field.DSSI, S57dssi); fields.put(S57field.DSPM, S57dspm); fields.put(S57field.DSPR, S57dspr); 125 fields.put(S57field.DSRC, S57dsrc); fields.put(S57field.DSHT, S57dsht); fields.put(S57field.DSAC, S57dsac); fields.put(S57field.CATD, S57catd); 126 fields.put(S57field.CATX, S57catx); fields.put(S57field.DDDF, S57dddf); fields.put(S57field.DDDR, S57dddr); fields.put(S57field.DDDI, S57dddi); 127 fields.put(S57field.DDOM, S57ddom); fields.put(S57field.DDRF, S57ddrf); fields.put(S57field.DDSI, S57ddsi); fields.put(S57field.DDSC, S57ddsc); 128 fields.put(S57field.FRID, S57frid); fields.put(S57field.FOID, S57foid); fields.put(S57field.ATTF, S57attf); fields.put(S57field.NATF, S57natf); 129 fields.put(S57field.FFPC, S57ffpc); fields.put(S57field.FFPT, S57ffpt); fields.put(S57field.FFPC, S57fspc); fields.put(S57field.FSPT, S57fspt); 130 fields.put(S57field.VRID, S57vrid); fields.put(S57field.ATTV, S57attv); fields.put(S57field.VRPC, S57vrpc); fields.put(S57field.VRPT, S57vrpt); 131 fields.put(S57field.SGCC, S57sgcc); fields.put(S57field.SG2D, S57sg2d); fields.put(S57field.SG3D, S57sg3d); fields.put(S57field.ARCC, S57arcc); 132 fields.put(S57field.AR2D, S57ar2d); fields.put(S57field.EL2D, S57el2d); fields.put(S57field.CT2D, S57ct2d); 133 } 134 135 private static byte[] buffer; 136 private static int offset; 137 private static int maxoff; 138 private static int index; 139 private static S57field field; 140 141 public static void setField(byte[] buf, int off, S57field fld, int len) { 142 buffer = buf; 143 offset = off; 144 maxoff = off + len - 1; 145 field = fld; 146 index = 0; 147 } 148 149 public static boolean more() { 150 return (offset < maxoff); 151 } 152 153 public static Object getSubf(byte[] buf, int off, S57field fld, S57subf subf) { 154 buffer = buf; 155 offset = off; 156 index = 0; 157 return getSubf(fld, subf); 158 } 159 160 public static Object getSubf(S57field fld, S57subf subf) { 161 field = fld; 162 index = 0; 163 return getSubf(subf); 164 } 165 166 public static Object getSubf(S57subf subf) { 167 ArrayList<S57subf> subs = fields.get(field); 168 if (index == subs.size()) 169 index = 0; 170 while (index < subs.size()) { 171 S57subf sub = subs.get(index++); 172 S57conv conv = convs.get(sub); 173 if (sub == subf) { 174 if (conv.bin == 0) { 175 if (conv.asc == 0) { 176 String str = ""; 177 while (buffer[offset] != 0x1f) { 178 str += buffer[offset++]; 179 } 180 offset += (conv.bin != 0) ? Math.abs(conv.bin) : conv.asc; 181 return str; 182 } else 183 return new String(buffer, offset, conv.asc); 184 } else { 185 int i = Math.abs(conv.bin); 186 long val = buffer[offset + --i]; 187 if (conv.bin > 0) 188 val &= 0xff; 189 while (i > 0) { 190 val = (val << 8) + (buffer[offset + --i] & 0xff); 191 } 192 offset += (conv.bin != 0) ? Math.abs(conv.bin) : conv.asc; 193 return val; 194 } 195 } else { 196 offset += (conv.bin != 0) ? Math.abs(conv.bin) : conv.asc; 197 } 198 } 199 return null; 130 200 } 131 201 -
applications/editors/josm/plugins/smed2/src/s57/S57map.java
r30157 r30183 13 13 14 14 import s57.S57att; 15 import s57.S57val.AttVal;16 15 import s57.S57att.*; 17 16 import s57.S57obj; … … 25 24 ANON, // Edge inner nodes 26 25 ISOL, // Node not part of Edge 27 CONN // Edge first and last nodes 26 CONN, // Edge first and last nodes 27 DPTH // Sounding nodes 28 28 } 29 29 … … 50 50 } 51 51 52 public class Dnode extends Snode { // All depth soundings 53 public double val; // Sounding value 54 55 public Dnode() { 56 flg = Nflag.DPTH; 57 lat = 0; 58 lon = 0; 59 val = 0; 60 } 61 public Dnode(double ilat, double ilon, double ival) { 62 flg = Nflag.DPTH; 63 lat = ilat; 64 lon = ilon; 65 val = ival; 66 } 67 } 68 52 69 public class Edge { // A polyline segment 53 70 public long first; // First CONN node … … 157 174 public class Feature { 158 175 public Fflag flag; 159 public long refs;176 public long id; 160 177 public Obj type; 161 178 public AttMap atts; … … 167 184 Feature() { 168 185 flag = Fflag.UNKN; 169 refs= 0;186 id = 0; 170 187 type = Obj.UNKOBJ; 171 188 atts = new AttMap(); … … 287 304 nodes.put(id, new Snode(Math.toRadians(lat), Math.toRadians(lon))); 288 305 feature = new Feature(); 289 feature. refs= id;306 feature.id = id; 290 307 feature.flag = Fflag.POINT; 291 308 edge = null; 292 309 } 293 310 311 public void addNode(long id, double lat, double lon, double depth) { 312 nodes.put(id, new Dnode(Math.toRadians(lat), Math.toRadians(lon), depth)); 313 feature = new Feature(); 314 feature.id = id; 315 feature.flag = Fflag.POINT; 316 edge = null; 317 } 318 294 319 public void addEdge(long id) { 295 320 feature = new Feature(); 296 feature. refs= id;321 feature.id = id; 297 322 feature.flag = Fflag.LINE; 298 323 edge = new Edge(); … … 312 337 public void addArea(long id) { 313 338 feature = new Feature(); 314 feature. refs= id;339 feature.id = id; 315 340 feature.flag = Fflag.AREA; 316 341 outers = new ArrayList<Long>(); … … 505 530 switch (feature.flag) { 506 531 case POINT: 507 return nodes.get(feature. refs);532 return nodes.get(feature.id); 508 533 case LINE: 509 Edge edge = edges.get(feature. refs);534 Edge edge = edges.get(feature.id); 510 535 EdgeIterator eit = new EdgeIterator(edge, true); 511 536 while (eit.hasNext()) { … … 542 567 return new Snode(llat + ((lat - llat) * harc / sarc), llon + ((lon - llon) * harc / sarc)); 543 568 case AREA: 544 Bound bound = areas.get(feature. refs).get(0);569 Bound bound = areas.get(feature.id).get(0); 545 570 BoundIterator bit = new BoundIterator(bound); 546 571 while (bit.hasNext()) {
Note:
See TracChangeset
for help on using the changeset viewer.