package com.moon.server.controller.data;
|
|
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.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;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
/**
|
* 栅格分析
|
* @author WWW
|
* @date 2023-08-23
|
*/
|
@Api(tags = "数据管理\\栅格分析")
|
@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({
|
@ApiImplicitParam(name = "wkt", value = "点WKT", dataType = "String", example = "")
|
})
|
@GetMapping(value = "/selectByPoint")
|
public ResponseMsg<Object> selectByPoint(String wkt) {
|
try {
|
Map<String, Double> map = new HashMap<>(5);
|
map.put("图层名", 0.0);
|
|
return success(map);
|
} catch (Exception ex) {
|
return fail(ex, null);
|
}
|
}
|
|
@SysLog()
|
@ApiOperation(value = "查询线分析")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "wkt", value = "线WKT", dataType = "String", example = "")
|
})
|
@GetMapping(value = "/selectByPolyline")
|
public ResponseMsg<Object> selectByPolyline(String wkt) {
|
try {
|
Map<String, List<Double>> map = new HashMap<>(5);
|
List<Double> list = new ArrayList<>();
|
list.add(0.0);
|
map.put("图层名", list);
|
|
return success(map);
|
} catch (Exception ex) {
|
return fail(ex, null);
|
}
|
}
|
|
@SysLog()
|
@ApiOperation(value = "查询面分析")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "wkt", value = "面WKT", dataType = "String", example = "")
|
})
|
@GetMapping(value = "/selectByPolygon")
|
public ResponseMsg<Object> selectByPolygon(String wkt) {
|
try {
|
Map<String, Double> map = new HashMap<>(5);
|
map.put("图层名", 0.0);
|
|
return success(map);
|
} catch (Exception ex) {
|
return fail(ex, null);
|
}
|
}
|
|
@SysLog()
|
@ApiOperation(value = "下载点分析")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "wkt", value = "点WKT", dataType = "String", example = "")
|
})
|
@GetMapping(value = "/downloadByPoint")
|
public void downloadByPoint(String wkt, HttpServletResponse res) {
|
try {
|
// ...
|
|
String filePath = "生成文件的路径";
|
WebHelper.download(filePath, "文件名", res);
|
} catch (Exception ex) {
|
log.error(ex.getMessage(), ex);
|
}
|
}
|
|
@SysLog()
|
@ApiOperation(value = "下载线分析")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "wkt", value = "线WKT", dataType = "String", example = "")
|
})
|
@GetMapping(value = "/downloadByPolyline")
|
public void downloadByPolyline(String wkt, HttpServletResponse res) {
|
try {
|
// ...
|
|
String filePath = "生成文件的路径";
|
WebHelper.download(filePath, "文件名", res);
|
} catch (Exception ex) {
|
log.error(ex.getMessage(), ex);
|
}
|
}
|
|
@SysLog()
|
@ApiOperation(value = "下载面分析")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "wkt", value = "面WKT", dataType = "String", example = "")
|
})
|
@GetMapping(value = "/downloadByPolygon")
|
public void downloadByPolygon(String wkt, HttpServletResponse res) {
|
try {
|
// ...
|
|
String filePath = "生成文件的路径";
|
WebHelper.download(filePath, "文件名", res);
|
} catch (Exception ex) {
|
log.error(ex.getMessage(), ex);
|
}
|
}
|
}
|