public void testSingleDataset() throws IOException { InvCatalogImpl cat = TestTDSAll.open(null); InvDataset ds = cat.findDatasetByID("testSingleDataset"); assert (ds != null) : "cant find dataset 'testSingleDataset'"; assert ds.getDataType() == FeatureType.GRID; ThreddsDataFactory fac = new ThreddsDataFactory(); ThreddsDataFactory.Result dataResult = fac.openFeatureDataset(ds, null); assert dataResult != null; assert !dataResult.fatalError; assert dataResult.featureDataset != null; GridDataset gds = (GridDataset) dataResult.featureDataset; GridDatatype grid = gds.findGridDatatype("Z_sfc"); assert grid != null; GridCoordSystem gcs = grid.getCoordinateSystem(); assert gcs != null; assert null == gcs.getVerticalAxis(); CoordinateAxis1D time = gcs.getTimeAxis1D(); assert time != null; assert time.getSize() == 1; assert 102840.0 == time.readScalarDouble(); dataResult.featureDataset.close(); }
public static void main(String args[]) { JFrame frame; final DatasetEditor editor = new DatasetEditor(); frame = new JFrame("Test DatasetEditor"); frame.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); JButton save = new JButton("Accept"); save.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { editor.accept(); editor.store2Dataset(); try { cat.writeXML(System.out, true); } catch (IOException e1) { e1.printStackTrace(); } } }); JPanel main = new JPanel(new BorderLayout()); main.add(editor, BorderLayout.CENTER); main.add(save, BorderLayout.NORTH); frame.getContentPane().add(main); frame.pack(); frame.setLocation(150, 10); frame.setVisible(true); // LOOK-NOSAVE java.net.Authenticator.setDefault(new UrlAuthenticatorDialog(frame)); // String url = "http://uni10.unidata.ucar.edu:8088/thredds/content/idd/models.xml"; String url = "http://thredds.ucar.edu/thredds/content/idd/models.xml"; InvCatalogFactory catFactory = InvCatalogFactory.getDefaultFactory(true); cat = catFactory.readXML(url); InvDatasetImpl ds = (InvDatasetImpl) cat.findDatasetByID("NCEP/NAM/V"); editor.setDataset(ds); }