LocationToElevation synchronic

184
1
Jump to solution
12-10-2017 02:03 AM
AnatBen_Israel
New Contributor II

Hello,

Is there a way to call LocationToElevation synchronically?

Something like the "await" in C# that will bypass the need to always wait for the slot...

It makes calculations so complicated when there is, for example, a loop in which each iteration needs the elevation.

Thanks

0 Kudos
1 Solution

Accepted Solutions
LukeSmallwood
Esri Contributor

Hi Anat, I hope you are well. Unfortunately, we do not currently have a synchronous version of this call. One approach that might work for you is to create a QEventLoop which you can run to wait until the operation completes.

I've included some code below that shows how that could work - any questions, let me know:

        auto startTaskId = surface->locationToElevation(loc).taskId();
        QEventLoop loop;
        loop.connect(surface, &Surface::locationToElevationCompleted, this, [this, &loop, startTaskId](QUuid taskId, double elevation)
        {
            if (taskId != startTaskId)
                return;
            qDebug() << elevation;
            loop.quit();
        });
        loop.connect(surface, &Surface::errorOccurred, &loop, &QEventLoop::quit);
        loop.exec();

View solution in original post

0 Kudos
1 Reply
LukeSmallwood
Esri Contributor

Hi Anat, I hope you are well. Unfortunately, we do not currently have a synchronous version of this call. One approach that might work for you is to create a QEventLoop which you can run to wait until the operation completes.

I've included some code below that shows how that could work - any questions, let me know:

        auto startTaskId = surface->locationToElevation(loc).taskId();
        QEventLoop loop;
        loop.connect(surface, &Surface::locationToElevationCompleted, this, [this, &loop, startTaskId](QUuid taskId, double elevation)
        {
            if (taskId != startTaskId)
                return;
            qDebug() << elevation;
            loop.quit();
        });
        loop.connect(surface, &Surface::errorOccurred, &loop, &QEventLoop::quit);
        loop.exec();

View solution in original post

0 Kudos