Java: is it possible to check if elevation for given point exists in Surface?

190
1
03-26-2018 10:55 PM
MarkoTandre
New Contributor

Hello,

If I ask (getElevationAsync(Point point)) from surface then I get 0 if it doesn't exist. How can I check if it exists in any of the ElevationSources?

I couldn't find anything how to check it.

Method getElevationAsync(Point point) should throw exception not return 0 elevation if it doesn't exist in any ElevationSource. This is bad practice and can do much harm.

The answer is not to use some url for elevations for entire world because most of the time my use case is offline and .tif file must be used as ElevationSource.

Reply
0 Kudos
1 Reply
LudoG
by
New Contributor

You can do it by checking all Envelope of each RasterElevationSource

double pointX = point.getX(); 
double pointY = point.getY();
for(ElevationSource elevationSource : surface.getElevationSources())
{
Envelope envelope = ((RasterElevationSource) elevationSource).getFullExtent();
if (pointX between envelope.getXMin() AND envelope.getXMax() AND pointY between envelope.getYMin() AND envelope.getYMax() )
return true;
}
return false;
Reply
0 Kudos