Skip to content

Commit a0d05e3

Browse files
committed
lets just commit
1 parent cc91bc2 commit a0d05e3

54 files changed

Lines changed: 368 additions & 4250 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.editorconfig

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Remove the line below if you want to inherit .editorconfig settings from higher directories
1+
# Remove the line below if you want to inherit .editorconfig settings from higher directories
22
root = true
33

44
# All files
@@ -270,3 +270,7 @@ dotnet_naming_style.underscore_camel_case.required_prefix = _
270270
dotnet_naming_style.underscore_camel_case.required_suffix =
271271
dotnet_naming_style.underscore_camel_case.word_separator =
272272
dotnet_naming_style.underscore_camel_case.capitalization = camel_case
273+
274+
# Public API analyzer
275+
276+
dotnet_public_api_analyzer.require_api_files = true

PolylineAlgorithm.slnx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@
99
<Project Path="samples/PolylineAlgorithm.NetTopologySuite.Sample/PolylineAlgorithm.NetTopologySuite.Sample.csproj" Id="27a8fc47-0a3c-49c7-af5e-530514827785" />
1010
</Folder>
1111
<Folder Name="/src/">
12-
<Project Path="src/PolylineAlgorithm.Gps/PolylineAlgorithm.Gps.csproj" Id="816a7001-8faf-472e-8927-86286149a8d1" />
1312
<Project Path="src/PolylineAlgorithm/PolylineAlgorithm.csproj" />
1413
</Folder>
1514
<Folder Name="/tests/">
16-
<Project Path="tests/PolylineAlgorithm.Gps.Tests/PolylineAlgorithm.Gps.Tests.csproj" />
1715
<Project Path="tests/PolylineAlgorithm.Tests/PolylineAlgorithm.Tests.csproj" />
1816
</Folder>
1917
<Folder Name="/utilities/" Id="02ea681e-c7d8-13c7-8484-4ac65e1b71e8">

benchmarks/PolylineAlgorithm.Benchmarks/PolylineAlgorithm.Benchmarks.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
</ItemGroup>
2626

2727
<ItemGroup>
28-
<ProjectReference Include="..\..\src\PolylineAlgorithm.Gps\PolylineAlgorithm.Gps.csproj" />
2928
<ProjectReference Include="..\..\src\PolylineAlgorithm\PolylineAlgorithm.csproj" />
3029
<ProjectReference Include="..\..\utilities\PolylineAlgorithm.Utility\PolylineAlgorithm.Utility.csproj" />
3130
</ItemGroup>

benchmarks/PolylineAlgorithm.Benchmarks/PolylineBenchmark.cs

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

benchmarks/PolylineAlgorithm.Benchmarks/PolylineDecoderBenchmark.cs

Lines changed: 46 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ namespace PolylineAlgorithm.Benchmarks;
77

88
using BenchmarkDotNet.Attributes;
99
using BenchmarkDotNet.Engines;
10-
using PolylineAlgorithm.Gps;
11-
using PolylineAlgorithm.Gps.Extensions;
10+
using PolylineAlgorithm.Abstraction;
1211
using PolylineAlgorithm.Utility;
1312

1413
/// <summary>
@@ -21,11 +20,6 @@ public class PolylineDecoderBenchmark {
2120
public int CoordinatesCount { get; set; }
2221

2322
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable.
24-
/// <summary>
25-
/// Polyline instance for benchmarks.
26-
/// </summary>
27-
public Polyline Polyline { get; private set; }
28-
2923
/// <summary>
3024
/// Encoded polyline as string.
3125
/// </summary>
@@ -44,37 +38,36 @@ public class PolylineDecoderBenchmark {
4438
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable.
4539

4640
/// <summary>
47-
/// Polyline decoder instance.
41+
/// String polyline decoder instance.
42+
/// </summary>
43+
private readonly StringPolylineDecoder _stringDecoder = new();
44+
45+
/// <summary>
46+
/// Char array polyline decoder instance.
4847
/// </summary>
49-
private readonly PolylineDecoder _decoder = new();
48+
private readonly CharArrayPolylineDecoder _charArrayDecoder = new();
49+
50+
/// <summary>
51+
/// String polyline decoder instance.
52+
/// </summary>
53+
private readonly MemoryCharPolylineDecoder _memoryCharDecoder = new();
5054

5155
/// <summary>
5256
/// Sets up benchmark data.
5357
/// </summary>
5458
[GlobalSetup]
5559
public void SetupData() {
56-
Polyline = Polyline.FromString(RandomValueProvider.GetPolyline(CoordinatesCount));
5760
String = RandomValueProvider.GetPolyline(CoordinatesCount);
5861
CharArray = RandomValueProvider.GetPolyline(CoordinatesCount).ToCharArray();
5962
Memory = RandomValueProvider.GetPolyline(CoordinatesCount).AsMemory();
6063
}
6164

62-
/// <summary>
63-
/// Benchmark: decode polyline instance.
64-
/// </summary>
65-
[Benchmark]
66-
public void PolylineDecoder_Decode_Polyline() {
67-
_decoder
68-
.Decode(Polyline)
69-
.Consume(_consumer);
70-
}
71-
7265
/// <summary>
7366
/// Benchmark: decode from string.
7467
/// </summary>
7568
[Benchmark]
7669
public void PolylineDecoder_Decode_String() {
77-
_decoder
70+
_stringDecoder
7871
.Decode(String)
7972
.Consume(_consumer);
8073
}
@@ -84,7 +77,7 @@ public void PolylineDecoder_Decode_String() {
8477
/// </summary>
8578
[Benchmark]
8679
public void PolylineDecoder_Decode_CharArray() {
87-
_decoder
80+
_charArrayDecoder
8881
.Decode(CharArray)
8982
.Consume(_consumer);
9083
}
@@ -94,8 +87,38 @@ public void PolylineDecoder_Decode_CharArray() {
9487
/// </summary>
9588
[Benchmark]
9689
public void PolylineDecoder_Decode_Memory() {
97-
_decoder
90+
_memoryCharDecoder
9891
.Decode(Memory)
9992
.Consume(_consumer);
10093
}
94+
95+
private sealed class StringPolylineDecoder : AbstractPolylineDecoder<string, (double Latitude, double Longitude)> {
96+
protected override (double Latitude, double Longitude) CreateCoordinate(double latitude, double longitude) {
97+
return (latitude, longitude);
98+
}
99+
100+
protected override ReadOnlyMemory<char> GetReadOnlyMemory(in string polyline) {
101+
return polyline?.AsMemory() ?? Memory<char>.Empty;
102+
}
103+
}
104+
105+
private sealed class CharArrayPolylineDecoder : AbstractPolylineDecoder<char[], (double Latitude, double Longitude)> {
106+
protected override (double Latitude, double Longitude) CreateCoordinate(double latitude, double longitude) {
107+
return (latitude, longitude);
108+
}
109+
110+
protected override ReadOnlyMemory<char> GetReadOnlyMemory(in char[] polyline) {
111+
return polyline?.AsMemory() ?? Memory<char>.Empty;
112+
}
113+
}
114+
115+
private sealed class MemoryCharPolylineDecoder : AbstractPolylineDecoder<ReadOnlyMemory<char>, (double Latitude, double Longitude)> {
116+
protected override (double Latitude, double Longitude) CreateCoordinate(double latitude, double longitude) {
117+
return (latitude, longitude);
118+
}
119+
120+
protected override ReadOnlyMemory<char> GetReadOnlyMemory(in ReadOnlyMemory<char> polyline) {
121+
return polyline;
122+
}
123+
}
101124
}

0 commit comments

Comments
 (0)