Skip to content

Commit

Permalink
added comments for publicly visible things of Argb, EnvelopeExt, Geom…
Browse files Browse the repository at this point in the history
…etryExt and LineStringExt
  • Loading branch information
jany-tenaj committed Jun 15, 2016
1 parent 2e0f860 commit fcbf2e1
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 7 deletions.
45 changes: 40 additions & 5 deletions Source/DotSpatial.Data/Argb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace DotSpatial.Data
{
/// <summary>
/// Tiny structure for storing A,R,G,B components of Color
/// Tiny structure for storing A,R,G,B components of Color.
/// </summary>
public struct Argb
{
Expand All @@ -16,12 +16,26 @@ public struct Argb

#endregion

/// <summary>
/// Creates a new Argb object from the given values. If the values are bigger than 255 they are changed to 255. If the values are smaller than 0 they are changed to 0.
/// </summary>
/// <param name="a">The a part of a color.</param>
/// <param name="r">The r part of a color.</param>
/// <param name="g">The g part of a color.</param>
/// <param name="b">The b part of a color.</param>
public Argb(int a, int r, int g, int b)
: this(ByteRange(a), ByteRange(r), ByteRange(g), ByteRange(b))
{

}

/// <summary>
/// Creates a new Argb object from the given values.
/// </summary>
/// <param name="a">The a part of a color.</param>
/// <param name="r">The r part of a color.</param>
/// <param name="g">The g part of a color.</param>
/// <param name="b">The b part of a color.</param>
public Argb(byte a, byte r, byte g, byte b)
{
_a = a;
Expand All @@ -30,44 +44,65 @@ public Argb(byte a, byte r, byte g, byte b)
_b = b;
}

/// <summary>
/// The A part of this Argb object.
/// </summary>
public byte A
{
get { return _a; }
}

/// <summary>
/// The B part of this Argb object.
/// </summary>
public byte B
{
get { return _b; }
}

/// <summary>
/// The G part of this Argb object.
/// </summary>
public byte G
{
get { return _g; }
}

/// <summary>
/// The R part of this Argb object.
/// </summary>
public byte R
{
get { return _r; }
}

/// <summary>
/// Returns an integer that ranges from 0 to 255. If value is larger than 255, the value will be equal to 255.
/// If the value is smaller than 255, it will be equal to 255.
/// Returns an byte that corresponds to the given value. If value is larger than 255, the value will be equal to 255.
/// If the value is smaller than 0, it will be equal to 0.
/// </summary>
/// <param name="value">A Double value to convert.</param>
/// <returns>An integer ranging from 0 to 255</returns>
/// <param name="value">An integer value to convert.</param>
/// <returns>A byte that corresponds to the integer ranging from 0 to 255.</returns>
public static byte ByteRange(int value)
{
if (value > 255) return 255;
if (value < 0) return 0;
return (byte)value;
}

/// <summary>
/// Converts this Argb to Color.
/// </summary>
/// <returns>Color build from the Argb values.</returns>
public Color ToColor()
{
return Color.FromArgb(A, R, G, B);
}

/// <summary>
/// Converts the given Color to Argb.
/// </summary>
/// <param name="color">color that gets converted.</param>
/// <returns>Argb object that contains the color values.</returns>
public static Argb FromColor(Color color)
{
return new Argb(color.A, color.R, color.G, color.B);
Expand Down
25 changes: 25 additions & 0 deletions Source/DotSpatial.NTSExtension/EnvelopeExt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,17 @@

namespace DotSpatial.NTSExtension
{
/// <summary>
/// This contains extension methods for GeoApi.Geometries.Envelope.
/// </summary>
public static class EnvelopeExt
{
/// <summary>
/// Initializes the envelopes Minimum.Z with the smaller of the two given z values and the Maximum.Z with the bigger of the two given z values.
/// </summary>
/// <param name="envelope">Envelope, whos Minimum and Maximum.Z should be initialized.</param>
/// <param name="z1">First z value.</param>
/// <param name="z2">Second z value.</param>
public static void InitZ(this Envelope envelope, double z1, double z2)
{
if (z1 < z2)
Expand All @@ -20,6 +29,12 @@ public static void InitZ(this Envelope envelope, double z1, double z2)
}
}

/// <summary>
/// Initializes the envelopes Minimum.M with the smaller of the two given m values and the Maximum.M with the bigger of the two given m values.
/// </summary>
/// <param name="envelope">Envelope, whos Minimum and Maximum.M should be initialized.</param>
/// <param name="m1">First m value.</param>
/// <param name="m2">Second m value.</param>
public static void InitM(this Envelope envelope, double m1, double m2)
{
if (m1 < m2)
Expand All @@ -34,13 +49,23 @@ public static void InitM(this Envelope envelope, double m1, double m2)
}
}

/// <summary>
/// Checks whether the given Envelope has M values.
/// </summary>
/// <param name="envelope">Envelope that gets checked.</param>
/// <returns>False if either envelope.Minimum.M or envelope.Maximum.M is not a number or Minimum.M is bigger than Maximum.M. </returns>
public static bool HasM(this Envelope envelope)
{
if (double.IsNaN(envelope.Minimum.M) || double.IsNaN(envelope.Maximum.M))
return false;
return envelope.Minimum.M <= envelope.Maximum.M;
}

/// <summary>
/// Checks whether the given Envelope has Z values.
/// </summary>
/// <param name="envelope">Envelope that gets checked.</param>
/// <returns>False if either envelope.Minimum.Z or envelope.Maximum.Z is not a number or Minimum.Z is bigger than Maximum.Z. </returns>
public static bool HasZ(this Envelope envelope)
{
if (double.IsNaN(envelope.Minimum.Z) || double.IsNaN(envelope.Maximum.Z))
Expand Down
4 changes: 4 additions & 0 deletions Source/DotSpatial.NTSExtension/GeometryExt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

namespace DotSpatial.NTSExtension
{
/// <summary>
/// Contains extension methods for GeoAPI.Geometries.IGeometry.
/// </summary>
public static class GeometryExt
{

Expand Down Expand Up @@ -50,6 +53,7 @@ public static void Rotate(this IGeometry self, Coordinate origin, double radAngl
break;
}
}

/// <summary>
/// Rotates the given coordinate by the given radian angle around the origin.
/// </summary>
Expand Down
9 changes: 7 additions & 2 deletions Source/DotSpatial.NTSExtension/LineStringExt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@

namespace DotSpatial.NTSExtension
{
/// <summary>
/// Contains extension methodes for GeoAPI.Geomtetries.ILineString.
/// </summary>
public static class LineStringExt
{

/// <summary>
/// Gets the value of the angle between the StartPoint and the EndPoint in Radian.
/// </summary>
/// </summary>
/// <param name="self">The ILineString, whose angle is returned.</param>
/// <remarks>added by JLeiss</remarks>
public static double RadAngle(this ILineString self)
{
Expand All @@ -28,7 +32,8 @@ public static double RadAngle(this ILineString self)
/// <summary>
/// Given the specified test point, this checks each segment, and will
/// return the closest point on the specified segment.
/// </summary>
/// </summary>
/// <param name="self">The ILineString, whose point is returned.</param>
/// <param name="testPoint">The point to test.</param>
public static Coordinate ClosestPoint(this ILineString self, Coordinate testPoint)
{
Expand Down

0 comments on commit fcbf2e1

Please sign in to comment.