Changeset 28938 in osm for applications/editors/josm/plugins
- Timestamp:
- 2012-11-15T19:05:19+01:00 (12 years ago)
- Location:
- applications/editors/josm/plugins/smed2/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/smed2/src/S57/S57dat.java
r28722 r28938 1 1 package S57; 2 2 3 import static org.openstreetmap.josm.tools.I18n.tr; 4 5 import java.awt.Dimension; 6 import java.awt.event.ActionListener; 3 7 import java.io.File; 8 import java.io.FileInputStream; 9 import java.io.FileNotFoundException; 10 import java.io.IOException; 11 12 import javax.swing.*; 13 14 import org.openstreetmap.josm.Main; 15 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 16 import org.openstreetmap.josm.data.osm.DataSet; 17 18 import panels.PanelMain; 19 20 import smed2.Smed2Action; 4 21 5 22 import S57.S57obj; … … 7 24 import S57.S57val; 8 25 9 public class S57dat {26 public class S57dat extends JPanel { 10 27 11 private class LRleader { 12 public int rlen; 28 private enum S57field { DSID, DSSI, DSPM, DSPR, DSRC, DSHT, DSAC, CATD, CATX, DDDF, DDDR, DDDI, DDOM, DDRF, DDSI, DDSC, 29 FRID, FOID, ATTF, NATF, FFPC, FFPT, FSPC, FSPT, VRID, ATTV, VRPC, VRPT, SGCC, SG2D, SG3D, ARCC, AR2D, EL2D, CT2D } 30 private enum S57dsid { RCNM, RCID, EXPP, INTU, DSNM, EDTN, UPDN, UADT, ISDT, STED, PRSP, PSDN, PRED, PROF, AGEN, COMT } 31 private enum S57dssi { DSTR, AALL, NALL, NOMR, NOCR, NOGR, NOLR, NOIN, NOCN, NOED, NOFA } 32 private enum S57dspm { RCNM, RCID, HDAT, VDAT, SDAT, CSCL, DUNO, HUNI, PUNI, COUN, COMF, SOMF, COMT } 33 private enum S57dspr { PROJ, PRP1, PRP2, PRP3, PRP4, FEAS, FNOR, FPMF, COMT } 34 private enum S57dsrc { RPID, RYCO, RXCO, CURP, FPMF, RXVL, RYVL, COMT } 35 private enum S57dsht { RCNM, RCID, PRCO, ESDT, LSDT, DCRT, CODT, COMT } 36 private enum S57dsac { RCNM, RCID, PACC, HACC, SACC, FPMF, COMT } 37 private enum S57catd { RCNM, RCID, FILE, LFIL, VOLM, IMPL, SLAT, WLON, NLAT, ELON, CRCS, COMT } 38 private enum S57catx { RCNM, RCID, NAM1, NAM2, COMT } 39 private enum S57dddf { RCNM, RCID, OORA, OAAC, OACO, OALL, OATY, DEFN, AUTH, COMT } 40 private enum S57dddr { RFTP, RFVL } 41 private enum S57dddi { RCNM, RCID, ATLB, ATDO, ADMU, ADFT, AUTH, COMT } 42 private enum S57ddom { RAVA, DVAL, DVSD, DEFN, AUTH } 43 private enum S57ddrf { RFTP, RFVL } 44 private enum S57ddsi { RCNM, RCID, OBLB } 45 private enum S57ddsc { ATLB, ASET, AUTH } 46 private enum S57frid { RCNM, RCID, PRIM, GRUP, OBJL, RVER, RUIN } 47 private enum S57foid { AGEN, FIDN, FIDS } 48 private enum S57attf { ATTL, ATVL } 49 private enum S57natf { ATTL, ATVL } 50 private enum S57ffpc { FFUI, FFIX, NFPT } 51 private enum S57ffpt { LNAM, RIND, COMT } 52 private enum S57fspc { FSUI, FSIX, NSPT } 53 private enum S57fspt { NAME, ORNT, USAG, MASK } 54 private enum S57vrid { RCNM, RCID, RVER, RUIN } 55 private enum S57attv { ATTL, ATVL } 56 private enum S57vrpc { VPUI, VPIX, NVPT } 57 private enum S57vrpt { NAME, ORNT, USAG, TOPI, MASK } 58 private enum S57sgcc { CCUI, CCIX, CCNC } 59 private enum S57sg2d { YCOO, XCOO } 60 private enum S57sg3d { YCOO, XCOO, VE3D } 61 private enum S57arcc { ATYP, SURF, ORDR, RESO, FPMF } 62 private enum S57ar2d { STPT, CTPT, ENPT, YCOO, XCOO } 63 private enum S57el2d { STPT, CTPT, ENPT, CDPM, CDPR, YCOO, XCOO } 64 private enum S57ct2d { YCOO, XCOO } 65 66 private File importFile; 67 private FileInputStream inp; 68 private OsmDataLayer layer; 69 private DataSet data; 70 71 private JButton importButton; 72 private ActionListener alImport = new ActionListener() { 73 public void actionPerformed(java.awt.event.ActionEvent e) { 74 if (e.getSource() == importButton) { 75 readFile(); 76 Smed2Action.panelS57.setVisible(false); 77 Smed2Action.panelMain.setVisible(true); 78 PanelMain.messageBar.setText("File imported"); 79 } 80 } 81 }; 82 private JButton cancelButton; 83 private ActionListener alCancel = new ActionListener() { 84 public void actionPerformed(java.awt.event.ActionEvent e) { 85 if (e.getSource() == cancelButton) { 86 try { 87 inp.close(); 88 } catch (IOException e1) {} 89 Smed2Action.panelS57.setVisible(false); 90 Smed2Action.panelMain.setVisible(true); 91 PanelMain.messageBar.setText("Import cancelled"); 92 } 93 } 94 }; 95 96 public S57dat() { 97 98 setLayout(null); 99 setSize(new Dimension(480, 480)); 100 cancelButton = new JButton(); 101 cancelButton.setBounds(250, 430, 100, 20); 102 cancelButton.setText(tr("Cancel")); 103 cancelButton.addActionListener(alCancel); 104 add(cancelButton); 105 importButton = new JButton(); 106 importButton.setBounds(370, 430, 100, 20); 107 importButton.setText(tr("Import")); 108 importButton.addActionListener(alImport); 109 add(importButton); 13 110 } 14 111 15 public S57dat(File file) { 16 112 public void startImport(File file) { 113 importFile = file; 114 try { 115 inp = new FileInputStream(file); 116 } catch (IOException e) { 117 PanelMain.messageBar.setText("Failed to open file"); 118 return; 119 } 120 Smed2Action.panelMain.setVisible(false); 121 Smed2Action.panelS57.setVisible(true); 122 } 123 124 private void readFile() { 125 // Read & convert file. 126 // read record at a time 127 // read leader 128 // if DDR, build conversion tables 129 // if DR, build data structures 130 // Extract list of features & present on chooser panel 131 } 132 133 private void importData() { 134 data = new DataSet(); 135 // Transfer selected features 136 layer = new OsmDataLayer(data, importFile.getName(), null); 137 layer.setUploadDiscouraged(true); 138 Main.main.addLayer(layer); 139 17 140 } 18 141 } -
applications/editors/josm/plugins/smed2/src/S57/S57obj.java
r28722 r28938 11 11 DMPGRD, DYKCON, EXEZNE, FAIRWY, FNCLNE, FERYRT, FSHZNE, FSHFAC, FSHGRD, FLODOC, FOGSIG, FORSTC, FRPARE, GATCON, GRIDRN, HRBARE, 12 12 HRBFAC, HULKES, ICEARE, ICNARE, ISTZNE, LAKARE, LAKSHR, LNDARE, LNDELV, LNDRGN, LNDMRK, LIGHTS, LITFLT, LITVES, LOCMAG, LOKBSN, 13 LOGPON, MAGVAR, MARCUL, MIPARE, MORFAC, NAVLNE, OBSTRN, OFSPLF, OSPARE, OILBAR, PILPNT, PILBOP, PIPARE, PIPOHD, PIPSOL, PONTON,13 LOGPON, MAGVAR, MARCUL, MIPARE, MORFAC, /*MPAARE,*/ NAVLNE, OBSTRN, OFSPLF, OSPARE, OILBAR, PILPNT, PILBOP, PIPARE, PIPOHD, PIPSOL, PONTON, 14 14 PRCARE, PRDARE, PYLONS, RADLNE, RADRNG, RADRFL, RADSTA, RTPBCN, RDOCAL, RDOSTA, RAILWY, RAPIDS, RCRTCL, RECTRC, RCTLPT, RSCSTA, 15 15 RESARE, RETRFL, RIVERS, RIVBNK, ROADWY, RUNWAY, SNDWAV, SEAARE, SPLARE, SBDARE, SLCONS, SISTAT, SISTAW, SILTNK, SLOTOP, SLOGRD, … … 40 40 ObjS57.put(Obj.LIGHTS,75); ObjS57.put(Obj.LITFLT,76); ObjS57.put(Obj.LITVES,77); ObjS57.put(Obj.LOCMAG,78); ObjS57.put(Obj.LOKBSN,79); 41 41 ObjS57.put(Obj.LOGPON,80); ObjS57.put(Obj.MAGVAR,81); ObjS57.put(Obj.MARCUL,82); ObjS57.put(Obj.MIPARE,83); ObjS57.put(Obj.MORFAC,84); 42 // ObjS57.put(Obj.MPAARE,?); 42 43 ObjS57.put(Obj.NAVLNE,85); ObjS57.put(Obj.OBSTRN,86); ObjS57.put(Obj.OFSPLF,87); ObjS57.put(Obj.OSPARE,88); ObjS57.put(Obj.OILBAR,89); 43 44 ObjS57.put(Obj.PILPNT,90); ObjS57.put(Obj.PILBOP,91); ObjS57.put(Obj.PIPARE,92); ObjS57.put(Obj.PIPOHD,93); ObjS57.put(Obj.PIPSOL,94); -
applications/editors/josm/plugins/smed2/src/S57/S57val.java
r28722 r28938 550 550 Functn.put(FncFNC.FNC_PILO, new S57enum(11, "pilot_office")); Functn.put(FncFNC.FNC_PILL, new S57enum(12, "pilot_lookout")); Functn.put(FncFNC.FNC_BANK, new S57enum(13, "bank")); 551 551 Functn.put(FncFNC.FNC_DIST, new S57enum(14, "district_control")); Functn.put(FncFNC.FNC_TRNS, new S57enum(15, "transit_shed")); Functn.put(FncFNC.FNC_FCTY, new S57enum(16, "factory")); 552 Functn.put(FncFNC.FNC_POWR, new S57enum(17, "power_station")); Functn.put(FncFNC.FNC_ADMIN, new S57enum(18, "administrative")); Functn.put(FncFNC.FNC_EDUC, new S57enum(19, "edu Cational"));552 Functn.put(FncFNC.FNC_POWR, new S57enum(17, "power_station")); Functn.put(FncFNC.FNC_ADMIN, new S57enum(18, "administrative")); Functn.put(FncFNC.FNC_EDUC, new S57enum(19, "educational")); 553 553 Functn.put(FncFNC.FNC_CHCH, new S57enum(20, "church")); Functn.put(FncFNC.FNC_CHPL, new S57enum(21, "chapel")); Functn.put(FncFNC.FNC_TMPL, new S57enum(22, "temple")); 554 554 Functn.put(FncFNC.FNC_PGDA, new S57enum(23, "pagoda")); Functn.put(FncFNC.FNC_SHSH, new S57enum(24, "shinto_shrine")); Functn.put(FncFNC.FNC_BTMP, new S57enum(25, "buddhist_temple")); 555 555 Functn.put(FncFNC.FNC_MOSQ, new S57enum(26, "mosque")); Functn.put(FncFNC.FNC_MRBT, new S57enum(27, "marabout")); Functn.put(FncFNC.FNC_LOOK, new S57enum(28, "lookout")); 556 Functn.put(FncFNC.FNC_COMM, new S57enum(29, "communi Cation")); Functn.put(FncFNC.FNC_TV, new S57enum(30, "television")); Functn.put(FncFNC.FNC_RADO, new S57enum(31, "radio"));556 Functn.put(FncFNC.FNC_COMM, new S57enum(29, "communication")); Functn.put(FncFNC.FNC_TV, new S57enum(30, "television")); Functn.put(FncFNC.FNC_RADO, new S57enum(31, "radio")); 557 557 Functn.put(FncFNC.FNC_RADR, new S57enum(32, "radar")); Functn.put(FncFNC.FNC_LGHT, new S57enum(33, "light_support")); Functn.put(FncFNC.FNC_MCWV, new S57enum(34, "microwave")); 558 558 Functn.put(FncFNC.FNC_COOL, new S57enum(35, "cooling")); Functn.put(FncFNC.FNC_OBS, new S57enum(36, "observation")); Functn.put(FncFNC.FNC_TMBL, new S57enum(37, "time_ball")); … … 1014 1014 keys.put(Att.DRVAL1, new S57key(Conv.F, null)); keys.put(Att.DRVAL2, new S57key(Conv.F, null)); keys.put(Att.DUNITS, new S57key(Conv.E, Dunits)); 1015 1015 keys.put(Att.ELEVAT, new S57key(Conv.F, null)); keys.put(Att.ESTRNG, new S57key(Conv.F, null)); keys.put(Att.EXCLIT, new S57key(Conv.E, Exclit)); 1016 keys.put(Att.EXPSOU, new S57key(Conv.E, Expsou)); keys.put(Att.FUNCTN, new S57key(Conv.L, Functn)); keys.put(Att.HEIGHT, new S57key(Conv. A, null));1016 keys.put(Att.EXPSOU, new S57key(Conv.E, Expsou)); keys.put(Att.FUNCTN, new S57key(Conv.L, Functn)); keys.put(Att.HEIGHT, new S57key(Conv.F, null)); 1017 1017 keys.put(Att.HUNITS, new S57key(Conv.E, Hunits)); keys.put(Att.HORACC, new S57key(Conv.F, null)); keys.put(Att.HORCLR, new S57key(Conv.F, null)); 1018 1018 keys.put(Att.HORLEN, new S57key(Conv.F, null)); keys.put(Att.HORWID, new S57key(Conv.F, null)); keys.put(Att.ICEFAC, new S57key(Conv.F, null)); … … 1020 1020 keys.put(Att.$JUSTV, new S57key(Conv.E, null)); keys.put(Att.LIFCAP, new S57key(Conv.F, null)); keys.put(Att.LITCHR, new S57key(Conv.E, Litchr)); 1021 1021 keys.put(Att.LITVIS, new S57key(Conv.L, Litvis)); keys.put(Att.MARSYS, new S57key(Conv.E, Marsys)); keys.put(Att.MLTYLT, new S57key(Conv.I, null)); 1022 keys.put(Att.NATION, new S57key(Conv.A, null)); keys.put(Att.NATCON, new S57key(Conv. L, Natcon)); keys.put(Att.NATSUR, new S57key(Conv.L, Natsur));1022 keys.put(Att.NATION, new S57key(Conv.A, null)); keys.put(Att.NATCON, new S57key(Conv.E, Natcon)); keys.put(Att.NATSUR, new S57key(Conv.L, Natsur)); 1023 1023 keys.put(Att.NATQUA, new S57key(Conv.L, Natqua)); keys.put(Att.NMDATE, new S57key(Conv.A, null)); keys.put(Att.OBJNAM, new S57key(Conv.S, null)); 1024 1024 keys.put(Att.ORIENT, new S57key(Conv.F, null)); keys.put(Att.PEREND, new S57key(Conv.A, null)); keys.put(Att.PERSTA, new S57key(Conv.A, null)); -
applications/editors/josm/plugins/smed2/src/panels/PanelMain.java
r28722 r28938 7 7 import java.awt.Rectangle; 8 8 import java.awt.event.ActionListener; 9 import java.io.File;10 9 11 10 import javax.swing.*; 12 11 13 12 import org.openstreetmap.josm.Main; 13 14 import smed2.Smed2Action; 14 15 15 16 import S57.S57dat; … … 28 29 } 29 30 }; 30 p ublicJButton openButton = null;31 private JButton openButton = null; 31 32 final JFileChooser fc = new JFileChooser(); 32 33 private ActionListener alOpen = new ActionListener() { 33 34 public void actionPerformed(java.awt.event.ActionEvent e) { 34 35 if (e.getSource() == openButton) { 36 messageBar.setText("Select file"); 35 37 int returnVal = fc.showOpenDialog(Main.parent); 36 38 if (returnVal == JFileChooser.APPROVE_OPTION) { 37 new S57dat(fc.getSelectedFile()); 38 messageBar.setText("Opening file"); 39 } 39 Smed2Action.panelS57.startImport(fc.getSelectedFile()); 40 } else { 41 messageBar.setText(""); 42 } 40 43 } 41 44 } … … 55 58 56 59 messageBar = new JTextField(); 57 messageBar.setBounds( new Rectangle(40, 430, 320, 20));60 messageBar.setBounds(40, 430, 320, 20); 58 61 messageBar.setEditable(false); 59 62 messageBar.setBackground(Color.WHITE); 60 63 add(messageBar); 61 64 openButton = new JButton(new ImageIcon(getClass().getResource("/images/fileButton.png"))); 62 openButton.setBounds( new Rectangle(10, 430, 20, 20));65 openButton.setBounds(10, 430, 20, 20); 63 66 add(openButton); 64 67 openButton.addActionListener(alOpen); 65 68 saveButton = new JButton(); 66 saveButton.setBounds( new Rectangle(370, 430, 100, 20));69 saveButton.setBounds(370, 430, 100, 20); 67 70 saveButton.setText(tr("Save")); 68 71 add(saveButton); -
applications/editors/josm/plugins/smed2/src/smed2/Smed2Action.java
r28722 r28938 15 15 import org.openstreetmap.josm.Main; 16 16 17 import S57.S57dat; 18 17 19 import panels.PanelMain; 18 20 … … 21 23 private static final long serialVersionUID = 1L; 22 24 private static String editor = tr("SeaMap Editor"); 23 private JFrame frame = null; 25 public static JFrame frame = null; 26 public static S57dat panelS57; 24 27 private boolean isOpen = false; 25 public PanelMain panelMain = null;28 public static PanelMain panelMain = null; 26 29 public ImageryLayer rendering; 27 30 … … 58 61 panelMain = new PanelMain(); 59 62 frame.add(panelMain); 63 panelS57 = new S57dat(); 64 panelS57.setVisible(false); 65 frame.add(panelS57); 60 66 System.out.println("hello"); 61 67 rendering = ImageryLayer.create(new ImageryInfo("OpenSeaMap"));
Note:
See TracChangeset
for help on using the changeset viewer.