【二次开发】CityMaker常见分析——瓦片挖洞

**

瓦片挖洞

**

一:技术原理:

瓦片挖洞用到了几何编辑模块的瓦片挖洞方法,主要作用是切除部分瓦片数据,显示出瓦片以下遮挡的部分模型。
瓦片挖洞主要分为两步:绘制挖洞面,进行瓦片挖洞。####
在这里插入图片描述

二:实现瓦片挖洞:

1. .Net代码

private void tileholeanalysis() 
{   
    AxRenderControl rendercontrol=getRenderControl();//获取控件
IGeometryFactory geoFactory = new GeometryFactory();

    //创建面要素,作为挖洞范围
    IPolygon fde_polygon = (IPolygon)geoFactory.CreateGeometry(gviGeometryType.gviGeometryPolygon,
                           gviVertexAttribute.gviVertexAttributeZ); 
    fde_polygon.SpatialCRS = crs as ISpatialCRS;//定义面坐标系(保证创建的面与瓦片数据坐标相通)
    
    //定义范围坐标
    IPoint fde_point = (IPoint)geoFactory.CreateGeometry(gviGeometryType.gviGeometryPoint,
                           gviVertexAttribute.gviVertexAttributeZ); //创建点
    fde_point.SetCoords(15527.52, 35748.21, 5.2, 0, 0);
    fde_polygon.ExteriorRing.AppendPoint(fde_point);
    fde_point.SetCoords(15567.42, 35684.12, 5.2, 0, 0);
    fde_polygon.ExteriorRing.AppendPoint(fde_point);
    fde_point.SetCoords(15604.36, 35708.22, 5.2, 0, 0);
    fde_polygon.ExteriorRing.AppendPoint(fde_point);
    fde_point.SetCoords(15562.71, 35771.03, 5.2, 0, 0);
    fde_polygon.ExteriorRing.AppendPoint(fde_point);
    fde_polygon.Close ();

//瓦片挖洞
I3DTileHole hole = rendercontrol.ObjectManager.Create3DTileHole(fde_polygon, System.Guid.Empty);
}

2. JS代码

function tileholeanalysis()
{
    var __g=document.getElementById("__g");//获取控件
    var geoFactory = __g.geometryFactory;

    //创建面要素,作为挖洞范围
    var fde_polygon = geoFactory.createGeometry(gviGeometryType.gviGeometryPolygon,
            gviVertexAttribute.gviVertexAttributeZ);

    //定义范围坐标
    var fde_point = geoFactory.createGeometry(gviGeometryType.gviGeometryPoint,
            gviVertexAttribute.gviVertexAttributeZ); //创建点
    fde_point.setCoords(15527.52, 35748.21, 5.2, 0, 0);
    fde_polygon.exteriorRing.appendPoint(fde_point);
    fde_point.setCoords(15567.42, 35684.12, 5.2, 0, 0);
    fde_polygon.exteriorRing.appendPoint(fde_point);
    fde_point.setCoords(15604.36, 35708.22, 5.2, 0, 0);
    fde_polygon.exteriorRing.appendPoint(fde_point);
    fde_point.setCoords(15562.71, 35771.03, 5.2, 0, 0);
    fde_polygon.exteriorRing.appendPoint(fde_point);
    fde_polygon.close ();

    //瓦片挖洞
    var hole = __g.objectManager.create3DTileHole(fde_polygon, __rootId);
}

三:注意事项

1、瓦片挖洞仅支持瓦片数据。
2、挖洞面必须闭合,推荐在挖洞前调用close方法手动闭合。
3、挖洞面需要与瓦片数据有相同的坐标系。
4、更多示例请参考SDK中级篇TileHole。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值