wuww
2025-04-15 2975fe8b88c0dd70a2dd5e06ad2fcd7d375c5043
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package com.se.nsl;
 
import com.se.nsl.helper.GdalHelper;
import org.gdal.gdal.Dataset;
import org.gdal.gdal.Driver;
import org.gdal.gdal.gdal;
import org.gdal.gdalconst.gdalconst;
import org.gdal.gdalconst.gdalconstConstants;
import org.junit.Test;
import org.springframework.boot.test.context.SpringBootTest;
 
import com.alibaba.fastjson.JSONObject;
import java.io.File;
import java.io.IOException;
import java.net.*;
import java.nio.ByteBuffer;
import java.nio.channels.DatagramChannel;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
 
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
public class AppTest {
    @Test
    public void procDepthFiles() {
        String path = "D:\\other\\simu\\uwsolver\\20250412\\depth";
        for (File file : new File(path).listFiles()) {
            if (!file.exists() || !file.isDirectory()) continue;
 
            File tif = new File(path + "\\" + file.getName() + "\\depth.tif");
            if (!tif.exists() || tif.isDirectory()) continue;
 
            File newFile = new File(path + "\\2025041200" + file.getName() + ".tif");
            System.out.println(newFile.getPath());
            tif.renameTo(newFile);
            file.delete();
        }
    }
 
    //@Test
    public void readZarr() throws Exception {
        GdalHelper.init("D:\\soft\\release-1928-x64-dev\\release-1928-x64\\bin");
 
        String zarrPath = "D:\\other\\simu\\CudaUWSolver.zarr";
        Dataset ds = null;
        try {
            Driver driver = gdal.GetDriverByName("Zarr");
            ds = gdal.Open(zarrPath, gdalconst.GA_ReadOnly);
            if (null == ds || ds.getRasterCount() < 1) return;
 
            System.out.println(ds.getRasterCount());
        } finally {
            if (null != ds) ds.delete();
        }
    }
 
    //@Test
    public void readZarr2() throws Exception {
        String zarrInputPath = "D:\\other\\simu\\out\\out.zarr";
        gdal.AllRegister();
        System.out.println("GDAL Initialized. Version: " + gdal.VersionInfo("RELEASE_NAME"));
 
        Dataset inputDataset = gdal.Open(zarrInputPath, gdalconst.GA_ReadOnly);
 
        if (inputDataset == null) {
            System.err.println("Could not open input dataset: " + zarrInputPath);
            return;
        }
 
        System.out.println("Successfully opened");
        System.out.println(
                "Driver: " + inputDataset.GetDriver().getShortName() + "/" + inputDataset.GetDriver().getLongName());
        System.out.println("Size: " + inputDataset.getRasterXSize() + "x" + inputDataset.getRasterYSize() + "x"
                + inputDataset.getRasterCount());
    }
}