package com.lf.server.controller.data;
|
|
import com.lf.server.annotation.SysLog;
|
import com.lf.server.config.PropertiesConfig;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParams;
|
import io.swagger.annotations.ApiOperation;
|
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.LogFactory;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.core.io.ClassPathResource;
|
import org.springframework.web.bind.annotation.*;
|
|
import javax.servlet.ServletOutputStream;
|
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletResponse;
|
import java.io.InputStream;
|
import java.nio.charset.StandardCharsets;
|
|
/**
|
* WMTS服务
|
* @author WWW
|
*/
|
@Api(tags = "数据管理\\WMTS服务")
|
@RestController
|
@RequestMapping("/wmts")
|
public class WmtsController {
|
@Autowired
|
PropertiesConfig config;
|
|
private final static Log log = LogFactory.getLog(WmtsController.class);
|
|
@SysLog()
|
@ApiOperation(value = "获取WMTS元数据")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "token", value = "令牌", required = true, dataType = "String", defaultValue = "token", paramType = "path")
|
})
|
@GetMapping("select/{token}/WMTSCapabilities.xml")
|
public void selectWmtsCapabilities(@PathVariable(name = "token") String token, HttpServletRequest req, HttpServletResponse res) {
|
try {
|
ClassPathResource resource = new ClassPathResource("wmts/web.xml");
|
if (!resource.exists()) {
|
return;
|
}
|
|
InputStream stream = resource.getInputStream();
|
byte[] data = new byte[stream.available()];
|
stream.read(data);
|
stream.close();
|
|
String url = req.getRequestURL().toString().replace("WMTSCapabilities.xml", "tile");
|
|
String result = new String(data, StandardCharsets.UTF_8);
|
result = result.replace("{url}", url);
|
byte[] bytes = result.getBytes(StandardCharsets.UTF_8);
|
|
res.setHeader("Content-Type", "application/xml;charset=UTF-8");
|
ServletOutputStream os = res.getOutputStream();
|
os.write(bytes);
|
os.flush();
|
} catch (Exception ex) {
|
log.error(ex.getMessage(), ex);
|
}
|
}
|
|
@ApiOperation(value = "获取WMTS瓦片")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "token", value = "令牌", required = true, dataType = "String", defaultValue = "token", paramType = "path"),
|
@ApiImplicitParam(name = "layer", value = "图层类型", required = true, dataType = "String", defaultValue = "TDTIMG"),
|
@ApiImplicitParam(name = "tilematrix", value = "层级", required = true, dataType = "Integer"),
|
@ApiImplicitParam(name = "tilerow", value = "行号", required = true, dataType = "Integer"),
|
@ApiImplicitParam(name = "tilecol", value = "列号", required = true, dataType = "Integer")
|
})
|
@GetMapping("select/{token}/tile")
|
public void selectWmtsTile(@RequestParam("layer") String layer, @RequestParam("tilematrix") Integer l, @RequestParam("tilerow") Integer r,
|
@RequestParam("tilecol") Integer c, @RequestParam("format") String format, @PathVariable(name = "token") String token,
|
HttpServletRequest req, HttpServletResponse res) {
|
try {
|
// ServletServerHttpRequest ssRequest = new ServletServerHttpRequest(request)
|
String base = config.getTilePath();
|
|
} catch (Exception ex) {
|
log.error(ex.getMessage(), ex);
|
}
|
}
|
}
|