From 3882625a89c92febdb9276388a82c98118e3617e Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期四, 16 十一月 2023 10:49:03 +0800
Subject: [PATCH] 添加 下载坡度分析Excel 接口

---
 src/main/java/com/moon/server/controller/data/RasterAnalysisController.java |   34 ++++++++++++++++++++++++++++++++++
 1 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/moon/server/controller/data/RasterAnalysisController.java b/src/main/java/com/moon/server/controller/data/RasterAnalysisController.java
index f28c92c..2396ad7 100644
--- a/src/main/java/com/moon/server/controller/data/RasterAnalysisController.java
+++ b/src/main/java/com/moon/server/controller/data/RasterAnalysisController.java
@@ -7,6 +7,7 @@
 import com.moon.server.helper.StringHelper;
 import com.moon.server.helper.WebHelper;
 import com.moon.server.service.data.RasterAnalysisService;
+import com.moon.server.service.data.SlopAnalysisService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
@@ -31,6 +32,9 @@
 public class RasterAnalysisController extends BaseController {
     @Resource
     RasterAnalysisService rasterService;
+
+    @Resource
+    SlopAnalysisService slopAnalysisService;
 
     private final static List<Integer> PIXELS = new ArrayList<>(Arrays.asList(1, 2, 4, 8, 16, 32, 64, 128, 256));
 
@@ -151,4 +155,34 @@
             log.error(ex.getMessage(), ex);
         }
     }
+
+    @SysLog()
+    @ApiOperation(value = "涓嬭浇鍧″害鍒嗘瀽Excel")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "wkt", value = "WKT瀛楃涓�", dataType = "String", example = "POLYGON ((56.61 33.94,115.04 33.56,114.09 -7.17,52.22 -6.22,56.61 33.94))")
+    })
+    @GetMapping(value = "/downloadSlopXls")
+    public void downloadSlopXls(String wkt, HttpServletRequest req, HttpServletResponse res) {
+        try {
+            if (StringHelper.isEmpty(wkt)) {
+                WebHelper.writeStr2Page(res, "WKT瀛楃涓蹭笉鑳戒负绌�");
+                return;
+            }
+            Geometry geo = Geometry.CreateFromWkt(wkt);
+            if (null == geo) {
+                WebHelper.writeStr2Page(res, "WKT瀛楃涓蹭笉姝g‘");
+                return;
+            }
+            int wktType = geo.GetGeometryType();
+            if (wktType != ogr.wkbPolygon) {
+                WebHelper.writeStr2Page(res, "WKT瀛楃涓插彧鏀寔闈㈢被鍨�");
+                return;
+            }
+
+            slopAnalysisService.downloadSlopXls(geo, res);
+        } catch (Exception ex) {
+            WebHelper.writeStr2Page(res, ex.getMessage());
+            log.error(ex.getMessage(), ex);
+        }
+    }
 }

--
Gitblit v1.9.3