New SMAP format
This commit is contained in:
@ -1,5 +1,5 @@
|
|||||||
server:
|
server:
|
||||||
port: 8083
|
port: 8085
|
||||||
ssl:
|
ssl:
|
||||||
key-store: classpath:keystore.jks
|
key-store: classpath:keystore.jks
|
||||||
key-store-password: QyKtWPZB
|
key-store-password: QyKtWPZB
|
||||||
|
|||||||
@ -2,13 +2,13 @@ package org.ccalm.weather;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Arrays;
|
import java.time.LocalDate;
|
||||||
import java.util.Calendar;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.IntStream;
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
|
|
||||||
import org.springframework.http.CacheControl;
|
import org.springframework.http.CacheControl;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||||
@ -64,6 +64,7 @@ public class GeoTIFFList {
|
|||||||
String NDWIPath="/opt/tomcat/geoserver/ROOT/data/GeoTIFF/NDWI";
|
String NDWIPath="/opt/tomcat/geoserver/ROOT/data/GeoTIFF/NDWI";
|
||||||
String NDSIPath="/opt/tomcat/geoserver/ROOT/data/GeoTIFF/NDSI";
|
String NDSIPath="/opt/tomcat/geoserver/ROOT/data/GeoTIFF/NDSI";
|
||||||
String SMAPPath="/opt/tomcat/geoserver/ROOT/data/GeoTIFF/SMAP";
|
String SMAPPath="/opt/tomcat/geoserver/ROOT/data/GeoTIFF/SMAP";
|
||||||
|
String SMAPPath2="/opt/geodata/SMAP";
|
||||||
String osName=System.getProperty("os.name");
|
String osName=System.getProperty("os.name");
|
||||||
if(osName.indexOf("Windows")>=0){
|
if(osName.indexOf("Windows")>=0){
|
||||||
NDVIPath="O:\\temp\\CCALM\\NDVI";
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user