fuchengshen
2022-07-09 3a25c05b5ab837714f30469cdcb1e2a77d8d7f6c
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
<template>
  <mars-pannel :visible="true" right="10" top="10">
    <a-form>
      <a-form-item label="范围">
        <a-radio-group v-model:value="formState.radioFanwei" @change="changeFanwei">
          <a-radio value="1">十进制</a-radio>
          <a-radio value="2">度分秒</a-radio>
          <a-radio value="3" title="2000平面坐标">平面坐标</a-radio>
        </a-radio-group>
      </a-form-item>
 
      <!-- 十进制的面板 -->
      <div v-show="formState.radioFanwei == '1'">
        <a-form-item label="经度" class="shijingzhi" @change="changeJWD">
          <mars-input v-model:value="formState.jd"> </mars-input>
        </a-form-item>
        <a-form-item label="纬度" class="shijingzhi">
          <mars-input v-model:value="formState.wd" @change="changeJWD"> </mars-input>
        </a-form-item>
        <a-form-item label="高程" class="shijingzhi">
          <mars-input v-model:value="formState.alt" @change="changeJWD"> </mars-input>
        </a-form-item>
      </div>
 
      <!-- 度分秒的面板 -->
      <div v-show="formState.radioFanwei == '2'">
        <a-form-item label="经度">
          <a-space>
            <mars-input v-model:value="formState.jdDegree" class="dufenmiao" @change="changeDMS"> </mars-input>°
            <mars-input v-model:value="formState.jdMinute" class="dufenmiao" @change="changeDMS"> </mars-input>'
            <mars-input v-model:value="formState.jdSecond" class="dufenmiao" @change="changeDMS"> </mars-input>"
          </a-space>
        </a-form-item>
        <a-form-item label="纬度">
          <a-space>
            <mars-input v-model:value="formState.wdDegree" class="dufenmiao" @change="changeDMS"> </mars-input>°
            <mars-input v-model:value="formState.wdMinute" class="dufenmiao" @change="changeDMS"> </mars-input>'
            <mars-input v-model:value="formState.wdSecond" class="dufenmiao" @change="changeDMS"> </mars-input>"
          </a-space>
        </a-form-item>
        <a-form-item label="高程" class="shijingzhi">
          <mars-input v-model:value="formState.alt"> </mars-input>
        </a-form-item>
      </div>
 
      <!-- 平面坐标的面板 -->
      <div v-show="formState.radioFanwei == '3'">
        <a-form-item label="分带">
          <a-radio-group v-model:value="formState.radioFendai" @change="changeFendai">
            <a-radio value="1">三度带</a-radio>
            <a-radio value="2">六度带</a-radio>
          </a-radio-group>
        </a-form-item>
        <a-form-item label="纵坐标" class="shijingzhi">
          <mars-input v-model:value="formState.gk6X" @change="changeGKZone"> </mars-input>
        </a-form-item>
        <a-form-item label="横坐标" class="shijingzhi">
          <mars-input v-model:value="formState.gk6Y" @change="changeGKZone"> </mars-input>
        </a-form-item>
        <a-form-item label="高度值" class="shijingzhi">
          <mars-input v-model:value="formState.alt" @change="changeGKZone"> </mars-input>
        </a-form-item>
      </div>
 
      <a-form-item class="f-pt f-tac">
        <a-space>
          <mars-button @click="bindMourseClick">图上拾取</mars-button>
          <mars-button @click="submitCenter">坐标定位</mars-button>
        </a-space>
      </a-form-item>
    </a-form>
  </mars-pannel>
</template>
 
<script setup lang="ts">
import { reactive } from "vue"
import * as mapWork from "./map.js"
import { $alert } from "@mars/components/mars-ui/index"
 
const formState = reactive({
  radioFanwei: "1",
  radioFendai: "2",
  jd: 0,
  wd: 0,
  alt: 0,
  jdDegree: 0,
  jdMinute: 0,
  jdSecond: 0,
  wdDegree: 0,
  wdMinute: 0,
  wdSecond: 0,
  gk6X: 0,
  gk6Y: 0
})
 
// 全局中间变量
let currJD: number
let currWD: number
let currGD: number
 
// 默认显示地图中心点坐标
mapWork.eventTarget.on("loadCenterPoint", function (event: any) {
  const point = event.point
  currJD = point.lng
  currWD = point.lat
  currGD = point.alt
  formState.jd = mapWork.marsUtilFormtNum(currJD, 6)
  formState.wd = mapWork.marsUtilFormtNum(currWD, 6)
  formState.alt = mapWork.marsUtilFormtNum(currGD, 6)
})
 
const changeJWD = () => {
  currJD = Number(formState.jd)
  currWD = Number(formState.wd)
  currGD = Number(formState.alt)
}
const changeDMS = () => {
  currJD = mapWork.marsDms2degree(formState.jdDegree, formState.jdMinute, formState.jdSecond)
  currWD = mapWork.marsDms2degree(formState.wdDegree, formState.wdMinute, formState.wdSecond)
}
 
const changeGKZone = () => {
  const zoon = mapWork.marsZONEtoCRS(Number(formState.gk6X), Number(formState.gk6Y), formState.radioFendai)
  currJD = zoon[0]
  currWD = zoon[1]
}
 
const changeFanwei = () => {
  switch (formState.radioFanwei) {
    case "2": // 度分秒
      formState.jdDegree = mapWork.marsPointTrans(currJD).degree
      formState.jdMinute = mapWork.marsPointTrans(currJD).minute
      formState.jdSecond = mapWork.marsPointTrans(currJD).second
 
      formState.wdDegree = mapWork.marsPointTrans(currWD).degree
      formState.wdMinute = mapWork.marsPointTrans(currWD).minute
      formState.wdSecond = mapWork.marsPointTrans(currWD).second
 
      break
    case "3": // CGCS2000
      changeFendai()
      break
    default:
      // 十进制
      formState.jd = mapWork.marsUtilFormtNum(currJD, 6)
      formState.wd = mapWork.marsUtilFormtNum(currWD, 6)
      break
  }
}
 
const changeFendai = () => {
  // 十进制转2000平面六分度
  const zoon = mapWork.marsProj4Trans(currJD, currWD, formState.radioFendai)
  formState.gk6X = mapWork.marsUtilFormtNum(zoon[0], 1)
  formState.gk6Y = mapWork.marsUtilFormtNum(zoon[1], 1)
}
 
const bindMourseClick = () => {
  mapWork.bindMourseClick()
}
 
mapWork.eventTarget.on("clickMap", (event: any) => {
  currJD = event.point.lng
  currWD = event.point.lat
  currGD = event.point.alt
 
  formState.jd = mapWork.marsUtilFormtNum(currJD, 6)
  formState.wd = mapWork.marsUtilFormtNum(currWD, 6)
  formState.alt = mapWork.marsUtilFormtNum(currGD, 6)
  changeFanwei()
  // 更新面板
  mapWork.updateMarker(false, currJD, currWD, currGD)
})
 
const submitCenter = () => {
  if (formState.jd > 180 || formState.jd < -180) {
    $alert("请输入有效的经度值!")
    return
  }
  if (formState.wd > 90 || formState.wd < -90) {
    $alert("请输入有效的纬度值!")
    return
  }
  mapWork.updateMarker(true, currJD, currWD, currGD)
}
</script>
<style scoped lang="less">
.shijingzhi {
  width: 286px;
}
.dufenmiao {
  width: 50px;
}
</style>