GeoJSON
This commit is contained in:
@ -10,8 +10,8 @@ spring:
|
||||
application:
|
||||
name: org-ccalm-main
|
||||
datasource:
|
||||
url: jdbc:postgresql://10.0.0.1:5432/CCALM?ApplicationName=org_ccalm_main&connectTimeout=10000&socketTimeout=30000
|
||||
#url: jdbc:postgresql://ccalm.org:5432/CCALM?ApplicationName=org_ccalm_main&ssl=true&sslmode=require&connectTimeout=10000&socketTimeout=10000
|
||||
#url: jdbc:postgresql://10.0.0.1:5432/CCALM?ApplicationName=org_ccalm_main&connectTimeout=10000&socketTimeout=30000
|
||||
url: jdbc:postgresql://ccalm.org:5432/CCALM?ApplicationName=org_ccalm_main&ssl=true&sslmode=require&connectTimeout=10000&socketTimeout=10000
|
||||
#url: jdbc:postgresql://127.0.0.1:5432/CCALM?ApplicationName=org_ccalm_main&ssl=true&sslmode=require&connectTimeout=10000&socketTimeout=10000
|
||||
username: postgres
|
||||
password: 309A86FF65A78FB428F4E38DFE35F730
|
||||
|
||||
@ -263,8 +263,8 @@ public class GeoGSON implements ServletContextAware {
|
||||
@ResponseBody
|
||||
public ResponseEntity<byte[]> podsDensity(
|
||||
@RequestParam(required = false, name = "country_id", defaultValue = "5") Integer countryId,
|
||||
@RequestParam(required = false, name = "date_from", defaultValue = "1750227418") Long dateFromUnix,
|
||||
@RequestParam(required = false, name = "date_to", defaultValue = "1758010618") Long dateToUnix,
|
||||
@RequestParam(required = false, name = "date_start", defaultValue = "1750227418") Long dateStartUnix,
|
||||
@RequestParam(required = false, name = "date_end", defaultValue = "1758010618") Long dateEndUnix,
|
||||
@CookieValue(value = "lng", defaultValue = "1") String language_id,
|
||||
HttpServletRequest request // Добавляем для получения заголовка Range
|
||||
) {
|
||||
@ -284,8 +284,8 @@ public class GeoGSON implements ServletContextAware {
|
||||
|
||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||
params.addValue("countryId", countryId);
|
||||
params.addValue("dateFrom", dateFromUnix);
|
||||
params.addValue("dateTo", dateToUnix);
|
||||
params.addValue("dateFrom", dateStartUnix);
|
||||
params.addValue("dateTo", dateEndUnix);
|
||||
|
||||
List<Map<String, Object>> rows = jdbcTemplate.queryForList(sql, params);
|
||||
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
package org.ccalm.main;
|
||||
|
||||
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileInputStream;
|
||||
@ -63,7 +65,9 @@ public class QGIS implements ServletContextAware {
|
||||
|
||||
//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
|
||||
public HttpEntity<byte[]> ajaxTamer(
|
||||
@ModelAttribute User user,
|
||||
@ -99,7 +103,6 @@ public class QGIS implements ServletContextAware {
|
||||
logger.info(ex.getMessage());
|
||||
}
|
||||
|
||||
|
||||
//Return content QGIS file.
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
|
||||
@ -108,7 +111,71 @@ public class QGIS implements ServletContextAware {
|
||||
|
||||
String fileAsString="";
|
||||
//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")))
|
||||
//TODO NEW format
|
||||
if(name!=null && (name.equals("frmlocust_pods_density")))
|
||||
{
|
||||
fileAsString = fileToString("static/resources/QGIS/" + name + ".qgs");
|
||||
|
||||
//String country_id=request.getParameter("country_id");
|
||||
//String locust_type_id=request.getParameter("locust_type_id");
|
||||
//String date_start=request.getParameter("date_start");
|
||||
//String date_end=request.getParameter("date_end");
|
||||
//String registered=request.getParameter("registered");
|
||||
|
||||
//Make SQL
|
||||
String sql = "mode=1";
|
||||
String sql2 = "mode=1";
|
||||
if(country_id!=null && !country_id.isEmpty())
|
||||
{
|
||||
if(country_id.equals("-1"))
|
||||
{
|
||||
//sql+=" and country_id in (7,3,4,2)"; TODO
|
||||
//sql2+=" and country_id in (7,3,4,2)"; TODO
|
||||
}else if(country_id.equals("-2"))
|
||||
{
|
||||
//sql+=" and country_id in (7,1,5,6,8,9,10)"; TODO
|
||||
//sql2+=" and country_id in (7,1,5,6,8,9,10)"; TODO
|
||||
}else
|
||||
{
|
||||
sql+="&country_id="+country_id;
|
||||
sql2+="&country_id="+country_id;
|
||||
}
|
||||
}
|
||||
if(locust_type_id!=null && !locust_type_id.isEmpty())
|
||||
{
|
||||
sql+="&locust_type_id="+locust_type_id;
|
||||
}
|
||||
if(date_start!=null && !date_start.isEmpty())
|
||||
{
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
LocalDateTime localDateTime = LocalDateTime.parse(date_start, formatter);
|
||||
long epochSeconds = localDateTime.toEpochSecond(ZoneOffset.UTC);
|
||||
sql+="&date_start="+epochSeconds;
|
||||
}
|
||||
if(date_end!=null && !date_end.isEmpty())
|
||||
{
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
LocalDateTime localDateTime = LocalDateTime.parse(date_start, formatter);
|
||||
long epochSeconds = localDateTime.toEpochSecond(ZoneOffset.UTC);
|
||||
sql+="&date_end="+epochSeconds;
|
||||
}
|
||||
|
||||
if(registered!=null && registered.equals("1"))
|
||||
{
|
||||
sql+="&registered=true";
|
||||
}else
|
||||
if(registered!=null && registered.equals("0"))
|
||||
{
|
||||
sql+="&registered=false";
|
||||
}
|
||||
|
||||
//Apply variables to text
|
||||
fileAsString=fileAsString.replaceAll("\\$\\{params\\}",sql);
|
||||
fileAsString=fileAsString.replaceAll("\\$\\{params2\\}",sql2);
|
||||
|
||||
}
|
||||
//TODO OLD format
|
||||
if(name!=null && (name.equals("frmlocust_hoppers_density") || name.equals("frmlocust_bands") || name.equals("frmlocust_adults_density") || name.equals("frmlocust_swarms")))
|
||||
{
|
||||
fileAsString = fileToString("static/resources/QGIS/" + name + ".qgs");
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user