sampleHeightMostDetailed method is not working

Hello,

I confronted an issue on sampleHeightMostDetailed method.
It doesn’t give any response even error.
It was working before but suddenly stopped responding.

What would be the possible cause that can be consider?

example code inside async function

        try {
            samples = await this._viewer.scene.sampleHeightMostDetailed(
                gridPos, [this._polygonShape], 0.5);
        } catch (err) {
            console.log(err)
        }

Thanks in advance,
Hiroshi

It manipulates the incoming data with updated height values. How do you know it doesn’t do that? Remember it does this in a Promise, so the await here is a bit ambigous. Do you have some code that spits out the values before and after?

Cheers,

Alex

Thanks for quick reply.

For example, when I run this code below, it doesn’t reach to “after”. So I guess it is waiting for the “sampleHeightMostDetailed”

        let samples;
        try {
            console.log("before", gridPos)
            samples = await this._viewer.scene.sampleHeightMostDetailed(
                gridPos, [this._polygonShape], 0.5);
        } catch (err) {
            console.log(err)
        }
        console.log("after", samples)

It reaches the “before” since it is showing on the console and showing the values in gridPos as well

Well, I’m no expert in using await, I prefer to flesh it out with a;

const promise = this.viewer.scene.sampleHeightMostDetailed(pos);
// before
promise.then(function(updatedPos) {
   // after
});

I would certainly try that to make sure you don’t have any odd await isses (stuff queued, try/catch troubles, etc.), for example if there’s an error it might not reach the catch() because it’s busy wrapped in the await mechanism.

Cheers,

Alex

1 Like

Thanks you so much for your help. @Alexander_Johannesen
The issue has been solved.