From 2975fe8b88c0dd70a2dd5e06ad2fcd7d375c5043 Mon Sep 17 00:00:00 2001
From: wuww <252740454@qq.com>
Date: 星期二, 15 四月 2025 09:57:08 +0800
Subject: [PATCH] 修改测试服务(处理源数据文件)

---
 src/test/java/com/se/nsl/AppTest.java |   58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 56 insertions(+), 2 deletions(-)

diff --git a/src/test/java/com/se/nsl/AppTest.java b/src/test/java/com/se/nsl/AppTest.java
index b3a8521..2affd86 100644
--- a/src/test/java/com/se/nsl/AppTest.java
+++ b/src/test/java/com/se/nsl/AppTest.java
@@ -1,5 +1,11 @@
 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;
 
@@ -22,7 +28,55 @@
 @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
 public class AppTest {
     @Test
-    public void t1() {
-        System.out.println("t1...");
+    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());
     }
 }

--
Gitblit v1.9.3