sbjw
2025-09-26 ae011aaafc3a5e508f90ded1bcb9854fa800bf9a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
import React, {PureComponent} from "react";
import * as echarts from 'echarts';
import {Button} from "antd";
import {CloseOutlined} from "@ant-design/icons";
 
export default class ProfilePage extends PureComponent {
    chartRef = React.createRef();
    chartInstance = null;
 
 
    constructor(props) {
        super(props);
        this.samplesObj = null;
        this.points = [];
        this.height = [];
        this.mapApiService = this.props.mapApiService;
        this.viewer = this.props.mapApiService.viewer;
    }
 
    componentDidMount() {
        // 初始化图表
        this.chartInstance = echarts.init(this.chartRef.current);
        if (this.props.profileResult) {
            this.points = this.props.profileResult;
            let dis = this.mapApiService.getDistance(this.points[0], this.points[1]);
            let interval = dis / 150;
            this.samplesObj = this.mapApiService.preciseLerpSampling(this.points[0], this.points[1], interval);
            this.getSamplingPoint();
        }
    }
 
    getSamplingPoint() {
        let points = this.samplesObj.points;
        let promise = this.mapApiService.sampleTerrainMostDetailed(points);
        promise.then(updatedPositions => {
            for (let i = 0; i < updatedPositions.length; i++) {
                if (updatedPositions[i].height) {
                    let h = updatedPositions[i].height;
                    this.height.push((h).toFixed(2)); // 取得高程值
                }
            }
            this.showChar();
        })
    }
 
    showChar() {
        let option = this.getOption();
        this.chartInstance.setOption(option);
    }
 
    getOption() {
        const option = {
            grid: {left: '100px', right: '50px', bottom: '25px'},
            tooltip: {
                trigger: 'axis'
            },
            xAxis: {
                type: 'category',
                boundaryGap: false,
                name: "km",
                axisLabel: {
                    color: '#fff'
                },
                axisLine: {
                    show: true,
                    lineStyle: {color: '#fff'}
                },  // 轴线样式
                data: this.samplesObj.dis
            },
            yAxis: {
                type: 'value',
                axisLine: {
                    show: true,
                    lineStyle: {color: '#fff'}
                },  // 轴线样式
                name: "m",
                axisLabel: {
                    color: '#fff'
                }
            },
            series: [
                {
                    name: '高程',
                    type: 'line',
                    smooth: true,
                    showSymbol: false,
                    data: this.height,
                    areaStyle: {
                        color: {
                            type: 'linear',
                            x: 0,
                            y: 0,
                            x2: 0,
                            y2: 1,
                            colorStops: [{
                                offset: 0, color: 'rgba(240,9,246,1)' // 0% 处的颜色
                            }, {
                                offset: 1, color: 'rgba(210,33,100,0.5)' // 100% 处的颜色
                            }]
                        }
                    }
                }
            ]
        };
        return option;
    }
 
    componentWillUnmount() {
        if (this.chartInstance) {
            this.chartInstance.dispose();
        }
    }
 
    closeEvent() {
        this.props.closeEvent(null);
        //this.mapFunction.mapApiService.disableTilt ();
    }
 
    render() {
        return (
            <div className="sightLine-char-container">
                <div className="title-container">
                    <div className="title-name">
                        <span>剖面分析</span>
                    </div>
                    <div className="icon-container">
                        <Button type="primary" onClick={this.closeEvent.bind(this)}><CloseOutlined/></Button>
                    </div>
                </div>
                <div className="sightLine-char-body">
                    <div
                        className="char-container"
                        ref={this.chartRef}
                        style={{width: '100%', height: '300px'}}
                    ></div>
                </div>
            </div>
        );
    }
}