Skip to main content

Profile Analysis

DMap3D.analysis.profile is used to analyze the elevation profile of terrain along a path and display it in chart form.

Import

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

Basic Usage

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

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

// Listen for analysis complete event
profile.onAnalysisEnd((result) => {
result.forEach((point) => {
console.log(`Distance: ${point.distance}m, Coordinate: ${point.lnglat}`)
})
})

// Activate drawing (user draws a path in the scene)
profile.activate()

Constructor

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

Parameters:

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

Options:

interface ProfileOptions {
perStep?: number // Number of sample points, 10-500, default 50
perExpansion?: number // Number of expansion points, 0-100, default 20
showChart?: boolean // Whether to show chart, default true
chartPosition?: { // Chart position
bottom?: string
left?: string
width?: string
height?: string
}
}

Methods

activate()

Activate path drawing functionality.

profile.activate()

deactivate()

Deactivate drawing functionality.

profile.deactivate()

startAnalysis(coords, distances)

Execute profile analysis directly via coordinate arrays.

const coords = [
[116.4074, 39.9042, 100],
[116.4174, 39.9142, 200],
[116.4274, 39.9042, 150]
]
const distances = [0, 1500, 3000]

const result = await profile.startAnalysis(coords, distances)

clear()

Clear drawn content.

profile.clear()

setPerStep(value)

Set the number of sample points (10-500).

profile.setPerStep(100)

setPerExpansion(value)

Set the number of expansion points (0-100).

profile.setPerExpansion(30)

showChart() / hideChart()

Show or hide the profile chart.

profile.showChart()
profile.hideChart()

getAnalysisResult()

Get the analysis result data.

const result = profile.getAnalysisResult()

destroy()

Destroy the tool and release resources.

profile.destroy()

Analysis Result

interface ProfileResultPoint {
distance: number // Distance from start point (meters)
lnglat: [number, number, number] // [longitude, latitude, height]
}

Complete Example

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

// Create profile analysis tool
const profile = new DMap3D.analysis.profile(viewer, {
perStep: 100,
perExpansion: 30,
showChart: true,
chartPosition: {
bottom: '20px',
left: '20px',
width: '600px',
height: '300px'
}
})

// Listen for analysis complete
profile.onAnalysisEnd((result) => {
console.log('Profile point count:', result.length)
const maxHeight = Math.max(...result.map(p => p.lnglat[2]))
console.log('Highest point:', maxHeight, 'meters')
})

// Activate drawing
profile.activate()

// Destroy
profile.destroy()