Changeset 30285 in osm
- Timestamp:
- 2014-02-17T14:27:01+01:00 (11 years ago)
- Location:
- applications/editors/josm/plugins/smed2
- Files:
-
- 27 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/smed2/js57toosm/build.xml
r30284 r30285 11 11 12 12 <target name="compile" depends="init" description="compile the source " > 13 <javac includeantruntime="false" srcdir="${src}" destdir="${build}" />13 <javac includeantruntime="false" srcdir="${src}" destdir="${build}" encoding="UTF-8"/> 14 14 </target> 15 15 -
applications/editors/josm/plugins/smed2/js57toosm/src/js57toosm/Js57toosm.java
r30284 r30285 1 /* Copyright 201 3Malcolm Herring1 /* Copyright 2014 Malcolm Herring 2 2 * 3 3 * This is free software: you can redistribute it and/or modify … … 51 51 MapBounds bounds = S57dec.decodeFile(in, types, map); 52 52 53 out.format("<?xml version='1.0' encoding='UTF-8'?> ");54 out.format("<osm version='0.6' generator='js57toosm'> ");55 out.format("<bounds minlat='%.8f' minlon='%.8f' maxlat='%.8f' maxlon='%.8f'/> ", bounds.minlat, bounds.minlon, bounds.maxlat, bounds.maxlon);53 out.format("<?xml version='1.0' encoding='UTF-8'?>%n"); 54 out.format("<osm version='0.6' generator='js57toosm'>%n"); 55 out.format("<bounds minlat='%.8f' minlon='%.8f' maxlat='%.8f' maxlon='%.8f'/>%n", bounds.minlat, bounds.minlon, bounds.maxlat, bounds.maxlon); 56 56 57 57 for (long id : map.index.keySet()) { -
applications/editors/josm/plugins/smed2/src/messages/Messages.java
r29996 r30285 1 /* Copyright 2014 Malcolm Herring 2 * 3 * This is free software: you can redistribute it and/or modify 4 * it under the terms of the GNU General Public License as published by 5 * the Free Software Foundation, version 3 of the License. 6 * 7 * For a copy of the GNU General Public License, see <http://www.gnu.org/licenses/>. 8 */ 9 1 10 package messages; 2 11 -
applications/editors/josm/plugins/smed2/src/panels/PanelMain.java
r30269 r30285 1 /* Copyright 2014 Malcolm Herring 2 * 3 * This is free software: you can redistribute it and/or modify 4 * it under the terms of the GNU General Public License as published by 5 * the Free Software Foundation, version 3 of the License. 6 * 7 * For a copy of the GNU General Public License, see <http://www.gnu.org/licenses/>. 8 */ 9 1 10 package panels; 2 11 … … 9 18 import java.awt.event.ActionListener; 10 19 import java.awt.image.BufferedImage; 11 import java.io.File; 12 import java.util.ArrayList; 13 import java.util.Iterator; 20 import java.io.*; 14 21 15 22 import javax.imageio.ImageIO; … … 20 27 import org.openstreetmap.josm.Main; 21 28 22 import s57.S57att.Att; 23 import s57.S57obj.Obj; 24 import s57.S57val.*; 29 import s57.S57att.*; 30 import s57.S57obj.*; 25 31 import s57.S57map.*; 26 32 import render.Renderer; … … 29 35 public class PanelMain extends JPanel { 30 36 31 Smed2Action dlg;32 37 BufferedImage img; 33 38 int w, h, z, f; … … 42 47 }; 43 48 private JButton importButton = null; 44 final JFileChooser ifc = new JFileChooser();49 JFileChooser ifc = new JFileChooser(Main.pref.get("smed2plugin.file")); 45 50 private ActionListener alImport = new ActionListener() { 46 51 public void actionPerformed(java.awt.event.ActionEvent e) { 47 52 if (e.getSource() == importButton) { 48 messageBar.setText("Select file"); 49 int returnVal = ifc.showOpenDialog(Main.parent); 50 if (returnVal == JFileChooser.APPROVE_OPTION) { 51 // xxx.startImport(ifc.getSelectedFile()); 52 } else { 53 messageBar.setText(""); 54 } 55 } 53 Smed2Action.panelS57.setVisible(true); 54 messageBar.setText("Select S-57 ENC file for import"); 55 int returnVal = ifc.showOpenDialog(Main.parent); 56 if (returnVal == JFileChooser.APPROVE_OPTION) { 57 try { 58 Main.pref.put("smed2plugin.file", ifc.getSelectedFile().getPath()); 59 Smed2Action.panelS57.startImport(ifc.getSelectedFile()); 60 } catch (IOException e1) { 61 Smed2Action.panelS57.setVisible(false); 62 messageBar.setText("IO Exception"); 63 } 64 } else { 65 Smed2Action.panelS57.setVisible(false); 66 messageBar.setText(""); 67 } 68 } 56 69 } 57 70 }; … … 62 75 public void actionPerformed(java.awt.event.ActionEvent e) { 63 76 if (e.getSource() == exportButton) { 64 messageBar.setText("Select file"); 77 Smed2Action.panelS57.setVisible(true); 78 messageBar.setText("Select S-57 ENC file for export"); 65 79 int returnVal = efc.showOpenDialog(Main.parent); 66 80 if (returnVal == JFileChooser.APPROVE_OPTION) { 67 // xxx.startExport(efc.getSelectedFile()); 81 try { 82 Smed2Action.panelS57.startExport(efc.getSelectedFile()); 83 } catch (IOException e1) { 84 Smed2Action.panelS57.setVisible(false); 85 messageBar.setText("IO Exception"); 86 } 68 87 } else { 69 messageBar.setText(""); 88 Smed2Action.panelS57.setVisible(false); 89 messageBar.setText(""); 70 90 } 71 91 } … … 73 93 }; 74 94 75 public PanelMain(Smed2Action dia) { 76 dlg = dia; 95 public PanelMain() { 77 96 setLayout(null); 78 97 setSize(new Dimension(480, 480)); … … 120 139 img = new BufferedImage(Integer.parseInt(wt.getText()), Integer.parseInt(ht.getText()), BufferedImage.TYPE_INT_ARGB); 121 140 Graphics2D g2 = img.createGraphics(); 122 Renderer.reRender(g2, Integer.parseInt(zt.getText()), Integer.parseInt(ft.getText()), dlg.map, dlg.rendering);141 Renderer.reRender(g2, Integer.parseInt(zt.getText()), Integer.parseInt(ft.getText()), Smed2Action.map, Smed2Action.rendering); 123 142 try { 124 143 ImageIO.write(img, "png", new File("/Users/mherring/Desktop/export.png")); -
applications/editors/josm/plugins/smed2/src/panels/ShowFrame.java
r30215 r30285 1 /* Copyright 2014 Malcolm Herring 2 * 3 * This is free software: you can redistribute it and/or modify 4 * it under the terms of the GNU General Public License as published by 5 * the Free Software Foundation, version 3 of the License. 6 * 7 * For a copy of the GNU General Public License, see <http://www.gnu.org/licenses/>. 8 */ 9 1 10 package panels; 2 11 -
applications/editors/josm/plugins/smed2/src/render/MapContext.java
r30150 r30285 1 /* Copyright 2014 Malcolm Herring 2 * 3 * This is free software: you can redistribute it and/or modify 4 * it under the terms of the GNU General Public License as published by 5 * the Free Software Foundation, version 3 of the License. 6 * 7 * For a copy of the GNU General Public License, see <http://www.gnu.org/licenses/>. 8 */ 9 1 10 package render; 2 11 -
applications/editors/josm/plugins/smed2/src/render/Renderer.java
r30281 r30285 1 /* Copyright 201 3Malcolm Herring1 /* Copyright 2014 Malcolm Herring 2 2 * 3 3 * This is free software: you can redistribute it and/or modify -
applications/editors/josm/plugins/smed2/src/render/Rules.java
r30269 r30285 1 /* Copyright 201 3Malcolm Herring1 /* Copyright 2014 Malcolm Herring 2 2 * 3 3 * This is free software: you can redistribute it and/or modify -
applications/editors/josm/plugins/smed2/src/render/Signals.java
r30190 r30285 1 /* Copyright 201 3Malcolm Herring1 /* Copyright 2014 Malcolm Herring 2 2 * 3 3 * This is free software: you can redistribute it and/or modify -
applications/editors/josm/plugins/smed2/src/s57/S57att.java
r30269 r30285 1 /* Copyright 2014 Malcolm Herring 2 * 3 * This is free software: you can redistribute it and/or modify 4 * it under the terms of the GNU General Public License as published by 5 * the Free Software Foundation, version 3 of the License. 6 * 7 * For a copy of the GNU General Public License, see <http://www.gnu.org/licenses/>. 8 */ 9 1 10 package s57; 2 11 -
applications/editors/josm/plugins/smed2/src/s57/S57dat.java
r30284 r30285 1 /* Copyright 2014 Malcolm Herring 2 * 3 * This is free software: you can redistribute it and/or modify 4 * it under the terms of the GNU General Public License as published by 5 * the Free Software Foundation, version 3 of the License. 6 * 7 * For a copy of the GNU General Public License, see <http://www.gnu.org/licenses/>. 8 */ 9 1 10 package s57; 2 11 12 import java.io.UnsupportedEncodingException; 3 13 import java.util.ArrayList; 4 14 import java.util.Arrays; … … 165 175 private static int index; 166 176 private static S57field field; 177 private static String aall = "US-ASCII"; 178 private static String nall = "US-ASCII"; 167 179 public static int rnum; 168 180 … … 219 231 if (conv.bin == 0) { 220 232 String str = ""; 233 int i = 0; 221 234 if (conv.asc == 0) { 222 while (buffer[offset] != 0x1f) { 223 str += (char)(buffer[offset++]); 224 } 225 offset++; 235 for (i=0; buffer[offset+i] != 0x1f; i++) {} 236 try { 237 String charset = ""; 238 if (field == S57field.ATTF) charset = aall; 239 else if (field == S57field.NATF) charset = nall; 240 else charset = "US-ASCII"; 241 str = new String(buffer, offset, i, charset); 242 } catch (UnsupportedEncodingException e) { 243 e.printStackTrace(); 244 } 245 offset += i + 1; 226 246 } else { 227 247 str = new String(buffer, offset, conv.asc); … … 239 259 } 240 260 offset += Math.abs(conv.bin); 261 if ((subf == S57subf.AALL) || (subf == S57subf.NALL)) { 262 String charset = ""; 263 switch ((int)val) { 264 case 0: 265 charset = "US-ASCII"; 266 break; 267 case 1: 268 charset = "ISO-8859-1"; 269 break; 270 case 2: 271 charset = "UTF-16LE"; 272 break; 273 } 274 if (subf == S57subf.NALL) { 275 nall = charset; 276 } else { 277 aall = charset; 278 } 279 } 241 280 return val; 242 281 } else { -
applications/editors/josm/plugins/smed2/src/s57/S57dec.java
r30284 r30285 1 /* Copyright 201 3Malcolm Herring1 /* Copyright 2014 Malcolm Herring 2 2 * 3 3 * This is free software: you can redistribute it and/or modify … … 65 65 } 66 66 break; 67 case DSSI: 68 S57dat.getSubf(record, fields + pos, S57field.DSSI, S57subf.AALL); 69 S57dat.getSubf(S57subf.NALL); 70 break; 67 71 case DSPM: 68 72 comf = (double) (Long) S57dat.getSubf(record, fields + pos, S57field.DSPM, S57subf.COMF); -
applications/editors/josm/plugins/smed2/src/s57/S57map.java
r30284 r30285 1 /* Copyright 201 3Malcolm Herring1 /* Copyright 2014 Malcolm Herring 2 2 * 3 3 * This is free software: you can redistribute it and/or modify … … 93 93 94 94 public enum Rflag { 95 UNKN, AGGR,MASTER, SLAVE95 UNKN, MASTER, SLAVE 96 96 } 97 97 … … 120 120 public ObjMap() { 121 121 super(Obj.class); 122 }123 }124 125 public class Aggr {126 public RelTab rels;127 public long par;128 public Aggr() {129 rels = new RelTab();130 par = 0;131 122 } 132 123 } … … 218 209 public Obj type; // Feature type 219 210 public AttMap atts; // Feature attributes 220 public Aggr aggr;// Related objects211 public RelTab rels; // Related objects 221 212 public ObjMap objs; // Slave object attributes 222 213 … … 224 215 reln = Rflag.UNKN; 225 216 geom = new Geom(Pflag.NOSP); 226 type = Obj. C_AGGR;217 type = Obj.UNKOBJ; 227 218 atts = new AttMap(); 228 aggr = new Aggr();219 rels = new RelTab(); 229 220 objs = new ObjMap(); 230 221 } … … 271 262 obj = Obj.BOYLAT; 272 263 if (obj == Obj.C_AGGR) 273 feature.reln = Rflag. AGGR;264 feature.reln = Rflag.UNKN; 274 265 feature.geom = new Geom(p); 275 266 feature.type = obj; … … 280 271 281 272 public void newObj(long id, int rind) { 282 Rflag r = Rflag. AGGR;273 Rflag r = Rflag.UNKN; 283 274 switch (rind) { 284 275 case 1: … … 292 283 break; 293 284 } 294 feature. aggr.rels.add(new Reln(id, r));285 feature.rels.add(new Reln(id, r)); 295 286 } 296 287 … … 354 345 for (long id : index.keySet()) { 355 346 Feature feature = index.get(id); 356 for (Reln reln : feature. aggr.rels) {347 for (Reln reln : feature.rels) { 357 348 Feature rel = index.get(reln.id); 358 349 if (cmpGeoms(feature.geom, rel.geom)) { 359 350 switch (reln.reln) { 360 case MASTER:361 feature.reln = Rflag.AGGR;362 break;363 351 case SLAVE: 364 352 feature.reln = Rflag.MASTER; … … 388 376 for (long id : index.keySet()) { 389 377 Feature feature = index.get(id); 390 for (Reln reln : feature. aggr.rels) {378 for (Reln reln : feature.rels) { 391 379 Feature rel = index.get(reln.id); 392 380 if (rel.reln == Rflag.SLAVE) { … … 408 396 nodes.put(id, node); 409 397 feature = new Feature(); 410 feature.reln = Rflag. AGGR;398 feature.reln = Rflag.UNKN; 411 399 feature.geom.prim = Pflag.POINT; 412 400 feature.geom.elems.add(new Prim(id)); … … 416 404 public void addEdge(long id) { 417 405 feature = new Feature(); 418 feature.reln = Rflag. AGGR;406 feature.reln = Rflag.UNKN; 419 407 feature.geom.prim = Pflag.LINE; 420 408 feature.geom.elems.add(new Prim(id)); … … 436 424 public void addArea(long id) { 437 425 feature = new Feature(); 438 feature.reln = Rflag. AGGR;426 feature.reln = Rflag.UNKN; 439 427 feature.geom.prim = Pflag.AREA; 440 428 feature.geom.elems.add(new Prim(id)); … … 447 435 448 436 public void addTag(String key, String val) { 437 feature.reln = Rflag.MASTER; 449 438 String subkeys[] = key.split(":"); 450 439 if ((subkeys.length > 1) && subkeys[0].equals("seamark")) { … … 461 450 att = S57att.enumAttribute(subkeys[2], obj); 462 451 } 463 ObjTab items = feature.objs.get(obj); 464 if (items == null) { 465 items = new ObjTab(); 466 feature.objs.put(obj, items); 467 Feature type = new Feature(); 468 type.reln = Rflag.SLAVE; 469 type.type = obj; 470 type.geom = feature.geom; 471 } 472 // AttMap atts = items.get(idx); 473 // if (atts == null) { 474 // atts = new AttMap(); 475 // items.put(idx, atts); 476 // } 477 // AttVal<?> attval = S57val.convertValue(val, att); 478 // if (attval.val != null) 479 // atts.put(att, attval); 452 ObjTab objs = feature.objs.get(obj); 453 if (objs == null) { 454 objs = new ObjTab(); 455 feature.objs.put(obj, objs); 456 } 457 AttMap atts = objs.get(idx); 458 if (atts == null) { 459 atts = new AttMap(); 460 objs.put(idx, atts); 461 } 462 AttVal<?> attval = S57val.convertValue(val, att); 463 if (attval.val != null) 464 atts.put(att, attval); 480 465 } else { 481 466 if (subkeys[1].equals("type")) { 482 467 obj = S57obj.enumType(val); 483 if (feature.objs.get(feature.type) == null) { 484 feature.objs.put(feature.type, new ObjTab()); 485 Feature type = new Feature(); 486 type.reln = Rflag.MASTER; 487 type.type = obj; 488 type.geom = feature.geom; 468 feature.type = obj; 469 ObjTab objs = feature.objs.get(obj); 470 if (objs == null) { 471 objs = new ObjTab(); 472 feature.objs.put(obj, objs); 473 } 474 AttMap atts = objs.get(0); 475 if (atts == null) { 476 atts = new AttMap(); 477 objs.put(0, atts); 489 478 } 490 479 } else { -
applications/editors/josm/plugins/smed2/src/s57/S57obj.java
r30283 r30285 1 /* Copyright 2014 Malcolm Herring 2 * 3 * This is free software: you can redistribute it and/or modify 4 * it under the terms of the GNU General Public License as published by 5 * the Free Software Foundation, version 3 of the License. 6 * 7 * For a copy of the GNU General Public License, see <http://www.gnu.org/licenses/>. 8 */ 9 1 10 package s57; 2 11 -
applications/editors/josm/plugins/smed2/src/s57/S57val.java
r30231 r30285 1 /* Copyright 2014 Malcolm Herring 2 * 3 * This is free software: you can redistribute it and/or modify 4 * it under the terms of the GNU General Public License as published by 5 * the Free Software Foundation, version 3 of the License. 6 * 7 * For a copy of the GNU General Public License, see <http://www.gnu.org/licenses/>. 8 */ 9 1 10 package s57; 2 11 -
applications/editors/josm/plugins/smed2/src/smed2/MapImage.java
r30150 r30285 1 /* Copyright 201 3Malcolm Herring1 /* Copyright 2014 Malcolm Herring 2 2 * 3 3 * This is free software: you can redistribute it and/or modify -
applications/editors/josm/plugins/smed2/src/smed2/Smed2.java
r30269 r30285 1 /* Copyright 201 3Malcolm Herring1 /* Copyright 2014 Malcolm Herring 2 2 * 3 3 * This is free software: you can redistribute it and/or modify -
applications/editors/josm/plugins/smed2/src/smed2/Smed2Action.java
r30157 r30285 1 /* Copyright 201 3Malcolm Herring1 /* Copyright 2014 Malcolm Herring 2 2 * 3 3 * This is free software: you can redistribute it and/or modify … … 31 31 import s57.S57map; 32 32 import s57.S57map.*; 33 33 import panels.PanelS57; 34 34 import panels.PanelMain; 35 35 import panels.ShowFrame; … … 41 41 private boolean isOpen = false; 42 42 public static PanelMain panelMain = null; 43 public MapImage rendering; 44 public S57map map = null; 43 public static PanelS57 panelS57 = null; 44 public static MapImage rendering; 45 public static S57map map = null; 45 46 public DataSet data = null; 46 47 … … 118 119 editFrame.setAlwaysOnTop(true); 119 120 editFrame.setVisible(true); 120 panelMain = new PanelMain( this);121 panelMain = new PanelMain(); 121 122 editFrame.add(panelMain); 123 124 panelS57 = new PanelS57(); 125 editFrame.add(panelS57); 122 126 123 127 showFrame = new ShowFrame(tr("Seamark Inspector")); 124 128 showFrame.setSize(new Dimension(300, 300)); 125 Rectangle rect = Main.map.mapView.getBounds(); 126 showFrame.setLocation(50, (rect.y + rect.height - 200)); 129 showFrame.setLocation(50, 400); 127 130 showFrame.setResizable(false); 128 131 showFrame.setAlwaysOnTop(true); … … 159 162 newLayer.data.addDataSetListener(dataSetListener); 160 163 data = newLayer.data; 161 makeMap();164 // makeMap(); 162 165 } else { 163 166 data = null; … … 181 184 Feature id = map.index.get(feature.getUniqueId()); 182 185 if (id != null) { 183 panelMain.parseMark(id);186 // panelMain.parseMark(id); 184 187 showFrame.setVisible(true); 185 188 showFrame.showFeature(feature, map); -
applications/editors/josm/plugins/smed2/src/symbols/Areas.java
r30215 r30285 1 /* Copyright 201 2Malcolm Herring1 /* Copyright 2014 Malcolm Herring 2 2 * 3 3 * This is free software: you can redistribute it and/or modify -
applications/editors/josm/plugins/smed2/src/symbols/Beacons.java
r30215 r30285 1 /* Copyright 201 2Malcolm Herring1 /* Copyright 2014 Malcolm Herring 2 2 * 3 3 * This is free software: you can redistribute it and/or modify -
applications/editors/josm/plugins/smed2/src/symbols/Buoys.java
r30215 r30285 1 /* Copyright 201 2Malcolm Herring1 /* Copyright 2014 Malcolm Herring 2 2 * 3 3 * This is free software: you can redistribute it and/or modify -
applications/editors/josm/plugins/smed2/src/symbols/Facilities.java
r30215 r30285 1 /* Copyright 201 2Malcolm Herring1 /* Copyright 2014 Malcolm Herring 2 2 * 3 3 * This is free software: you can redistribute it and/or modify -
applications/editors/josm/plugins/smed2/src/symbols/Harbours.java
r30215 r30285 1 /* Copyright 201 2Malcolm Herring1 /* Copyright 2014 Malcolm Herring 2 2 * 3 3 * This is free software: you can redistribute it and/or modify -
applications/editors/josm/plugins/smed2/src/symbols/Landmarks.java
r30215 r30285 1 /* Copyright 201 2Malcolm Herring1 /* Copyright 2014 Malcolm Herring 2 2 * 3 3 * This is free software: you can redistribute it and/or modify -
applications/editors/josm/plugins/smed2/src/symbols/Notices.java
r30215 r30285 1 /* Copyright 201 2Malcolm Herring1 /* Copyright 2014 Malcolm Herring 2 2 * 3 3 * This is free software: you can redistribute it and/or modify -
applications/editors/josm/plugins/smed2/src/symbols/Symbols.java
r30226 r30285 1 /* Copyright 201 3Malcolm Herring1 /* Copyright 2014 Malcolm Herring 2 2 * 3 3 * This is free software: you can redistribute it and/or modify -
applications/editors/josm/plugins/smed2/src/symbols/Topmarks.java
r30215 r30285 1 /* Copyright 201 2Malcolm Herring1 /* Copyright 2014 Malcolm Herring 2 2 * 3 3 * This is free software: you can redistribute it and/or modify
Note:
See TracChangeset
for help on using the changeset viewer.