@Test public void writeGridAsPointNetcdf() throws JDOMException, IOException { String endpoint = TestOnLocalServer.withHttpPath(ds+"?var="+varName+query+"&accept=netcdf"); File tempFile = tempFolder.newFile(); logger.debug(" write {} to {}", endpoint, tempFile.getAbsolutePath()); try (HTTPSession session = HTTPFactory.newSession(endpoint)) { HTTPMethod method = HTTPFactory.Get(session); int statusCode = method.execute(); if (statusCode != 200) { logger.debug("statusCode = {} '{}'", statusCode, method.getResponseAsString()); return; } IO.appendToFile(method.getResponseAsStream(), tempFile.getAbsolutePath()); } logger.debug(" file length {} bytes exists={} {}", tempFile.length(), tempFile.exists(), tempFile.getAbsolutePath()); // Open the result file as Station feature dataset Formatter errlog = new Formatter(); try (FeatureDataset fd = FeatureDatasetFactoryManager.open(FeatureType.STATION, tempFile.getAbsolutePath(), null, errlog)) { assertNotNull(errlog.toString(), fd); VariableSimpleIF v = fd.getDataVariable(varName); assertNotNull(varName, v); } }
Assert.assertNotNull("fdataset.getDataVariables()", dataVars); for (VariableSimpleIF v : dataVars) { Assert.assertNotNull(v.getShortName(), fdataset.getDataVariable(v.getShortName()));
@Test public void checkGridAsPointNetcdf() throws JDOMException, IOException { String endpoint = TestOnLocalServer.withHttpPath(ds+"?var="+varName+query+"&accept=netcdf"); byte[] content = TestOnLocalServer.getContent(endpoint, 200, ContentType.netcdf); Assert.assertNotNull(content); logger.debug("return size = {}", content.length); // Open the binary response in memory Formatter errlog = new Formatter(); try (NetcdfFile nf = NetcdfFile.openInMemory("checkGridAsPointNetcdf.nc", content)) { FeatureDataset fd = FeatureDatasetFactoryManager.wrap(FeatureType.STATION, new NetcdfDataset(nf), null, errlog); assertNotNull(errlog.toString(), fd); VariableSimpleIF v = fd.getDataVariable(varName); assertNotNull(varName, v); } } }
Assert.assertNotNull(covName, fd.getDataVariable(covName));