月球大数据地理空间分析展示平台-【后端】-月球后台服务
13693261870
2023-11-16 d2811d5ee9b13f301326d18b118dde40ba811b14
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.SlopeAnalysisService;
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
    SlopeAnalysisService slopeAnalysisService;
    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 ((-103.2 -12.9,-84.2 -14.3,-86.8 -27.5,-105.1 -25.3,-103.2 -12.9))")
    })
    @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;
            }
            slopeAnalysisService.downloadSlopXls(geo, res);
        } catch (Exception ex) {
            WebHelper.writeStr2Page(res, ex.getMessage());
            log.error(ex.getMessage(), ex);
        }
    }
}