ansel0926
2022-05-17 885edef97a642aaceede847c084f70156cbfe9a9
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
//采样事件
 
function sampleEventQuery() {
    var sampleInput = $("#sampleInput").val();
    var project = $("#sample_project_select").val();
    var starttime = $("#sample_date_start").val();
    var endtime = $("#sample_date_end").val();
    var radiotype = $('input[name="sampleRadio"]:checked').val()
    var type = '';
    var url = '';
    if (radiotype == 'sampleradio_project') {
        type = 'project';
        url = path + "/listSampleEventByProject?access_token=" + access_token + "&project_id=" + project +
            "&type=" + type + "&sample_name=" + sampleInput;
    } else if (radiotype == 'sampleradio_date') {
        type = 'time';
        url = path + "/listSampleEventByProject?access_token=" + access_token + "&start_time=" + starttime +
            "&type=" + type + "&end_time=" + endtime + "&sample_name=" + sampleInput;
    } else if (radiotype == 'sampleradio_scope') {
        type = 'scope';
    }
    $.ajax({
        type: "post",
        async: false,
        url: url,
        contentType: "application/json;charset=utf-8",
        success: function (data) {
            if (data != null) {
                showSampleTables(data);
            }
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            console.log("ajax请求失败!")
        }
    });
}
 
//列表显示所有的项目信息
function showSampleTables(data) {
    $("#sample_tales").html('');
    var content = '';
    content += '<tbody>';
    content += '<tr><td  style="width:30%;">采样编号</td>';
    content += '<td style="width:15%;">采样时间</td>';
    content += '<td style="width:20%;">调查类型</td>';
    content += '<td style="width:20%;">采样状态</td>';
    content += '<td style="width:15%;">操作</td></tr>';
    for (var i = 0; i < data.length; i++) {
        var type = '';
        var state = data[i].state;
        var oDate = timestampToTime(parseInt(data[i].create_time) * 1000);
        if (data[i].type == 0) {
            type = '<font>初步调查</font>';
        } else {
            type = '<font color="red">详细调查</font>';
        }
        if (data[i].state == 0) {
            state = '未采样';
        } else if (data[i].state == 1) {
            state = '<font color="red">已采样</font>';
        } else {
            state = '<font color="blue">已送检</font>';
        }
 
        content += '<tr><td>' + data[i].sample_no + '</td>'
            + '<td>' + oDate + '</td>'
            + '<td>' + type + '</td>'
            + '<td>' + state + '</td>'
            + '<td>'
            + '<a onclick="toSamplePointOnMap(\'' + data[i].longitude + '\',\'' + data[i].latitude + '\'' + ')"><font color="blue">查看</font></a>'
            + '</tr>';
    }
    content += '</tbody>';
    if (data.length == 0) {
        content += '<font color="red">未查询到数据呀</font>';
    }
    $("#sample_tales").html(content);
    showSamplePointOnMap(data);
}
 
//一个一个点进行绘制
function drawSamplePointOnMap(data) {
    var entity = viewer.entities.getById("draw_sample_" + data.id);
    if (entity == undefined) {//如果不存在则添加  
 
        viewer.entities.add({
            id: "draw_sample_" + data.id,
            name: data.sample_name,
            position: Cesium.Cartesian3.fromDegrees(data.longitude, data.latitude),
            point: {
                pixelSize: 12,
                color: Cesium.Color.BLUE,
                outlineColor: Cesium.Color.WHITE,
                outlineWidth: 3,
                outline: true,
                disableDepthTestDistance: Number.POSITIVE_INFINITY,
                heightReference: Cesium.HeightReference.RELATIVE_TO_GROUND
            },
            label: {
                show: true,
                verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
                horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
                font: 'bold 14px Helvetica',
                fillColor: Cesium.Color.WHITE,
                text: data.sample_name,
                disableDepthTestDistance: Number.POSITIVE_INFINITY,
                heightReference: Cesium.HeightReference.RELATIVE_TO_GROUND
            }
        });
        viewer.camera.flyTo({
            destination: Cesium.Cartesian3.fromDegrees(data.longitude, data.latitude, 3000),
        });
 
    }
}
//加载集合点
function drawSampleListPointOnMap(data) {
    for (var i = 0; i < data.length; i++) {
 
        var entity = viewer.entities.getById("draw_sample_" + data[i].id);
        if (entity == undefined) {//如果不存在则添加  
 
            viewer.entities.add({
                id: "draw_sample_" + data[i].id,
                name: data[i].sample_name,
                position: Cesium.Cartesian3.fromDegrees(data[i].longitude, data[i].latitude),
                point: {
                    pixelSize: 12,
                    color: Cesium.Color.BLUE,
                    outlineColor: Cesium.Color.WHITE,
                    outlineWidth: 3,
                    outline: true,
                    disableDepthTestDistance: Number.POSITIVE_INFINITY,
                    heightReference: Cesium.HeightReference.RELATIVE_TO_GROUND
                },
                label: {
                    show: true,
                    verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
                    horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
                    font: 'bold 14px Helvetica',
                    fillColor: Cesium.Color.WHITE,
                    text: data[i].sample_name,
                    disableDepthTestDistance: Number.POSITIVE_INFINITY,
                    heightReference: Cesium.HeightReference.RELATIVE_TO_GROUND
                }
            });
        }
    }
    viewer.camera.flyTo({
        destination: Cesium.Cartesian3.fromDegrees(data[0].longitude, data[0].latitude, 3000),
    });
}
 
//显示点
function showSamplePointOnMap(data) {
    var color = $('input[name="sampleColorRadio"]:checked').val();
    var cesu;
    if (color == "red") {
        cesu = Cesium.Color.RED;
    } else if (color == "blue") {
        cesu = Cesium.Color.BLUE;
    } else if (color == "green") {
        cesu = Cesium.Color.GREEN;
    } else if (color == "dingzi") {
        cesu = "dingzi";
    }
 
    for (var i = 0; i < data.length; i++) {
        var entity = viewer.entities.getById("draw_sample_" + data[i].id);
 
        if (entity == undefined) {//如果不存在则添加  
            if (cesu == "dingzi") {
 
                viewer.entities.add({
                    id: "draw_sample_" + data[i].id,
                    name: data[i].sample_name,
                    position: Cesium.Cartesian3.fromDegrees(data[i].longitude, data[i].latitude),
                    label: {
                        show: true,
                        verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
                        horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
                        font: 'bold 14px Helvetica',
                        fillColor: Cesium.Color.WHITE,
                        text: '',
                        disableDepthTestDistance: Number.POSITIVE_INFINITY,
                        heightReference: Cesium.HeightReference.RELATIVE_TO_GROUND
                    },
                    billboard: {
                        image: '../images/icon/钉子blue.png',
                        width: 35,
                        height: 35,
                        rotation: 0,
                        verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
                        horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
                        disableDepthTestDistance: Number.POSITIVE_INFINITY,//广告牌不进行深度检测
                        heightReference: Cesium.HeightReference.RELATIVE_TO_GROUND
                    }
                });
 
 
            } else {
                viewer.entities.add({
                    id: "draw_sample_" + data[i].id,
                    name: data[i].sample_name,
                    position: Cesium.Cartesian3.fromDegrees(data[i].longitude, data[i].latitude),
                    point: {
                        pixelSize: 12,
                        color: cesu,
                        outlineColor: Cesium.Color.WHITE,
                        outlineWidth: 3,
                        outline: true,
                        disableDepthTestDistance: Number.POSITIVE_INFINITY,
                        heightReference: Cesium.HeightReference.RELATIVE_TO_GROUND
                    },
                    label: {
                        show: true,
                        verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
                        horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
                        font: 'bold 14px Helvetica',
                        fillColor: Cesium.Color.WHITE,
                        text: data[i].sample_name,
                        disableDepthTestDistance: Number.POSITIVE_INFINITY,
                        heightReference: Cesium.HeightReference.RELATIVE_TO_GROUND
                    }
                });
            }
        }
    }
}
 
//清除
function sampleClear() {
    $("#sample_tales").html('');
    clearPointOnMap();
}
//清除
function clearPointOnMap() {
    var entitys = viewer.entities._entities._array;
    for (var i = 0; i < entitys.length; i++) {
        if (entitys[i]._id.indexOf("draw_sample_") != -1) {
            viewer.entities.remove(entitys[i]);
            i--;
        }
    }
}
 
//跳转到查询的点
function toSamplePointOnMap(lng, lat) {
    viewer.camera.flyTo({
        destination: Cesium.Cartesian3.fromDegrees(lng, lat, 3000),
    });
}
//时间转化
function timestampToTime(timestamp) {
    var date = new Date(timestamp)
    var Y = date.getFullYear() + '-'
    var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-'
    var D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' '
 
    return Y + M + D;
}