Ejemplo n.º 1
0
 /// <summary>
 /// Calculates the approximate area of a point on a map projection with the given
 /// characteristics, by transforming the point and its nearest neighbors to latitude and
 /// longitude, calculating the midpoints between them, and calculating the area of the
 /// region enclosed within those midpoints.
 /// </summary>
 /// <param name="region">The mapped region.</param>
 /// <param name="planet">The mapped planet.</param>
 /// <param name="x">The x coordinate of a point on a map projection, with zero as the
 /// westernmost point.</param>
 /// <param name="y">The y coordinate of a point on a map projection, with zero as the
 /// northernmost point.</param>
 /// <param name="resolution">The vertical resolution of the projection.</param>
 /// <param name="options">
 /// The map projection options used to generate the map used.
 /// </param>
 /// <returns>The area of the given point, in m².</returns>
 public static HugeNumber GetAreaOfLocalPoint(
     this SurfaceRegion region,
     Planetoid planet,
     int x, int y,
     int resolution,
     MapProjectionOptions options) => SurfaceMap.GetAreaOfPointFromRadiusSquared(
     planet.RadiusSquared,
     x, y,
     (int)Math.Floor(resolution * options.AspectRatio),
     resolution,
     region.GetProjection(planet, options.EqualArea));
Ejemplo n.º 2
0
 /// <summary>
 /// Gets the elevation at the given <paramref name="latitude"/> and <paramref
 /// name="longitude"/>, in meters.
 /// </summary>
 /// <param name="region">The mapped region.</param>
 /// <param name="planet">The mapped planet.</param>
 /// <param name="elevationMap">An elevation map.</param>
 /// <param name="latitude">The latitude at which to determine elevation.</param>
 /// <param name="longitude">The longitude at which to determine elevation.</param>
 /// <param name="equalArea">
 /// If <see langword="true"/> the projection is a cylindrical equal-area projection.
 /// Otherwise, an equirectangular projection will be used.
 /// </param>
 /// <returns>
 /// The elevation at the given <paramref name="latitude"/> and <paramref name="longitude"/>,
 /// in meters. Or <see cref="double.NaN"/> if the given <paramref name="latitude"/> and
 /// <paramref name="longitude"/> are not contained within this region.
 /// </returns>
 public static double GetElevationAt(
     this SurfaceRegion region,
     Planetoid planet,
     Image <L16> elevationMap,
     double latitude,
     double longitude,
     bool equalArea = false) => region.IsPositionWithin(planet, latitude, longitude)
     ? (elevationMap.GetValueFromImage(
            latitude,
            longitude,
            region.GetProjection(planet, equalArea),
            true)
        - planet.NormalizedSeaLevel)
 * planet.MaxElevation
     : double.NaN;
Ejemplo n.º 3
0
 /// <summary>
 /// Produces an elevation map projection of this region.
 /// </summary>
 /// <param name="region">The mapped region.</param>
 /// <param name="planet">The planet being mapped.</param>
 /// <param name="resolution">The vertical resolution of the projection.</param>
 /// <param name="equalArea">
 /// If <see langword="true"/> the projection will be a cylindrical equal-area projection.
 /// Otherwise, an equirectangular projection will be used.
 /// </param>
 /// <returns>
 /// A projected map of elevation. Pixel luminosity indicates elevation relative to <see
 /// cref="Planetoid.MaxElevation"/>, with values below the midpoint indicating elevations
 /// below the mean surface.
 /// </returns>
 public static Image <L16> GetElevationMap(
     this SurfaceRegion region,
     Planetoid planet,
     int resolution,
     bool equalArea = false) => planet.GetElevationMap(resolution, region.GetProjection(planet, equalArea));