diff --git a/org_ccalm_weather.yml b/org_ccalm_weather.yml
index 71a5023..477f717 100644
--- a/org_ccalm_weather.yml
+++ b/org_ccalm_weather.yml
@@ -22,14 +22,21 @@ 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
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
+
+springdoc:
+ api-docs:
+ path: /api-docs
+ swagger-ui:
+ disable-swagger-default-url: true
+ path: /myproject
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 5551499..27accc2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,86 +1,123 @@
- 4.0.0
-
- org.springframework.boot
- spring-boot-starter-parent
- 3.3.3
-
-
- org.ccalm
- weather
- 0.0.8-SNAPSHOT
- weather
- Weather APP
-
- 21
-
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 3.4.2
+
+
+ org.ccalm
+ weather
+ 0.0.9-SNAPSHOT
+ weather
+ Weather APP
+
+ 21
+
-
-
- unidata
- Unidata UCAR Repository
- https://artifacts.unidata.ucar.edu/content/repositories/unidata-releases/
-
-
+
+
+ unidata
+ Unidata UCAR Repository
+ https://artifacts.unidata.ucar.edu/content/repositories/unidata-releases/
+
+
-
-
- org.springframework.boot
- spring-boot-starter-web
-
-
- org.postgresql
- postgresql
- runtime
-
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
- net.logstash.logback
- logstash-logback-encoder
- 6.6
-
-
-
-
- edu.ucar
- netcdfAll
- 5.3.1
-
-
-
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+ org.postgresql
+ postgresql
+ runtime
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ net.logstash.logback
+ logstash-logback-encoder
+ 6.6
+
+
+ org.json
+ json
+ 20231013
+
+
+
+ com.vaadin.external.google
+ android-json
+ 0.0.20131108.vaadin1
+ runtime
+
+
+ org.json
+ json
+
+
+
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
-
-
- build-info
-
-
-
-
+
+
+ edu.ucar
+ netcdfAll
+ 5.3.1
+
-
- org.apache.maven.plugins
- maven-surefire-plugin
- 2.22.2
-
-
- file:org_ccalm_weather.yml
-
-
-
+
+ org.springdoc
+ springdoc-openapi-starter-webmvc-ui
+ 2.6.0
+
+
+ org.webjars
+ webjars-locator
+ 0.52
+
-
-
+
+ org.projectlombok
+ lombok
+ 1.18.36
+ provided
+
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+ build-info
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 2.22.2
+
+
+ file:org_ccalm_weather.yml
+
+
+
+
+
+
diff --git a/src/main/java/org/ccalm/weather/AirTemperature.java b/src/main/java/org/ccalm/weather/AirTemperature.java
index 7ca3919..5511ac3 100644
--- a/src/main/java/org/ccalm/weather/AirTemperature.java
+++ b/src/main/java/org/ccalm/weather/AirTemperature.java
@@ -4,44 +4,36 @@ import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
-import java.io.PrintWriter;
import java.sql.*;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.Date;
import java.util.concurrent.TimeUnit;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import javax.servlet.ServletContext;
//import javax.servlet.http.HttpServletResponse;
+import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
+import org.ccalm.weather.models.PointModel;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import tools.DBTools;
import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.core.io.ClassPathResource;
import org.springframework.http.CacheControl;
import org.springframework.stereotype.Controller;
-import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.ServletContextAware;
-import org.w3c.dom.Document;
-
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
//import main.DownloadFromHTTP;
-import org.ccalm.weather.WeatherDownload;
import tctable.Tools;
+import tools.StdTools;
import ucar.ma2.Array;
import ucar.nc2.Dimension;
import ucar.nc2.Variable;
import ucar.nc2.dataset.NetcdfDataset;
+import org.json.JSONObject;
@Controller
public class AirTemperature implements ServletContextAware {
@@ -72,6 +64,25 @@ public class AirTemperature implements ServletContextAware {
this.context = servletContext;
}
+ //---------------------------------------------------------------------------
+ public JSONObject createJSONError(int code, String message, String setting, String marker) {
+ JSONObject json = new JSONObject();
+ //try {
+ json.put("error_code", code);
+ if(message!=null && !message.isBlank()) {
+ json.put("error_message", Arrays.asList(message));
+ }
+ if(setting!=null && !setting.isBlank()) {
+ json.put("error_setting", Arrays.asList(setting));
+ }
+ if(marker!=null && !marker.isBlank()) {
+ json.put("error_marker", marker);
+ }
+ //} catch (JSONException e) {
+ // logger.error(e);
+ //}
+ return json;
+ }
//---------------------------------------------------------------------------
/**
* This function is run every day from CRON, to see the settings call the function: "sudo crontab -e -u tomcat" on PC 127.0.0.1
@@ -133,12 +144,18 @@ public class AirTemperature implements ServletContextAware {
//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;
- File f = new File(data_dir+"temp"+File.separator+"air_text.idx");
- if(f.exists()) {
- if (!f.delete()) {
+ File f1 = new File(data_dir+"temp"+File.separator+"air_text.idx");
+ if(f1.exists()) {
+ if (!f1.delete()) {
System.out.println("Failed to delete the file \"air_text.idx\".");
}
}
+ File f2 = new File(data_dir+"temp"+File.separator+"air_text.f000");
+ if(f2.exists()) {
+ if (!f2.delete()) {
+ System.out.println("Failed to delete the file \"air_text.f000\".");
+ }
+ }
WeatherDownload wd = new WeatherDownload();
if(wd.download(URL+".idx", data_dir+"temp"+File.separator+"air_text.idx", "0", ""))
@@ -507,68 +524,90 @@ public class AirTemperature implements ServletContextAware {
}
//---------------------------------------------------------------------------
@CrossOrigin
- @RequestMapping(value = "/geodatalist/getAirTemperature",method = RequestMethod.GET,produces = "application/json;charset=UTF-8")
+ @RequestMapping(value = "/geodatalist/getAirTemperature",method = {RequestMethod.POST,RequestMethod.GET},produces = "application/json;charset=utf-8")
@ResponseBody
- public Object getAirTemperature(@RequestParam("date") String date,@RequestParam("hours") int hours,@RequestParam("lat") double lat, @RequestParam("lon") double lon,HttpServletResponse response) {
-
+ public ResponseEntity