月球大数据地理空间分析展示平台-【后端】-月球后台服务
13693261870
2023-11-16 3882625a89c92febdb9276388a82c98118e3617e
添加 下载坡度分析Excel 接口
已添加1个文件
已修改3个文件
65 ■■■■■ 文件已修改
src/main/java/com/moon/server/config/WebConfig.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/moon/server/controller/data/RasterAnalysisController.java 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/moon/server/service/data/SlopAnalysisService.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application.yml 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/moon/server/config/WebConfig.java
@@ -13,6 +13,7 @@
import org.springframework.web.servlet.config.annotation.*;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.List;
/**
@@ -104,7 +105,7 @@
        //SerializerFeature.PrettyFormat);
        converter.setFastJsonConfig(config);
        converter.setDefaultCharset(Charset.forName("UTF-8"));
        converter.setDefaultCharset(StandardCharsets.UTF_8);
        converters.add(converter);
    }
}
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字符串不正确");
                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);
        }
    }
}
src/main/java/com/moon/server/service/data/SlopAnalysisService.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,26 @@
package com.moon.server.service.data;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.gdal.ogr.Geometry;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse;
/**
 * æ …格分析服务
 * @author WWW
 * @date 2023-11-16
 */
@Service
public class SlopAnalysisService {
    private final static Log log = LogFactory.getLog(SlopAnalysisService.class);
    /**
     * ä¸‹è½½å¡åº¦åˆ†æžExcel
     */
    public void downloadSlopXls(Geometry polygon, HttpServletResponse res) {
    }
}
src/main/resources/application.yml
@@ -150,5 +150,7 @@
    upload: D:\Moon\upload
    # ä¸´æ—¶ç›®å½•
    temp: D:\Moon\temp
    # å¡åº¦åˆ†æž
    slop: D:\Moon\dtm\dtm100m_slope_moon2000.tif
  # ä¸Šä¼ é™„件表
  attachTabs: