坐标修改、提示框样式修改
This commit is contained in:
		| @ -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 = ` | ||||
|                   <span>x:</span><span>${Number(result.points[0].x.toFixed(6))}</span> | ||||
|                   <span style="margin-left: 5px;">y:</span><span>${Number(result.points[0].y.toFixed(6))}</span> | ||||
|                   <span style="margin-left: 5px;">z:</span><span>${Number(result.points[0].z.toFixed(6))}</span> | ||||
|                 ` | ||||
|               } | ||||
|  | ||||
|             } | ||||
|           } | ||||
|         } | ||||
| @ -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 = ` | ||||
|                   <span>x:</span><span>${Number(result.points[0].x.toFixed(6))}</span> | ||||
|                   <span style="margin-left: 5px;">y:</span><span>${Number(result.points[0].y.toFixed(6))}</span> | ||||
| @ -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 | ||||
| } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user