Skip to content

Commit e57c484

Browse files
authored
Merge pull request #295 from vivet/VERSION_423
Version 423
2 parents fa358ca + 1f45321 commit e57c484

File tree

9 files changed

+190
-19
lines changed

9 files changed

+190
-19
lines changed

.tests/GoogleApi.Test/Maps/StaticMaps/StaticMapsTests.cs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,47 @@ public void StaticMapsWhenPathsTest()
8787
Assert.AreEqual(Status.Ok, result.Status);
8888
}
8989

90+
[Test]
91+
public void StaticMapsWhenPathsAsEncodedPolylineTest()
92+
{
93+
var request = new StaticMapsRequest
94+
{
95+
Key = this.Settings.ApiKey,
96+
Paths = new List<MapPath>
97+
{
98+
new()
99+
{
100+
Weight = 10,
101+
Geodesic = false,
102+
Color = "color1",
103+
FillColor = "fillcolor1",
104+
EncodedPoints = GoogleFunctions.EncodePolyLine(new List<Coordinate>
105+
{
106+
new(60.170877, 24.942796),
107+
new(60.180877, 24.952796)
108+
})
109+
},
110+
new()
111+
{
112+
Weight = 11,
113+
Geodesic = true,
114+
Color = "color1",
115+
FillColor = "fillcolor2",
116+
Points = new List<Location>
117+
{
118+
new(new Coordinate(60.170877, 24.942796)),
119+
new(new Coordinate(60.180877, 24.952796))
120+
}
121+
}
122+
}
123+
};
124+
125+
var result = GoogleMaps.StaticMaps.Query(request);
126+
127+
Assert.IsNotNull(result);
128+
Assert.AreEqual(Status.Ok, result.Status);
129+
}
130+
90131
[Test]
91132
public void StaticMapsWhenStylesTest()
92133
{

.tests/GoogleApi.Test/Translate/Languages/LanguagesTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public void LanguagesTest()
2525

2626
var languages = result.Data.Languages;
2727
Assert.IsNotNull(languages);
28-
Assert.AreEqual(127, languages.Count());
28+
Assert.AreEqual(135, languages.Count());
2929
}
3030

3131
[Test]
@@ -43,7 +43,7 @@ public void LanguagesWhenTargetTest()
4343

4444
var languages = result.Data.Languages;
4545
Assert.IsNotNull(languages);
46-
Assert.AreEqual(127, languages.Count());
46+
Assert.AreEqual(135, languages.Count());
4747
}
4848

4949
[Test]

.tests/GoogleApi.UnitTests/Maps/StaticMaps/StaticMapsRequestTests.cs

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,40 @@ public void GetQueryStringParametersWhenPathsTest()
177177
Assert.AreEqual(pathExpected, path.Value);
178178
}
179179

180+
[Test]
181+
public void GetQueryStringParametersWhenPathsAndEncodedPointsTest()
182+
{
183+
var request = new StaticMapsRequest
184+
{
185+
Key = "key",
186+
Center = new Location(new Coordinate(1, 1)),
187+
ZoomLevel = 1,
188+
Paths = new List<MapPath>
189+
{
190+
new()
191+
{
192+
Weight = 10,
193+
Geodesic = false,
194+
Color = "color",
195+
FillColor = "fillcolor",
196+
EncodedPoints = GoogleFunctions.EncodePolyLine(new List<Coordinate>
197+
{
198+
new(1, 1),
199+
new(2, 2)
200+
})
201+
}
202+
}
203+
};
204+
205+
var queryStringParameters = request.GetQueryStringParameters();
206+
Assert.IsNotNull(queryStringParameters);
207+
208+
var path = queryStringParameters.FirstOrDefault(x => x.Key == "path");
209+
var pathExpected = request.Paths.First().ToString();
210+
Assert.IsNotNull(path);
211+
Assert.AreEqual(pathExpected, path.Value);
212+
}
213+
180214
[Test]
181215
public void GetQueryStringParametersWhenPathsMultipleTest()
182216
{
@@ -229,7 +263,28 @@ public void GetQueryStringParametersWhenPathsMultipleTest()
229263
}
230264

231265
[Test]
232-
public void GetQueryStringParametersWhenPathsWhenPointsIsEmptyTest()
266+
public void GetQueryStringParametersWhenPathsWhenPointsIsEmptyAndEncodedPointsIsNotNullTest()
267+
{
268+
var request = new StaticMapsRequest
269+
{
270+
Key = "key",
271+
Center = new Location(new Coordinate(1, 1)),
272+
ZoomLevel = 1,
273+
Paths = new List<MapPath>
274+
{
275+
new()
276+
{
277+
Color = "color",
278+
EncodedPoints = "encoded-points"
279+
}
280+
}
281+
};
282+
283+
Assert.DoesNotThrow(() => request.GetQueryStringParameters());
284+
}
285+
286+
[Test]
287+
public void GetQueryStringParametersWhenPathsWhenPointsIsEmptyAndEncodedPointsIsNullTest()
233288
{
234289
var request = new StaticMapsRequest
235290
{

GoogleApi/Entities/Maps/Common/Location.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using GoogleApi.Entities.Common;
1+
using System;
2+
using GoogleApi.Entities.Common;
23

34
namespace GoogleApi.Entities.Maps.Common;
45

@@ -13,20 +14,26 @@ public class Location
1314
public string String { get; }
1415

1516
/// <summary>
16-
///
17+
/// Constructor.
1718
/// </summary>
18-
/// <param name="address"></param>
19+
/// <param name="address">The address string.</param>
1920
public Location(Address address)
2021
{
22+
if (address == null)
23+
throw new ArgumentNullException(nameof(address));
24+
2125
this.String = address.ToString();
2226
}
2327

2428
/// <summary>
25-
///
29+
/// Constructor.
2630
/// </summary>
2731
/// <param name="coordinate"></param>
2832
public Location(Coordinate coordinate)
2933
{
34+
if (coordinate == null)
35+
throw new ArgumentNullException(nameof(coordinate));
36+
3037
this.String = coordinate.ToString();
3138
}
3239

GoogleApi/Entities/Maps/StaticMaps/Request/MapPath.cs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,17 @@ public class MapPath
4040
public virtual string FillColor { get; set; }
4141

4242
/// <summary>
43-
/// Gets or sets the collection of points for this path
43+
/// Gets or sets the collection of points for this path.
4444
/// </summary>
4545
public virtual IEnumerable<Location> Points { get; set; } = new List<Location>();
4646

47+
/// <summary>
48+
/// Encoded Points.
49+
/// Instead of using points, Encoded Points can be set. This will override Points.
50+
/// Use when having a lot of locations, where the url otherwise would get too long.
51+
/// </summary>
52+
public virtual string EncodedPoints { get; set; }
53+
4754
/// <summary>
4855
/// Returns a string representation of a <see cref="MapPath"/>.
4956
/// </summary>
@@ -52,8 +59,12 @@ public override string ToString()
5259
{
5360
var weight = $"weight:{this.Weight}";
5461
var geodesic = $"geodesic:{this.Geodesic.ToString().ToLower()}";
55-
var color = this.Color != null ? $"color:{this.Color}" : null;
56-
var fillColor = this.FillColor != null ? $"fillcolor:{this.FillColor}" : null;
62+
var color = this.Color != null
63+
? $"color:{this.Color}"
64+
: null;
65+
var fillColor = this.FillColor != null
66+
? $"fillcolor:{this.FillColor}"
67+
: null;
5768

5869
var styles = new[]
5970
{
@@ -63,7 +74,9 @@ public override string ToString()
6374
fillColor
6475
}.Where(x => x != null);
6576

66-
var points = string.Join("|", this.Points.Select(x => x.ToString()));
77+
var points = this.EncodedPoints == null
78+
? string.Join("|", this.Points.Select(x => x.ToString()))
79+
: $"enc:{this.EncodedPoints}";
6780

6881
return $"{string.Join("|", styles)}|{points}";
6982
}

GoogleApi/Entities/Maps/StaticMaps/Request/StaticMapsRequest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public override IList<KeyValuePair<string, string>> GetQueryStringParameters()
134134
if (this.Center == null || !this.ZoomLevel.HasValue)
135135
{
136136
var hasMarkers = this.Markers.Any() && this.Markers.SelectMany(x => x.Locations).Any();
137-
var hasPaths = this.Paths.Any() && this.Paths.SelectMany(x => x.Points).Any();
137+
var hasPaths = this.Paths.Any() && (this.Paths.SelectMany(x => x.Points).Any() || this.Paths.SelectMany(x => x.EncodedPoints).Any());
138138
var hasVisibles = this.Visibles.Any();
139139

140140
if (!hasMarkers && !hasPaths && !hasVisibles)
@@ -172,7 +172,7 @@ public override IList<KeyValuePair<string, string>> GetQueryStringParameters()
172172
{
173173
foreach (var path in this.Paths)
174174
{
175-
if (path.Points.Count() <= 1)
175+
if (path.Points.Count() <= 1 && path.EncodedPoints == null)
176176
throw new ArgumentException($"{nameof(this.Paths)} must contain two or more locations");
177177

178178
parameters.Add("path", path.ToString());

GoogleApi/Entities/Translate/Common/Enums/Language.cs

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,5 +770,59 @@ public enum Language
770770
/// Zulu.
771771
/// </summary>
772772
[EnumMember(Value = "ts")]
773-
Tsonga
773+
Tsonga,
774+
775+
/// <summary>
776+
/// Bambara.
777+
/// </summary>
778+
[EnumMember(Value = "bm")]
779+
Bambara,
780+
781+
/// <summary>
782+
/// Bhojpuri.
783+
/// </summary>
784+
[EnumMember(Value = "bho")]
785+
Bhojpuri,
786+
787+
/// <summary>
788+
/// Central Kurdish.
789+
/// </summary>
790+
[EnumMember(Value = "ckb")]
791+
CentralKurdish,
792+
793+
/// <summary>
794+
/// Dogri .
795+
/// </summary>
796+
[EnumMember(Value = "doi")]
797+
Dogri,
798+
799+
/// <summary>
800+
/// Goan Konkani.
801+
/// </summary>
802+
[EnumMember(Value = "gom")]
803+
GoanKonkani,
804+
805+
/// <summary>
806+
/// Iloko.
807+
/// </summary>
808+
[EnumMember(Value = "ilo")]
809+
Iloko,
810+
811+
/// <summary>
812+
/// Zulu.
813+
/// </summary>
814+
[EnumMember(Value = "Lushai")]
815+
Abc7,
816+
817+
/// <summary>
818+
/// Maithili.
819+
/// </summary>
820+
[EnumMember(Value = "mai")]
821+
Maithili,
822+
823+
/// <summary>
824+
/// Manipuri.
825+
/// </summary>
826+
[EnumMember(Value = "mni-Mtei")]
827+
Manipuri
774828
}

GoogleApi/GoogleApi.csproj

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
<NoWarn />
88
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
99
<PlatformTarget>AnyCPU</PlatformTarget>
10-
<AssemblyVersion>4.2.2.0</AssemblyVersion>
11-
<FileVersion>4.2.2.0</FileVersion>
12-
<Version>4.2.2.0</Version>
10+
<AssemblyVersion>4.2.3.0</AssemblyVersion>
11+
<FileVersion>4.2.3.0</FileVersion>
12+
<Version>4.2.3.0</Version>
1313
<SignAssembly>True</SignAssembly>
1414
<AssemblyOriginatorKeyFile>GoogleApi.snk</AssemblyOriginatorKeyFile>
1515
<LangVersion>latest</LangVersion>
@@ -21,7 +21,8 @@
2121
<Description>Google Places, Maps, Roads, Search and Translate. Requests and Responses are complete with Google api documentation and references.</Description>
2222
<PackageTags>google api map maps place places elevation snaptoroad snaptoroads snap road roads speed speedlimit coordinate geo geocode geocoder geocoding geolocation search text nearby radar translate translation detect detection language languages nearest geography point geocoordinate address location latitude longitude distance duration matrix distancematrix direction directions travel path journey trip photo photos timezone time zone autocomplete auto-complete traffic spatial</PackageTags>
2323
<PackageReleaseNotes>
24-
- Better exception handling, removed use of system exceptions (@boobyangers).
24+
- Added override for polyline paths in static maps.
25+
- Added missing supported translate langauges.
2526
</PackageReleaseNotes>
2627
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
2728
<RepositoryType>GitHub</RepositoryType>

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: 4.2.2.{build}
1+
version: 4.2.3.{build}
22
skip_tags: true
33
max_jobs: 1
44
image: Visual Studio 2022

0 commit comments

Comments
 (0)