月球大数据地理空间分析展示平台-【后端】-月球后台服务
13693261870
2023-09-10 1052cd1f5ea5d3e9fad2c332e5bd8fba4af6710c
src/main/java/com/moon/server/controller/data/RasterAnalysisController.java
@@ -3,15 +3,18 @@
import com.moon.server.annotation.SysLog;
import com.moon.server.controller.all.BaseController;
import com.moon.server.entity.all.ResponseMsg;
import com.moon.server.entity.data.ImageEntity;
import com.moon.server.helper.WebHelper;
import com.moon.server.service.data.RasterAnalysisService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.gdal.ogr.Geometry;
import org.gdal.ogr.ogr;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
@@ -28,6 +31,31 @@
@RestController
@RequestMapping("/rasterAnalysis")
public class RasterAnalysisController extends BaseController {
    @Resource
    RasterAnalysisService rasterService;
    @SysLog()
    @ApiOperation(value = "根据geometry获取对应范围的灰度值")
    @PostMapping
    public ResponseMsg<Object> rasterAnalysis(@RequestBody List<ImageEntity> images) {
        // 输入的几何Geometry: POINT (75.772 2.498)
        String geometryString = images.get(0).getGeometryString();
        Geometry geometry = Geometry.CreateFromWkt(geometryString);
        for (ImageEntity i : images) {
            String path = i.getPath();
            if (geometry.GetGeometryType() == ogr.wkbPoint) {
                i.setResult(rasterService.processPoint(path, geometryString, i.getPointSize()));
            } else if (geometry.GetGeometryType() == ogr.wkbLineString) {
                i.setResult(rasterService.processLine(path, geometryString));
            } else if (geometry.GetGeometryType() == ogr.wkbPolygon) {
                i.setResult(rasterService.processPolygon(path, geometryString));
            }
        }
        return success(images);
    }
    @SysLog()
    @ApiOperation(value = "查询点分析")
    @ApiImplicitParams({