1. GeoUtil

1.1. new GeoUtil()

Geo通用工具类

1.2. 方法

1.2.1. GeoUtil.flyTo(longitude, latitude, height, time)

飞行至某个点的正上方

Param Type Description
longitude Number

经度

latitude Number

纬度

height Number

高度

time Number

飞行时间[可选,默认2秒

Example

BOSGeo.GeoUtil.flyTo(120.009, 35.870, 1000);

1.2.2. GeoUtil.flyToBBox(bbox)

飞行至指定范围

Param Type Description
bbox Array.<Number>

通过西南角和东北角的经纬度坐标点表示范围[西,南,东,北

Example

BOSGeo.GeoUtil.flyToBBox([120.000222, 35.867862, 120.017962, 35.872760]);

1.2.3. GeoUtil.flyToOffset(longitude, latitude, [time], [height])

飞行至某个点位,45°俯视角

Param Type Default Description
longitude Number

经度

latitude Number

纬度

[time] Number 2

飞行时间,默认2秒

[height] Number 150

高度,默认150米

Example

BOSGeo.GeoUtil.flyToOffset(120.009, 35.870, 2, 1000);

1.2.4. GeoUtil.flyToUnderground([undergroundStyle], [altitude], [flyToPitch])

相机进入地上或者地下

Param Type Default Description
[undergroundStyle] Boolean true

是否进入地下,true为是,false为否,默认为true。

[altitude] Number -10

进入地下或地上时相机的高度,进入地下的默认高度为-10,进入地上时的默认高度为50。

[flyToPitch] Number -45

进入地下或地上时相机的俯仰角,进入地下的默认俯仰角为2°,进入地上时的默认俯仰角为-45°。

Example

BOSGeo.GeoUtil.flyToUnderground(true); //切换进入地下地上

1.2.5. GeoUtil.getCameraPositionOrientation() ⇒ Object

获取当前相机的坐标和视角

Returns : Object -

-返回相机笛卡尔坐标(position-{x,y,z})和视角信息(orientation-{heading, pitch, roll}分别代表偏航角、俯仰角和翻滚角,单位为弧度)

Example

let posOri = BOSGeo.GeoUtil.getCameraPositionOrientation();
console.log("相机坐标-对象", BOSGeo.GeoUtil.cartesian2degress(posOri.position));
console.log("相机坐标-数组", BOSGeo.GeoUtil.cartesianToArray(posOri.position));
console.log("相机视角", BOSGeo.Math.toDegrees(posOri.orientation.heading), BOSGeo.Math.toDegrees(posOri.orientation.pitch), BOSGeo.Math.toDegrees(posOri.orientation.roll));

1.2.6. GeoUtil.getCameraPositionOrientation2() ⇒ Object

获取当前相机的坐标和视角

Returns : Object -

posAndOri -返回相机地理坐标(position-[经度,纬度,高度])和视角信息(orientation-[偏航角,俯仰角,翻滚角] ,单位为角度)

Example

let posOri = BOSGeo.GeoUtil.getCameraPositionOrientation2();
console.log("相机方位", posOri);

1.2.7. GeoUtil.cameraJudgeVisible(height, tileset, isjudgeRange, [nearFar]) ⇒ Boolean

根据相机视角高判断是否显示3DTiles模型

Returns : Boolean -

visible 返回3DTiles模型是否显示

Param Type Description
height Number

判断显示的最大高度

tileset Cesium3DTileset

3DTiles模型对象

isjudgeRange Boolean

是否进行判断在视角范围内进行显示

[nearFar] Array.<number>

模型距离相机的最近和最远显示距离,默认值[0.0,Number.MAX_VALUE],模型之外范围均可见

Example

BOSGeo.GeoUtil.cameraJudgeVisible(3000, tileset, true, [0, 4500])

1.2.8. GeoUtil.distanceDisplayConditionVisible(model, nearFar) ⇒ boolean

模型距离相机的最近和最远显示距离

Returns : boolean -

是否可见

Param Type Description
model Object

model -3DTiles或model模型对象

nearFar Array.<number>

模型距离相机的最近和最远显示距离,默认值[0.0,Number.MAX_VALUE],模型之外范围均可见

Example

BOSGeo.GeoUtil.distanceDisplayConditionVisible(tileset, [0, 4500])

1.2.9. GeoUtil.viewFix(longitude, latitude, height, orientation, duration, complete)

飞行至指定位置和视角

Param Type Description
longitude Number

经度

latitude Number

纬度

height Number

相机高度

orientation Object

方位,{heading,pitch,roll},分别代表偏航角、俯仰角、翻滚角,单位为度, 取值范围分别为-180≤heading≤180、-90≤pitch≤90、-180≤roll≤180

duration Number

飞行时间,单位为秒

complete function

相机停止移动之后的回调函数

Example

let orientation = {
    heading: 0, 
    pitch: -45, 
    roll: 0
};
function completeCallback() {
    alert("您已到达目的地!")
}
BOSGeo.GeoUtil.viewFix(113.8, 22.6, 10000, orientation, 3, completeCallback);

1.2.10. GeoUtil.getRetangleFromPoints(points, [gap]) ⇒ Array.<Number>

根据输入点集计算多边形区域

Returns : Array.<Number> -

范围最大最小经纬度范围坐标,格式为[minLon, minLat, maxLon, maxLat]

Param Type Default Description
points Array.<Number>

坐标数组

[gap] Number 3

当points为经纬度高度数组时 gap = 3,为经纬度数组时 gap = 2

Example

BOSGeo.GeoUtil.getRetangleFromPoints(points, gap)

1.2.11. GeoUtil.computeModelMatrix(longitude, latitude, height, heading, pitch, roll) ⇒ Matrix4

计算模型矩阵

Returns : Matrix4 -

返回4*4的转换矩阵

Param Type Description
longitude Number

经度(单位为度)

latitude Number

纬度(单位为度)

height Number

高度(单位为米)

heading Number

偏航角(单位为度)

pitch Number

俯仰角(单位为度)

roll Number

翻滚角(单位为度)

Example

BOSGeo.GeoUtil.computeModelMatrix(120.12, 34.0, 0, 0, 0, 0);

1.2.12. GeoUtil.getTileMatrix4(longitude, latitude, height, heading) ⇒ Matrix4

获取模型矩阵

Returns : Matrix4 -

返回4*4的转换矩阵

Param Type Description
longitude Number

经度(单位为度)

latitude Number

纬度(单位为度)

height Number

高度(单位为米)

heading Number

heading角(单位为度)

Example

BOSGeo.GeoUtil.getTileMatrix4(longitude, latitude, height, heading);

1.2.13. GeoUtil.getModelScale(model) ⇒ Cartesian3

获取模型的缩放尺寸

Returns : Cartesian3 -

模型在xyz方向的缩放尺寸

Param Type Description
model Cesium3DTileset | Model

3DTiles或glTF模型

Example

var scaleInfo = BOSGeo.GeoUtil.getModelScale(tileset);

1.2.14. GeoUtil.getTilesetClippingMatrix(tileset) ⇒ Matrix4

获取模型剖切面集合对应的转换矩阵

Returns : Matrix4 -

剖切面集合的转换矩阵

Param Type Description
tileset Cesium3DTileset

待剖切的3DTiles模型对象

Example

BOSGeo.GeoUtil.getTilesetClippingMatrix(tileset);

1.2.15. GeoUtil.cartesianToArray(cartesian3) ⇒ Array.<Number>

笛卡尔坐标转地理坐标(经纬度和海拔高度)

Returns : Array.<Number> -

返回包含经纬度和高度的数组

Param Type Description
cartesian3 Cartesian3

三维笛卡尔坐标

Example

let coord = BOSGeo.Cartesian3.fromDegrees(114.042, 22.516, 0);//经纬度坐标转笛卡尔坐标
BOSGeo.GeoUtil.cartesianToArray(coord);

1.2.16. GeoUtil.cartesian2degress(cartesian3) ⇒ Object

笛卡尔坐标转地理坐标(经纬度和海拔高度)

Returns : Object -

返回包含经纬度和高度的对象

Param Type Description
cartesian3 Cartesian3

三维笛卡尔坐标

Example

let coord = BOSGeo.Cartesian3.fromDegrees(114.042, 22.516, 0);//经纬度坐标转笛卡尔坐标
BOSGeo.GeoUtil.cartesian2degress(coord);

1.2.17. GeoUtil.geoCoord2windowCoord(geoCoord) ⇒ Cartesian2

地理坐标转屏幕坐标

Returns : Cartesian2 -

二维屏幕坐标

Param Type Description
geoCoord Cartesian3 | Array.<Number>

可以是三维笛卡尔坐标也可以是经纬度坐标数组

Example

let geoCoord = BOSGeo.Cartesian3.fromDegrees(114.042, 22.516, 0);//经纬度坐标转笛卡尔坐标
BOSGeo.GeoUtil.geoCoord2windowCoord(geoCoord);

1.2.18. GeoUtil.getCartographic(geoCoord) ⇒ Cartesian2

屏幕坐标转地理坐标

Returns : Object -

经纬度高程坐标{x,y,z}

Param Type Description
position Cartesian2

二维屏幕坐标

Example

let windowCoord =BOSGeo.Cartesian2(150, 250);//屏幕坐标
BOSGeo.GeoUtil.getCartographic(windowCoord);

1.2.19. GeoUtil.getPickPosition(windowCoord) ⇒ Array.<Number>

获取鼠标选中位置的坐标点(实时获取ArcGIS地形的高程信息性能较差,如有需要建议使用其他地形数据)

Returns : Array.<Number> -

返回包含经纬度和高度的数组

Param Type Description
windowCoord Object

屏幕坐标

Example

BOSGeo.GeoUtil.getPickPosition(windowCoord);

1.2.20. GeoUtil.modelToparams(modellayer) ⇒ Object

获取glTF模型的参数

Returns : Object -

返回包含模型经度、纬度、高度、偏航角、俯仰角、翻滚角和包围盒半径的对象

Param Type Description
modellayer Primitive

gltf模型

Example

BOSGeo.GeoUtil.modelToparams(model)

1.2.21. GeoUtil.tileToparams(3DTiles模型) ⇒ Object

获取3dtile模型的参数

Returns : Object -

返回包含模型经度、纬度、高度、偏航角、俯仰角、翻滚角和包围盒半径的对象

Param Type
3DTiles模型 Cesium3DTileset

Example

BOSGeo.GeoUtil.tileToparams(tileset)

1.2.22. GeoUtil.calculateModelPositionConfig(model) ⇒ Object

获取模型参数

Returns : Object -

返回包含模型经度、纬度、高度、偏航角、俯仰角、翻滚角和包围盒半径的对象

Param Type
model Cesium3DTileset | Model

Example

BOSGeo.GeoUtil.calculateModelPositionConfig(model)

1.2.23. GeoUtil.getLinkedPointList(startPosition, endPosition, length, num) ⇒ Array

计算两点之间的弧线

Returns : Array -

弧线

Param Type Description
startPosition cartesian

起始位置

endPosition cartesian

终点位置

length Number

最高点的高度

num Number

返回点的数量

Example

BOSGeo.GeoUtil.getLinkedPointList(startPosition, endPosition, length, num);

1.2.24. GeoUtil.swapFeature(model, previousIdConfig, nextModelParam, callback)

模型替换

Param Type Default Description
model Cesium3DTileset | Model

白模模型或替换白模模型的模型

previousIdConfig Object

提供被替换的要素信息,{key:'id', value:'xxxx'},表示唯一标志与值。

[previousIdConfig.key] String 'id'

模型的唯一标志字段,默认为"id";

previousIdConfig.value String

模型唯一标志字段的值,用于获取要替换的图块;

nextModelParam Object

提供接替换模型要素的信息

nextModelParam.url String

模型地址;

[nextModelParam.featureType] String BOSGeo.FeatureType.TILES

模型类型,包括BOSGeo.FeatureType.TILES, FeatureType.GLTF,FeatureType.BIM,FeatureType.PHOTO和FeatureType.POINTCLOUD;

[nextModelParam.name] String

名称,不设置则为undefined;

[nextModelParam.position] Cartesian3 | Array.<number>

模型位置,三维笛卡尔坐标或者经纬度坐标;

[nextModelParam.rotation] Array.<number> [0,0,0]

模型角度,[偏航角,俯仰角,翻滚角],单位为角度;

[nextModelParam.scale] Number 1

模型缩放比例;

[nextModelParam.enhance] Boolean false

增强模型光,若为true,luminanceAtZenith=0.8,模型显示将变得更明亮;

[nextModelParam.luminanceAtZenith] Number 0.2

自定义太阳在天顶时模型的亮度,用于该模型的过程环境光,若enhance为true,该参数将不起作用;

callback function

替换成功的回调,会将当前新增的模型(Cesium3DTileset | Model)作为参数返回

Example

const {WGS84_POSITION, FEATURE} = BOSGeo.MapPickType;
geomap.on(BOSGeo.MapEventType.LEFT_CLICK, (e) => {
    const p = e.wgs84_position;
    if (e.feature) {
        const picked = BOSGeo.GeoUtil.getPickTargetFeature(e.feature);
        let pickedModel = picked.target; //点击的整个模型

        //属于白模
        if (pickedModel.featureType === BOSGeo.FeatureType.WHITE_MODEL) {
            let pickedPart = picked.currentTarget;
            const uniqueId = 'name'; //f.getPropertyNames();
            const curBuilding = {
                key: uniqueId,
                value: pickedPart.getProperty(uniqueId),
            }

            const nextModelConfig = {
                url: 'https://bosgeo.boswinner.com/geoData/models/glTF/CesiumBoxTest.gltf',
                position: [p.longitude, p.latitude, 100],
                featureType: BOSGeo.FeatureType.GLTF,
                scale: 5,
            }

            //关键函数:
            BOSGeo.GeoUtil.swapFeature(pickedModel, curBuilding, nextModelConfig, () => alert('更换模型加载完毕'));
        }
        //属于被替换后的模型,再次替换
        else if (picked.isForSwap) {
            BOSGeo.GeoUtil.swapFeature(picked.swapTarget, picked.swapConfig, {
                url: 'https://bosgeo.boswinner.com/geoData/models/glb/WaterBottle.glb',
                position: [p.longitude, p.latitude, 100],
                featureType: BOSGeo.FeatureType.GLTF,
                scale: 30,
            }, () => alert('更换模型加载完毕'));

            //取消当前替换替换:
            //BOSGeo.GeoUtil.cancelSwapFeature(picked.swapTarget, picked.swapConfig); 

            //取消所有替换: 
            //BOSGeo.GeoUtil.cancelSwapFeature(picked.swapTarget); 
        }

    }

}, [WGS84_POSITION, FEATURE])

1.2.25. GeoUtil.cancelSwapFeature(whiteModel, [previousIdConfig])

取消白模模型整体替换

Param Type Description
whiteModel Cesium3DTileset

需要取消的白模模型

[previousIdConfig] Object

选填,若提供则取消单个替换,否则取消所有替换,该参数中提供被替换的要素信息,{key:'id', value:'xxxx'},表示唯一标志与值。

1.2.26. GeoUtil.getPickTargetFeature(feature) ⇒ Object

获取地图拾取对象并配置属性。结合地图监听事件,获取在地图上拾取的feature(模型<Model、Cesium3DTileset>或矢量要素<Point、Line、Area的Entity>)对象,并配置属性,用于替换和移动等操作。

Returns: Object -

返回添加属性后的对象{type, target}

Param Type Description
feature Object

来自地图拾取函数所获得的对象

Example

const {FEATURE} = BOSGeo.MapPickType;
geomap.on(BOSGeo.MapEventType.LEFT_CLICK, (e) => {
    if (e.feature) {
        const target = BOSGeo.GeoUtil.getPickTargetFeature(e.feature).target;
    }
}, [FEATURE])

1.2.27. GeoUtil.selectFeature(feature, [selectColor], callback)

选中模型或者点线面要素(3dtiles、gltf、point、line、area对象,这些要素需通过layer添加),并高亮显示

Param Type Default Description
feature Model PointLineArea

选中要素,支持多个要素以数组方式传入

[selectColor] String '#04fffd8c'

被选中要素的颜色,可以是 #rgb, #rgba, #rrggbb, #rrggbbaa, rgb(), rgba(), hsl()或者hsla()格式的css颜色值;

callback function

选中后的回调函数,callback(last, current)参数包括上次选中的要素(存在数组中)与这次选中的要素

Example

geomap.on(BOSGeo.MapEventType.LEFT_CLICK, (e) => {
    if (e.feature) {
        const f = BOSGeo.GeoUtil.getPickTargetFeature(e.feature).target;
        BOSGeo.GeoUtil.selectFeature(f, '#23a3de', function (last, current) {
            console.log('上次选中元素:', last);
            console.log('这次选中元素:', current);
        });
    }

}, [BOSGeo.MapPickType.FEATURE]);

1.2.28. GeoUtil.modifyingElement(feature, modifyOptions, callback)

调整点线面图层中的元素

Param Type Description
feature PointLineArea

点图层(PointLayer,LayerType.POINT)通过add方法添加的点,线图层(LineLayer,LayerType.LINE)通过add方法添加的线,面图层(AreaLayer,LayerType.AREA)通过add方法添加的面。

modifyOptions Object

调整选项

[modifyOptions.point] Object

调整点图层中的Point对象,选项包括

[modifyOptions.point.offset] Array.<Number>

Point对象在xyz方向的偏移.

[modifyOptions.point.scale] Number

Point对象缩放,默认1.0

[modifyOptions.point.font] String

Point对象修改文字字体

[modifyOptions.point.fontColor] String

Point对象修改文字颜色

[modifyOptions.point.image] String \ Image

Point对象修改图片

[modifyOptions.point.imageColor] String

Point对象修改图片颜色

[modifyOptions.line] Object

调整线图层中的Line对象,选项包括

[modifyOptions.line.width] Number

Line对象粗细

[modifyOptions.line.isReverse] Boolean

Line对象是否逆向,适用于流动线

[modifyOptions.line.heightOffset] Number

Line对象整体高度偏移(在初始状态的基础上增加或者减少的量)

[modifyOptions.line.customMaterial] CustomLineMaterial

Line对象自定义材质

[modifyOptions.area] Object

调整面图层中的Area对象,选项包括

[modifyOptions.area.landMaterial] CustomAreaMaterial

Area对象中区域面的材质

[modifyOptions.area.wallMaterial] CustomAreaMaterial

Area对象存在墙时,墙材质。

[modifyOptions.area.wallHeight] Number

Area对象存在墙时,墙高度。

callback function

修改后的回调函数

Example

//创建点图层:pointLayer
//添加点:point
BOSGeo.GeoUtil.modifyingElement(point,{point:{fontColor:'#a31515',font:'italic bold 200px arial,sans-serif'}});
//创建线图层:lineLayer
//添加线: line
var lineMaterial = BOSGeo.CustomLineMaterial.LineColorMaterial.clone();
lineMaterial.color = BOSGeo.Color.fromCssColorString('#fff000');
BOSGeo.GeoUtil.modifyingElement(line,{line:{width: 10, isReverse: true, customMaterial: lineMaterial}});
//创建面图层:areaLayer
//添加面: area
BOSGeo.GeoUtil.modifyingElement(area,{area:{landMaterial:BOSGeo.CustomAreaMaterial.CheckboardMaterial }});

1.2.29. GeoUtil.setTilesetMatrix(modelMatrix, position, orientation, [scale])

设置3DTiles模型位置、角度、大小 NOTE: 可以直接传tileset._root.transform

Param Type Default Description
modelMatrix Array.<number>

模型转换矩阵.

position Cartesian3 | Array.<number>

模型位置,三维笛卡尔坐标或者经纬度坐标

orientation Array.<number>

模型角度,[偏航角,俯仰角,翻滚角],单位为角度

[scale] Number 1

缩放比例,取值范围(0-1]

Example

BOSGeo.GeoUtil.setTilesetMatrix(modelMatrix, position, orientation, scale);

1.2.30. GeoUtil.setTilesetHeight(tileset, heightOffset)

调整模型高度

Param Type Description
tileset Cesium3DTileset

3DTiles模型对象

heightOffset Number

模型需整体抬升或降低的高度

Example

BOSGeo.GeoUtil.setTilesetHeight(tiles.feature, 10);

1.2.31. GeoUtil.setGltfModelMatrix(model, position, orientation, [scale])

设置gltf模型位置、角度、大小 NOTE: 不能传model.modelMatrix

Param Type Default Description
model Primitive

glTF模型,调整后会把scale、orientation记录到model._modifyOptions参数中,位置记录到model._modelPosition

position Cartesian3 | Array.<number>

模型位置,三维笛卡尔坐标或者经纬度坐标

orientation Array.<number>

模型角度,[偏航角,俯仰角,翻滚角]

[scale] Number 1

缩放比例,取值范围(0-1]

Example

BOSGeo.GeoUtil.setGltfModelMatrix(model, position, orientation, scale);

1.2.32. GeoUtil.modifyingModel(model, modifyOptions, callback) ⇒ Object

调整模型方位和缩放比例

Param Type Description
model Cesium3DTileset | Model

3DTiles或glTF模型

modifyOptions Object
[modifyOptions.scale] Array.<Number>

对模型在xyz方向的缩放,如[1,1,1],默认null,即不起效,设置后记录在model._modifyOptions.scale中,调整后的缩放值存在model._scaleXYZ中;

[modifyOptions.rotation] Array.<Number>

模型旋转角度[heading, pitch, roll],如[0,0,0],默认[0,0,0],即不起效,设置后记录在model._modifyOptions.rotation中,调整后的旋转角度存在model._rotation中;

[modifyOptions.offset] Array.<Number>

模型在xyz方向的偏移,常用于模型拖动,如[0,0,0],默认[0,0,0],调整后的经纬度位置存在model._modelPosition中,与modifyOptions.position作用类似,设置modifyOptions.position时不起效,设置后记录在model._modifyOptions.offset中。

[modifyOptions.position] Array.<Number>

设置模型的经纬度高程进行调整,如[112,23,10],默认为null,即不起效,调整后的经纬度位置存在model._modelPosition中,模型原始位置为model.model_position,适用于输入经纬度高程对模型进行调整,设置后modifyOptions.offset不起效,两者均调整模型位置。

callback function

修改后的回调函数

Returns : Object -

模型调整后最终的方位和缩放信息,包括位置(position-[经度,纬度,高度])、旋转角(rotation-[偏航角,俯仰角,翻滚角] ,单位为角度)和模型在xyz方向的缩放(scaleXYZ)。

Example

//创建模型图层:modelLayer
//添加模型
myModel = modelLayer.add({
    name: '测试模型',
    url: 'https://bosgeo.boswinner.com/geoData/models/glTF/CesiumBoxTest.gltf',    //9kb  
    position: [113, 23, 10],
    featureType: BOSGeo.FeatureType.GLTF
});
BOSGeo.GeoUtil.modifyingModel(myModel, {offset: [0, 0, 100]});

1.2.33. GeoUtil.computeCirclePolygon(center, radius) ⇒ Array.<cartesian3>

圆形细分

Returns: Array.<cartesian3> -

返回圆形细分的坐标

Param Type Description
center Array.<Number> \ cartesian3

圆心坐标,可以是经纬度坐标数组,也可以是三维笛卡尔坐标对象

radius Number

半径,须大于0

Example

BOSGeo.GeoUtil.computeCirclePolygon(center, radius);

1.2.34. GeoUtil.getTileCaches(tileset) ⇒ Array.<Cesium3DTile>

获取tileset的当前Cesium3DTile对象缓存

Param Type Description
tileset Cesium3DTileset

3DTiles模型对象

Example

var tiles = BOSGeo.GeoUtil.getTileCaches(tileset);

1.2.35. GeoUtil.getFeatureByKey(tileset, key) ⇒ Cesium3DTileFeature | undefined

获取tileset的当前缓存中属性key的Cesium3DTileFeature对象

Param Type Description
tileset Cesium3DTileset

3DTiles模型对象

key String

构件key

Example

var feature = BOSGeo.GeoUtil.getFeatureByKey(tileset, key);

1.2.36. GeoUtil.getLocalAxisInfo(origin, localSystem) ⇒ Object | undefined

获取局部坐标系三个轴的单位方向向量

Param Type Description
origin Cartesian3

坐标系原点

[localSystem] Matrix4

选填,坐标系矩阵,默认ENU坐标系

Example

var center = BOSGeo.Cartesian3.fromDegrees(113.2, 23.2);
var {normalX, normalY, normalZ} = GeoUtil.getLocalAxisInfo(center);

1.2.37. GeoUtil.getLocalRotationMatrix(origin, rotateAngles) ⇒ Matrix4

获取ENU坐标系下绕三个局部轴的旋转矩阵

Param Type Description
origin Cartesian3

局部坐标系原点

rotateAngles Cartesian3

xyz分别表示由XYZ轴正方向朝原点逆时针旋转角度值,单位为度

Example

const origin = Cartesian3.fromDegrees(113, 22, 10);
const pointA = Cartesian3.fromDegrees(113, 22, 20);
const rotation = GeoUtil.getLocalRotationMatrix(origin, new BOSGeo.Cartesian3(0, 180, 0));
const pointA1 = Matrix4.multiplyByPoint(rotation, pointA, new BOSGeo.Cartesian3());

1.2.38. GeoUtil.getWorldTranslation(origin, localTranslation) ⇒ Cartesian4

将指定位置处ENU坐标系下的平移量转换为世界坐标系下

Returns: Cartesian4 -

世界坐标系下的平移量(前三个分类表示方向,第四个分类表示所有的平移距离)

See: BOSGeo.ModelStyler.setTilesetTranslationByKey

Param Type Description
origin Cartesian3

局部ENU坐标系原点的世界坐标

localTranslation Cartesian4

局部ENU坐标系下的平移量,前三个分量只表示方向,第四个分量表示所有的平移距离

1.2.39. GeoUtil.getWorldTranslationByAxisInfo(localAxisMatrix, translation) ⇒ Cartesian4

将指定轴向的局部坐标系下的平移量转换为世界坐标系下

Returns: Cartesian4 -

前三个值只表示方向,第四个分量表示所有的平移量

See: BOSGeo.ModelStyler.setTilesetTranslationByKey

Param Type Description
localAxisMatrix Matrix3

任意局部坐标系的旋转缩放矩阵

translation Cartesian4

前三个值只表示方向,第四个分量表示所有的平移量

1.2.40. GeoUtil.setTileVisibleRange(tileset, geojsonData, [longitudeField], [latitudeField])

设置tileset的显示范围

Param Type Default Description
tileset Cesium3DTileset

3DTiles模型对象

geojsonData GeoJSON

控制3DTiles显示范围的面状geojson对象

[longitudeField] String 'cesium#longitude'

经度属性字段名

[latitudeField] String 'cesium#latitude'

纬度属性字段名

Example

let url='https://geoserver-alpha.boswinner.com/BOSGeo/ows?service=WFS&version=1.0.0&request=GetFeature&outputformat=json&typename=BOSGeo:shenzhenXZQ'
 BOSGeo.Resource.fetchJson(url).then(function(result) {
    BOSGeo.GeoUtil.setTileVisibleRange(tileset, result);
 })

1.2.41. GeoUtil.computeCoordinateTransform(computedTransform, paramPoints) ⇒ Object

计算GIS坐标和BIM坐标之间的转换参数

Returns : Object -

返回转换参数包含computedTransform和dx、dy、dz的偏移值

Param Type Description
computedTransform Matrix4

tileset根节点的computedTransform

paramPoints Object

包含3个及以上gis坐标点和对应的bim坐标点

paramPoints.gisPoints Array.<Cartesian3>

包含3个及以上的cartesian3坐标点

paramPoints.bimPoints Array.<Object>

包含3个及以上对应的bim坐标点,bim坐标点对象包含x,y,z属性

Example

let testModel = modelLayer.add({
    name: 'testModel',
    // 江湖别墅
    url: 'https://bos3d.bimwinner.com/api/j798920c67de49e4aeb3634e52a84548/geomodels/G1622167164209/data/tileset.json',
    featureType: BOSGeo.FeatureType.BIM,
});
modelLayer.zoomTo(testModel);


// 计算转换平移矩阵的对应点参数
var gisPoints = [], bimPoints = [];
// 获取gis坐标点方法,代码中添加以下代码并在gis场景中左键点击:
//   geomap.on(BOSGeo.MapEventType.LEFT_CLICK, (e) => {
//     console.log('position', e);
//   },[BOSGeo.MapPickType.WORLD_POSITION]);
//   获取bim坐标点的方法,控制台输入以下代码并在bos3d场景中左键点击:
//   viewer3D.viewerImpl.modelManager.addEventListener( BOS3D.EVENTS.ON_CLICK_PICK, 
//    function(event){ 
//        console.log(event.intersectInfo.point); 
//    }
// );
// 注意在bos3d中选点时不要将镜头拉的太近,会引起较大误差,应在适当距离(可以看清但不要尽量拉大)多次选取同一点来判断是否准确
gisPoints[0] = new BOSGeo.Cartesian3(-2306175.997040795, 5401542.534233195, 2478749.9094140474); //第一个gis坐标系取点
bimPoints[0] = {x: -5517.482001081882, y: -11686.318398392534, z: 6910.569410699635}; //第一个bim坐标系取点
gisPoints[1] = new BOSGeo.Cartesian3(-2306179.3834942114, 5401536.589428768, 2478759.7118662223); //第二个gis坐标系取点
bimPoints[1] = {x: -67.99999999999926, y: -1044.8105901346412, z: 6908.269118283033}; //第二个bim坐标系取点
gisPoints[2] = new BOSGeo.Cartesian3(-2306175.785566032, 5401533.93439871, 2478761.7414075597); //第三个gis坐标系取点
bimPoints[2] = {x: -2334.814467913469, y: 2323.0000000000023, z: 4147.070791432408}; //第三个bim坐标系取点
var paramPoints = {
    gisPoints,
    bimPoints
};

// 3DTiles的根节点computedTransform
var rootTransform, resPoint;

testModel.readyPromise.then(() => {
    rootTransform = testModel.root.computedTransform;
    let coorTransform = BOSGeo.GeoUtil.computeCoordinateTransform(rootTransform, paramPoints);
    console.log(coorTransform);
})

1.2.42. GeoUtil.toBIMPoint(coorTransform, point) ⇒ Object

GIS坐标转为BIM坐标

Returns : Object -

包含x、y、z的BIM坐标

Param Type Description
coorTransform Object

通过computeCoordinateTransform方法得到的转换参数

point Cartesian3

待转换的GIS坐标

Example

let testModel = modelLayer.add({
    name: 'testModel',
    // 江湖别墅
    url: 'https://bos3d.bimwinner.com/api/j798920c67de49e4aeb3634e52a84548/geomodels/G1622167164209/data/tileset.json',
    featureType: BOSGeo.FeatureType.BIM,
});
modelLayer.zoomTo(testModel);


// 计算转换平移矩阵的对应点参数
var gisPoints = [], bimPoints = [];
// 注意在bos3d中选点时不要将镜头拉的太近,会引起较大误差,应在适当距离(可以看清但不要尽量拉大)多次选取同一点来判断是否准确
gisPoints[0] = new BOSGeo.Cartesian3(-2306175.997040795, 5401542.534233195, 2478749.9094140474); //第一个gis坐标系取点
bimPoints[0] = {x: -5517.482001081882, y: -11686.318398392534, z: 6910.569410699635}; //第一个bim坐标系取点
gisPoints[1] = new BOSGeo.Cartesian3(-2306179.3834942114, 5401536.589428768, 2478759.7118662223); //第二个gis坐标系取点
bimPoints[1] = {x: -67.99999999999926, y: -1044.8105901346412, z: 6908.269118283033}; //第二个bim坐标系取点
gisPoints[2] = new BOSGeo.Cartesian3(-2306175.785566032, 5401533.93439871, 2478761.7414075597); //第三个gis坐标系取点
bimPoints[2] = {x: -2334.814467913469, y: 2323.0000000000023, z: 4147.070791432408}; //第三个bim坐标系取点
var paramPoints = {
    gisPoints,
    bimPoints
};

// 3dTiles的根节点computedTransform
var rootTransform, resPoint;

testModel.readyPromise.then(()=>{
    rootTransform = testModel.root.computedTransform;
    let coordinateTransform = BOSGeo.GeoUtil.computeCoordinateTransform(rootTransform, paramPoints);
    console.log(coordinateTransform);
    var point = new BOSGeo.Cartesian3( -2306174.5516214916, 5401546.04463069, 2478750.522077943);
    resPoint = BOSGeo.GeoUtil.toBIMPoint(coorTransform,point);
})

1.2.43. GeoUtil.toGISPoint(coorTransform, point) ⇒ Cartesian3

BIM坐标转为GIS坐标

Returns : Cartesian3 -

Cartesian3类型的GIS坐标

Param Type Description
coorTransform Object

通过computeCoordinateTransform方法得到的转换参数

point Object

待转换的BIM坐标

Example

let testModel = modelLayer.add({
    name: 'testModel',
    // 江湖别墅
    url: 'https://bos3d.bimwinner.com/api/j798920c67de49e4aeb3634e52a84548/geomodels/G1622167164209/data/tileset.json',
    featureType: BOSGeo.FeatureType.BIM,
});
modelLayer.zoomTo(testModel);


// 计算转换平移矩阵的对应点参数
var gisPoints = [], bimPoints = [];
// 注意在bos3d中选点时不要将镜头拉的太近,会引起较大误差,应在适当距离(可以看清但不要尽量拉大)多次选取同一点来判断是否准确
gisPoints[0] = new BOSGeo.Cartesian3(-2306175.997040795, 5401542.534233195, 2478749.9094140474); //第一个gis坐标系取点
bimPoints[0] = {x: -5517.482001081882, y: -11686.318398392534, z: 6910.569410699635}; //第一个bim坐标系取点
gisPoints[1] = new BOSGeo.Cartesian3(-2306179.3834942114, 5401536.589428768, 2478759.7118662223); //第二个gis坐标系取点
bimPoints[1] = {x: -67.99999999999926, y: -1044.8105901346412, z: 6908.269118283033}; //第二个bim坐标系取点
gisPoints[2] = new BOSGeo.Cartesian3(-2306175.785566032, 5401533.93439871, 2478761.7414075597); //第三个gis坐标系取点
bimPoints[2] = {x: -2334.814467913469, y: 2323.0000000000023, z: 4147.070791432408}; //第三个bim坐标系取点
var paramPoints = {
    gisPoints,
    bimPoints
};

// 3DTiles的根节点computedTransform
var rootTransform, resPoint;

testModel.readyPromise.then(() => {
    rootTransform = testModel.root.computedTransform;
    let coordinateTransform = BOSGeo.GeoUtil.computeCoordinateTransform(rootTransform, paramPoints);
    console.log(coordinateTransform);
    var point = {x: -8224.824277898897, y: -12155.717773210326, z: 9599.429074945496};
    resPoint = BOSGeo.GeoUtil.toGISPoint(coorTransform, point);
})

1.2.44. GeoUtil.flyToComponent(tileset, serviceParams, [highlightColor])

定位到构件

Param Type Default Description
tileset Cesium3DTileset

构件所属BIM模型对象

serviceParams Object

构件定位信息查询后台服务参数

serviceParams.site String

请求服务域名/IP地址

serviceParams.databaseKey String

数据库key

serviceParams.geoKey String

模型key,以'G-'开头的GeoModelKey

serviceParams.componentKey String

构件key关键字

[serviceParams.token] String ''

BOS后台接口操作的通关令牌,默认为空,当GeoMap中的token属性有赋值时为GeoMap.token

[highlightColor] String '#56ebfd'

定位构件的高亮颜色

Example

var modelLayer = layerManager.createLayer(BOSGeo.LayerType.MODEL, 'model1', {customGroupId: 'model'});
var tileset = modelLayer.add({
    url: "https://bos3d-alpha.bimwinner.com/api/y3f1d6fa04c54c728141b36880fac46a/geomodels/G1614756326311/data/tileset.json",
    name: "江湖别墅",
    featureType: BOSGeo.FeatureType.BIM,
    position: [114.028841, 22.550412, 4.6],
    rotation: [-17.6, 0, 0],
    scale: 0.001
});
BOSGeo.GeoUtil.flyToComponent(
    tileset,
    {
        site: 'https://bos3d-alpha.bimwinner.com',
        databaseKey: 'y3f1d6fa04c54c728141b36880fac46a',
        geoKey: 'G1614756326311',
        componentKey: 'M1614755277553_232775',
        token: ''
    },
    '#67ADDF'
);
版权所有@盈嘉互联(北京)科技有限公司 京ICP备15051988号-9 Copyright © 2022 all right reserved,powered by Gitbook该文件修订时间: 2022-07-19 11:34:25

results matching ""

    No results matching ""