Changeset 31063 in osm for applications/editors/josm/plugins/seachart/src/s57
- Timestamp:
- 2015-03-27T09:22:05+01:00 (10 years ago)
- Location:
- applications/editors/josm/plugins/seachart/src/s57
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/seachart/src/s57/S57dat.java
r30894 r31063 11 11 12 12 import java.io.UnsupportedEncodingException; 13 import java.util.ArrayList; 14 import java.util.Arrays; 15 import java.util.EnumMap; 13 import java.util.*; 16 14 17 15 public class S57dat { -
applications/editors/josm/plugins/seachart/src/s57/S57dec.java
r30894 r31063 22 22 byte[] leader = new byte[24]; 23 23 boolean ddr = false; 24 int length ;25 int fields ;24 int length = 0; 25 int fields = 0;; 26 26 int mapfl, mapfp, mapts, entry; 27 27 String tag; … … 39 39 40 40 while (in.read(leader) == 24) { 41 try { 41 42 length = Integer.parseInt(new String(leader, 0, 5)) - 24; 42 43 ddr = (leader[6] == 'L'); 43 44 fields = Integer.parseInt(new String(leader, 12, 5)) - 24; 45 } catch (Exception e) { 46 System.err.println("Invalid file format - Encrypted/compressed ENC file?"); 47 System.exit(-1); 48 } 44 49 mapfl = leader[20] - '0'; 45 50 mapfp = leader[21] - '0'; -
applications/editors/josm/plugins/seachart/src/s57/S57map.java
r31044 r31063 524 524 } 525 525 if (osm.att != Att.UNKATT) { 526 atts.put(osm.att, new AttVal<>(osm. att, osm.conv, osm.val));526 atts.put(osm.att, new AttVal<>(osm.conv, osm.val)); 527 527 } 528 528 } else { … … 536 536 objs.put(0, atts); 537 537 if (osm.att != Att.UNKATT) { 538 atts.put(osm.att, new AttVal<>(osm. att, osm.conv, osm.val));538 atts.put(osm.att, new AttVal<>(osm.conv, osm.val)); 539 539 } 540 540 index.put(++xref, base); -
applications/editors/josm/plugins/seachart/src/s57/S57val.java
r31027 r31063 35 35 36 36 public static class AttVal<V> { 37 public Att att;37 // public Att att; 38 38 public Conv conv; 39 39 public V val; 40 AttVal(Att a, Conv c, V v) { 41 att = a; conv = c; val = v; 40 // AttVal(Att a, Conv c, V v) { 41 // att = a; conv = c; val = v; 42 // } 43 AttVal(Conv c, V v) { 44 conv = c; val = v; 42 45 } 43 46 } … … 1129 1132 case A: 1130 1133 case S: 1131 return new AttVal<String>( att,conv, val);1134 return new AttVal<String>(conv, val); 1132 1135 case E: 1133 1136 ArrayList<Enum<?>> list = new ArrayList<Enum<?>>(); 1134 1137 list.add(s57Enum(val, att)); 1135 return new AttVal<ArrayList<?>>( att,Conv.E, list);1138 return new AttVal<ArrayList<?>>(Conv.E, list); 1136 1139 case L: 1137 1140 list = new ArrayList<Enum<?>>(); … … 1139 1142 list.add(s57Enum(item, att)); 1140 1143 } 1141 return new AttVal<ArrayList<?>>( att,Conv.L, list);1144 return new AttVal<ArrayList<?>>(Conv.L, list); 1142 1145 case I: 1143 1146 try { 1144 return new AttVal<Long>( att,Conv.I, Long.parseLong(val));1147 return new AttVal<Long>(Conv.I, Long.parseLong(val)); 1145 1148 } catch (Exception e) { 1146 1149 break; … … 1148 1151 case F: 1149 1152 try { 1150 return new AttVal<Double>( att,Conv.F, Double.parseDouble(val));1153 return new AttVal<Double>(Conv.F, Double.parseDouble(val)); 1151 1154 } catch (Exception e) { 1152 1155 break; … … 1165 1168 } 1166 1169 1167 1168 public static String stringValue(AttVal<?> attval) { // Convert SCM value object to OSM attribute value string 1170 public static String stringValue(AttVal<?> attval, Att att) { // Convert SCM value object to OSM attribute value string 1169 1171 if (attval != null) { 1170 1172 switch (attval.conv) { … … 1173 1175 return (String) attval.val; 1174 1176 case E: 1175 EnumMap<?, ?> map = keys.get(att val.att).map;1177 EnumMap<?, ?> map = keys.get(att).map; 1176 1178 return ((S57enum) map.get(((ArrayList<?>) attval.val).get(0))).val; 1177 1179 case L: 1178 1180 String str = ""; 1179 map = keys.get(att val.att).map;1181 map = keys.get(att).map; 1180 1182 for (Object item : (ArrayList<?>) attval.val) { 1181 1183 if (!str.isEmpty()) … … 1211 1213 case A: 1212 1214 case S: 1213 return new AttVal<String>( att,Conv.S, val);1215 return new AttVal<String>(Conv.S, val); 1214 1216 case E: 1215 1217 ArrayList<Enum<?>> list = new ArrayList<Enum<?>>(); 1216 1218 list.add(osmEnum(val, att)); 1217 return new AttVal<ArrayList<?>>( att,Conv.E, list);1219 return new AttVal<ArrayList<?>>(Conv.E, list); 1218 1220 case L: 1219 1221 list = new ArrayList<Enum<?>>(); … … 1221 1223 list.add(osmEnum(item, att)); 1222 1224 } 1223 return new AttVal<ArrayList<?>>( att,Conv.L, list);1225 return new AttVal<ArrayList<?>>(Conv.L, list); 1224 1226 case I: 1225 1227 try { 1226 return new AttVal<Long>( att,Conv.I, Long.parseLong(val));1228 return new AttVal<Long>(Conv.I, Long.parseLong(val)); 1227 1229 } catch (Exception e) { 1228 1230 break; … … 1230 1232 case F: 1231 1233 try { 1232 return new AttVal<Double>( att,Conv.F, Double.parseDouble(val));1234 return new AttVal<Double>(Conv.F, Double.parseDouble(val)); 1233 1235 } catch (Exception e) { 1234 1236 break; 1235 1237 } 1236 1238 } 1237 return new AttVal<Object>( att,keys.get(att).conv, null);1239 return new AttVal<Object>(keys.get(att).conv, null); 1238 1240 } 1239 1241
Note:
See TracChangeset
for help on using the changeset viewer.