Skip to content

Commit 86c6c5f

Browse files
author
Petr Sramek
committed
restructured PolylineAlgorithm project
1 parent 8433984 commit 86c6c5f

File tree

13 files changed

+22
-26
lines changed

13 files changed

+22
-26
lines changed

README.md

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
Lightweight .NET Standard 2.0 library implementing <a href="https://developers.google.com/maps/documentation/utilities/polylinealgorithm">Google Polyline Algorithm</a>. Designed with respect to flexibility, but still with easy to use.
44

5-
## Getting started
6-
### Prerequisites
5+
## Prerequisites
76

87
.NET Polyline Algorithm is avalable as nuget package <a href="https://www.nuget.org/packages/Cloudikka.PolylineAlgorithm/">Cloudikka.PolylineAlgorithm</a> targeting .NET Standard 2.0.
98

@@ -15,66 +14,54 @@ NuGet Package Manager:
1514

1615
`Cloudikka.PolylineAlgorithm`
1716

18-
#### Warning
19-
20-
Library is using <a href="https://msdn.microsoft.com/en-us/library/mt744804(v=vs.110).aspx">ValueTuple<T1, T2> Structure</a>. ValueTuple struct is avalable in .NET Framework 4.7 and above. Incase your project is targeting lower version of .NET Framework you probably have to install <a href="https://www.nuget.org/packages/System.ValueTuple/">System.ValueTuple</a> NuGet package. (not tested yet)
21-
22-
Command line:
23-
24-
`Install-Package System.ValueTuple`
25-
26-
NuGet Package Manager:
27-
28-
`System.ValueTuple`
29-
30-
### Hot to use it
17+
## Hot to use it
3118

3219
There are three ways how to use .NET Polyline Algorithm library based on your needs. For each is available Encode and Decode methods.
3320

34-
#### Static methods
21+
### Static methods
3522

3623
Whenever you just need to encode or decode Google polyline you can use static methods defined in static PolylineAlgorithm class.
3724

38-
##### Decoding
25+
#### Decoding
3926

4027
```csharp
4128
string polyline = "polyline";
4229
IEnumerable<(double, double)> coordinates = PolylineAlgorithm.Decode(polyline);
4330
```
4431

45-
##### Encoding
32+
#### Encoding
4633

4734
```csharp
4835
IEnumerable<(double, double)> coordinates = new (double, double) [] { (35.635, 76.27182), (35.2435, 75.625), ... };
4936
string polyline = PolylineAlgorithm.Encode(coordinates);
5037
```
5138

5239

53-
#### Default instance
40+
### Default instance
5441

5542
If you need to use dependency injection, you would like to have instance to deliver the work for you. In that case you can use default instance of PolylineEncoding class, which implements IPolylineEncoding<(double Latitude, double Longitude)> interface.
5643

57-
##### Decoding
44+
#### Decoding
5845

5946
```csharp
6047
string polyline = "polyline";
6148
var encoding = new PolylineEncoding();
6249
IEnumerable<(double, double)> coordinates = encoding.Decode(polyline);
6350
```
6451

65-
##### Encoding
52+
#### Encoding
6653

6754
```csharp
6855
IEnumerable<(double, double)> coordinates = new (double, double) [] { (35.635, 76.27182), (35.2435, 75.625), ... };
6956
var encoding = new PolylineEncoding();
7057
string polyline = encoding.Encode(coordinates);
7158
```
7259

73-
#### Inherited base class
60+
### Inherited base class
7461

7562
There may be a scenario you need to pass and return different types to and from without a need to add another extra layer. In this case you can inherit PolylineEncodingBase<T> class and override template methods CreateResult and GetCoordinates.
7663

77-
##### Inheriting
64+
#### Inheriting
7865

7966
```csharp
8067
public class MyPolylineEncoding : PolylineEncodingBase<Coordinate> {

benchmarks/PolylineAlgorithm.Benchmarks/PolylineDecoderBenchmark.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace PolylineAlgorithm.Benchmarks;
88
using BenchmarkDotNet.Attributes;
99
using BenchmarkDotNet.Engines;
1010
using BenchmarkDotNet.Order;
11+
using PolylineAlgorithm.Abstraction;
1112

1213
[MemoryDiagnoser]
1314
[MarkdownExporter]

benchmarks/PolylineAlgorithm.Benchmarks/PolylineEncoderBenchmark.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace PolylineAlgorithm.Benchmarks;
88
using BenchmarkDotNet.Attributes;
99
using BenchmarkDotNet.Engines;
1010
using BenchmarkDotNet.Order;
11+
using PolylineAlgorithm.Abstraction;
1112

1213
[MemoryDiagnoser]
1314
[MarkdownExporter]

src/PolylineAlgorithm.DependencyInjection.Autofac/ContainerBuilderExtensions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace PolylineAlgorithm.DependencyInjection.Autofac;
77

88
using global::Autofac;
9+
using PolylineAlgorithm.Abstraction;
910

1011
public static class ContainerBuilderExtensions {
1112
/// <summary>

src/PolylineAlgorithm.DependencyInjection.Microsoft/ServiceCollectionExtensions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace PolylineAlgorithm.DependencyInjection.Microsoft;
77

88
using global::Microsoft.Extensions.DependencyInjection;
9+
using PolylineAlgorithm.Abstraction;
910

1011
public static class ServiceCollectionExtensions {
1112
/// <summary>

src/PolylineAlgorithm/ICoordinateValidator.cs renamed to src/PolylineAlgorithm/Abstraction/ICoordinateValidator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
44
//
55

6-
namespace PolylineAlgorithm;
6+
namespace PolylineAlgorithm.Abstraction;
77

88
/// <summary>
99
/// Provides validation of a coordinate value.

src/PolylineAlgorithm/IPolylineDecoder.cs renamed to src/PolylineAlgorithm/Abstraction/IPolylineDecoder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
44
//
55

6-
namespace PolylineAlgorithm;
6+
namespace PolylineAlgorithm.Abstraction;
77

88
using System.Collections.Generic;
99

src/PolylineAlgorithm/IPolylineEncoder.cs renamed to src/PolylineAlgorithm/Abstraction/IPolylineEncoder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
44
//
55

6-
namespace PolylineAlgorithm;
6+
namespace PolylineAlgorithm.Abstraction;
77

88
using System.Collections.Generic;
99

src/PolylineAlgorithm/CoordinateValidator.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
namespace PolylineAlgorithm;
77

8+
using PolylineAlgorithm.Abstraction;
89
using PolylineAlgorithm.Internal;
910

1011
/// <inheritdoc cref="ICoordinateValidator" />

src/PolylineAlgorithm/PolylineDecoder.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
namespace PolylineAlgorithm;
77

8+
using PolylineAlgorithm.Abstraction;
89
using PolylineAlgorithm.Internal;
910

1011
/// <inheritdoc cref="IPolylineDecoder" />

src/PolylineAlgorithm/PolylineEncoder.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
namespace PolylineAlgorithm;
77

8+
using PolylineAlgorithm.Abstraction;
89
using PolylineAlgorithm.Internal;
910
using System;
1011
using System.Collections.Generic;

tests/PolylineAlgorithm.DependencyInjection.Autofac.Tests/ContainerBuilderExtensionsTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
namespace PolylineAlgorithm.DependencyInjection.Autofac.Tests;
77

8+
using PolylineAlgorithm.Abstraction;
89
using PolylineAlgorithm.DependencyInjection.Autofac;
910

1011
[TestClass]

tests/PolylineAlgorithm.DependencyInjection.Microsoft.Tests/ServiceCollectionExtensionsTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
namespace PolylineAlgorithm.DependencyInjection.Tests;
77

8+
using PolylineAlgorithm.Abstraction;
89
using PolylineAlgorithm.DependencyInjection.Microsoft;
910

1011
[TestClass]

0 commit comments

Comments
 (0)