WorldWind Series 14: DEM Data loading and application--taking Srtm as an example (next)

Source: Internet
Author: User

Use the TerrainAccessor.cs class 120 lines of code

public virtual Terraintile Getelevationarray (double, double south, double, double, int, samples) {
Terraintile res = null;
res = new Terraintile (null);
Res. North = North;
Res. South = South;
Res. West = West;
Res. east = East;
Res. Samplespertile = samples;
Res. IsInitialized = true;
Res. IsValid = true;
Double latrange = Math.Abs (North-south);
Double lonrange = Math.Abs (east-west);
float[,] data = new Float[samples,samples];
Float scalefactor = (float) 1/(samples-1);
for (int x = 0; x < samples, + +)
{
for (int y = 0; y < samples; y++)
{
D ouble Curlat = north-scalefactor * Latrange * x;
Double Curlon = West + scalefactor * lonrange * y;     
//Key, get the elevation value of all the tile sample points
Data[x,y = Getelevationat (Curlat, Curlon, 0);
}
}
Res. Elevationdata = data;
Return res;
}

Key code: Data[x,y] = Getelevationat (Curlat, Curlon, 0);

Getelevationat (); In TerrainAccessor.cs is an abstract method. The true implementation is overloaded in the Terrainaccessor subclass Nltterrainaccessor.

120行  public override float GetElevationAt(double latitude, double longitude)
   {
    return GetElevationAt(latitude, longitude, m_terrainTileService.SamplesPerTile / m_terrainTileService.LevelZeroTileSizeDegrees);
   }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.