Skip to content

Commit adf7188

Browse files
author
Petr Šrámek
committed
Merge branch 'beta'
2 parents 685dc17 + 003d937 commit adf7188

20 files changed

+788
-431
lines changed

docs/docfx.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{
2+
}

src/Cloudikka.PolylineAlgorithm/Cloudikka.PolylineAlgorithm.sln

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "nuget", "nuget", "{7F9807A1
1414
..\..\nuget\Cloudikka.PolylineAlgorithm.nuspec = ..\..\nuget\Cloudikka.PolylineAlgorithm.nuspec
1515
EndProjectSection
1616
EndProject
17-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cloudikka.PolylineAlgorithm.Tests", "..\..\tests\Cloudikka.PolylineAlgorithm.Tests\Cloudikka.PolylineAlgorithm.Tests.csproj", "{10B555A6-E4C9-4828-B4A6-64E248CC1D14}"
17+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{B9F2E949-4493-4131-84B1-C6AB372B62F5}"
18+
ProjectSection(SolutionItems) = preProject
19+
..\..\docs\docfx.json = ..\..\docs\docfx.json
20+
EndProjectSection
21+
EndProject
22+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cloudikka.PolylineAlgorithm.Tests", "..\..\tests\Cloudikka.PolylineAlgorithm.Tests\Cloudikka.PolylineAlgorithm.Tests.csproj", "{30324A08-AA42-425D-87DA-8F9C6AF60454}"
1823
EndProject
1924
Global
2025
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -26,17 +31,17 @@ Global
2631
{882322A6-E758-4662-8D1C-7C555C8FC3F2}.Debug|Any CPU.Build.0 = Debug|Any CPU
2732
{882322A6-E758-4662-8D1C-7C555C8FC3F2}.Release|Any CPU.ActiveCfg = Release|Any CPU
2833
{882322A6-E758-4662-8D1C-7C555C8FC3F2}.Release|Any CPU.Build.0 = Release|Any CPU
29-
{10B555A6-E4C9-4828-B4A6-64E248CC1D14}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
30-
{10B555A6-E4C9-4828-B4A6-64E248CC1D14}.Debug|Any CPU.Build.0 = Debug|Any CPU
31-
{10B555A6-E4C9-4828-B4A6-64E248CC1D14}.Release|Any CPU.ActiveCfg = Release|Any CPU
32-
{10B555A6-E4C9-4828-B4A6-64E248CC1D14}.Release|Any CPU.Build.0 = Release|Any CPU
34+
{30324A08-AA42-425D-87DA-8F9C6AF60454}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
35+
{30324A08-AA42-425D-87DA-8F9C6AF60454}.Debug|Any CPU.Build.0 = Debug|Any CPU
36+
{30324A08-AA42-425D-87DA-8F9C6AF60454}.Release|Any CPU.ActiveCfg = Release|Any CPU
37+
{30324A08-AA42-425D-87DA-8F9C6AF60454}.Release|Any CPU.Build.0 = Release|Any CPU
3338
EndGlobalSection
3439
GlobalSection(SolutionProperties) = preSolution
3540
HideSolutionNode = FALSE
3641
EndGlobalSection
3742
GlobalSection(NestedProjects) = preSolution
3843
{882322A6-E758-4662-8D1C-7C555C8FC3F2} = {51C886AF-D610-48A4-9D73-2DEB38742801}
39-
{10B555A6-E4C9-4828-B4A6-64E248CC1D14} = {576FEFFC-B624-40C3-A8AF-4E5233802EA0}
44+
{30324A08-AA42-425D-87DA-8F9C6AF60454} = {576FEFFC-B624-40C3-A8AF-4E5233802EA0}
4045
EndGlobalSection
4146
GlobalSection(ExtensibilityGlobals) = postSolution
4247
SolutionGuid = {93A268DC-0947-4FBB-B495-DDAD4B013D82}

src/Cloudikka.PolylineAlgorithm/Cloudikka.PolylineAlgorithm/Constants.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
namespace Cloudikka.PolylineAlgorithm {
77
/// <summary>
8-
/// Defines the <see cref="Constants" />
8+
/// Defines global constant values
99
/// </summary>
10-
public static class Constants {
10+
internal static class Constants {
1111
#region Constants
1212

1313
/// <summary>
@@ -23,13 +23,13 @@ public static class Constants {
2323
#endregion
2424

2525
/// <summary>
26-
/// Defines the <see cref="ASCII" />
26+
/// Defines ASCII characters constant values
2727
/// </summary>
28-
public static class ASCII {
28+
internal static class ASCII {
2929
#region Constants
3030

3131
/// <summary>
32-
/// Defines the ASCII QuestionMark
32+
/// Defines the ASCII Question Mark
3333
/// </summary>
3434
public const int QuestionMark = 63;
3535

@@ -39,21 +39,21 @@ public static class ASCII {
3939
public const int Space = 32;
4040

4141
/// <summary>
42-
/// Defines the ASCII UnitSeparator
42+
/// Defines the ASCII Unit Separator
4343
/// </summary>
4444
public const int UnitSeparator = 31;
4545

4646
#endregion
4747
}
4848

4949
/// <summary>
50-
/// Defines the <see cref="Coordinate" />
50+
/// Defines coordinates constant values
5151
/// </summary>
52-
public static class Coordinate {
52+
internal static class Coordinate {
5353
#region Constants
5454

5555
/// <summary>
56-
/// Defines the maximum value for Latitude
56+
/// Defines the maximum value for latitude
5757
/// </summary>
5858
public const int MaxLatitude = 90;
5959

src/Cloudikka.PolylineAlgorithm/Cloudikka.PolylineAlgorithm/Encoding/IPolylineEncoding.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,24 @@ namespace Cloudikka.PolylineAlgorithm.Encoding {
99
#region Interfaces
1010

1111
/// <summary>
12-
/// Defines the <see cref="IPolylineEncoding{T}" />
12+
/// Defines base interface for all polyline encodings
1313
/// </summary>
14-
/// <typeparam name="T"></typeparam>
14+
/// <typeparam name="T">Desired type used to decode to and encode from</typeparam>
1515
public interface IPolylineEncoding<T> {
1616
#region Methods
1717

1818
/// <summary>
19-
/// The Decode
19+
/// Method performs decoding from polyline encoded <see cref="System.String"/> to <see cref="IEnumerable{T}"/>
2020
/// </summary>
21-
/// <param name="source">The <see cref="string"/></param>
21+
/// <param name="source">The <see cref="string"/> as polyline encoded source</param>
2222
/// <returns>The <see cref="IEnumerable{T}"/></returns>
2323
IEnumerable<T> Decode(string source);
2424

2525
/// <summary>
26-
/// The Encode
26+
/// Method performs encoding from generic type to polyline encoded <see cref="System.String"/>
2727
/// </summary>
28-
/// <param name="source">The <see cref="IEnumerable{T}"/></param>
29-
/// <returns>The <see cref="string"/></returns>
28+
/// <param name="source">Coordinates to encode</param>
29+
/// <returns>Polyline encoded result</returns>
3030
string Encode(IEnumerable<T> source);
3131

3232
#endregion

src/Cloudikka.PolylineAlgorithm/Cloudikka.PolylineAlgorithm/Encoding/PolylineEncoding.cs

Lines changed: 13 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -4,63 +4,31 @@
44
//
55

66
namespace Cloudikka.PolylineAlgorithm.Encoding {
7-
using System;
8-
using System.Collections.Generic;
9-
using System.Linq;
10-
117
/// <summary>
12-
/// Defines the <see cref="PolylineEncoding{T}" />
8+
/// Defines default polyline encoding with generic <see cref="System.ValueTuple[double, double]"/>
139
/// </summary>
14-
/// <typeparam name="T"></typeparam>
15-
public abstract class PolylineEncoding<T> : IPolylineEncoding<T> {
10+
public class PolylineEncoding : PolylineEncodingBase<(double Latitude, double Longitude)> {
1611
#region Methods
1712

1813
/// <summary>
19-
/// The Decode
14+
/// Method creates <see cref="System.ValueTuple[double, double]"/> result from passed latitude and longitude arguments
2015
/// </summary>
21-
/// <param name="source">The <see cref="string"/></param>
22-
/// <returns>The <see cref="IEnumerable{T}"/></returns>
23-
public IEnumerable<T> Decode(string source) {
24-
if (String.IsNullOrEmpty(source)) {
25-
throw new ArgumentException(ExceptionMessageResource.SourcePolylineStringCannotBeNullOrEmpty, nameof(source));
26-
}
27-
28-
char[] polyline = source.ToCharArray();
29-
30-
return PolylineAlgorithm.Decode(polyline)
31-
.Select(c => CreateResult(c.Latitude, c.Longitude));
16+
/// <param name="latitude">Latitude value</param>
17+
/// <param name="longitude">Longitude value</param>
18+
/// <returns>Returns created instance of <see cref="System.ValueTuple[double, double]"/></returns>
19+
protected override (double Latitude, double Longitude) CreateResult(double latitude, double longitude) {
20+
return (latitude, longitude);
3221
}
3322

3423
/// <summary>
35-
/// The Encode
24+
/// Method creates <see cref="System.ValueTuple[double, double]"/>
3625
/// </summary>
37-
/// <param name="source">The <see cref="IEnumerable{T}"/></param>
38-
/// <returns>The <see cref="string"/></returns>
39-
public string Encode(IEnumerable<T> source) {
40-
if (source == null || !source.Any()) {
41-
throw new ArgumentException(ExceptionMessageResource.SourceCharArrayCannotBeNullOrEmpty, nameof(source));
42-
}
43-
44-
var coordinates = source.Select(s => GetCoordinate(s));
45-
46-
return PolylineAlgorithm.Encode(coordinates);
26+
/// <param name="source">The <see cref="(double Latitude, double Longitude)"/></param>
27+
/// <returns>Returns created coordinate <see cref="System.ValueTuple[double, double]"/></returns>
28+
protected override (double Latitude, double Longitude) GetCoordinate((double Latitude, double Longitude) source) {
29+
return source;
4730
}
4831

49-
/// <summary>
50-
/// The CreateResult
51-
/// </summary>
52-
/// <param name="latitude">The <see cref="double"/></param>
53-
/// <param name="longitude">The <see cref="double"/></param>
54-
/// <returns>The <see cref="T"/></returns>
55-
protected abstract T CreateResult(double latitude, double longitude);
56-
57-
/// <summary>
58-
/// The GetCoordinates
59-
/// </summary>
60-
/// <param name="source">The <see cref="IEnumerable{T}"/></param>
61-
/// <returns>The <see cref="IEnumerable{(double Latitude, double Longitude)}"/></returns>
62-
protected abstract (double Latitude, double Longitude) GetCoordinate(T source);
63-
6432
#endregion
6533
}
6634
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
//
2+
// Copyright (c) Petr Šrámek. All rights reserved.
3+
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
4+
//
5+
6+
namespace Cloudikka.PolylineAlgorithm.Encoding {
7+
using System;
8+
using System.Collections.Generic;
9+
using System.Linq;
10+
11+
/// /// <summary>
12+
/// Defines base class for all polyline encodings
13+
/// </summary>
14+
/// <typeparam name="T"></typeparam>
15+
public abstract class PolylineEncodingBase<T> : IPolylineEncoding<T> {
16+
#region Methods
17+
18+
/// <summary>
19+
/// Method performs decode operation and coversion to desired type
20+
/// </summary>
21+
/// <param name="source">The <see cref="string"/></param>
22+
/// <returns>The <see cref="IEnumerable{T}"/></returns>
23+
public IEnumerable<T> Decode(string source) {
24+
if (String.IsNullOrEmpty(source)) {
25+
throw new ArgumentException(ExceptionMessageResource.ArgumentCannotBeNullOrEmpty, nameof(source));
26+
}
27+
28+
char[] polyline = source.ToCharArray();
29+
30+
return PolylineAlgorithm.Decode(polyline)
31+
.Select(c => CreateResult(c.Latitude, c.Longitude));
32+
}
33+
34+
/// <summary>
35+
/// Method performs conversion to coordinate tuple and encode operation.
36+
/// </summary>
37+
/// <param name="source">The <see cref="IEnumerable{T}"/></param>
38+
/// <returns>The <see cref="string"/></returns>
39+
public string Encode(IEnumerable<T> source) {
40+
if (source == null || !source.Any()) {
41+
throw new ArgumentException(ExceptionMessageResource.ArgumentCannotBeNullOrEmpty, nameof(source));
42+
}
43+
44+
var coordinates = source.Select(s => GetCoordinate(s));
45+
46+
return PolylineAlgorithm.Encode(coordinates);
47+
}
48+
49+
/// <summary>
50+
/// Method creates <see cref="T"/> result from passed latitude and longitude arguments
51+
/// </summary>
52+
/// <param name="latitude">Latitude value</param>
53+
/// <param name="longitude">Longitude value</param>
54+
/// <returns>Returns created instance of <see cref="T"/></returns>
55+
protected abstract T CreateResult(double latitude, double longitude);
56+
57+
/// <summary>
58+
/// The GetCoordinates
59+
/// </summary>
60+
/// <param name="source">The <see cref="IEnumerable{T}"/></param>
61+
/// <returns>The <see cref="IEnumerable{(double Latitude, double Longitude)}"/></returns>
62+
protected abstract (double Latitude, double Longitude) GetCoordinate(T source);
63+
64+
#endregion
65+
}
66+
}

src/Cloudikka.PolylineAlgorithm/Cloudikka.PolylineAlgorithm/Encoding/TuplePolylineEncoding.cs

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)