Skip to content

Commit 547a267

Browse files
committed
updated documentation, added file headers
1 parent cf2c7b7 commit 547a267

17 files changed

+320
-219
lines changed

src/PolylineAlgorithm/Abstraction/IPolylineDecoder.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ namespace PolylineAlgorithm.Abstraction;
1212
/// </summary>
1313
public interface IPolylineDecoder {
1414
/// <summary>
15-
/// Decodes an encoded polyline string into a collection of geographic coordinates.
15+
/// Decodes the specified encoded polyline into a sequence of geographic coordinates.
1616
/// </summary>
17-
/// <param name="polyline">The <see cref="Polyline"/> instance representing the encoded polyline string.</param>
17+
/// <param name="polyline">
18+
/// The <see cref="Polyline"/> instance containing the encoded polyline string to decode.
19+
/// </param>
1820
/// <returns>
19-
/// An <see cref="IEnumerable{T}"/> of <see cref="Coordinate"/> objects representing the decoded geographic coordinates.
21+
/// An <see cref="IEnumerable{T}"/> of <see cref="Coordinate"/> representing the decoded latitude and longitude pairs.
2022
/// </returns>
2123
IEnumerable<Coordinate> Decode(Polyline polyline);
2224
}

src/PolylineAlgorithm/Abstraction/IPolylineEncoder.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ namespace PolylineAlgorithm.Abstraction;
1212
/// </summary>
1313
public interface IPolylineEncoder {
1414
/// <summary>
15-
/// Encodes a collection of geographic coordinates into an encoded polyline string.
15+
/// Encodes a sequence of geographic coordinates into an encoded polyline representation.
1616
/// </summary>
17-
/// <param name="coordinates">A collection of <see cref="Coordinate"/> objects to encode.</param>
17+
/// <param name="coordinates">
18+
/// The collection of <see cref="Coordinate"/> instances to encode into a polyline.
19+
/// </param>
1820
/// <returns>
19-
/// A <see cref="Polyline"/> instance representing the encoded polyline string.
21+
/// A <see cref="Polyline"/> containing the encoded polyline string that represents the input coordinates.
2022
/// </returns>
2123
Polyline Encode(IEnumerable<Coordinate> coordinates);
2224
}

src/PolylineAlgorithm/Coordinate.cs

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,51 +12,56 @@ namespace PolylineAlgorithm;
1212
using System.Globalization;
1313
using System.Runtime.InteropServices;
1414
/// <summary>
15-
/// Represents a latitude and longitude coordinate pair.
15+
/// Represents a geographic coordinate as a pair of latitude and longitude values.
1616
/// </summary>
1717
[DebuggerDisplay("{ToString()}")]
1818
[StructLayout(LayoutKind.Sequential, Pack = 8, Size = 16)]
1919
public readonly struct Coordinate : IEquatable<Coordinate> {
2020
/// <summary>
21-
/// Initializes a new instance of the <see cref="Coordinate"/> struct with default values for <see cref="Latitude"/> and <see cref="Longitude"/>.
21+
/// Initializes a new instance of the <see cref="Coordinate"/> struct with default values (0) for <see cref="Latitude"/> and <see cref="Longitude"/>.
2222
/// </summary>
2323
public Coordinate() {
2424
Latitude = default;
2525
Longitude = default;
2626
}
2727

2828
/// <summary>
29-
/// Initializes a new instance of the <see cref="Coordinate"/> struct with specified latitude and longitude values.
29+
/// Initializes a new instance of the <see cref="Coordinate"/> struct with the specified latitude and longitude values.
3030
/// </summary>
31-
/// <param name="latitude">The latitude value, in degrees.</param>
32-
/// <param name="longitude">The longitude value, in degrees.</param>
31+
/// <param name="latitude">The latitude component, in degrees.</param>
32+
/// <param name="longitude">The longitude component, in degrees.</param>
3333
public Coordinate(double latitude, double longitude) {
3434
Latitude = latitude;
3535
Longitude = longitude;
3636
}
3737

3838
/// <summary>
39-
/// Gets the latitude value of the coordinate, in degrees.
39+
/// Gets the latitude component of the coordinate, in degrees.
4040
/// </summary>
4141
public double Latitude { get; }
4242

4343
/// <summary>
44-
/// Gets the longitude value of the coordinate, in degrees.
44+
/// Gets the longitude component of the coordinate, in degrees.
4545
/// </summary>
4646
public double Longitude { get; }
4747

4848
/// <summary>
49-
/// Determines whether the coordinate is the default value (both <see cref="Latitude"/> and <see cref="Longitude"/> are 0).
49+
/// Determines whether this coordinate is the default value (both <see cref="Latitude"/> and <see cref="Longitude"/> are 0).
5050
/// </summary>
51-
/// <returns><see langword="true"/> if the coordinate is the default value; otherwise, <see langword="false"/>.</returns>
51+
/// <returns>
52+
/// <see langword="true"/> if both latitude and longitude are 0; otherwise, <see langword="false"/>.
53+
/// </returns>
5254
public bool IsDefault()
5355
=> Latitude == default
5456
&& Longitude == default;
5557

5658
/// <summary>
57-
/// Determines whether the coordinate is valid by checking if both <see cref="Latitude"/> and <see cref="Longitude"/> are within their respective valid ranges.
59+
/// Determines whether this coordinate is valid by checking if both <see cref="Latitude"/> and <see cref="Longitude"/>
60+
/// are within their respective valid ranges as defined by the default <see cref="ICoordinateValidator"/>.
5861
/// </summary>
59-
/// <returns><see langword="true"/> if the coordinate is valid; otherwise, <see langword="false"/>.</returns>
62+
/// <returns>
63+
/// <see langword="true"/> if the coordinate is within valid latitude and longitude ranges; otherwise, <see langword="false"/>.
64+
/// </returns>
6065
public bool IsValid() => ICoordinateValidator.Default.IsValid(this);
6166

6267
#region Overrides
@@ -70,9 +75,11 @@ public bool IsDefault()
7075
public override int GetHashCode() => HashCode.Combine(Latitude, Longitude);
7176

7277
/// <summary>
73-
/// Returns a string representation of the coordinate in the format: { Latitude: [double], Longitude: [double] }.
78+
/// Returns a string representation of this coordinate in the format: <c>{ Latitude: [double], Longitude: [double] }</c>.
7479
/// </summary>
75-
/// <returns>A string representation of the coordinate.</returns>
80+
/// <returns>
81+
/// A string representation of the coordinate.
82+
/// </returns>
7683
[ExcludeFromCodeCoverage]
7784
public override string ToString() {
7885
return $"{{ {nameof(Latitude)}: {Latitude.ToString("G", CultureInfo.InvariantCulture)}, {nameof(Longitude)}: {Longitude.ToString("G", CultureInfo.InvariantCulture)} }}";
@@ -83,10 +90,12 @@ public override string ToString() {
8390
#region IEquatable<Coordinate> implementation
8491

8592
/// <summary>
86-
/// Determines whether the current coordinate is equal to another coordinate.
93+
/// Indicates whether this coordinate is equal to another <see cref="Coordinate"/> instance.
8794
/// </summary>
88-
/// <param name="other">The coordinate to compare with the current coordinate.</param>
89-
/// <returns><see langword="true"/> if the coordinates are equal; otherwise, <see langword="false"/>.</returns>
95+
/// <param name="other">The coordinate to compare with this instance.</param>
96+
/// <returns>
97+
/// <see langword="true"/> if both latitude and longitude are equal; otherwise, <see langword="false"/>.
98+
/// </returns>
9099
public bool Equals(Coordinate other) {
91100
return Latitude == other.Latitude &&
92101
Longitude == other.Longitude;
@@ -101,7 +110,9 @@ public bool Equals(Coordinate other) {
101110
/// </summary>
102111
/// <param name="left">The first coordinate to compare.</param>
103112
/// <param name="right">The second coordinate to compare.</param>
104-
/// <returns><see langword="true"/> if the coordinates are equal; otherwise, <see langword="false"/>.</returns>
113+
/// <returns>
114+
/// <see langword="true"/> if both coordinates are equal; otherwise, <see langword="false"/>.
115+
/// </returns>
105116
[ExcludeFromCodeCoverage]
106117
public static bool operator ==(Coordinate left, Coordinate right) => left.Equals(right);
107118

@@ -110,7 +121,9 @@ public bool Equals(Coordinate other) {
110121
/// </summary>
111122
/// <param name="left">The first coordinate to compare.</param>
112123
/// <param name="right">The second coordinate to compare.</param>
113-
/// <returns><see langword="true"/> if the coordinates are not equal; otherwise, <see langword="false"/>.</returns>
124+
/// <returns>
125+
/// <see langword="true"/> if the coordinates are not equal; otherwise, <see langword="false"/>.
126+
/// </returns>
114127
[ExcludeFromCodeCoverage]
115128
public static bool operator !=(Coordinate left, Coordinate right) => !(left == right);
116129

src/PolylineAlgorithm/Extensions/PolylineDecoderExtensions.cs

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,32 @@
1-
namespace PolylineAlgorithm.Extensions;
1+
//
2+
// Copyright © Pete Sramek. All rights reserved.
3+
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
4+
//
5+
6+
namespace PolylineAlgorithm.Extensions;
27

38
using PolylineAlgorithm.Abstraction;
49
using System;
510
using System.Collections.Generic;
611

712
/// <summary>
8-
/// Provides extension methods for the <see cref="IPolylineDecoder"/> interface to simplify decoding operations.
13+
/// Provides extension methods for the <see cref="IPolylineDecoder"/> interface to facilitate decoding encoded polylines.
914
/// </summary>
1015
public static class PolylineDecoderExtensions {
1116
/// <summary>
12-
/// Decodes an encoded polyline string into a collection of geographic coordinates.
17+
/// Decodes an encoded polyline string into a sequence of geographic coordinates.
1318
/// </summary>
14-
/// <param name="decoder">The <see cref="IPolylineDecoder"/> instance used to decode the polyline.</param>
15-
/// <param name="polyline">The encoded polyline string to decode.</param>
19+
/// <param name="decoder">
20+
/// The <see cref="IPolylineDecoder"/> instance used to perform the decoding operation.
21+
/// </param>
22+
/// <param name="polyline">
23+
/// The encoded polyline string to decode.
24+
/// </param>
1625
/// <returns>
17-
/// An <see cref="IEnumerable{T}"/> of <see cref="Coordinate"/> objects representing the decoded geographic coordinates.
26+
/// An <see cref="IEnumerable{Coordinate}"/> containing the decoded latitude and longitude pairs.
1827
/// </returns>
1928
/// <exception cref="ArgumentNullException">
20-
/// Thrown if the <paramref name="decoder"/> is <see langword="null"/>.
29+
/// Thrown if <paramref name="decoder"/> is <see langword="null"/>.
2130
/// </exception>
2231
public static IEnumerable<Coordinate> Decode(this IPolylineDecoder decoder, string polyline) {
2332
if (decoder is null) {
@@ -28,15 +37,19 @@ public static IEnumerable<Coordinate> Decode(this IPolylineDecoder decoder, stri
2837
}
2938

3039
/// <summary>
31-
/// Decodes an encoded polyline represented as a character array into a collection of geographic coordinates.
40+
/// Decodes an encoded polyline represented as a character array into a sequence of geographic coordinates.
3241
/// </summary>
33-
/// <param name="decoder">The <see cref="IPolylineDecoder"/> instance used to decode the polyline.</param>
34-
/// <param name="polyline">The encoded polyline represented as a character array to decode.</param>
42+
/// <param name="decoder">
43+
/// The <see cref="IPolylineDecoder"/> instance used to perform the decoding operation.
44+
/// </param>
45+
/// <param name="polyline">
46+
/// The encoded polyline as a character array to decode.
47+
/// </param>
3548
/// <returns>
36-
/// An <see cref="IEnumerable{T}"/> of <see cref="Coordinate"/> objects representing the decoded geographic coordinates.
49+
/// An <see cref="IEnumerable{Coordinate}"/> containing the decoded latitude and longitude pairs.
3750
/// </returns>
3851
/// <exception cref="ArgumentNullException">
39-
/// Thrown if the <paramref name="decoder"/> is <see langword="null"/>.
52+
/// Thrown if <paramref name="decoder"/> is <see langword="null"/>.
4053
/// </exception>
4154
public static IEnumerable<Coordinate> Decode(this IPolylineDecoder decoder, char[] polyline) {
4255
if (decoder is null) {

src/PolylineAlgorithm/Extensions/PolylineEncoderExtensions.cs

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,34 @@
1-
namespace PolylineAlgorithm.Extensions;
1+
//
2+
// Copyright © Pete Sramek. All rights reserved.
3+
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
4+
//
5+
6+
namespace PolylineAlgorithm.Extensions;
27

38
using PolylineAlgorithm.Abstraction;
49
using System;
510
using System.Collections.Generic;
611

712
/// <summary>
8-
/// Provides extension methods for the <see cref="IPolylineEncoder"/> interface to simplify encoding operations.
13+
/// Provides extension methods for the <see cref="IPolylineEncoder"/> interface to facilitate encoding geographic coordinates into polylines.
914
/// </summary>
1015
public static class PolylineEncoderExtensions {
1116
/// <summary>
12-
/// Encodes a collection of geographic coordinates into an encoded polyline string.
17+
/// Encodes a collection of <see cref="Coordinate"/> instances into an encoded polyline.
1318
/// </summary>
14-
/// <typeparam name="Coordinate">The type representing a geographic coordinate.</typeparam>
15-
/// <param name="encoder">The <see cref="IPolylineEncoder"/> instance used to encode the coordinates.</param>
16-
/// <param name="coordinates">A collection of coordinates to encode.</param>
19+
/// <param name="encoder">
20+
/// The <see cref="IPolylineEncoder"/> instance used to perform the encoding operation.
21+
/// </param>
22+
/// <param name="coordinates">
23+
/// The collection of <see cref="Coordinate"/> objects to encode.
24+
/// </param>
1725
/// <returns>
18-
/// A <see cref="Polyline"/> instance representing the encoded polyline string.
26+
/// A <see cref="Polyline"/> representing the encoded polyline string for the provided coordinates.
1927
/// </returns>
2028
/// <exception cref="ArgumentNullException">
21-
/// Thrown if the <paramref name="encoder"/> is <see langword="null"/>.
29+
/// Thrown if <paramref name="encoder"/> is <see langword="null"/>.
2230
/// </exception>
23-
public static Polyline Encode<Coordinate>(this IPolylineEncoder encoder, ICollection<Coordinate> coordinates) {
31+
public static Polyline Encode(this IPolylineEncoder encoder, ICollection<Coordinate> coordinates) {
2432
if (encoder is null) {
2533
throw new ArgumentNullException(nameof(encoder));
2634
}
@@ -29,15 +37,19 @@ public static Polyline Encode<Coordinate>(this IPolylineEncoder encoder, ICollec
2937
}
3038

3139
/// <summary>
32-
/// Encodes an array of geographic coordinates into an encoded polyline string.
40+
/// Encodes an array of <see cref="Coordinate"/> instances into an encoded polyline.
3341
/// </summary>
34-
/// <param name="encoder">The <see cref="IPolylineEncoder"/> instance used to encode the coordinates.</param>
35-
/// <param name="coordinates">An array of coordinates to encode.</param>
42+
/// <param name="encoder">
43+
/// The <see cref="IPolylineEncoder"/> instance used to perform the encoding operation.
44+
/// </param>
45+
/// <param name="coordinates">
46+
/// The array of <see cref="Coordinate"/> objects to encode.
47+
/// </param>
3648
/// <returns>
37-
/// A <see cref="Polyline"/> instance representing the encoded polyline string.
49+
/// A <see cref="Polyline"/> representing the encoded polyline string for the provided coordinates.
3850
/// </returns>
3951
/// <exception cref="ArgumentNullException">
40-
/// Thrown if the <paramref name="encoder"/> is <see langword="null"/>.
52+
/// Thrown if <paramref name="encoder"/> is <see langword="null"/>.
4153
/// </exception>
4254
public static Polyline Encode(this IPolylineEncoder encoder, Coordinate[] coordinates) {
4355
if (encoder is null) {

0 commit comments

Comments
 (0)