package com.onemap.spatial.controller; import com.onemap.common.core.utils.StringUtils; import com.onemap.common.core.web.domain.RequestResult; import com.onemap.spatial.domain.ShpVo; import com.onemap.spatial.domain.WktsVo; import com.onemap.spatial.service.IImageService; import com.onemap.spatial.service.IShpFileSaveService; import com.onemap.spatial.service.IWriteShpServer; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.HashMap; import java.util.Map; @RestController @RequestMapping("/shp") public class ShpController { @Resource private IWriteShpServer writeShpServer; @Autowired private IShpFileSaveService shpFileSaveService; @PostMapping("/write/ewkt") public RequestResult writeShpByEWkt(@RequestBody ShpVo shpVo) throws Exception { String path = writeShpServer.writeShpByEWkt(shpVo.getWkt(), shpVo.getFileName()); Map map = new HashMap<>(); map.put("path", path); return RequestResult.success(map); } @PostMapping("/write/wkt") public RequestResult writeShpByWkt(@RequestBody ShpVo shpVo) throws Exception { String path = writeShpServer.writeShpByWkt(shpVo.getWkt(), shpVo.getFileName()); Map map = new HashMap<>(); map.put("path", path.replace("\\", "/")); return RequestResult.success(map); } @GetMapping("/read/file") public RequestResult readFile(String filepath) { if (StringUtils.isEmpty(filepath)) { return RequestResult.error("filepath is null"); } shpFileSaveService.readFile(filepath); return RequestResult.success(0); } }