SMAP
This commit is contained in:
2
pom.xml
2
pom.xml
@ -10,7 +10,7 @@
|
||||
</parent>
|
||||
<groupId>org.ccalm</groupId>
|
||||
<artifactId>main</artifactId>
|
||||
<version>1.0.6</version>
|
||||
<version>1.0.7</version>
|
||||
<name>main</name>
|
||||
<description>main</description>
|
||||
<properties>
|
||||
|
||||
@ -3081,7 +3081,7 @@ public class AcceptASDCController implements ServletContextAware {
|
||||
}
|
||||
|
||||
//@RequestMapping(value = {"/get", "/api/locust/v01/"},params = {"fn"},method = { RequestMethod.GET, RequestMethod.POST })
|
||||
//Для проверки какие фото есть на сервере а каких нет чтобы удалить из имена фотографий которых нет в базе
|
||||
//Для проверки какие фото есть на сервере а каких нет чтобы удалить имена фотографий которых нет в базе
|
||||
@RequestMapping(value = {"/photolist", "/api/locust/v01/"},method = RequestMethod.GET, produces = "text/html")
|
||||
@ResponseBody
|
||||
public Object getPhotoList() {
|
||||
|
||||
@ -66,9 +66,11 @@ public class QGIS implements ServletContextAware {
|
||||
// return new User("none");
|
||||
//}
|
||||
|
||||
//TEST https://127.0.0.1:8083/api/locust/v01/QGIS?name=SMAP&date=2025-05-30
|
||||
//TEST https://ccalm.org/api/locust/v01/QGIS?name=SMAP&day=150
|
||||
@RequestMapping(value = {"/QGIS", "/api/locust/v01/QGIS"},method = RequestMethod.GET,produces = "application/octet-stream")
|
||||
@ResponseBody
|
||||
public HttpEntity<byte[]> ajaxTamer(@ModelAttribute User user, @RequestParam(required=false,name="day") String day, @RequestParam(required=false,name="name") String name, @RequestParam(required=false,name="time") String time, @RequestParam(required=false,name="time_start") String time_start, @RequestParam(required=false,name="time_end") String time_end, @RequestParam(required=false,name="country_id") String country_id, @RequestParam(required=false,name="locust_type_id") String locust_type_id, @RequestParam(required=false,name="date_start") String date_start, @RequestParam(required=false,name="date_end") String date_end, @RequestParam(required=false,name="registered") String registered, @RequestParam(required=false,name="year") String year, @RequestParam(required=false,name="region_id") String region_id, @RequestParam(required=false,name="country_name") String country_name, @RequestParam(required=false,name="lng") String language_id, HttpServletResponse response)
|
||||
public HttpEntity<byte[]> ajaxTamer(@ModelAttribute User user, @RequestParam(required=false,name="day") String day,@RequestParam(required=false,name="date") String date, @RequestParam(required=false,name="name") String name, @RequestParam(required=false,name="time") String time, @RequestParam(required=false,name="time_start") String time_start, @RequestParam(required=false,name="time_end") String time_end, @RequestParam(required=false,name="country_id") String country_id, @RequestParam(required=false,name="locust_type_id") String locust_type_id, @RequestParam(required=false,name="date_start") String date_start, @RequestParam(required=false,name="date_end") String date_end, @RequestParam(required=false,name="registered") String registered, @RequestParam(required=false,name="year") String year, @RequestParam(required=false,name="region_id") String region_id, @RequestParam(required=false,name="country_name") String country_name, @RequestParam(required=false,name="lng") String language_id, HttpServletResponse response)
|
||||
{
|
||||
if(language_id!=null && !language_id.isEmpty()) user.language_id=language_id;
|
||||
logger.info("user.id="+user.id+" user.name="+user.name+" user.language_id="+user.language_id);
|
||||
@ -96,7 +98,7 @@ public class QGIS implements ServletContextAware {
|
||||
//Pods (кубышки)
|
||||
if(name!=null && (name.equals("frmlocust_pods_density") || name.equals("frmlocust_hoppers_density") || name.equals("frmlocust_bands") || name.equals("frmlocust_adults_density") || name.equals("frmlocust_swarms")))
|
||||
{
|
||||
fileAsString = fileToString(context.getRealPath("/resources/QGIS/" + name + ".qgs"));
|
||||
fileAsString = fileToString("static/resources/QGIS/" + name + ".qgs");
|
||||
|
||||
//String country_id=request.getParameter("country_id");
|
||||
//String locust_type_id=request.getParameter("locust_type_id");
|
||||
@ -154,7 +156,7 @@ public class QGIS implements ServletContextAware {
|
||||
|
||||
if(name!=null && name.equals("frmlocustdel"))
|
||||
{
|
||||
fileAsString = fileToString(context.getRealPath("/resources/QGIS/" + name + ".qgs"));
|
||||
fileAsString = fileToString("static/resources/QGIS/" + name + ".qgs");
|
||||
|
||||
//String country_id=request.getParameter("country_id");
|
||||
//String date_start=request.getParameter("date_start");
|
||||
@ -231,7 +233,7 @@ public class QGIS implements ServletContextAware {
|
||||
sql+=" and locust_type_id="+locust_type_id;
|
||||
}
|
||||
|
||||
fileAsString = fileToString(context.getRealPath("/resources/QGIS/" + name + ".qgs"));
|
||||
fileAsString = fileToString("static/resources/QGIS/" + name + ".qgs");
|
||||
//Apply variables to text
|
||||
fileAsString=fileAsString.replaceAll("\\$\\{year\\}",year);
|
||||
fileAsString=fileAsString.replaceAll("\\$\\{sql\\}",sql);
|
||||
@ -254,7 +256,7 @@ public class QGIS implements ServletContextAware {
|
||||
sql+=" and locust_type_id="+locust_type_id;
|
||||
}
|
||||
|
||||
fileAsString = fileToString(context.getRealPath("/resources/QGIS/" + name + ".qgs"));
|
||||
fileAsString = fileToString("static/resources/QGIS/" + name + ".qgs");
|
||||
//Apply variables to text
|
||||
fileAsString=fileAsString.replaceAll("\\$\\{year\\}",year);
|
||||
fileAsString=fileAsString.replaceAll("\\$\\{sql\\}",sql);
|
||||
@ -277,7 +279,7 @@ public class QGIS implements ServletContextAware {
|
||||
}
|
||||
}
|
||||
|
||||
fileAsString = fileToString(context.getRealPath("/resources/QGIS/" + name + ".qgs"));
|
||||
fileAsString = fileToString("static/resources/QGIS/" + name + ".qgs");
|
||||
//Apply variables to text
|
||||
fileAsString=fileAsString.replaceAll("\\$\\{country\\}",country_name);
|
||||
fileAsString=fileAsString.replaceAll("\\$\\{sql2\\}",sql2);
|
||||
@ -301,7 +303,7 @@ public class QGIS implements ServletContextAware {
|
||||
}
|
||||
}
|
||||
|
||||
fileAsString = fileToString(context.getRealPath("/resources/QGIS/" + name + ".qgs"));
|
||||
fileAsString = fileToString("static/resources/QGIS/" + name + ".qgs");
|
||||
//Apply variables to text
|
||||
fileAsString=fileAsString.replaceAll("\\$\\{country\\}",country_name);
|
||||
fileAsString=fileAsString.replaceAll("\\$\\{sql2\\}",sql2);
|
||||
@ -325,7 +327,7 @@ public class QGIS implements ServletContextAware {
|
||||
}
|
||||
}
|
||||
|
||||
fileAsString = fileToString(context.getRealPath("/resources/QGIS/" + name + ".qgs"));
|
||||
fileAsString = fileToString("static/resources/QGIS/" + name + ".qgs");
|
||||
//Apply variables to text
|
||||
fileAsString=fileAsString.replaceAll("\\$\\{country\\}",country_name);
|
||||
fileAsString=fileAsString.replaceAll("\\$\\{sql2\\}",sql2);
|
||||
@ -349,7 +351,7 @@ public class QGIS implements ServletContextAware {
|
||||
}
|
||||
}
|
||||
|
||||
fileAsString = fileToString(context.getRealPath("/resources/QGIS/" + name + ".qgs"));
|
||||
fileAsString = fileToString("static/resources/QGIS/" + name + ".qgs");
|
||||
//Apply variables to text
|
||||
fileAsString=fileAsString.replaceAll("\\$\\{country\\}",country_name);
|
||||
fileAsString=fileAsString.replaceAll("\\$\\{sql2\\}",sql2);
|
||||
@ -358,7 +360,7 @@ public class QGIS implements ServletContextAware {
|
||||
}
|
||||
if(name!=null && name.equals("NDVI"))
|
||||
{
|
||||
fileAsString = fileToString(context.getRealPath("/resources/QGIS/NDVI.qgs"));
|
||||
fileAsString = fileToString("static/resources/QGIS/NDVI.qgs");
|
||||
if(day!=null && day.length()>0)
|
||||
fileAsString = fileAsString.replaceAll("\\$\\{day\\}",day+"_");
|
||||
else
|
||||
@ -366,7 +368,7 @@ public class QGIS implements ServletContextAware {
|
||||
}
|
||||
if(name!=null && name.equals("NDWI"))
|
||||
{
|
||||
fileAsString = fileToString(context.getRealPath("/resources/QGIS/NDWI.qgs"));
|
||||
fileAsString = fileToString("static/resources/QGIS/NDWI.qgs");
|
||||
if(day!=null && day.length()>0)
|
||||
fileAsString = fileAsString.replaceAll("\\$\\{day\\}",day+"_");
|
||||
else
|
||||
@ -374,7 +376,7 @@ public class QGIS implements ServletContextAware {
|
||||
}
|
||||
if(name!=null && name.equals("IVI"))
|
||||
{
|
||||
fileAsString = fileToString(context.getRealPath("/resources/QGIS/IVI.qgs"));
|
||||
fileAsString = fileToString("static/resources/QGIS/IVI.qgs");
|
||||
if(year!=null && year.length()>0)
|
||||
fileAsString = fileAsString.replaceAll("\\$\\{year\\}",year+"_");
|
||||
else
|
||||
@ -382,7 +384,7 @@ public class QGIS implements ServletContextAware {
|
||||
}
|
||||
if(name!=null && name.equals("NDWI_CMP"))
|
||||
{
|
||||
fileAsString = fileToString(context.getRealPath("/resources/QGIS/NDWI_CMP.qgs"));
|
||||
fileAsString = fileToString("static/resources/QGIS/NDWI_CMP.qgs");
|
||||
if(day!=null && day.length()>0)
|
||||
fileAsString = fileAsString.replaceAll("\\$\\{day\\}",day+"_");
|
||||
else
|
||||
@ -390,19 +392,19 @@ public class QGIS implements ServletContextAware {
|
||||
}
|
||||
if(name!=null && name.equals("NDSI"))
|
||||
{
|
||||
fileAsString = fileToString(context.getRealPath("/resources/QGIS/NDSI.qgs"));
|
||||
fileAsString = fileToString("static/resources/QGIS/NDSI.qgs");
|
||||
if(day!=null && day.length()>0)
|
||||
fileAsString = fileAsString.replaceAll("\\$\\{day\\}",day+"_");
|
||||
else
|
||||
fileAsString = fileAsString.replaceAll("\\$\\{day\\}","");
|
||||
}
|
||||
if(name!=null && name.equals("SMAP"))
|
||||
if(name!=null && name.equals("SMAP")) //https://127.0.0.1:8083/api/locust/v01/QGIS?name=SMAP&date=2025-05-30
|
||||
{
|
||||
fileAsString = fileToString(context.getRealPath("/resources/QGIS/SMAP.qgs"));
|
||||
if(day!=null && day.length()>0)
|
||||
fileAsString = fileAsString.replaceAll("\\$\\{day\\}",day+"_");
|
||||
fileAsString = fileToString("static/resources/QGIS/SMAP.qgs");
|
||||
if(date!=null && !date.isEmpty())
|
||||
fileAsString = fileAsString.replaceAll("\\$\\{date\\}",date);
|
||||
else
|
||||
fileAsString = fileAsString.replaceAll("\\$\\{day\\}","");
|
||||
fileAsString = fileAsString.replaceAll("\\$\\{date\\}","");
|
||||
}
|
||||
|
||||
//Send data
|
||||
@ -415,27 +417,42 @@ public class QGIS implements ServletContextAware {
|
||||
this.context=servletContext;
|
||||
}
|
||||
|
||||
public String fileToString(String fName)
|
||||
{
|
||||
|
||||
public String fileToString(String fName) {
|
||||
StringBuilder sb = new StringBuilder(1024);
|
||||
try
|
||||
{
|
||||
InputStream is = new FileInputStream(fName);
|
||||
BufferedReader buf = new BufferedReader(new InputStreamReader(is));
|
||||
String line = buf.readLine();
|
||||
while(line != null)
|
||||
{
|
||||
|
||||
// 1. Сначала пробуем как внешний файл
|
||||
try (InputStream is = new FileInputStream(fName);
|
||||
BufferedReader buf = new BufferedReader(new InputStreamReader(is))) {
|
||||
|
||||
String line;
|
||||
while ((line = buf.readLine()) != null) {
|
||||
sb.append(line).append("\n");
|
||||
line = buf.readLine();
|
||||
}
|
||||
buf.close();
|
||||
return sb.toString();
|
||||
|
||||
} catch (Exception e) {
|
||||
System.out.println("Не найден внешний файл, пробую искать в ресурсах: " + fName);
|
||||
}
|
||||
catch (Exception e){
|
||||
System.out.println("Error: "+e.getMessage());
|
||||
|
||||
// 2. Если файла нет, пробуем как ресурс из classpath
|
||||
try (InputStream is = new ClassPathResource(fName).getInputStream();
|
||||
BufferedReader buf = new BufferedReader(new InputStreamReader(is))) {
|
||||
|
||||
String line;
|
||||
while ((line = buf.readLine()) != null) {
|
||||
sb.append(line).append("\n");
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
System.out.println("Ошибка при чтении из ресурсов: " + e.getMessage());
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String trt(Connection conn,String key,User user)
|
||||
{
|
||||
String result="";
|
||||
|
||||
@ -1411,12 +1411,12 @@ new Calendar({
|
||||
if(opt!=null) opt.selected = true;
|
||||
});
|
||||
|
||||
$.getJSON(url+"geodatalist/GeoTIFF?fn=smap_list", function(result){
|
||||
$.getJSON(url+"geodatalist/GeoTIFF?fn=smap_list2", function(result){
|
||||
let list = document.getElementById("filter_smap_day");
|
||||
let opt=null;
|
||||
$.each(result, function(i, field){
|
||||
opt = document.createElement("option");
|
||||
opt.value = field.num;
|
||||
opt.value = field.date;
|
||||
opt.text = field.date;
|
||||
list.add(opt);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user