Skip to main content

Contour Analysis

DMap3D.analysis.contour is used to display contour line effects on terrain.

Import

import DMap3D from 'dmap3d'
import * as Cesium from 'cesium'

Basic Usage

const viewer = new Cesium.Viewer('cesiumContainer')

// Create contour analysis tool
const contour = new DMap3D.analysis.contour(viewer)

// Show contour lines
contour.show()

Constructor

new DMap3D.analysis.contour(viewer, options?)

Parameters:

  • viewer - Cesium.Viewer instance
  • options? - Optional configuration

Options:

interface ContourOptions {
width?: number // Line width, 1-10 pixels, default 1
spacing?: number // Contour interval, 1-1000 meters, default 100
color?: string // Line color, default white
}

Methods

show()

Show contour lines.

contour.show()

hide()

Hide contour lines.

contour.hide()

setWidth(width)

Set contour line width (1-10 pixels).

contour.setWidth(2)

setSpacing(spacing)

Set contour interval (1-1000 meters).

contour.setSpacing(50) // One contour line every 50 meters

setColor(color)

Set contour line color.

contour.setColor('#00FF00')

getWidth() / getSpacing() / getColor()

Get current configuration values.

console.log('Width:', contour.getWidth())
console.log('Spacing:', contour.getSpacing())
console.log('Color:', contour.getColor())

isActive()

Check whether contour lines are currently displayed.

if (contour.isActive()) {
contour.hide()
}

destroy()

Destroy the tool and release resources.

contour.destroy()

Complete Example

const viewer = new Cesium.Viewer('cesiumContainer')

// Create contour tool
const contour = new DMap3D.analysis.contour(viewer, {
width: 2,
spacing: 50,
color: '#00FF00'
})

// Show contour lines
contour.show()

// Dynamically adjust parameters
contour.setSpacing(100)
contour.setColor('#FFFF00')
contour.setWidth(3)

// Hide
contour.hide()

// Destroy
contour.destroy()