Changeset 31704 in osm for applications/editors/josm/plugins/seachart/src/s57/S57dec.java
- Timestamp:
- 2015-10-26T16:40:54+01:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/seachart/src/s57/S57dec.java
r31660 r31704 18 18 public class S57dec { // S57 ENC file input & map conversion 19 19 20 public static MapBounds decodeFile(FileInputStream in, S57map map) throws IOException {20 public static void decodeChart(FileInputStream in, S57map map) throws IOException { 21 21 S57dat.rnum = 0; 22 22 byte[] leader = new byte[24]; … … 36 36 S57map.Pflag pflag = S57map.Pflag.NOSP; 37 37 long objl = 0; 38 MapBounds bounds = map.new MapBounds();39 38 40 39 while (in.read(leader) == 24) { … … 59 58 pos = Integer.parseInt(new String(record, idx+mapts+mapfl, mapfp)); 60 59 if (!ddr) { 61 switch ( S57dat.enumField(tag)) {62 case I8RI:63 int i8rn = ((Long) S57dat. getSubf(record, fields + pos, S57field.I8RI, S57subf.I8RN)).intValue();60 switch (tag.toString()) { 61 case "0001": 62 int i8rn = ((Long) S57dat.decSubf(record, fields + pos, S57field.I8RI, S57subf.I8RN)).intValue(); 64 63 if (i8rn != ++S57dat.rnum) { 65 64 System.err.println("Out of order record ID"); … … 68 67 } 69 68 break; 70 case DSSI:71 S57dat. getSubf(record, fields + pos, S57field.DSSI, S57subf.AALL);72 S57dat. getSubf(S57subf.NALL);73 break; 74 case DSPM:75 comf = (double) (Long) S57dat. getSubf(record, fields + pos, S57field.DSPM, S57subf.COMF);76 somf = (double) (Long) S57dat. getSubf(S57subf.SOMF);77 break; 78 case FRID:69 case "DSSI": 70 S57dat.decSubf(record, fields + pos, S57field.DSSI, S57subf.AALL); 71 S57dat.decSubf(S57subf.NALL); 72 break; 73 case "DSPM": 74 comf = (double) (Long) S57dat.decSubf(record, fields + pos, S57field.DSPM, S57subf.COMF); 75 somf = (double) (Long) S57dat.decSubf(S57subf.SOMF); 76 break; 77 case "FRID": 79 78 inFeature = true; 80 switch (((Long)S57dat. getSubf(record, fields + pos, S57field.FRID, S57subf.PRIM)).intValue()) {79 switch (((Long)S57dat.decSubf(record, fields + pos, S57field.FRID, S57subf.PRIM)).intValue()) { 81 80 case 1: 82 81 pflag = S57map.Pflag.POINT; … … 91 90 pflag = S57map.Pflag.NOSP; 92 91 } 93 objl = (Long)S57dat. getSubf(S57subf.OBJL);94 break; 95 case FOID:96 name = (Long) S57dat. getSubf(record, fields + pos, S57field.FOID, S57subf.LNAM);92 objl = (Long)S57dat.decSubf(S57subf.OBJL); 93 break; 94 case "FOID": 95 name = (Long) S57dat.decSubf(record, fields + pos, S57field.FOID, S57subf.LNAM); 97 96 map.newFeature(name, pflag, objl); 98 97 break; 99 case ATTF:98 case "ATTF": 100 99 S57dat.setField(record, fields + pos, S57field.ATTF, len); 101 100 do { 102 long attl = (Long) S57dat. getSubf(S57subf.ATTL);103 String atvl = ((String) S57dat. getSubf(S57subf.ATVL)).trim();101 long attl = (Long) S57dat.decSubf(S57subf.ATTL); 102 String atvl = ((String) S57dat.decSubf(S57subf.ATVL)).trim(); 104 103 if (!atvl.isEmpty()) { 105 104 map.newAtt(attl, atvl); … … 107 106 } while (S57dat.more()); 108 107 break; 109 case FFPT:108 case "FFPT": 110 109 S57dat.setField(record, fields + pos, S57field.FFPT, len); 111 110 do { 112 name = (Long) S57dat. getSubf(S57subf.LNAM);113 int rind = ((Long) S57dat. getSubf(S57subf.RIND)).intValue();114 S57dat. getSubf(S57subf.COMT);111 name = (Long) S57dat.decSubf(S57subf.LNAM); 112 int rind = ((Long) S57dat.decSubf(S57subf.RIND)).intValue(); 113 S57dat.decSubf(S57subf.COMT); 115 114 map.newObj(name, rind); 116 115 } while (S57dat.more()); 117 116 break; 118 case FSPT:117 case "FSPT": 119 118 S57dat.setField(record, fields + pos, S57field.FSPT, len); 120 119 do { 121 name = (Long) S57dat. getSubf(S57subf.NAME) << 16;122 map.newPrim(name, (Long) S57dat. getSubf(S57subf.ORNT), (Long) S57dat.getSubf(S57subf.USAG));123 S57dat. getSubf(S57subf.MASK);124 } while (S57dat.more()); 125 break; 126 case VRID:120 name = (Long) S57dat.decSubf(S57subf.NAME) << 16; 121 map.newPrim(name, (Long) S57dat.decSubf(S57subf.ORNT), (Long) S57dat.decSubf(S57subf.USAG)); 122 S57dat.decSubf(S57subf.MASK); 123 } while (S57dat.more()); 124 break; 125 case "VRID": 127 126 inFeature = false; 128 name = (long) (Long)S57dat. getSubf(record, fields + pos, S57field.VRID, S57subf.RCNM);127 name = (long) (Long)S57dat.decSubf(record, fields + pos, S57field.VRID, S57subf.RCNM); 129 128 switch ((int) name) { 130 129 case 110: … … 139 138 } 140 139 name <<= 32; 141 name += (Long) S57dat. getSubf(S57subf.RCID);140 name += (Long) S57dat.decSubf(S57subf.RCID); 142 141 name <<= 16; 143 142 if (nflag == Nflag.ANON) { … … 145 144 } 146 145 break; 147 case VRPT:146 case "VRPT": 148 147 S57dat.setField(record, fields + pos, S57field.VRPT, len); 149 148 do { 150 long conn = (Long) S57dat. getSubf(S57subf.NAME) << 16;151 int topi = ((Long) S57dat. getSubf(S57subf.TOPI)).intValue();149 long conn = (Long) S57dat.decSubf(S57subf.NAME) << 16; 150 int topi = ((Long) S57dat.decSubf(S57subf.TOPI)).intValue(); 152 151 map.addConn(conn, topi); 153 S57dat. getSubf(S57subf.MASK);154 } while (S57dat.more()); 155 break; 156 case SG2D:152 S57dat.decSubf(S57subf.MASK); 153 } while (S57dat.more()); 154 break; 155 case "SG2D": 157 156 S57dat.setField(record, fields + pos, S57field.SG2D, len); 158 157 do { 159 double lat = (double) ((Long) S57dat. getSubf(S57subf.YCOO)) / comf;160 double lon = (double) ((Long) S57dat. getSubf(S57subf.XCOO)) / comf;158 double lat = (double) ((Long) S57dat.decSubf(S57subf.YCOO)) / comf; 159 double lon = (double) ((Long) S57dat.decSubf(S57subf.XCOO)) / comf; 161 160 if (nflag == Nflag.ANON) { 162 161 map.newNode(++name, lat, lon, nflag); … … 164 163 map.newNode(name, lat, lon, nflag); 165 164 } 166 if (lat < bounds.minlat) 167 bounds.minlat = lat; 168 if (lat > bounds.maxlat) 169 bounds.maxlat = lat; 170 if (lon < bounds.minlon) 171 bounds.minlon = lon; 172 if (lon > bounds.maxlon) 173 bounds.maxlon = lon; 174 } while (S57dat.more()); 175 break; 176 case SG3D: 165 lat = Math.toRadians(lat); 166 lon = Math.toRadians(lon); 167 if (lat < map.bounds.minlat) 168 map.bounds.minlat = lat; 169 if (lat > map.bounds.maxlat) 170 map.bounds.maxlat = lat; 171 if (lon < map.bounds.minlon) 172 map.bounds.minlon = lon; 173 if (lon > map.bounds.maxlon) 174 map.bounds.maxlon = lon; 175 } while (S57dat.more()); 176 break; 177 case "SG3D": 177 178 S57dat.setField(record, fields + pos, S57field.SG3D, len); 178 179 do { 179 double lat = (double) ((Long) S57dat. getSubf(S57subf.YCOO)) / comf;180 double lon = (double) ((Long) S57dat. getSubf(S57subf.XCOO)) / comf;181 double depth = (double) ((Long) S57dat. getSubf(S57subf.VE3D)) / somf;180 double lat = (double) ((Long) S57dat.decSubf(S57subf.YCOO)) / comf; 181 double lon = (double) ((Long) S57dat.decSubf(S57subf.XCOO)) / comf; 182 double depth = (double) ((Long) S57dat.decSubf(S57subf.VE3D)) / somf; 182 183 map.newNode(name++, lat, lon, depth); 183 if (lat < bounds.minlat) 184 bounds.minlat = lat; 185 if (lat > bounds.maxlat) 186 bounds.maxlat = lat; 187 if (lon < bounds.minlon) 188 bounds.minlon = lon; 189 if (lon > bounds.maxlon) 190 bounds.maxlon = lon; 184 lat = Math.toRadians(lat); 185 lon = Math.toRadians(lon); 186 if (lat < map.bounds.minlat) 187 map.bounds.minlat = lat; 188 if (lat > map.bounds.maxlat) 189 map.bounds.maxlat = lat; 190 if (lon < map.bounds.minlon) 191 map.bounds.minlon = lon; 192 if (lon > map.bounds.maxlon) 193 map.bounds.maxlon = lon; 191 194 } while (S57dat.more()); 192 195 break; … … 204 207 in.close(); 205 208 206 return bounds;209 return; 207 210 } 208 211
Note:
See TracChangeset
for help on using the changeset viewer.