资源相关
This commit is contained in:
33
src/main/java/com/yj/earth/sdk/CltController.java
Normal file
33
src/main/java/com/yj/earth/sdk/CltController.java
Normal file
@ -0,0 +1,33 @@
|
||||
package com.yj.earth.sdk;
|
||||
|
||||
import com.yj.earth.common.config.ServerConfig;
|
||||
import com.yj.earth.common.util.HttpUtil;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
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 javax.annotation.Resource;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@Tag(name = "模型数据相关")
|
||||
@RequestMapping("/data/clt")
|
||||
public class CltController {
|
||||
|
||||
@Resource
|
||||
private DirectService directService;
|
||||
|
||||
@Operation(summary = "获取倾斜模型数据")
|
||||
@GetMapping("/{sourceId}/**")
|
||||
public Object getData(HttpServletRequest request) {
|
||||
return HttpUtil.doGetForByteArrayResponse(directService.getDirectUrl(request));
|
||||
}
|
||||
}
|
||||
32
src/main/java/com/yj/earth/sdk/DirectService.java
Normal file
32
src/main/java/com/yj/earth/sdk/DirectService.java
Normal file
@ -0,0 +1,32 @@
|
||||
package com.yj.earth.sdk;
|
||||
|
||||
import com.yj.earth.common.config.ServerConfig;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
@Service
|
||||
public class DirectService {
|
||||
|
||||
@Resource
|
||||
private ServerConfig serverConfig;
|
||||
|
||||
/**
|
||||
* 获取转发的SDK地址
|
||||
*/
|
||||
public String getDirectUrl(HttpServletRequest request) {
|
||||
try {
|
||||
// 获取原始请求的完整URL
|
||||
String originalUrl = request.getRequestURL().toString();
|
||||
// 解析原始URL
|
||||
URL url = new URL(originalUrl);
|
||||
// 构建新URL、保持协议、主机、路径不变、只替换端口
|
||||
return new URL(url.getProtocol(), serverConfig.getHost(), serverConfig.getSdkPort(), url.getPath()).toString();
|
||||
} catch (MalformedURLException e) {
|
||||
throw new RuntimeException("转发到SDK错误");
|
||||
}
|
||||
}
|
||||
}
|
||||
29
src/main/java/com/yj/earth/sdk/MbtilesController.java
Normal file
29
src/main/java/com/yj/earth/sdk/MbtilesController.java
Normal file
@ -0,0 +1,29 @@
|
||||
package com.yj.earth.sdk;
|
||||
|
||||
import com.yj.earth.common.util.HttpUtil;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
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 javax.annotation.Resource;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@Tag(name = "模型数据相关")
|
||||
@RequestMapping("/data/mbtiles")
|
||||
public class MbtilesController {
|
||||
@Resource
|
||||
private DirectService directService;
|
||||
|
||||
@Operation(summary = "获取二维影像数据")
|
||||
@GetMapping("{sourceId}/{z}/{x}/{y}.{format}")
|
||||
public Object getData(HttpServletRequest request) {
|
||||
return HttpUtil.doGetForByteArrayResponse(directService.getDirectUrl(request));
|
||||
}
|
||||
}
|
||||
35
src/main/java/com/yj/earth/sdk/PakController.java
Normal file
35
src/main/java/com/yj/earth/sdk/PakController.java
Normal file
@ -0,0 +1,35 @@
|
||||
package com.yj.earth.sdk;
|
||||
|
||||
import com.yj.earth.common.util.HttpUtil;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
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 javax.annotation.Resource;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@Tag(name = "模型数据相关")
|
||||
@RequestMapping("/data/pak")
|
||||
public class PakController {
|
||||
@Resource
|
||||
private DirectService directService;
|
||||
@Operation(summary = "获取地形描述文件")
|
||||
@GetMapping("/{mark}/layer.json")
|
||||
public Object jsonBySourceIdAndParam(HttpServletRequest request) {
|
||||
return HttpUtil.doGetForByteArrayResponse(directService.getDirectUrl(request));
|
||||
}
|
||||
|
||||
@Operation(summary = "获取地形相关的数据")
|
||||
@GetMapping("/{mark}/{z}/{x}/{y}.{suffix}")
|
||||
public Object data(HttpServletRequest request){
|
||||
return HttpUtil.doGetForByteArrayResponse(directService.getDirectUrl(request));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user