| | |
| | | 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.all.StaticData; |
| | | 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; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 栅格分析 |
| | | * @author WWW |
| | | * @date 2023-08-23 |
| | | */ |
| | | @Api(tags = "数据管理\\栅格分析") |
| | | @RestController |
| | | @SuppressWarnings("ALL") |
| | | @RequestMapping("/rasterAnalysis") |
| | | 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)); |
| | | |
| | |
| | | @SysLog() |
| | | @ApiOperation(value = "查询面分析") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "wkt", value = "面WKT", dataType = "String", example = "POLYGON ((165.680851 31.333443,166.383982 31.283475,166.016355 30.908709,165.680851 31.333443))") |
| | | //@ApiImplicitParam(name = "wkt", value = "面WKT", dataType = "String", example = "POLYGON ((165.680851 31.333443,166.383982 31.283475,166.016355 30.908709,165.680851 31.333443))") |
| | | @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 = "/selectByPolygon") |
| | | public ResponseMsg<Object> selectByPolygon(String wkt) { |
| | |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "使用WKT查询分析,结果以消息推送") |
| | | @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))"), |
| | | @ApiImplicitParam(name = "size", value = "像素值(点)或节点数(线)", dataType = "Integer", example = "16") |
| | | }) |
| | | @GetMapping(value = "/selectByWktForPost") |
| | | public void selectByWktForPost(String wkt, Integer size, 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.wkbPoint && wktType != ogr.wkbLineString && wktType != ogr.wkbPolygon) { |
| | | WebHelper.writeStr2Page(res, "WKT字符串只支持点、线串和面类型"); |
| | | return; |
| | | } |
| | | if (null == size || size < 0 || size > StaticData.I1024) { |
| | | WebHelper.writeStr2Page(res, "像素值(点)或节点数(线)值不正确"); |
| | | return; |
| | | } |
| | | |
| | | String token = WebHelper.getToken(req); |
| | | rasterService.analysisForPost(geo, size, token); |
| | | } catch (Exception ex) { |
| | | log.error(ex.getMessage(), ex); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "下载坡度分析Excel") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "wkt", value = "WKT字符串", dataType = "String", example = "POLYGON ((-73.093 4.598,-72.494 4.669,-72.951 4.241,-73.093 4.598))") |
| | | }) |
| | | @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); |
| | | } |
| | | } |
| | | } |