Changeset 31659 in osm for applications/editors/josm/plugins/seachart/js57toosm/src
- Timestamp:
- 2015-10-21T11:34:01+02:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/seachart/js57toosm/src/js57toosm/Js57toosm.java
r31598 r31659 30 30 static PrintStream out; 31 31 static S57map map; 32 static final ArrayList<Att> typatts = new ArrayList<Att>(); static { 33 typatts.add(Att.OBJNAM); typatts.add(Att.NOBJNM); typatts.add(Att.STATUS); typatts.add(Att.INFORM); typatts.add(Att.NINFOM); 34 typatts.add(Att.PEREND); typatts.add(Att.PERSTA); typatts.add(Att.CONDTN); typatts.add(Att.CONRAD); typatts.add(Att.CONVIS); 35 } 32 36 33 37 public static void main(String[] args) throws IOException { … … 39 43 System.exit(-1); 40 44 } 41 in = new FileInputStream(args[0]); 42 out = new PrintStream(args[2]); 45 try { 46 in = new FileInputStream(args[0]); 47 } catch (IOException e) { 48 System.err.println("Input file: " + e.getMessage()); 49 System.exit(-1); 50 } 51 try { 52 out = new PrintStream(args[2]); 53 } catch (IOException e) { 54 System.err.println("Output file: " + e.getMessage()); 55 in.close(); 56 System.exit(-1); 57 } 43 58 ArrayList<Obj> types = new ArrayList<Obj>(); 59 try { 44 60 Scanner tin = new Scanner(new FileInputStream(args[1])); 45 61 while (tin.hasNext()) { … … 49 65 } 50 66 tin.close(); 67 } catch (IOException e) { 68 System.err.println("Types file: " + e.getMessage()); 69 in.close(); 70 out.close(); 71 System.exit(-1); 72 } 51 73 52 74 map = new S57map(true); … … 72 94 if ((feature.type == Obj.SOUNDG) && (node.flg == S57map.Nflag.DPTH)) 73 95 out.format(" <tag k='seamark:sounding:depth' v='%.1f'/>%n", ((Dnode) node).val); 74 writeAtts(feature , type);96 writeAtts(feature); 75 97 out.format(" </node>%n"); 76 98 done.add(ref); … … 116 138 } 117 139 out.format(" <tag k='seamark:type' v='%s'/>%n", type); 118 writeAtts(feature , type);140 writeAtts(feature); 119 141 out.format(" </way>%n"); 120 142 } … … 161 183 } 162 184 out.format(" <tag k='seamark:type' v='%s'/>%n", type); 163 writeAtts(feature , type);185 writeAtts(feature); 164 186 out.format(" </relation>%n"); 165 187 } … … 172 194 } 173 195 174 static void writeAtts(Feature feature , String type) {196 static void writeAtts(Feature feature) { 175 197 for (Map.Entry<Att, AttVal<?>> item : feature.atts.entrySet()) { 176 198 String attstr = S57att.stringAttribute(item.getKey()); 177 199 String valstr = S57val.stringValue(item.getValue(), item.getKey()); 178 if (!attstr.isEmpty() && !valstr.isEmpty()) 179 out.format(" <tag k='seamark:%s:%s' v='%s'/>%n", type, attstr, StringEscapeUtils.escapeXml10(valstr)); 200 if (!attstr.isEmpty() && !valstr.isEmpty()) { 201 if (typatts.contains(item.getKey())) { 202 out.format(" <tag k='seamark:%s' v='%s'/>%n", attstr, StringEscapeUtils.escapeXml10(valstr)); 203 } else { 204 out.format(" <tag k='seamark:%s:%s' v='%s'/>%n", S57obj.stringType(feature.type), attstr, StringEscapeUtils.escapeXml10(valstr)); 205 } 206 } 180 207 } 181 208 for (Obj obj : feature.objs.keySet()) { 182 209 ObjTab tab = feature.objs.get(obj); 183 210 for (int ix : tab.keySet()) { 184 type = S57obj.stringType(obj);185 211 AttMap atts = tab.get(ix); 186 212 for (Map.Entry<Att, AttVal<?>> item : atts.entrySet()) { … … 189 215 if (!attstr.isEmpty() && !valstr.isEmpty()) { 190 216 if ((ix == 0) && (tab.size() == 1)) { 191 out.format(" <tag k='seamark:%s:%s' v='%s'/>%n", type, attstr, StringEscapeUtils.escapeXml10(valstr));217 out.format(" <tag k='seamark:%s:%s' v='%s'/>%n", S57obj.stringType(obj), attstr, StringEscapeUtils.escapeXml10(valstr)); 192 218 } else { 193 out.format(" <tag k='seamark:%s:%d:%s' v='%s'/>%n", type, ix + 1, attstr, StringEscapeUtils.escapeXml10(valstr));219 out.format(" <tag k='seamark:%s:%d:%s' v='%s'/>%n", S57obj.stringType(obj), ix + 1, attstr, StringEscapeUtils.escapeXml10(valstr)); 194 220 } 195 221 }
Note:
See TracChangeset
for help on using the changeset viewer.