This sample demonstrates how to create client side elevation profile analysis in a Scene. This analysis allows creating custom elevation profile workflows and accompanying UI. The analysis can be created programmatically and added to the Scene component's analyses collection.
The sample computes and visualizes two profile lines: one for the ground and one for a referenced cable railway feature.
const analysis = new ElevationProfileAnalysis({
profiles: [
// first profile line samples the ground elevation
{
type: "ground",
color: "rgba(150, 75, 0, 0.2)",
},
// second profile samples the clicked cabel railway line
{
type: "input",
color: "rgba(30, 160, 220, 1)",
},
],
});
viewElement.analyses.add(analysis);
By accessing the analysis view, one can programmatically start
interactive analysis operations, e.g. the pickFeature()
method allows to pick a line feature from the scene as an input to the analysis. One can make choosing the input continuous by calling the pick
again after the previous feature was clicked on. This is repeated until either Escape
is pressed or abort
called.
const analysisView = await viewElement.whenAnalysisView(analysis);
// Use AbortController to stop the picking operation at some later point
let abortController;
async function startPicking() {
// Stop any pending picking operation.
abortController?.abort();
// Create a new abort controller for the new operation and get a reference to its signal.
abortController = new AbortController();
const { signal } = abortController;
try {
// After one line is picked, call the pickFeature() method again.
// This is done until the picking is stopped/aborted.
while (!signal.aborted) {
// Start picking a feature from the scene and get reference to the returned results.
const pickedResult = await analysisView.pickFeature({
signal,
});
if (signal.aborted) {
return;
}
}
} catch (error) {
if (error.name === "AbortError") {
console.log("Picking operation was stopped.");
}
}
}
The analysis view is also used to access the results of the analysis. The results collection includes information about each initialized profile line, including generation progress state and samples that can be used to create a chart visualization.