Changeset 30189 in osm for applications
- Timestamp:
- 2014-01-07T10:14:08+01:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/smed2/js57toosm/src/js57toosm/Js57toosm.java
r30188 r30189 19 19 public class Js57toosm { 20 20 21 public static int rnum = 0;22 23 21 public static void main(String[] args) throws IOException { 24 22 25 23 FileInputStream in = new FileInputStream("/Users/mherring/boatsw/oseam/josm/plugins/smed2/js57toosm/tst.000"); 26 24 PrintStream out = System.out; 25 26 S57dat.rnum = 0; 27 27 28 28 byte[] leader = new byte[24]; … … 58 58 pos = Integer.parseInt(new String(record, idx+mapts+mapfl, mapfp)); 59 59 if (!ddr) { 60 if ("0001".equals(tag)) { 61 int i8rn = ((Long)S57dat.getSubf(record, fields+pos, S57field.I8RI, S57subf.I8RN)).intValue(); 62 if (i8rn != ++rnum) { 63 out.println("Out of order record ID"); 64 in.close(); 65 System.exit(-1); 66 } 67 } else if ("DSID".equals(tag)) { 68 } else if ("DSSI".equals(tag)) { 69 } else if ("DSPM".equals(tag)) { 70 comf = (double)(Long)S57dat.getSubf(record, fields+pos, S57field.DSPM, S57subf.COMF); 71 somf = (double)(Long)S57dat.getSubf(S57subf.SOMF); 72 } else if ("FRID".equals(tag)) { 73 } else if ("FOID".equals(tag)) { 74 } else if ("ATTF".equals(tag)) { 75 } else if ("NATF".equals(tag)) { 76 } else if ("FFPC".equals(tag)) { 77 } else if ("FFPT".equals(tag)) { 78 } else if ("FSPC".equals(tag)) { 79 } else if ("FSPT".equals(tag)) { 80 } else if ("VRID".equals(tag)) { 81 name = (Long)S57dat.getSubf(record, fields+pos, S57field.VRID, S57subf.RCNM); 82 switch ((int)name) { 83 case 110: 84 nflag = Nflag.ISOL; 85 break; 86 case 120: 87 nflag = Nflag.CONN; 88 break; 89 default: 90 nflag = Nflag.ANON; 91 break; 92 } 93 name <<= 32; 94 name += (Long)S57dat.getSubf(record, fields+pos, S57field.VRID, S57subf.RCID); 95 name <<= 16; 96 if (nflag == Nflag.ANON) { 97 map.newEdge(name); 98 } 99 } else if ("ATTV".equals(tag)) { 100 } else if ("VRPC".equals(tag)) { 101 } else if ("VRPT".equals(tag)) { 102 name = (Long)S57dat.getSubf(record, fields+pos, S57field.VRPT, S57subf.NAME) << 16; 103 int topi = ((Long)S57dat.getSubf(S57subf.TOPI)).intValue(); 104 map.addConn(name, topi); 105 name = (Long)S57dat.getSubf(S57subf.NAME) << 16; 106 topi = ((Long)S57dat.getSubf(S57subf.TOPI)).intValue(); 107 map.addConn(name, topi); 108 } else if ("SGCC".equals(tag)) { 109 } else if ("SG2D".equals(tag)) { 110 S57dat.setField(record, fields + pos, S57field.SG2D, len); 111 while (S57dat.more()) { 112 double lat = (double) ((Long) S57dat.getSubf(S57subf.YCOO)) / comf; 113 double lon = (double) ((Long) S57dat.getSubf(S57subf.XCOO)) / comf; 114 if (nflag == Nflag.ANON) { 115 map.newNode(++name, lat, lon, nflag); 116 } else { 117 map.newNode(name, lat, lon, nflag); 118 } 119 if (lat < minlat) minlat = lat; 120 if (lat > maxlat) maxlat = lat; 121 if (lon < minlon) minlon = lon; 122 if (lon > maxlon) maxlon = lon; 123 } 124 } else if ("SG3D".equals(tag)) { 125 S57dat.setField(record, fields + pos, S57field.SG3D, len); 126 while (S57dat.more()) { 127 double lat = (double) ((Long) S57dat.getSubf(S57subf.YCOO)) / comf; 128 double lon = (double) ((Long) S57dat.getSubf(S57subf.XCOO)) / comf; 129 double depth = (double) ((Long) S57dat.getSubf(S57subf.VE3D)) / somf; 130 map.newNode(name++, lat, lon, depth); 131 if (lat < minlat) minlat = lat; 132 if (lat > maxlat) maxlat = lat; 133 if (lon < minlon) minlon = lon; 134 if (lon > maxlon) maxlon = lon; 135 } 136 } 60 switch (tag) { 61 case "0001": 62 int i8rn = ((Long) S57dat.getSubf(record, fields + pos, S57field.I8RI, S57subf.I8RN)).intValue(); 63 if (i8rn != ++S57dat.rnum) { 64 out.println("Out of order record ID"); 65 in.close(); 66 System.exit(-1); 67 } 68 break; 69 case "DSID": 70 break; 71 case "DSSI": 72 break; 73 case "DSPM": 74 comf = (double) (Long) S57dat.getSubf(record, fields + pos, S57field.DSPM, S57subf.COMF); 75 somf = (double) (Long) S57dat.getSubf(S57subf.SOMF); 76 break; 77 case "FRID": 78 break; 79 case "FOID": 80 break; 81 case "ATTF": 82 break; 83 case "NATF": 84 break; 85 case "FFPC": 86 break; 87 case "FFPT": 88 break; 89 case "FSPC": 90 break; 91 case "FSPT": 92 break; 93 case "VRID": 94 name = (Long) S57dat.getSubf(record, fields + pos, S57field.VRID, S57subf.RCNM); 95 switch ((int) name) { 96 case 110: 97 nflag = Nflag.ISOL; 98 break; 99 case 120: 100 nflag = Nflag.CONN; 101 break; 102 default: 103 nflag = Nflag.ANON; 104 break; 105 } 106 name <<= 32; 107 name += (Long) S57dat.getSubf(record, fields + pos, S57field.VRID, S57subf.RCID); 108 name <<= 16; 109 if (nflag == Nflag.ANON) { 110 map.newEdge(name); 111 } 112 break; 113 case "ATTV": 114 break; 115 case "VRPC": 116 break; 117 case "VRPT": 118 name = (Long) S57dat.getSubf(record, fields + pos, S57field.VRPT, S57subf.NAME) << 16; 119 int topi = ((Long) S57dat.getSubf(S57subf.TOPI)).intValue(); 120 map.addConn(name, topi); 121 name = (Long) S57dat.getSubf(S57subf.NAME) << 16; 122 topi = ((Long) S57dat.getSubf(S57subf.TOPI)).intValue(); 123 map.addConn(name, topi); 124 break; 125 case "SGCC": 126 break; 127 case "SG2D": 128 S57dat.setField(record, fields + pos, S57field.SG2D, len); 129 while (S57dat.more()) { 130 double lat = (double) ((Long) S57dat.getSubf(S57subf.YCOO)) / comf; 131 double lon = (double) ((Long) S57dat.getSubf(S57subf.XCOO)) / comf; 132 if (nflag == Nflag.ANON) { 133 map.newNode(++name, lat, lon, nflag); 134 } else { 135 map.newNode(name, lat, lon, nflag); 136 } 137 if (lat < minlat) 138 minlat = lat; 139 if (lat > maxlat) 140 maxlat = lat; 141 if (lon < minlon) 142 minlon = lon; 143 if (lon > maxlon) 144 maxlon = lon; 145 } 146 break; 147 case "SG3D": 148 S57dat.setField(record, fields + pos, S57field.SG3D, len); 149 while (S57dat.more()) { 150 double lat = (double) ((Long) S57dat.getSubf(S57subf.YCOO)) / comf; 151 double lon = (double) ((Long) S57dat.getSubf(S57subf.XCOO)) / comf; 152 double depth = (double) ((Long) S57dat.getSubf(S57subf.VE3D)) / somf; 153 map.newNode(name++, lat, lon, depth); 154 if (lat < minlat) 155 minlat = lat; 156 if (lat > maxlat) 157 maxlat = lat; 158 if (lon < minlon) 159 minlon = lon; 160 if (lon > maxlon) 161 maxlon = lon; 162 } 163 break; 164 } 137 165 } 138 166 }
Note:
See TracChangeset
for help on using the changeset viewer.