Select to view content in your preferred language

Change Elevation Source at runtime

706
3
Jump to solution
05-31-2023 05:42 AM
Labels (3)
FlorianKowalsky
New Contributor III

Is it possible to Change the ElevationSource at runtime?

I have two elevation Files (File1.tif and File2.tif) and i want to switch them.

MyScene.BaseSurface.ElevationSources.Clear());

if(file1)
{
	elevationSource = new RasterElevationSource(new List<string> { @"C:\File1.tif" });
}
else
{
	elevationSource = new RasterElevationSource(new List<string> { @"C:\File2.tif" });
}

elevationSource.LoadAsync();
MyScene.BaseSurface.ElevationSources.Add(elevationSource);

  

But if i switch, the Elevation sources seemed to be merged.

0 Kudos
1 Solution

Accepted Solutions
FlorianKowalsky
New Contributor III

Thanks

Yes it works

 

This Code Works:

RasterElevationSource elevationSource = null;
if (isFile1)
{
     elevationSource = new RasterElevationSource(new List<string> { @"C:\File1.tif" });
}
else
{
     elevationSource = new RasterElevationSource(new List<string> { @"C:\File2.tif" });
}

Surface surface = new Surface();
surface.ElevationSources.Add(elevationSource);
await elevationSource.LoadAsync();
await surface.LoadAsync();
MyScene.BaseSurface = surface;

View solution in original post

0 Kudos
3 Replies
KoushikHajra
Esri Contributor

Hello @FlorianKowalsky 

Thank you for reaching out to us with your question. You should be able to do it, except that you found a bug. I've logged an internal bug for it. 

As a workaround, you can create and set (on the scene) a new baseSurface object every time, with the desired elevation source. Hopefully, that'll get you going in the meantime. Please let us know if you run into any further issues.

Thank you!

Koushik

0 Kudos
FlorianKowalsky
New Contributor III

Thanks

Yes it works

 

This Code Works:

RasterElevationSource elevationSource = null;
if (isFile1)
{
     elevationSource = new RasterElevationSource(new List<string> { @"C:\File1.tif" });
}
else
{
     elevationSource = new RasterElevationSource(new List<string> { @"C:\File2.tif" });
}

Surface surface = new Surface();
surface.ElevationSources.Add(elevationSource);
await elevationSource.LoadAsync();
await surface.LoadAsync();
MyScene.BaseSurface = surface;
0 Kudos
KoushikHajra
Esri Contributor

That's great to see! If you have any further questions, please reach out. 

0 Kudos