New SMAP format

This commit is contained in:
2025-09-08 07:28:49 +05:00
parent 29fa1e5860
commit 068597b414
3 changed files with 48 additions and 6 deletions

View File

@ -1,5 +1,5 @@
server:
port: 8083
port: 8085
ssl:
key-store: classpath:keystore.jks
key-store-password: QyKtWPZB

View File

@ -2,13 +2,13 @@ package org.ccalm.weather;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.List;
import java.util.*;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.concurrent.TimeUnit;
import java.util.stream.IntStream;
import org.springframework.http.CacheControl;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
@ -64,6 +64,7 @@ public class GeoTIFFList {
String NDWIPath="/opt/tomcat/geoserver/ROOT/data/GeoTIFF/NDWI";
String NDSIPath="/opt/tomcat/geoserver/ROOT/data/GeoTIFF/NDSI";
String SMAPPath="/opt/tomcat/geoserver/ROOT/data/GeoTIFF/SMAP";
String SMAPPath2="/opt/geodata/SMAP";
String osName=System.getProperty("os.name");
if(osName.indexOf("Windows")>=0){
NDVIPath="O:\\temp\\CCALM\\NDVI";
@ -227,6 +228,47 @@ public class GeoTIFFList {
}
}
if (fn.equals("smap_list2")) {
List<LocalDate> dateList = new ArrayList<>();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
File root = new File(SMAPPath2);
File[] yearDirs = root.listFiles(File::isDirectory);
if (yearDirs != null) {
for (File yearDir : yearDirs) {
File[] files = yearDir.listFiles((dir, name) -> name.toLowerCase().endsWith(".tiff"));
if (files != null) {
for (File file : files) {
String fileName = file.getName(); // "2025-01-30.tiff"
String datePart = fileName.substring(0, fileName.indexOf('.')); // "2025-01-30"
try {
LocalDate date = LocalDate.parse(datePart, formatter);
dateList.add(date);
} catch (Exception e) {
// если имя файла не в формате даты — пропускаем
}
}
}
}
}
// Убираем дубликаты и сортируем
TreeSet<LocalDate> uniqueSorted = new TreeSet<>(dateList);
if (!uniqueSorted.isEmpty()) {
StringBuilder sb = new StringBuilder("[");
for (LocalDate date : uniqueSorted) {
String strDate = date.format(formatter);
sb.append("{\"date\":\"").append(strDate).append("\"},");
}
sb.setLength(sb.length() - 1); // убрать последнюю запятую
sb.append("]");
result = sb.toString();
} else {
result = "[]";
}
}
return result;
}
}