# 渲染坐标系
渲染坐标系(CoordinateSystem)用于实现GIS数据原始坐标与世界坐标(即渲染坐标)之间的相互转换,当前提供空间直角(CartesianCoordinateSystem)、CAD(CADCoordinateSystem)、墨卡托(MercatorCoordinateSystem)三种类型渲染坐标系。
提示
当前常用的GIS数据包括以下几种:
地测数据(巷道、工作面、地层、钻孔等),通常使用北京54、西安、CGCS2000这三种坐标系;
瓦片地图数据,通常使用Web墨卡托投影坐标系;
3D瓦片数据,通常使用WGS84经纬度坐标系;
CAD瓦片数据
使用渲染坐标系将GIS数据原始坐标转到世界坐标时会经历以下两步操作:
1️⃣ 原始坐标 -> 标准GIS坐标系,根据渲染坐标系类型选择相应的变换,将原始坐标转到标准GIS坐标。
提示
GIS数据原始坐标通常使用左手坐标系,且X-Y平面为水平面,Z轴为向上轴,如下图所示:

提示
标准GIS坐标系使用右手坐标系,且X-Z平面为水平面,Y轴为向上轴,如下图所示:

标准GIS坐标系是绝对坐标系,坐标值是真实的 “大” 坐标。
2️⃣ 标准GIS坐标系 -> 世界坐标系,将标准GIS坐标减去相对中心点变换到世界坐标。
提示
世界坐标系同标准GIS坐标系一样使用右手坐标系,且世界坐标系是相对坐标系。
# 相对中心点
标准GIS坐标使用双精度类型无法直接用于渲染(因为GPU不支持双精度数据),需要减去相对中心点将双精度坐标转为单精度坐标(即世界坐标系),可以通过渲染坐标系提供的属性和方法设置相对中心点。
注意
需要在标准GIS坐标转世界坐标之前设置相对中心点,且相对中心点坐标采用标准GIS坐标系!
🌏 relativeCenter 获取&设置相对中心点。
// 获取当前相对中心点
const relativeCenter = coordinateSystem.relativeCenter;
// 设置相对中心点
coordinateSystem.relativeCenter = [ 12267093.365897719, 100.0, -4816072.715104974 ];
2
3
4
5
🌏 isRelativeCenterValid 判断当前相对中心点是否有效(即,判断中心点是否已设置)。
// 判断相对中心点是否有效
if ( !coordinateSystem.isRelativeCenterValid() ) {
// 相对中心点未设置,需要设置相对中心点
coordinateSystem.relativeCenter = [ 12267093.365897719, 100.0, -4816072.715104974 ];
}
2
3
4
5
6
7
🌏 resetRelativeCenter 重置当前相对中心点(即,将相对中心点设置为无效)。
// 重置当前相对中心点
coordinateSystem.resetRelativeCenter();
2
注意
相对中心点通常只需要设置一次,除非GIS原始数据坐标系或渲染坐标系发生改变。
# 坐标转换接口
🌏 fromGeodeticToGIS 地测坐标转标准GIS坐标,左手坐标系->右手坐标系。
// 地测(巷道、工作面、地层、钻孔等数据)坐标转标准GIS坐标
const gis = coordinateSystem.fromGeodeticToGIS( 12267145.673681745, 4816017.480262117, 0.0 );
2
🌏 fromGISToGeodetic 标准GIS坐标转地测坐标,右手坐标系->左手坐标系。
// 标准GIS坐标转地测坐标
const geodetic = coordinateSystem.fromGISToGeodetic( 12267145.673681745, 0.0, -4816017.480262117 );
2
🌏 fromGeographicToGIS 地理坐标(经度、纬度、海拔高度)转标准GIS坐标。
// 地理坐标转标准GIS坐标
const gis = coordinateSystem.fromGeographicToGIS( 110.20345733675236, 39.65668117021778, 10.0 );
2
🌏 fromGISToGeographic 标准GIS坐标转地理坐标(经度、纬度、海拔高度)。
// 标准GIS坐标转地理坐标
const geographic = coordinateSystem.fromGISToGeographic( 100.0, 0.0, 500.0 );
2
🌏 fromGISToWorld 标准GIS坐标转世界坐标,右手坐标系->右手坐标系。
// 标准GIS坐标转世界坐标
const world = coordinateSystem.fromGISToWorld( 12267145.673681745, 0.0, -4816017.480262117 );
2
🌏 fromWorldToGIS 世界坐标转标准GIS坐标,右手坐标系->右手坐标系。
// 世界坐标转标准GIS坐标
const gis = coordinateSystem.fromWorldToGIS( 100.0, 0.0, 500.0 );
2
🌏 fromGeodeticToWorld 地测坐标转世界坐标,左手坐标系->右手坐标系。
// 地测(巷道、工作面、地层、钻孔等数据)坐标转世界坐标
const world = coordinateSystem.fromGeodeticToWorld( 37431100.40625, 4391638, 0.0 );
2
🌏 fromWorldToGeodetic 世界坐标转地测坐标,右手坐标系->左手坐标系。
// 世界坐标转地测坐标
const geodetic = coordinateSystem.fromWorldToGeodetic( 100.0, 0.0, 500.0 );
2
🌏 fromGeographicToWorld 地理坐标(经度、纬度,海拔高度)转世界坐标。
// 地理坐标转世界坐标
const world = coordinateSystem.fromGeographicToWorld( 110.20345733675236, 39.65668117021778, 10.0 );
2
🌏 fromWorldToGeographic 世界坐标转地理坐标(经度、纬度、海拔高度)。
// 世界坐标转地理坐标
const geographic = coordinateSystem.fromWorldToGeographic( 100.0, 0.0, 500.0 );
2
# 空间直角渲染坐标系
空间直角渲染坐标系(CartesianCoordinateSystem)为默认渲染坐标系,支持相同坐标系数据叠加渲染,不支持不同坐标系数据叠加渲染。
# CAD渲染坐标系
CAD渲染坐标系(CADCoordinateSystem)为TX3D Engine特有坐标系,可以用于实现巷道和CAD瓦片地图叠加渲染。
提示
创建CAD渲染坐标系时,需要设置CAD图边界范围
import { CADCoordinateSystem } from '@tx3d/core';
const coordinateSystem = new CADCoordinateSystem( [ 537346.5415420881, 4441092.000029248, 558622.5415859604, 4426908.000000001 ] );
2
3
# 墨卡托渲染坐标系
墨卡托渲染坐标系(MercatorCoordinateSystem)适用于地测数据与地图数据叠加渲染。
提示
坐标转换之前需要先调用setGeodeticOptions设置地测坐标变换参数
1️⃣ 通过坐标系名称设置地测坐标系参数-setGeodeticOptions
// 设置地测坐标系为“北京54”
coordinateSystem.setGeodeticOptions( 'BEIJING54' );
2
2️⃣ 通过EPSG编码设置地测坐标系参数-setGeodeticOptions
// 设置地测坐标系EPSG
coordinateSysem.setGeodeticOptions( 4525 );
2
地测坐标变换参数详见GeodeticOptions。
注意
1️⃣ 如果地测数据包含“带号”则不需要设置zone参数,反之则需要设置:
不设置zone参数
// 设置地测坐标系为“CGCS2000”
coordinateSysem.setGeodeticOptions( 'CGCS2000' );
// 地测坐标(包含带号)转标准GIS坐标
const gis = coordinateSystem.fromGeodeticToGIS( 37430872.40625, 4391450, 1315.724976 );
2
3
4
5
设置zone参数
// 设置地测坐标系EPSG编码为4525,并指定“带号”
coordinateSysem.setGeodeticOptions( 4525, { zone: 37 } );
// 地测坐标(不包含带号)转标准GIS坐标
const gis = coordinateSystem.fromGeodeticToGIS( 430872.40625, 4391450, 1315.724976 );
2
3
4
5
2️⃣ 可以通过ignoreZoneWhenToGeodetic参数控制标准GIS坐标转地测坐标的结果是否包含带号:
不包含带号
// 设置地测坐标系,设置标准GIS坐标转地测坐标结果不包含带号
coordinateSysem.setGeodeticOptions( 'CGCS2000', { zone: 37, ignoreZoneWhenToGeodetic: true } );
// 标准GIS坐标转地测坐标(不包含带号)
const geodetic = coordinateSystem.fromGISToGeodetic( 12266799.840676304, 1315.724976, -4815825.251295619 ); // 转换结果为[ 430872.40625, 4391450, 1315.724976 ]
2
3
4
5
包含带号
// 设置地测坐标系,设置标准GIS坐标转地测坐标结果包含带号
coordinateSysem.setGeodeticOptions( 4525, { ignoreZoneWhenToGeodetic: false } );
// 标准GIS坐标转地测坐标(包含带号)
const geodetic = coordinateSystem.fromGISToGeodetic( 12266799.840676304, 1315.724976, -4815825.251295619 ); // 转换结果为[ 37430872.40625, 4391450, 1315.724976 ]
2
3
4
5