@Test void AscDataWriterWritesDssFile(){ String inFile = new File(getClass().getResource( "/normalizer/qpe.dss").getFile()).toString(); String variableName = " DataReader reader = DataReader.builder() .path(inFile) .variable(variableName) .build(); List<VortexData> dtos = new ArrayList<>(reader.getDtos()); String fileName = ImageUtils.generateFileName("qpe", (VortexGrid) dtos.get(0), ImageFileType.ASC); Path destination = Paths.get("C:/Temp",fileName); DataWriter writer = DataWriter.builder() .destination(destination) .data(dtos) .build(); writer.write(); }
@Override public void write() { List<VortexGrid> grids = data.stream() .filter(vortexData -> vortexData instanceof VortexGrid) .map(vortexData -> (VortexGrid) vortexData) .collect(Collectors.toList()); grids.forEach(grid -> { VortexGrid gridOut; if (grid.dy() < 0){ gridOut = grid; } else { float[] flipped = MatrixUtils.flipArray(grid.data(), grid.nx(), grid.ny()); gridOut = VortexGrid.builder() .dx(grid.dx()).dy(grid.dy()) .nx(grid.nx()).ny(grid.ny()) .originX(grid.originX()) .originY(grid.originY() + grid.dy() * grid.ny()) .wkt(grid.wkt()) .data(flipped) .units(grid.units()) .fileName(grid.fileName()) .shortName(grid.shortName()) .fullName(grid.fullName()) .description(grid.description()) .startTime(grid.startTime()) .endTime(grid.endTime()) .interval(grid.interval()) .build(); } Dataset dataset = RasterUtils.getDatasetFromVortexGrid(gridOut); ArrayList<String> gdalOptions = new ArrayList<>(); gdalOptions.add("-of"); gdalOptions.add("AAIGrid"); gdalOptions.add("-co"); gdalOptions.add("FORCE_CELLSIZE=TRUE"); TranslateOptions translateOptions = new TranslateOptions(new Vector<>(gdalOptions)); Dataset out = gdal.Translate(destination.toString(), dataset, translateOptions); out.FlushCache(); out.delete(); }); }
AscDataWriter extends DataWriter { @Override public void write() { List<VortexGrid> grids = data.stream() .filter(vortexData -> vortexData instanceof VortexGrid) .map(vortexData -> (VortexGrid) vortexData) .collect(Collectors.toList()); grids.forEach(grid -> { VortexGrid gridOut; if (grid.dy() < 0){ gridOut = grid; } else { float[] flipped = MatrixUtils.flipArray(grid.data(), grid.nx(), grid.ny()); gridOut = VortexGrid.builder() .dx(grid.dx()).dy(grid.dy()) .nx(grid.nx()).ny(grid.ny()) .originX(grid.originX()) .originY(grid.originY() + grid.dy() * grid.ny()) .wkt(grid.wkt()) .data(flipped) .units(grid.units()) .fileName(grid.fileName()) .shortName(grid.shortName()) .fullName(grid.fullName()) .description(grid.description()) .startTime(grid.startTime()) .endTime(grid.endTime()) .interval(grid.interval()) .build(); } Dataset dataset = RasterUtils.getDatasetFromVortexGrid(gridOut); ArrayList<String> gdalOptions = new ArrayList<>(); gdalOptions.add("-of"); gdalOptions.add("AAIGrid"); gdalOptions.add("-co"); gdalOptions.add("FORCE_CELLSIZE=TRUE"); TranslateOptions translateOptions = new TranslateOptions(new Vector<>(gdalOptions)); Dataset out = gdal.Translate(destination.toString(), dataset, translateOptions); out.FlushCache(); out.delete(); }); } }
AscDataWriter extends DataWriter { @Override public void write() { List<VortexGrid> grids = data.stream() .filter(vortexData -> vortexData instanceof VortexGrid) .map(vortexData -> (VortexGrid) vortexData) .collect(Collectors.toList()); grids.forEach(grid -> { VortexGrid gridOut; if (grid.dy() < 0){ gridOut = grid; } else { float[] flipped = MatrixUtils.flipArray(grid.data(), grid.nx(), grid.ny()); gridOut = VortexGrid.builder() .dx(grid.dx()).dy(grid.dy()) .nx(grid.nx()).ny(grid.ny()) .originX(grid.originX()) .originY(grid.originY() + grid.dy() * grid.ny()) .wkt(grid.wkt()) .data(flipped) .units(grid.units()) .fileName(grid.fileName()) .shortName(grid.shortName()) .fullName(grid.fullName()) .description(grid.description()) .startTime(grid.startTime()) .endTime(grid.endTime()) .interval(grid.interval()) .build(); } Dataset dataset = RasterUtils.getDatasetFromVortexGrid(gridOut); ArrayList<String> gdalOptions = new ArrayList<>(); gdalOptions.add("-of"); gdalOptions.add("AAIGrid"); gdalOptions.add("-co"); gdalOptions.add("FORCE_CELLSIZE=TRUE"); TranslateOptions translateOptions = new TranslateOptions(new Vector<>(gdalOptions)); Dataset out = gdal.Translate(destination.toString(), dataset, translateOptions); out.FlushCache(); out.delete(); }); } AscDataWriter(DataWriterBuilder builder); }
AscDataWriter extends DataWriter { @Override public void write() { List<VortexGrid> grids = data.stream() .filter(vortexData -> vortexData instanceof VortexGrid) .map(vortexData -> (VortexGrid) vortexData) .collect(Collectors.toList()); grids.forEach(grid -> { VortexGrid gridOut; if (grid.dy() < 0){ gridOut = grid; } else { float[] flipped = MatrixUtils.flipArray(grid.data(), grid.nx(), grid.ny()); gridOut = VortexGrid.builder() .dx(grid.dx()).dy(grid.dy()) .nx(grid.nx()).ny(grid.ny()) .originX(grid.originX()) .originY(grid.originY() + grid.dy() * grid.ny()) .wkt(grid.wkt()) .data(flipped) .units(grid.units()) .fileName(grid.fileName()) .shortName(grid.shortName()) .fullName(grid.fullName()) .description(grid.description()) .startTime(grid.startTime()) .endTime(grid.endTime()) .interval(grid.interval()) .build(); } Dataset dataset = RasterUtils.getDatasetFromVortexGrid(gridOut); ArrayList<String> gdalOptions = new ArrayList<>(); gdalOptions.add("-of"); gdalOptions.add("AAIGrid"); gdalOptions.add("-co"); gdalOptions.add("FORCE_CELLSIZE=TRUE"); TranslateOptions translateOptions = new TranslateOptions(new Vector<>(gdalOptions)); Dataset out = gdal.Translate(destination.toString(), dataset, translateOptions); out.FlushCache(); out.delete(); }); } AscDataWriter(DataWriterBuilder builder); @Override void write(); }
AscDataWriter extends DataWriter { @Override public void write() { List<VortexGrid> grids = data.stream() .filter(vortexData -> vortexData instanceof VortexGrid) .map(vortexData -> (VortexGrid) vortexData) .collect(Collectors.toList()); grids.forEach(grid -> { VortexGrid gridOut; if (grid.dy() < 0){ gridOut = grid; } else { float[] flipped = MatrixUtils.flipArray(grid.data(), grid.nx(), grid.ny()); gridOut = VortexGrid.builder() .dx(grid.dx()).dy(grid.dy()) .nx(grid.nx()).ny(grid.ny()) .originX(grid.originX()) .originY(grid.originY() + grid.dy() * grid.ny()) .wkt(grid.wkt()) .data(flipped) .units(grid.units()) .fileName(grid.fileName()) .shortName(grid.shortName()) .fullName(grid.fullName()) .description(grid.description()) .startTime(grid.startTime()) .endTime(grid.endTime()) .interval(grid.interval()) .build(); } Dataset dataset = RasterUtils.getDatasetFromVortexGrid(gridOut); ArrayList<String> gdalOptions = new ArrayList<>(); gdalOptions.add("-of"); gdalOptions.add("AAIGrid"); gdalOptions.add("-co"); gdalOptions.add("FORCE_CELLSIZE=TRUE"); TranslateOptions translateOptions = new TranslateOptions(new Vector<>(gdalOptions)); Dataset out = gdal.Translate(destination.toString(), dataset, translateOptions); out.FlushCache(); out.delete(); }); } AscDataWriter(DataWriterBuilder builder); @Override void write();  }