Am I not calling GetZsFromSurfaceAsync Correctly?

488
3
05-08-2020 02:48 PM
DHuantes
New Contributor III

Using GetZsFromSurfaceAsync with or without the second optional parameter always returns an error.  See screen shot of l_elevationResult contents... What am I doing wrong?  No matter what I try I keep getting Geometry as null and Status as CalculationError as shown in screen shot.  Thanks!

MapPoint pt = MapPointBuilder.CreateMapPoint(l_cellTemp.getCorner1().X, l_cellTemp.getCorner1().Y);
try
{
    var l_elevationResult = await MapView.Active.Map.GetZsFromSurfaceAsync(pt,"Range_TIN");
}
catch(Exception ex)
{
    MessageBox.Show(ex.Message);
}                       }

0 Kudos
3 Replies
DHuantes
New Contributor III

Ok... Just some clarification....   The "pop-up" in the second screen shot of original post is from placing a break point on the closing brace following the call to MapView.Active.Map.GetZsFromSurfaceAsync and when they break point was hit I hovered over the l_elevationResult to show the dialog in the screen shot.

Since my original post, I thought maybe I need use geodetic coordinates (i.e. Lat/Lon).  In addition, I thought I'd try other surfaces as well.  So below is an updated screenshot of the code I'm using...

So I'm still creating the initial MapPoint using my projection coordinates (British National Grid if that's important) to instantiate the MapPoint on line 156 and that's the Geometry being passed to GetZsFromSurfaceAsnyc on lines 159,160, and 161.  But then I overwrite my local l_x, l_y with geodetic coordinates for the same area and instantiate a new MapPoint using those coordinates but the subsequent calls to GetZsFromSurfaceAsync still result in l_elevationResult being in the same state as shown in my initial post.

Of course, each call to GetZsFromSurfaceAsync is going to overwrite the next but I was using this code in Debug mode and checking each return value one by one as each ran just in case you were wondering....  Thanks!

Wolf
by Esri Regular Contributor
Esri Regular Contributor

The OverlayGroundSurface sample in the "ArcGIS Pro SDK Community Samples" GitHub Repo is using GetZsFromSurfaceAsync.  It should work for a single point.  However, I think you have to specify the correct spatial reference when you create your test point.  

DHuantes
New Contributor III

Excellent... Didn't have a chance to look until just now.  I was talking to ESRI Tech Support and they mentioned your reply.  So I went ahead and tried it using MapView.Active.Map.SpatialReference as the spatial reference argument when instantiating my MapPoint and it resolve the problem.   Thank you!

0 Kudos