dcb
2025-07-09 e53252b99e7b49b435b7a6ee3eab21ae1bd7a055
src/main/java/com/se/nsl/controller/SimuController.java
@@ -10,6 +10,7 @@
import com.se.nsl.utils.SimulateType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.Parameter;
import lombok.extern.slf4j.Slf4j;
import org.gdal.ogr.Geometry;
import org.gdal.ogr.ogr;
@@ -205,24 +206,40 @@
    @ApiOperation(value = "crossSection")
    @GetMapping("/crossSection")
    public R<Object> crossSection(String serviceName, double[] startPoint, double[] endPoint) {
    public R<Object> crossSection(@Parameter(description = "方案id,示例:50") Integer id,
                                  @Parameter(description = "时间戳,示例:1751552400000") Long time,
                                  @Parameter(description = "起点坐标,示例:116.59049537485063,40.564178548127686") String startPoint,
                                  @Parameter(description = "终点坐标,示例:116.5901406492509,40.56499045715429") String endPoint) {
        if (null == id || id < 1) return clientError("id不能为空");
        Simu simu = simuService.selectById(id);
        if (simu == null) {
            return clientError("找不到对应的服务");
        }
        String serviceName = simu.getServiceName();
        if (serviceName == null) {
            return clientError("服务名不能为空");
            return fail("找不到对应的服务");
        }
        if (startPoint == null) {
            return clientError("起点不能为空");
        }
        if (startPoint.length < 2) {
            return clientError("起点至少包含x,y两个值");
        }
        if (endPoint == null) {
            return clientError("终点不能为空");
        }
        if (endPoint.length < 2) {
            return clientError("终点至少包含x,y两个值");
        String[] sp = startPoint.split(",");
        double[] s = new double[] {Double.parseDouble(sp[0]), Double.parseDouble(sp[1])};
        String[] ep = endPoint.split(",");
        double[] e = new double[] {Double.parseDouble(ep[0]), Double.parseDouble(ep[1])};
        try {
            if (time == null) {
                List<CrossSectionAnalysisResult> result = scas.crossSectionAnalysis(serviceName, s, e);
                return success(result, result.size());
            } else {
                CrossSectionAnalysisResult res = scas.crossSectionAnalysis(serviceName, s, e, time);
                return success(res, 1);
            }
        } catch (IllegalArgumentException ex) {
            return fail(ex.getMessage(), null);
        }
        List<CrossSectionAnalysisResult> result = scas.crossSectionAnalysis(serviceName, startPoint, endPoint);
        return success(result);
    }
    @ApiOperation(value = "stop")