diff --git a/src/Global/MouseCoordinate/index.js b/src/Global/MouseCoordinate/index.js index d1fa1dd..d029d35 100644 --- a/src/Global/MouseCoordinate/index.js +++ b/src/Global/MouseCoordinate/index.js @@ -68,6 +68,58 @@ const MouseCoordinate = (sdk, status) => { tmovement = { ...movement.endPosition } }) + const posiToCoordinate = (coordinateSystem, position) => { + let type + switch (coordinateSystem) { + case 'EPSG:32601'://WGS84 通用横轴墨卡托投影 + //带号 = ⌊(经度 + 180)/6⌋ + 1 + var dh = Math.round((position.lng + 180) / 6 + 1) + + if (position.lat > 0) {//北纬 + type = 32600 + dh + type = 'EPSG:' + type + } else {//南纬 + type = 32700 + dh + type = 'EPSG:' + type + } + break; + case 'EPSG:4534'://2000 坐标 3 度不带代号 + //N = round(经度/3) + //EPSG = N - 25 + 4534 + + var dh3y = Math.round(position.lng / 3) + type = dh3y - 25 + 4534 + type = 'EPSG:' + type + break; + case 'EPSG:4513'://2000 坐标 3 度带代号 + //N = round(经度/3) + //EPSG = N - 25 + 4513 + var dh3w = Math.round(position.lng / 3) + type = dh3w - 25 + 4513 + type = 'EPSG:' + type + break; + case 'EPSG:4502'://2000 坐标 6 度不带代号 + let zoneNumber = Math.floor(position.lng / 6) + 31 + // 中国区域6度带带号范围为13-23 + if (zoneNumber < 13) zoneNumber = 13; + if (zoneNumber > 23) zoneNumber = 23; + type = (zoneNumber - 13) + 4502 + type = 'EPSG:' + type + break; + case 'EPSG:4491'://2000 坐标 6 度带代号 + //N = floor(longitude/6) + 31 + var dh6 = Math.floor(position.lng / 6) + 31 + // 中国区域6度带带号范围为13-23 + if (dh6 < 13) dh6 = 13; + if (dh6 > 23) dh6 = 23; + type = (dh6 - 13) + 4491 + type = 'EPSG:' + type + break; + default: + break; + } + return type + } const getPosition = () => { if (!targetSdk) { return @@ -142,7 +194,8 @@ const MouseCoordinate = (sdk, status) => { } } else { - let result = tools.convert([{ x: degrees.lng, y: degrees.lat, z: degrees.alt }], 'EPSG:4326', coordinateSystem) + // let result = tools.convert([{ x: degrees.lng, y: degrees.lat, z: degrees.alt }], 'EPSG:4326', coordinateSystem) + let result = tools.convert([{ x: degrees.lng, y: degrees.lat, z: degrees.alt }], 'EPSG:4326', posiToCoordinate(coordinateSystem, degrees)) position = result.points[0] contentElm.innerHTML = `

x:${position.x.toFixed(6)}

y:${position.y.toFixed(6)}

z:${position.z.toFixed(6)}

` } diff --git a/src/Global/global.js b/src/Global/global.js index 630f0d0..b4f133c 100644 --- a/src/Global/global.js +++ b/src/Global/global.js @@ -230,13 +230,16 @@ function CesiumContainer(sdk, options) { } } else { - let result = proj.convert([{ x: position.lng, y: position.lat, z: position.alt }], 'EPSG:4326', coordinateSystem) - console.log(result, 'result12'); - infoElm.innerHTML = ` + // let result = proj.convert([{ x: position.lng, y: position.lat, z: position.alt }], 'EPSG:4326', coordinateSystem) + let result = proj.convert([{ x: position.lng, y: position.lat, z: position.alt }], 'EPSG:4326', posiToCoordinate(coordinateSystem, position)) + if (result.points.length) { + infoElm.innerHTML = ` x:${Number(result.points[0].x.toFixed(6))} y:${Number(result.points[0].y.toFixed(6))} z:${Number(result.points[0].z.toFixed(6))} ` + } + } } } @@ -803,8 +806,8 @@ function setCoordinateSystem(sdk, epsg) { } } else { - let result = proj.convert([{ x: position.lng, y: position.lat, z: position.alt }], 'EPSG:4326', coordinateSystem) - console.log(result, 'result') + // let result = proj.convert([{ x: position.lng, y: position.lat, z: position.alt }], 'EPSG:4326', coordinateSystem) + let result = proj.convert([{ x: position.lng, y: position.lat, z: position.alt }], 'EPSG:4326', posiToCoordinate(coordinateSystem, position)) infoElm.innerHTML = ` x:${Number(result.points[0].x.toFixed(6))} y:${Number(result.points[0].y.toFixed(6))} @@ -812,7 +815,58 @@ function setCoordinateSystem(sdk, epsg) { ` } } +function posiToCoordinate(coordinateSystem, position) { + let type + switch (coordinateSystem) { + case 'EPSG:32601'://WGS84 通用横轴墨卡托投影 + //带号 = ⌊(经度 + 180)/6⌋ + 1 + var dh = Math.floor((position.lng + 180) / 6 + 1) + if (position.lat > 0) {//北纬 + type = 32600 + dh + type = 'EPSG:' + type + } else {//南纬 + type = 32700 + dh + type = 'EPSG:' + type + } + break; + case 'EPSG:4534'://2000 坐标 3 度不带代号 + //N = round(经度/3) + //EPSG = N - 25 + 4534 + + var dh3y = Math.round(position.lng / 3) + type = dh3y - 25 + 4534 + type = 'EPSG:' + type + break; + case 'EPSG:4513'://2000 坐标 3 度带代号 + //N = round(经度/3) + //EPSG = N - 25 + 4513 + var dh3w = Math.round(position.lng / 3) + type = dh3w - 25 + 4513 + type = 'EPSG:' + type + break; + case 'EPSG:4502'://2000 坐标 6 度不带代号 + let zoneNumber = Math.floor(position.lng / 6) + 31 + // 中国区域6度带带号范围为13-23 + if (zoneNumber < 13) zoneNumber = 13; + if (zoneNumber > 23) zoneNumber = 23; + type = (zoneNumber - 13) + 4502 + type = 'EPSG:' + type + break; + case 'EPSG:4491'://2000 坐标 6 度带代号 + //N = floor(longitude/6) + 31 + var dh6 = Math.floor(position.lng / 6) + 31 + // 中国区域6度带带号范围为13-23 + if (dh6 < 13) dh6 = 13; + if (dh6 > 23) dh6 = 23; + type = (dh6 - 13) + 4491 + type = 'EPSG:' + type + break; + default: + break; + } + return type +} function getDMS() { return positionType } diff --git a/static/custom/css/index.css b/static/custom/css/index.css index 13c193a..23e7778 100644 --- a/static/custom/css/index.css +++ b/static/custom/css/index.css @@ -3862,12 +3862,24 @@ } #YJ-custom-message.success { - background-color: #f0f9eb; - color: rgb(82, 196, 26); + /* background-color: #f0f9eb; */ + /* color: rgb(82, 196, 26); */ + background: + linear-gradient(180deg, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), + linear-gradient(0deg, rgba(27, 248, 195, 0.5) 0%, rgba(27, 248, 195, 0) 100%); + font-size: 14px !important; + font-weight: 500 !important; + color: rgba(27, 248, 195, 1); } #YJ-custom-message.warning { - background-color: #fdf6ec; - color: #e6a23c; + /* background-color: #fdf6ec; + color: #e6a23c; */ + background: + linear-gradient(180deg, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), + linear-gradient(0deg, rgba(255, 161, 69, 0.5) 0%, rgba(255, 161, 69, 0) 100%); + font-size: 14px !important; + font-weight: 500 !important; + color: rgba(255, 161, 69, 1) } /* 滑入动画 */