|
|
@@ -66,9 +66,11 @@ public class QGIS implements ServletContextAware {
|
|
|
|
// return new User("none");
|
|
|
|
// 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")
|
|
|
|
@RequestMapping(value = {"/QGIS", "/api/locust/v01/QGIS"},method = RequestMethod.GET,produces = "application/octet-stream")
|
|
|
|
@ResponseBody
|
|
|
|
@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;
|
|
|
|
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);
|
|
|
|
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 (кубышки)
|
|
|
|
//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")))
|
|
|
|
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 country_id=request.getParameter("country_id");
|
|
|
|
//String locust_type_id=request.getParameter("locust_type_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"))
|
|
|
|
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 country_id=request.getParameter("country_id");
|
|
|
|
//String date_start=request.getParameter("date_start");
|
|
|
|
//String date_start=request.getParameter("date_start");
|
|
|
@@ -231,7 +233,7 @@ public class QGIS implements ServletContextAware {
|
|
|
|
sql+=" and locust_type_id="+locust_type_id;
|
|
|
|
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
|
|
|
|
//Apply variables to text
|
|
|
|
fileAsString=fileAsString.replaceAll("\\$\\{year\\}",year);
|
|
|
|
fileAsString=fileAsString.replaceAll("\\$\\{year\\}",year);
|
|
|
|
fileAsString=fileAsString.replaceAll("\\$\\{sql\\}",sql);
|
|
|
|
fileAsString=fileAsString.replaceAll("\\$\\{sql\\}",sql);
|
|
|
@@ -254,7 +256,7 @@ public class QGIS implements ServletContextAware {
|
|
|
|
sql+=" and locust_type_id="+locust_type_id;
|
|
|
|
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
|
|
|
|
//Apply variables to text
|
|
|
|
fileAsString=fileAsString.replaceAll("\\$\\{year\\}",year);
|
|
|
|
fileAsString=fileAsString.replaceAll("\\$\\{year\\}",year);
|
|
|
|
fileAsString=fileAsString.replaceAll("\\$\\{sql\\}",sql);
|
|
|
|
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
|
|
|
|
//Apply variables to text
|
|
|
|
fileAsString=fileAsString.replaceAll("\\$\\{country\\}",country_name);
|
|
|
|
fileAsString=fileAsString.replaceAll("\\$\\{country\\}",country_name);
|
|
|
|
fileAsString=fileAsString.replaceAll("\\$\\{sql2\\}",sql2);
|
|
|
|
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
|
|
|
|
//Apply variables to text
|
|
|
|
fileAsString=fileAsString.replaceAll("\\$\\{country\\}",country_name);
|
|
|
|
fileAsString=fileAsString.replaceAll("\\$\\{country\\}",country_name);
|
|
|
|
fileAsString=fileAsString.replaceAll("\\$\\{sql2\\}",sql2);
|
|
|
|
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
|
|
|
|
//Apply variables to text
|
|
|
|
fileAsString=fileAsString.replaceAll("\\$\\{country\\}",country_name);
|
|
|
|
fileAsString=fileAsString.replaceAll("\\$\\{country\\}",country_name);
|
|
|
|
fileAsString=fileAsString.replaceAll("\\$\\{sql2\\}",sql2);
|
|
|
|
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
|
|
|
|
//Apply variables to text
|
|
|
|
fileAsString=fileAsString.replaceAll("\\$\\{country\\}",country_name);
|
|
|
|
fileAsString=fileAsString.replaceAll("\\$\\{country\\}",country_name);
|
|
|
|
fileAsString=fileAsString.replaceAll("\\$\\{sql2\\}",sql2);
|
|
|
|
fileAsString=fileAsString.replaceAll("\\$\\{sql2\\}",sql2);
|
|
|
@@ -358,7 +360,7 @@ public class QGIS implements ServletContextAware {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(name!=null && name.equals("NDVI"))
|
|
|
|
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)
|
|
|
|
if(day!=null && day.length()>0)
|
|
|
|
fileAsString = fileAsString.replaceAll("\\$\\{day\\}",day+"_");
|
|
|
|
fileAsString = fileAsString.replaceAll("\\$\\{day\\}",day+"_");
|
|
|
|
else
|
|
|
|
else
|
|
|
@@ -366,7 +368,7 @@ public class QGIS implements ServletContextAware {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(name!=null && name.equals("NDWI"))
|
|
|
|
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)
|
|
|
|
if(day!=null && day.length()>0)
|
|
|
|
fileAsString = fileAsString.replaceAll("\\$\\{day\\}",day+"_");
|
|
|
|
fileAsString = fileAsString.replaceAll("\\$\\{day\\}",day+"_");
|
|
|
|
else
|
|
|
|
else
|
|
|
@@ -374,7 +376,7 @@ public class QGIS implements ServletContextAware {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(name!=null && name.equals("IVI"))
|
|
|
|
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)
|
|
|
|
if(year!=null && year.length()>0)
|
|
|
|
fileAsString = fileAsString.replaceAll("\\$\\{year\\}",year+"_");
|
|
|
|
fileAsString = fileAsString.replaceAll("\\$\\{year\\}",year+"_");
|
|
|
|
else
|
|
|
|
else
|
|
|
@@ -382,7 +384,7 @@ public class QGIS implements ServletContextAware {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(name!=null && name.equals("NDWI_CMP"))
|
|
|
|
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)
|
|
|
|
if(day!=null && day.length()>0)
|
|
|
|
fileAsString = fileAsString.replaceAll("\\$\\{day\\}",day+"_");
|
|
|
|
fileAsString = fileAsString.replaceAll("\\$\\{day\\}",day+"_");
|
|
|
|
else
|
|
|
|
else
|
|
|
@@ -390,19 +392,19 @@ public class QGIS implements ServletContextAware {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(name!=null && name.equals("NDSI"))
|
|
|
|
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)
|
|
|
|
if(day!=null && day.length()>0)
|
|
|
|
fileAsString = fileAsString.replaceAll("\\$\\{day\\}",day+"_");
|
|
|
|
fileAsString = fileAsString.replaceAll("\\$\\{day\\}",day+"_");
|
|
|
|
else
|
|
|
|
else
|
|
|
|
fileAsString = fileAsString.replaceAll("\\$\\{day\\}","");
|
|
|
|
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"));
|
|
|
|
fileAsString = fileToString("static/resources/QGIS/SMAP.qgs");
|
|
|
|
if(day!=null && day.length()>0)
|
|
|
|
if(date!=null && !date.isEmpty())
|
|
|
|
fileAsString = fileAsString.replaceAll("\\$\\{day\\}",day+"_");
|
|
|
|
fileAsString = fileAsString.replaceAll("\\$\\{date\\}",date);
|
|
|
|
else
|
|
|
|
else
|
|
|
|
fileAsString = fileAsString.replaceAll("\\$\\{day\\}","");
|
|
|
|
fileAsString = fileAsString.replaceAll("\\$\\{date\\}","");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//Send data
|
|
|
|
//Send data
|
|
|
@@ -415,27 +417,42 @@ public class QGIS implements ServletContextAware {
|
|
|
|
this.context=servletContext;
|
|
|
|
this.context=servletContext;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public String fileToString(String fName)
|
|
|
|
|
|
|
|
{
|
|
|
|
public String fileToString(String fName) {
|
|
|
|
StringBuilder sb = new StringBuilder(1024);
|
|
|
|
StringBuilder sb = new StringBuilder(1024);
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
// 1. Сначала пробуем как внешний файл
|
|
|
|
InputStream is = new FileInputStream(fName);
|
|
|
|
try (InputStream is = new FileInputStream(fName);
|
|
|
|
BufferedReader buf = new BufferedReader(new InputStreamReader(is));
|
|
|
|
BufferedReader buf = new BufferedReader(new InputStreamReader(is))) {
|
|
|
|
String line = buf.readLine();
|
|
|
|
|
|
|
|
while(line != null)
|
|
|
|
String line;
|
|
|
|
{
|
|
|
|
while ((line = buf.readLine()) != null) {
|
|
|
|
sb.append(line).append("\n");
|
|
|
|
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();
|
|
|
|
return sb.toString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String trt(Connection conn,String key,User user)
|
|
|
|
public String trt(Connection conn,String key,User user)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
String result="";
|
|
|
|
String result="";
|
|
|
|