Changeset 31735 in osm for applications/editors/josm/plugins/seachart/josmtos57/src
- Timestamp:
- 2015-11-08T09:49:14+01:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/seachart/josmtos57/src/josmtos57/Josmtos57.java
r31731 r31735 11 11 12 12 import java.io.*; 13 import java.util.HashMap; 14 import java.util.Scanner; 13 import java.util.*; 15 14 import java.util.zip.CRC32; 16 15 16 import s57.S57dat; 17 17 import s57.S57enc; 18 18 import s57.S57map; 19 19 import s57.S57osm; 20 import s57.S57dat.*; 20 21 21 22 public class Josmtos57 { … … 37 38 'I', 'L', '!', 'V', 'O', 'L', 'M', '!', 'I', 'M', 'P', 'L', '!', 'S', 'L', 'A', 'T', '!', 'W', 'L', 'O', 'N', '!', 'N', 'L', 'A', 'T', '!', 'E', 'L', 'O', 'N', 38 39 '!', 'C', 'R', 'C', 'S', '!', 'C', 'O', 'M', 'T', 0x1f, '(', 'A', '(', '2', ')', ',', 'I', '(', '1', '0', ')', ',', '3', 'A', ',', 'A', '(', '3', ')', ',', '4', 39 'R', ',', '2', 'A', ')', 0x1e 40 }; 41 42 static byte[] entry = { 43 //*** 0 44 '0', '0', '1', '0', '1', ' ', 'D', ' ', ' ', ' ', ' ', ' ', '0', '0', '0', '5', '3', ' ', ' ', ' ', '5', '5', '0', '4', // Leader 45 '0', '0', '0', '1', '0', '0', '0', '0', '6', '0', '0', '0', '0', '0', 'C', 'A', 'T', 'D', '0', '0', '0', '4', '2', '0', '0', '0', '0', '6', 0x1e, // Directory 46 '0', '0', '0', '0', '0', 0x1e, 47 //*** 48 'C', 'D', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', // Record name+number 49 //*** 50 'C', 'A', 'T', 'A', 'L', 'O', 'G', '.', '0', '3', '1', 0x1f, // File name 51 0x1f, // File long name 52 'V', '0', '1', 'X', '0', '1', 0x1f, // Volume 53 'A', 'S', 'C', // Implementation 54 0x1f, 0x1f, 0x1f, 0x1f, // minlat, minlon, maxlat, maxlon 55 0x1f, // CRC32 56 0x1f, 0x1e // Comment 40 'R', ',', '2', 'A', ')', 0x1e, 41 '0', '0', '1', '0', '1', ' ', 'D', ' ', ' ', ' ', ' ', ' ', '0', '0', '0', '5', '3', ' ', ' ', ' ', '5', '5', '0', '4', 42 '0', '0', '0', '1', '0', '0', '0', '0', '6', '0', '0', '0', '0', '0', 'C', 'A', 'T', 'D', '0', '0', '0', '4', '2', '0', '0', '0', '0', '6', 0x1e, 43 '0', '0', '0', '0', '0', 0x1e, 'C', 'D', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', 'C', 'A', 'T', 'A', 'L', 'O', 'G', '.', '0', '3', '1', 0x1f, 44 0x1f, 'V', '0', '1', 'X', '0', '1', 0x1f, 'A', 'S', 'C', 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1e 57 45 }; 58 46 … … 62 50 static byte[] buf; 63 51 static HashMap<String, String> meta; 52 static ArrayList<Fparams> fields; 53 static byte[] record; 64 54 65 55 public static void main(String[] args) throws IOException { 66 56 67 map = new S57map( true);57 map = new S57map(false); 68 58 int idx = 0; 69 59 … … 76 66 meta = new HashMap<String, String>(); 77 67 meta.put("FILE", args[3]); 78 // while (min.hasNext()) { 79 // String[] tokens = min.next().split("="); 80 // meta.put(tokens[0], tokens[1]); 81 // } 68 while (min.hasNext()) { 69 String[] tokens = min.next().split("="); 70 if (tokens.length >= 2) 71 meta.put(tokens[0], tokens[1].split("[ #]")[0]); 72 } 82 73 min.close(); 83 74 } catch (IOException e) { … … 118 109 out.close(); 119 110 111 buf = new byte[header.length]; 112 System.arraycopy(header, 0, buf, 0, header.length); 113 idx = header.length; 114 int recs = 2; 115 fields = new ArrayList<Fparams>(); 116 fields.add(new Fparams(S57field.CATD, new Object[]{ "CD", recs, args[3], "", "V01X01", "BIN", Math.toDegrees(map.bounds.minlat), 117 Math.toDegrees(map.bounds.minlon), Math.toDegrees(map.bounds.maxlat), Math.toDegrees(map.bounds.maxlon), String.format("%08X", crc.getValue()), "" })); 118 record = S57dat.encRecord(String.valueOf(recs++), fields); 119 buf = Arrays.copyOf(buf, (buf.length + record.length)); 120 System.arraycopy(record, 0, buf, idx, record.length); 121 idx += record.length; 122 120 123 try { 121 124 File file = new File(args[2] + "CATALOG.031"); 122 125 if (file.exists()) file.delete(); 123 126 out = new FileOutputStream(file, false); 127 out.write(buf, 0, idx); 124 128 } catch (IOException e) { 125 129 System.err.println("Catalogue file: " + e.getMessage());
Note:
See TracChangeset
for help on using the changeset viewer.