Skip to content

Commit eb9b38b

Browse files
Merge pull request #19 from blackboxlogic/develop
Develop
2 parents 4ddf25a + d768924 commit eb9b38b

File tree

4 files changed

+22
-13
lines changed

4 files changed

+22
-13
lines changed

FunctionalTests/Tests.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ public static class Tests
1414
{
1515
private static Bounds WashingtonDC = new Bounds()
1616
{
17-
MinLongitude = -77.0371918f,
18-
MinLatitude = 38.9067186f,
19-
MaxLongitude = -77.03599990f,
20-
MaxLatitude = 38.907734f,
17+
MinLongitude = -77.0671918f,
18+
MinLatitude = 38.9007186f,
19+
MaxLongitude = -77.00099990f,
20+
MaxLatitude = 38.98734f,
2121
};
2222

2323
private static Bounds TraceArea = new Bounds()
@@ -65,22 +65,25 @@ public static async Task TestClient(INonAuthClient client)
6565
var wayComplete = await client.GetCompleteWay(wayId);
6666
var relation = await client.GetRelation(relationId);
6767
var relationComplete = await client.GetCompleteRelation(relationId);
68-
var nodeVersion = await client.GetNodeVersion(nodeId, 3);
68+
var nodeVersion = await client.GetNodeVersion(nodeId, 1);
6969
NotNull(node, way, wayComplete, relation, relationComplete, nodeVersion);
7070
var nodeHistory = await client.GetNodeHistory(nodeId);
7171
var multifetchNodes = await client.GetNodes(new Dictionary<long, long?>() { { nodeId, null }, { nodeId + 1, 1 } });
7272
var nodeRelations = await client.GetNodeRelations(nodeId);
7373
var nodeWays = await client.GetNodeWays(nodeId);
7474
var multifetchElements = await client.GetElements(
7575
map.Nodes.Select(n => new OsmGeoKey(n)).Concat(map.Ways.Select(n => new OsmGeoKey(n))).ToArray());
76-
True(nodeHistory?.Any(), multifetchNodes?.Any(), nodeRelations?.Any(), nodeWays?.Any(), multifetchElements?.Any());
76+
True(nodeHistory?.Any(), multifetchNodes?.Any());
77+
NotNull(nodeRelations, nodeWays, multifetchElements);
7778
var changeset = await client.GetChangeset(node.ChangeSetId.Value);
7879
var changesetWithDiscussion = await client.GetChangeset(node.ChangeSetId.Value, true);
7980
NotNull(changeset, changesetWithDiscussion?.Discussion);
8081
var changesets = await client.QueryChangesets(WashingtonDC, null, null, null, null, false, false, null);
8182
True(changesets?.Any());
8283
changesets = await client.QueryChangesets(null, node.UserId, null, null, null, false, false, null);
8384
True(changesets?.Any());
85+
changesets = await client.QueryChangesets(null, node.UserId, null, DateTime.MinValue, null, false, false, null);
86+
True(changesets?.Any());
8487
changesets = await client.QueryChangesets(null, null, node.UserName, null, null, false, false, null);
8588
True(changesets?.Any());
8689
changesets = await client.QueryChangesets(null, null, null, null, null, false, false, new long[] { 151176, 151177 });

src/INonAuthClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,6 @@ public interface INonAuthClient
4949
Task<Note[]> GetNotes(Bounds bounds, int limit = 100, int maxClosedDays = 7);
5050
Task<Stream> GetNotesRssFeed(Bounds bounds);
5151
Task<Note[]> QueryNotes(string searchText, long? userId, string userName, int? limit, int? maxClosedDays, DateTime? fromDate, DateTime? toDate);
52-
Task<Note> CreateNote(float latitude, float longitude, string text);
52+
Task<Note> CreateNote(double latitude, double longitude, string text);
5353
}
5454
}

src/NonAuthClient.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
using System.Web;
1515
using Microsoft.Extensions.Logging;
1616
using OsmSharp.Db;
17+
using System.Globalization;
1718

1819
namespace OsmSharp.IO.API
1920
{
@@ -489,8 +490,8 @@ public async Task<Changeset[]> QueryChangesets(Bounds bounds, long? userId, stri
489490
if (bounds != null) query["bbox"] = ToString(bounds);
490491
if (userId.HasValue) query["user"] = userId.ToString();
491492
if (userName != null) query["display_name"] = userName;
492-
if (minClosedDate.HasValue) query["time"] = minClosedDate.ToString();
493-
if (maxOpenedDate.HasValue) query.Add("time", maxOpenedDate.ToString());
493+
if (minClosedDate.HasValue) query["time"] = FormatNoteDate(minClosedDate.Value);
494+
if (maxOpenedDate.HasValue) query.Add("time", FormatNoteDate(maxOpenedDate.Value));
494495
if (openOnly) query["open"] = "true";
495496
if (closedOnly) query["closed"] = "true";
496497
if (ids != null) query["changesets"] = string.Join(",", ids);
@@ -644,7 +645,7 @@ private static string FormatNoteDate(DateTime date)
644645
/// <see href="https://wiki.openstreetmap.org/wiki/API_v0.6#Create_a_new_note:_Create:_POST_.2Fapi.2F0.6.2Fnotes">
645646
/// POST /api/0.6/notes</see>.
646647
/// </summary>
647-
public async Task<Note> CreateNote(float latitude, float longitude, string text)
648+
public async Task<Note> CreateNote(double latitude, double longitude, string text)
648649
{
649650
var query = HttpUtility.ParseQueryString(string.Empty);
650651
query["text"] = text;
@@ -685,6 +686,11 @@ protected string ToString(float number)
685686
return number.ToString(OsmMaxPrecision);
686687
}
687688

689+
protected string ToString(double number)
690+
{
691+
return number.ToString(OsmMaxPrecision);
692+
}
693+
688694
#region Http
689695
protected static readonly Func<string, string> Encode = HttpUtility.UrlEncode;
690696

src/OsmApiClient.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
<PropertyGroup>
44
<TargetFramework>netstandard2.0</TargetFramework>
55
<PackageId>OsmApiClient</PackageId>
6-
<Version>0.0.3</Version>
6+
<Version>0.0.4</Version>
77
<RepositoryUrl>https://github.com/OsmSharp/osm-api-client/</RepositoryUrl>
8-
<PackageReleaseNotes>Adding GetElements(OsmGeoKey[] keys) which can fetch multiple element types in one call.</PackageReleaseNotes>
8+
<PackageReleaseNotes>Fixed a bug in QueryChangesets() when supplying a time range</PackageReleaseNotes>
99
<PackageProjectUrl>https://github.com/OsmSharp/osm-api-client/</PackageProjectUrl>
10-
<Description>This is a simple C# client to allow using OSM API easily.</Description>
10+
<Description>This is a simple C# client to allow using OSM API.</Description>
1111
<PackageTags>osm;openstreetmap;client</PackageTags>
1212
<PackageLicenseExpression>MIT</PackageLicenseExpression>
1313
<Copyright>Copyright 2019 Alex Hennings &amp; Harel Mazor</Copyright>

0 commit comments

Comments
 (0)