Changeset 31722 in osm for applications/editors/josm/plugins/seachart/src/s57/S57enc.java
- Timestamp:
- 2015-10-29T23:01:53+01:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/seachart/src/s57/S57enc.java
r31704 r31722 9 9 10 10 package s57; 11 12 import java.io.UnsupportedEncodingException; 13 import java.util.HashMap; 14 import java.util.Map; 15 16 import s57.S57dat.*; 17 import s57.S57map.*; 11 18 12 19 public class S57enc { // S57 ENC file generation … … 120 127 '1', 0x1f, '0', 0x1f, 121 128 //*** 2035 122 '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', // Date x2 129 '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', // Date x2 (from system) 123 130 '0', '3', '.', '1', 0x14, 0x1f, 0x1f, 0x01, 0x26, 0x0f, 'G', 'e', 'n', 'e', 'r', 'a', 't', 'e', 'd', ' ', 'b', 'y', ' ', 124 131 'O', 'p', 'e', 'n', 'S', 'e', 'a', 'M', 'a', 'p', '.', 'o', 'r', 'g', 0x1f, 0x1e, … … 126 133 0x02, 0x01, 0x02, 127 134 //*** 2093 128 0x0 2, 0x00, 0x00, 0x00, // # of meta records135 0x00, 0x00, 0x00, 0x00, // # of meta records (from metas counter) 129 136 0x00, 0x00, 0x00, 0x00, 130 0x00, 0x00, 0x00, 0x00, // # of geo records 137 0x00, 0x00, 0x00, 0x00, // # of geo records (from geos counter) 131 138 0x00, 0x00, 0x00, 0x00, 132 0x00, 0x00, 0x00, 0x00, // # of isolated node records 133 0x00, 0x00, 0x00, 0x00, // # of connected node records 134 0x00, 0x00, 0x00, 0x00, // # of edge records 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) 135 142 0x00, 0x00, 0x00, 0x00, 0x1e, 136 143 … … 143 150 0x14, 0x01, 0x00, 0x00, 0x00, 0x02, 0x17, 0x17, 144 151 //*** 2176 145 0x00, 0x00, 0x00, 0x00, // Scale 146 0x01, // Depth units 147 0x01, // Height units 148 0x01, 0x01, (byte)0x80, (byte)0x96, (byte)0x98, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x1f, 0x1e 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 149 159 }; 150 160 151 private static byte[] leader = {'0', '0', '0', '0', '0', ' ', 'D', ' ', ' ', ' ', ' ', ' ', '0', '0', '0', '0', '0', ' ', ' ', ' ', '0', '0', '0', '0'}; 161 static final double COMF=10000000; 162 static final double SOMF=10; 163 152 164 static int idx; 153 154 public static int encodeChart(S57map map, byte[] buf) throws IndexOutOfBoundsException { 165 static int recs; 166 static int isols; 167 static int conns; 168 static int metas; 169 static int geos; 170 static int rcid; 171 172 public static int encodeChart(S57map map, HashMap<String, String> meta, byte[] buf) throws IndexOutOfBoundsException, UnsupportedEncodingException { 173 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 */ 155 184 156 int idx = leader.length; 185 recs = rcid = 3; 186 isols = conns = metas = geos = 0; 157 187 for (idx = 0; idx < header.length; idx++) { 158 188 buf[idx] = header[idx]; 159 189 } 190 // byte[] file = S57dat.encSubf(S57subf.FILE, meta.get("FILE")); 191 192 for (Map.Entry<Long, S57map.Snode> entry : map.nodes.entrySet()) { 193 S57map.Snode node = entry.getValue(); 194 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)); 196 System.arraycopy(record, 0, buf, idx, record.length); 197 idx += record.length; 198 isols++; 199 recs++; 200 } 201 } 160 202 161 203 return idx; … … 164 206 public static int encodeCatalogue(S57map map, byte[] buf) throws IndexOutOfBoundsException { 165 207 166 167 int idx = leader.length;168 for (int i = 0; i < idx; i++) {169 buf[i] = leader[i];170 }171 172 208 return idx; 173 209 }
Note:
See TracChangeset
for help on using the changeset viewer.