| | |
| | | package com.lf.server.controller.data; |
| | | |
| | | import com.lf.server.annotation.SysLog; |
| | | import com.lf.server.entity.all.StaticData; |
| | | import com.lf.server.helper.GdalHelper; |
| | | import com.lf.server.helper.StringHelper; |
| | | 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.GetMapping; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.ServletOutputStream; |
| | | import javax.servlet.http.HttpServletRequest; |
| | |
| | | @RestController |
| | | @RequestMapping("/wmts") |
| | | public class WmtsController { |
| | | @Autowired |
| | | PropertiesConfig config; |
| | | |
| | | private final static Log log = LogFactory.getLog(WmtsController.class); |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "查询WMTS元数据") |
| | | @ApiOperation(value = "获取WMTS元数据") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "token", value = "令牌", dataType = "String", required = true, defaultValue = "token", paramType = "path")}) |
| | | @GetMapping("select/metas/{token}") |
| | | public void selectMetas(String service, String version, String request, @PathVariable(name = "token") String token, HttpServletRequest req, HttpServletResponse res) { |
| | | @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 { |
| | | if (!StaticData.WMTS.equals(service) || !StaticData.CAPABILITY.equals(request)) { |
| | | return; |
| | | } |
| | | |
| | | ClassPathResource resource = new ClassPathResource("wmts/web.xml"); |
| | | if (!resource.exists()) { |
| | | return; |
| | |
| | | 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"); |
| | |
| | | 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); |
| | | } |
| | | } |
| | | } |