# TerrainAnalyse

TerrainAnalyse 地形分析功能的主要类

#### new Cesium.TerrainAnalyse(viewer, options)
MapGIS/Provider/TerrainAnalyse.js 73

Name | Type | Description
--- | --- | ---
`viewer` | Viewer | 场景视图对象
`options` | Object | optional 包含以下属性的对象
Name | Type | Default | Description
--- | --- | --- | ---
`contourColor` | Color | `Color.RED.clone()` | optional 等高线颜色默认为红色
`contourWidth` | Number | `2.0` | optional 等高线宽度
`contourSpacing` | Number | `150.0` | optional 等高线间距
`enableContour` | Boolean | `false` | optional 等高线是否开启
`minHeight` | Number | `0` | optional 高程最小值
`maxHeight` | Number | `1000` | optional 高程最大值
`gradual` | array | `true` | optional 颜色是否有渐变效果
`elevationRampColor` | array |  | optional 高程色表
`slopeRampColor` | array |  | optional 坡度色表
`aspectRampColor` | array |  | optional 坡向色表
`bandPositionsColorsArray` | array |  | optional 等值面高度和颜色数组
`selectedShading` | String |  | optional //地形分析渲染类型包括高程赋色'elevation'、坡度分析'slope'、坡向分析'aspect',坡向箭头+坡度颜色分析'arrowAspectSlope',等值面分析'elevationBand'。

##### Example:

    var drawElement = new Cesium.DrawElement(viewer);
    var terrainAnalyse = new Cesium.TerrainAnalyse(viewer);
    // 1. 坡度分析
    drawElement.startDrawingPolygon({
        callback: function (reslut) {
            terrainAnalyse.changeAnalyseArea(reslut.positions);
            terrainAnalyse.selectedShading = 'slope';
        }
    });
    // 2. 坡向分析
    drawElement.startDrawingPolygon({
        callback: function (result) {
            terrainAnalyse.changeAnalyseArea(result.positions);
            terrainAnalyse.selectedShading = 'aspectArrow';
        }
    });
    // 3. 坡度坡向分析
    drawElement.startDrawingPolygon({
        callback: function (result) {
            terrainAnalyse.changeAnalyseArea(result.positions);
            terrainAnalyse.selectedShading = 'arrowAspectSlope';
        }
    });
    // 4. 结束分析
    terrainAnalyse.destroy();

### Methods

#### calculateSlopeAndAspect(screenPoint) → Object
MapGIS/Provider/TerrainAnalyse.js 956

根据输入屏幕坐标查询坡度坡向值

Name | Type | Description
--- | --- | ---
`screenPoint` | Cartesian2 | 查询坡度坡向值的屏幕坐标

##### Returns:

result 返回查询结果

##### Example:

    var terrainAnalyse = new Cesium.TerrainAnalyse(viewer, {});
    result = terrainAnalyse.calculateSlopeAndAspect(screenPoint);
    // 坡度值，单位度，范围0-90°
    slopeAngle = result.slope
    // 坡向值，单位度，范围0-360°
    aspectAngle = result.aspect
    // 坡向的8方位描述。可能的取值为N、NE、E、SE、S、SW、W、NW
    aspectDescription = result.aspectDescription

#### changeAnalyseArea(positions)
MapGIS/Provider/TerrainAnalyse.js 484

更新分析区域

Name | Type | Description
--- | --- | ---
`positions` | Array | 分析范围（世界坐标）

##### Example:

    terrainAnalyse.changeAnalyseArea(positions);

#### changeArrowAspectRepeat(cartesian2)
MapGIS/Provider/TerrainAnalyse.js 546

修改坡向箭头密度

Name | Type | Description
--- | --- | ---
`cartesian2` | Cartesian2 | x,y方向上的重复次数

##### Example:

    var  cartesian2= new Cesium.Cartesian2(3.0,3.0);
    changeArrowAspectRepeat(cartesian2);

#### changeColorTable(colorTable, ShadingType)
MapGIS/Provider/TerrainAnalyse.js 512

更新色表

Name | Type | Description
--- | --- | ---
`colorTable` | Array | 色表
`ShadingType` | String | 渲染类型，高程赋色'elevation'、坡度分析'slope'、坡向分析'aspect'。

##### Example:

    var defaultColor = ['#000000', '#2747E0', '#D33B7D', '#D33038', '#FF9742', '#ffd700', '#FFFFFF'];
    terrainAnalyse.changeColorTable(defaultColor,'elevation');

#### changeColorTableDis(colorTableDis, ShadingType)
MapGIS/Provider/TerrainAnalyse.js 530

更新色表间距值

Name | Type | Description
--- | --- | ---
`colorTableDis` | Array | 色表间距值
`ShadingType` | String | 渲染类型，高程赋色'elevation'、坡度分析'slope'、坡向分析'aspect'。

##### Example:

    var defaultColor = [0, 0.2, 0.3,0.4, 0.5, 0.6, 1];
    terrainAnalyse.changeColorTableDis(defaultColor,'elevation');

#### changeContours(ContourSpacing, ContourWidth, ContourColor)
MapGIS/Provider/TerrainAnalyse.js 462

修改等高线宽度，间距和颜色

Name | Type | Description
--- | --- | ---
`ContourSpacing` | Number | 修改等间距
`ContourWidth` | Number | 修改等高线宽度
`ContourColor` | Color | 修改等高线颜色

#### destroy()
MapGIS/Provider/TerrainAnalyse.js 1034

移除坡度坡向，等值面，等高线等分析结果

#### queryInfo(getResult)
MapGIS/Provider/TerrainAnalyse.js 985

右键点击查询坡度坡向值

Name | Type | Description
--- | --- | ---
`getResult` | function | 回调返回结果

##### Example:

    var getResult = function(e){console.log(e)};
    var terrainAnalyse = new Cesium.TerrainAnalyse(viewer, {});
    terrainAnalyse.queryInfo(getResult);

#### removeQueryInfo()
MapGIS/Provider/TerrainAnalyse.js 1018

移除点击查询坡度坡向值事件

#### removeTerrainFlatten()
MapGIS/Provider/TerrainAnalyse.js 1078

移除地形压平

#### terrainFlatten(positions, flattenHeight) → Boolean
MapGIS/Provider/TerrainAnalyse.js 1050

地形压平

Name | Type | Description
--- | --- | ---
`positions` | Array | 多边形顶点坐标数组
`flattenHeight` | Number | 压平到指定高度

##### Returns:

返回是否成功执行

#### updateElevationBandMaterial(bandPositions, gradient, bandThickness, bandTransparency, backgroundTransparency, colorsArray)
MapGIS/Provider/TerrainAnalyse.js 694

开启地形等值面分析

Name | Type | Description
--- | --- | ---
`bandPositions` | Array | 等值面数组，高度，单位米
`gradient` | Boolean | 是否渐变
`bandThickness` | Number | 等值面宽度
`bandTransparency` | Number | 等值面透明度
`backgroundTransparency` | Number | 等值面背景透明度
`colorsArray` | Array | 等值面颜色数组(数组长度不小于bandPositions)

##### Example:

    var bandPositions = [400,800,1300];
    var terrainA = new Cesium.TerrainAnalyse(viewer);

    var colorsArray =[Cesium.Color.RED,Cesium.Color.BLUE,Cesium.Color.GREEN];
    terrainAnalyse.updateElevationBandMaterial(bandPositions,false,100,1.0,0.0,colorsArray);

#### updateMaterial(selectedShading)
MapGIS/Provider/TerrainAnalyse.js 560

开启地形分析，坡度，坡向和等值线

Name | Type | Description
--- | --- | ---
`selectedShading` | String | 地形分析类型

##### Example:

    terrainAnalyse.updateMaterial('elevation'); //地形分析渲染类型包括高程赋色'elevation'、坡度分析'slope'、坡向分析'aspect',坡向箭头+坡度颜色分析'arrowAspectSlope',等值面分析'elevationBand'。