Compare commits

...

4 Commits

Author SHA1 Message Date
17d0649cee log 2025-09-15 07:25:08 +05:00
068597b414 New SMAP format 2025-09-08 07:28:49 +05:00
29fa1e5860 New server nomads.ncep.noaa.gov 2025-07-14 21:08:37 +05:00
fe4ca18541 Set APP short name 2025-06-30 07:29:56 +05:00
7 changed files with 120 additions and 38 deletions

View File

@ -1,5 +1,5 @@
server:
port: 8083
port: 8085
ssl:
key-store: classpath:keystore.jks
key-store-password: QyKtWPZB
@ -22,16 +22,16 @@ custom:
data_dir: /data/
db_all:
#url: jdbc:postgresql://92.46.48.43:5444/weather?ApplicationName=kz_mcp_weather&sslmode=require
url: jdbc:postgresql://192.168.0.90:5432/weather?ApplicationName=kz_mcp_weather&sslmode=require
#url: jdbc:postgresql://127.0.0.1:5432/weather?ApplicationName=kz_mcp_weather&sslmode=require
#url: jdbc:postgresql://192.168.0.90:5432/weather?ApplicationName=kz_mcp_weather&sslmode=require
url: jdbc:postgresql://127.0.0.1:5432/weather?ApplicationName=kz_mcp_weather&sslmode=require
login: postgres
password: PasSecrKey1
password: 309A86FF65A78FB428F4E38DFE35F730
db_ru:
#url: jdbc:postgresql://92.46.48.43:5444/weather_ru?ApplicationName=kz_mcp_weather&sslmode=require
url: jdbc:postgresql://192.168.0.90:5432/weather_ru?ApplicationName=kz_mcp_weather&sslmode=require
#url: jdbc:postgresql://127.0.0.1:5432/weather_ru?ApplicationName=kz_mcp_weather&sslmode=require
#url: jdbc:postgresql://192.168.0.90:5432/weather_ru?ApplicationName=kz_mcp_weather&sslmode=require
url: jdbc:postgresql://127.0.0.1:5432/weather_ru?ApplicationName=kz_mcp_weather&sslmode=require
login: postgres
password: PasSecrKey1
password: 309A86FF65A78FB428F4E38DFE35F730
springdoc:

17
pom.xml
View File

@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.4.2</version>
<version>3.5.5</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>org.ccalm</groupId>
@ -40,11 +40,7 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
<version>6.6</version>
</dependency>
<!--dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
@ -95,12 +91,16 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
<version>8.1</version>
</dependency>
</dependencies>
<build>
<finalName>org-ccalm-weather</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
@ -127,4 +127,5 @@
</plugins>
</build>
</project>

View File

@ -91,7 +91,10 @@ public class AirTemperature implements ServletContextAware {
*/
@RequestMapping(value = "/geodatalist/AirTemperature",method = RequestMethod.GET,produces = "text/html;charset=UTF-8")
@ResponseBody
public Object ajaxTamer(/*@RequestParam(required=true,name="forecast") String forecast,*/@RequestParam(required=false,name="date") String date) {
public Object ajaxTamer(
/*@RequestParam(required=true,name="forecast") String forecast,*/
@RequestParam(required=false,name="date") String date
) {
String forecast = "000";
String result="";
@ -142,7 +145,8 @@ public class AirTemperature implements ServletContextAware {
String measurement = "TMP:2 m above ground";
//Build URL to download
String URL = "https://www.ftp.ncep.noaa.gov/data/nccf/com/gfs/prod/gfs."+date+"/"+time+"/atmos/gfs.t"+time+"z.pgrb2.0p25.f"+forecast;
//String URL = "https://www.ftp.ncep.noaa.gov/data/nccf/com/gfs/prod/gfs."+date+"/"+time+"/atmos/gfs.t"+time+"z.pgrb2.0p25.f"+forecast;
String URL = "https://nomads.ncep.noaa.gov/pub/data/nccf/com/gfs/prod/gfs."+date+"/"+time+"/atmos/gfs.t"+time+"z.pgrb2.0p25.f"+forecast;
File f1 = new File(data_dir+"temp"+File.separator+"air_text.idx");
if(f1.exists()) {

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;
}
}

View File

@ -159,7 +159,8 @@ public class Precipitation implements ServletContextAware {
String measurement = "APCP:surface:0-1 day acc fcst";
//Build URL to download
String URL = "https://www.ftp.ncep.noaa.gov/data/nccf/com/gfs/prod/gfs."+date+"/"+time+"/atmos/gfs.t"+time+"z.pgrb2.0p25.f"+forecast;
//String URL = "https://www.ftp.ncep.noaa.gov/data/nccf/com/gfs/prod/gfs."+date+"/"+time+"/atmos/gfs.t"+time+"z.pgrb2.0p25.f"+forecast;
String URL = "https://nomads.ncep.noaa.gov/pub/data/nccf/com/gfs/prod/gfs."+date+"/"+time+"/atmos/gfs.t"+time+"z.pgrb2.0p25.f"+forecast;
File f1 = new File(data_dir+"temp"+File.separator+"pre_text.idx");
if(f1.exists()) {

View File

@ -101,7 +101,7 @@ public class SoilTmperature implements ServletContextAware {
}*/
//---------------------------------------------------------------------------
/**
* Example: http://127.0.0.1:8081/geodatalist/DownloadSoil?forecast=000
* Example: https://127.0.0.1:8083/geodatalist/DownloadSoil?forecast=000
* @param response
* @param forecast
* @param date
@ -165,7 +165,8 @@ public class SoilTmperature implements ServletContextAware {
//String measurement = "TSOIL:0.1-0.4 m below ground";
//Build URL to download
String URL = "https://www.ftp.ncep.noaa.gov/data/nccf/com/gfs/prod/gfs."+date+"/"+time+"/atmos/gfs.t"+time+"z.pgrb2.0p25.f"+forecast;
//String URL = "https://www.ftp.ncep.noaa.gov/data/nccf/com/gfs/prod/gfs."+date+"/"+time+"/atmos/gfs.t"+time+"z.pgrb2.0p25.f"+forecast;
String URL = "https://nomads.ncep.noaa.gov/pub/data/nccf/com/gfs/prod/gfs."+date+"/"+time+"/atmos/gfs.t"+time+"z.pgrb2.0p25.f"+forecast;
File f1 = new File(data_dir+"temp"+File.separator+"text.idx");
if(f1.exists()) {
@ -550,7 +551,7 @@ public class SoilTmperature implements ServletContextAware {
}
//---------------------------------------------------------------------------
//Weighted interpolation
@RequestMapping(value = "/geodatalist/getSoil",method = {RequestMethod.POST,RequestMethod.GET},produces = "application/json;charset=utf-8")
@RequestMapping(value = "/geodatalist/getSoilTemperature",method = {RequestMethod.POST,RequestMethod.GET},produces = "application/json;charset=utf-8")
@ResponseBody
public ResponseEntity<Object> getSoil(HttpServletResponse response, HttpServletRequest request, @RequestBody PointModel pointModel, @CookieValue(value = "lng", defaultValue = "1") String language_id) {
String headerValue = CacheControl.maxAge(60, TimeUnit.SECONDS).getHeaderValue();

View File

@ -1,32 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!-- Please check if the user has access to the directory from which the application is being executed -->
<!-- Ваш кастомный conversionRule для single-line исключений -->
<conversionRule conversionWord="exOneLine" converterClass="org.ccalm.dbms.SingleLineThrowableProxyConverter"/>
<property name="LOGS" value="logs" />
<springProperty scope="context" name="appName" source="spring.application.name"/>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOGS}/${appName}.log</file>
<encoder>
<pattern>{"timestamp":"%d{yyyy-MM-dd'T'HH:mm:ss.SSS'Z'}","thread":"[%thread]","level":"%level","logger":"%logger{36}","marker":"%X{marker}","message":"%msg"}%n</pattern>
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
<!-- Кастомные имена полей -->
<fieldNames>
<timestamp>timestamp</timestamp> <!-- Без @ -->
<level>level</level>
<message>message</message>
<stack_trace>exception</stack_trace>
<version>[ignore]</version>
<threadName>[ignore]</threadName>
<loggerName>[ignore]</loggerName>
<levelValue>[ignore]</levelValue>
<mdc>[ignore]</mdc>
</fieldNames>
<!-- Формат timestamp -->
<timestampPattern>yyyy-MM-dd'T'HH:mm:ss.SSS'Z'</timestampPattern>
<timestampTimeZone>UTC</timestampTimeZone>
<!-- Включаем маркеры (tags для MarkerFactory) -->
<includeTags>true</includeTags>
<!-- Отключаем лишние данные -->
<includeCallerData>false</includeCallerData>
<includeContext>false</includeContext>
<!-- Single-line исключения -->
<throwableConverter class="net.logstash.logback.stacktrace.ShortenedThrowableConverter">
<maxDepthPerThrowable>1</maxDepthPerThrowable>
<maxLength>1024</maxLength>
<shortenedClassNameLength>20</shortenedClassNameLength>
<exclude>$$FastClassByCGLIB$$</exclude>
<exclude>$$EnhancerBySpringCGLIB$$</exclude>
</throwableConverter>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOGS}/${appName}.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<maxHistory>30</maxHistory>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<maxHistory>30</maxHistory>
<totalSizeCap>3GB</totalSizeCap>
</rollingPolicy>
</appender>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{yyyy-MM-dd'T'HH:mm:ss.SSS'Z'} | %level | %logger{36} | %X{marker} | %msg%n</pattern>
<pattern>
%d{yyyy-MM-dd'T'HH:mm:ss.SSS'Z'} | %level | %logger{36} | %marker | %msg%n
</pattern>
</encoder>
</appender>
<!--root level="info"-->
<root level="warn">
<root level="info">
<appender-ref ref="FILE" />
<appender-ref ref="CONSOLE" />
</root>