Skip to content

Commit 56ffe1d

Browse files
committed
Updating to latest OsmSharp (Still a pre-release)
Switching ints to longs for versions and IDs.
1 parent d05c76b commit 56ffe1d

File tree

6 files changed

+33
-33
lines changed

6 files changed

+33
-33
lines changed

FunctionalTests/Tests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public static async Task TestClient(INonAuthClient client)
6767
var nodeVersion = await client.GetNodeVersion(nodeId, 3);
6868
NotNull(node, way, wayComplete, relation, relationComplete, nodeVersion);
6969
var nodeHistory = await client.GetNodeHistory(nodeId);
70-
var multifetchNodes = await client.GetNodes(new Dictionary<long, int?>() { { nodeId, null }, { nodeId + 1, 1 } });
70+
var multifetchNodes = await client.GetNodes(new Dictionary<long, long?>() { { nodeId, null }, { nodeId + 1, 1 } });
7171
var nodeRelations = await client.GetNodeRelations(nodeId);
7272
var nodeWays = await client.GetNodeWays(nodeId);
7373
True(nodeHistory?.Any(), multifetchNodes?.Any(), nodeRelations?.Any(), nodeWays?.Any());

src/AuthClient.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public async Task<long> CreateElement(long changesetId, OsmGeo osmGeo)
140140
}
141141

142142
/// <inheritdoc />
143-
public async Task<int> UpdateElement(long changesetId, ICompleteOsmGeo osmGeo)
143+
public async Task<long> UpdateElement(long changesetId, ICompleteOsmGeo osmGeo)
144144
{
145145
switch (osmGeo.Type)
146146
{
@@ -156,27 +156,27 @@ public async Task<int> UpdateElement(long changesetId, ICompleteOsmGeo osmGeo)
156156
}
157157

158158
/// <inheritdoc />
159-
public async Task<int> UpdateElement(long changesetId, OsmGeo osmGeo)
159+
public async Task<long> UpdateElement(long changesetId, OsmGeo osmGeo)
160160
{
161161
Validate.ElementHasAVersion(osmGeo);
162162
var address = BaseAddress + $"0.6/{osmGeo.Type.ToString().ToLower()}/{osmGeo.Id}";
163163
var osmRequest = GetOsmRequest(changesetId, osmGeo);
164164
var content = new StringContent(osmRequest.SerializeToXml());
165165
var responseContent = await SendAuthRequest(HttpMethod.Put, address, content);
166166
var newVersionNumber = await responseContent.ReadAsStringAsync();
167-
return int.Parse(newVersionNumber);
167+
return long.Parse(newVersionNumber);
168168
}
169169

170170
/// <inheritdoc />
171-
public async Task<int> DeleteElement(long changesetId, OsmGeo osmGeo)
171+
public async Task<long> DeleteElement(long changesetId, OsmGeo osmGeo)
172172
{
173173
Validate.ElementHasAVersion(osmGeo);
174174
var address = BaseAddress + $"0.6/{osmGeo.Type.ToString().ToLower()}/{osmGeo.Id}";
175175
var osmRequest = GetOsmRequest(changesetId, osmGeo);
176176
var content = new StringContent(osmRequest.SerializeToXml());
177177
var responseContent = await SendAuthRequest(HttpMethod.Delete, address, content);
178178
var newVersionNumber = await responseContent.ReadAsStringAsync();
179-
return int.Parse(newVersionNumber);
179+
return long.Parse(newVersionNumber);
180180
}
181181

182182
/// <inheritdoc />
@@ -220,7 +220,7 @@ public async Task<GpxFile[]> GetTraces()
220220
}
221221

222222
/// <inheritdoc />
223-
public async Task<int> CreateTrace(GpxFile gpx, Stream fileStream)
223+
public async Task<long> CreateTrace(GpxFile gpx, Stream fileStream)
224224
{
225225
var address = BaseAddress + "0.6/gpx/create";
226226
var form = new MultipartFormDataContent();
@@ -233,7 +233,7 @@ public async Task<int> CreateTrace(GpxFile gpx, Stream fileStream)
233233
form.Add(stream, "file", cleanName);
234234
var content = await SendAuthRequest(HttpMethod.Post, address, form);
235235
var id = await content.ReadAsStringAsync();
236-
return int.Parse(id);
236+
return long.Parse(id);
237237
}
238238

239239
/// <inheritdoc />

src/IAuthClient.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,15 @@ public interface IAuthClient : INonAuthClient
114114
/// <param name="changesetId">The ID of an OPEN Changeset.</param>
115115
/// <param name="osmGeo"></param>
116116
/// <returns>The Element's new version number</returns>
117-
Task<int> UpdateElement(long changesetId, ICompleteOsmGeo osmGeo);
117+
Task<long> UpdateElement(long changesetId, ICompleteOsmGeo osmGeo);
118118
/// <summary>
119119
/// Updates an element using a <see cref="OsmGeo"/> object
120120
/// <see href="https://wiki.openstreetmap.org/wiki/API_v0.6#Update:_PUT_.2Fapi.2F0.6.2F.5Bnode.7Cway.7Crelation.5D.2F.23id">
121121
/// PUT /api/0.6/[node|way|relation]/#id</see>
122122
/// </summary>
123123
/// <param name="changesetId">The ID of an OPEN Changeset.</param>
124124
/// <returns>The Element's new version number</returns>
125-
Task<int> UpdateElement(long changesetId, OsmGeo osmGeo);
125+
Task<long> UpdateElement(long changesetId, OsmGeo osmGeo);
126126
/// <summary>
127127
/// Delete an OSM element as part of the given changeset
128128
/// <see href="https://wiki.openstreetmap.org/wiki/API_v0.6#Delete:_DELETE_.2Fapi.2F0.6.2F.5Bnode.7Cway.7Crelation.5D.2F.23id">
@@ -131,7 +131,7 @@ public interface IAuthClient : INonAuthClient
131131
/// <param name="changesetId">The ID of an OPEN Changeset.</param>
132132
/// <param name="osmGeo"></param>
133133
/// <returns>The Element's new version number</returns>
134-
Task<int> DeleteElement(long changesetId, OsmGeo osmGeo);
134+
Task<long> DeleteElement(long changesetId, OsmGeo osmGeo);
135135
/// <summary>
136136
/// Gets the current User's GPX Trace Files
137137
/// <see href="https://wiki.openstreetmap.org/wiki/API_v0.6#List:_GET_.2Fapi.2F0.6.2Fuser.2Fgpx_files">
@@ -147,7 +147,7 @@ public interface IAuthClient : INonAuthClient
147147
/// <param name="gpx"></param>
148148
/// <param name="fileStream"></param>
149149
/// <returns>The GPX Trace File's ID</returns>
150-
Task<int> CreateTrace(GpxFile gpx, Stream fileStream);
150+
Task<long> CreateTrace(GpxFile gpx, Stream fileStream);
151151
/// <summary>
152152
/// Updates a GPX Trace File (overwrites with a new one)
153153
/// <see href="https://wiki.openstreetmap.org/wiki/API_v0.6#Update:_PUT_.2Fapi.2F0.6.2Fgpx.2F.23id">

src/INonAuthClient.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ public interface INonAuthClient
2323
Task<Node[]> GetNodeHistory(long id);
2424
Task<Way[]> GetWayHistory(long id);
2525
Task<Relation[]> GetRelationHistory(long id);
26-
Task<Node> GetNodeVersion(long id, int version);
27-
Task<Way> GetWayVersion(long id, int version);
28-
Task<Relation> GetRelationVersion(long id, int version);
26+
Task<Node> GetNodeVersion(long id, long version);
27+
Task<Way> GetWayVersion(long id, long version);
28+
Task<Relation> GetRelationVersion(long id, long version);
2929
Task<Node[]> GetNodes(params long[] ids);
3030
Task<Way[]> GetWays(params long[] ids);
3131
Task<Relation[]> GetRelations(params long[] ids);
32-
Task<Node[]> GetNodes(IEnumerable<KeyValuePair<long, int?>> idVersions);
33-
Task<Way[]> GetWays(IEnumerable<KeyValuePair<long, int?>> idVersions);
34-
Task<Relation[]> GetRelations(IEnumerable<KeyValuePair<long, int?>> idVersions);
32+
Task<Node[]> GetNodes(IEnumerable<KeyValuePair<long, long?>> idVersions);
33+
Task<Way[]> GetWays(IEnumerable<KeyValuePair<long, long?>> idVersions);
34+
Task<Relation[]> GetRelations(IEnumerable<KeyValuePair<long, long?>> idVersions);
3535
Task<Relation[]> GetNodeRelations(long id);
3636
Task<Relation[]> GetWayRelations(long id);
3737
Task<Relation[]> GetRelationRelations(long id);
@@ -40,8 +40,8 @@ public interface INonAuthClient
4040
Task<Changeset[]> QueryChangesets(Bounds bounds, long? userId, string userName, DateTime? minClosedDate, DateTime? maxOpenedDate, bool openOnly, bool closedOnly, long[] ids);
4141
Task<OsmChange> GetChangesetDownload(long changesetId);
4242
Task<Stream> GetTrackPoints(Bounds bounds, int pageNumber = 0);
43-
Task<GpxFile> GetTraceDetails(int id);
44-
Task<TypedStream> GetTraceData(int id);
43+
Task<GpxFile> GetTraceDetails(long id);
44+
Task<TypedStream> GetTraceData(long id);
4545
Task<Note> GetNote(long id);
4646
Task<Note[]> GetNotes(Bounds bounds, int limit = 100, int maxClosedDays = 7);
4747
Task<Stream> GetNotesRssFeed(Bounds bounds);

src/NonAuthClient.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ public async Task<Relation[]> GetRelationHistory(long id)
238238
/// <see href="https://wiki.openstreetmap.org/wiki/API_v0.6#Version:_GET_.2Fapi.2F0.6.2F.5Bnode.7Cway.7Crelation.5D.2F.23id.2F.23version">
239239
/// GET /api/0.6/node/#id/#version</see>.
240240
/// </summary>
241-
public async Task<Node> GetNodeVersion(long id, int version)
241+
public async Task<Node> GetNodeVersion(long id, long version)
242242
{
243243
return await GetElementVersion<Node>(id, version);
244244
}
@@ -248,7 +248,7 @@ public async Task<Node> GetNodeVersion(long id, int version)
248248
/// <see href="https://wiki.openstreetmap.org/wiki/API_v0.6#Version:_GET_.2Fapi.2F0.6.2F.5Bnode.7Cway.7Crelation.5D.2F.23id.2F.23version">
249249
/// GET /api/0.6/way/#id/#version</see>.
250250
/// </summary>
251-
public async Task<Way> GetWayVersion(long id, int version)
251+
public async Task<Way> GetWayVersion(long id, long version)
252252
{
253253
return await GetElementVersion<Way>(id, version);
254254
}
@@ -258,7 +258,7 @@ public async Task<Way> GetWayVersion(long id, int version)
258258
/// <see href="https://wiki.openstreetmap.org/wiki/API_v0.6#Version:_GET_.2Fapi.2F0.6.2F.5Bnode.7Cway.7Crelation.5D.2F.23id.2F.23version">
259259
/// GET /api/0.6/relation/#id/#version</see>.
260260
/// </summary>
261-
public async Task<Relation> GetRelationVersion(long id, int version)
261+
public async Task<Relation> GetRelationVersion(long id, long version)
262262
{
263263
return await GetElementVersion<Relation>(id, version);
264264
}
@@ -268,7 +268,7 @@ public async Task<Relation> GetRelationVersion(long id, int version)
268268
/// <see href="https://wiki.openstreetmap.org/wiki/API_v0.6#Version:_GET_.2Fapi.2F0.6.2F.5Bnode.7Cway.7Crelation.5D.2F.23id.2F.23version">
269269
/// GET /api/0.6/[node|way|relation]/#id/#version</see>.
270270
/// </summary>
271-
private async Task<TOsmGeo> GetElementVersion<TOsmGeo>(long id, int version) where TOsmGeo : OsmGeo, new()
271+
private async Task<TOsmGeo> GetElementVersion<TOsmGeo>(long id, long version) where TOsmGeo : OsmGeo, new()
272272
{
273273
var type = new TOsmGeo().Type.ToString().ToLower();
274274
var address = BaseAddress + $"0.6/{type}/{id}/{version}";
@@ -308,7 +308,7 @@ public async Task<Relation[]> GetRelations(params long[] ids)
308308

309309
private async Task<TOsmGeo[]> GetElements<TOsmGeo>(params long[] ids) where TOsmGeo : OsmGeo, new()
310310
{
311-
var idVersions = ids.Select(id => new KeyValuePair<long, int?>(id, null));
311+
var idVersions = ids.Select(id => new KeyValuePair<long, long?>(id, null));
312312
return await GetElements<TOsmGeo>(idVersions);
313313
}
314314

@@ -317,7 +317,7 @@ public async Task<Relation[]> GetRelations(params long[] ids)
317317
/// <see href="https://wiki.openstreetmap.org/wiki/API_v0.6#Multi_fetch:_GET_.2Fapi.2F0.6.2F.5Bnodes.7Cways.7Crelations.5D.3F.23parameters">
318318
/// GET /api/0.6/nodes?#parameters</see>.
319319
/// </summary>
320-
public async Task<Node[]> GetNodes(IEnumerable<KeyValuePair<long, int?>> idVersions)
320+
public async Task<Node[]> GetNodes(IEnumerable<KeyValuePair<long, long?>> idVersions)
321321
{
322322
return await GetElements<Node>(idVersions);
323323
}
@@ -327,7 +327,7 @@ public async Task<Node[]> GetNodes(IEnumerable<KeyValuePair<long, int?>> idVersi
327327
/// <see href="https://wiki.openstreetmap.org/wiki/API_v0.6#Multi_fetch:_GET_.2Fapi.2F0.6.2F.5Bnodes.7Cways.7Crelations.5D.3F.23parameters">
328328
/// GET /api/0.6/ways?#parameters</see>.
329329
/// </summary>
330-
public async Task<Way[]> GetWays(IEnumerable<KeyValuePair<long, int?>> idVersions)
330+
public async Task<Way[]> GetWays(IEnumerable<KeyValuePair<long, long?>> idVersions)
331331
{
332332
return await GetElements<Way>(idVersions);
333333
}
@@ -337,7 +337,7 @@ public async Task<Way[]> GetWays(IEnumerable<KeyValuePair<long, int?>> idVersion
337337
/// <see href="https://wiki.openstreetmap.org/wiki/API_v0.6#Multi_fetch:_GET_.2Fapi.2F0.6.2F.5Bnodes.7Cways.7Crelations.5D.3F.23parameters">
338338
/// GET /api/0.6/relations?#parameters</see>.
339339
/// </summary>
340-
public async Task<Relation[]> GetRelations(IEnumerable<KeyValuePair<long, int?>> idVersions)
340+
public async Task<Relation[]> GetRelations(IEnumerable<KeyValuePair<long, long?>> idVersions)
341341
{
342342
return await GetElements<Relation>(idVersions);
343343
}
@@ -347,7 +347,7 @@ public async Task<Relation[]> GetRelations(IEnumerable<KeyValuePair<long, int?>>
347347
/// <see href="https://wiki.openstreetmap.org/wiki/API_v0.6#Multi_fetch:_GET_.2Fapi.2F0.6.2F.5Bnodes.7Cways.7Crelations.5D.3F.23parameters">
348348
/// GET /api/0.6/[nodes|ways|relations]?#parameters</see>.
349349
/// </summary>
350-
private async Task<TOsmGeo[]> GetElements<TOsmGeo>(IEnumerable<KeyValuePair<long, int?>> idVersions) where TOsmGeo : OsmGeo, new()
350+
private async Task<TOsmGeo[]> GetElements<TOsmGeo>(IEnumerable<KeyValuePair<long, long?>> idVersions) where TOsmGeo : OsmGeo, new()
351351
{
352352
var type = new TOsmGeo().Type.ToString().ToLower();
353353
// For exmple: "12,13,14v1,15v1"
@@ -494,7 +494,7 @@ public virtual async Task<Stream> GetTrackPoints(Bounds bounds, int pageNumber =
494494
/// <see href="https://wiki.openstreetmap.org/wiki/API_v0.6#Download_Metadata:_GET_.2Fapi.2F0.6.2Fgpx.2F.23id.2Fdetails">
495495
/// GET /api/0.6/gpx/#id/details</see>.
496496
/// </summary>
497-
public async Task<GpxFile> GetTraceDetails(int id)
497+
public async Task<GpxFile> GetTraceDetails(long id)
498498
{
499499
var address = BaseAddress + $"0.6/gpx/{id}/details";
500500
var osm = await Get<Osm>(address, c => AddAuthentication(c, address));
@@ -508,7 +508,7 @@ public async Task<GpxFile> GetTraceDetails(int id)
508508
/// This will return exactly what was uploaded, which might not be a gpx file (it could be a zip etc.)
509509
/// </summary>
510510
/// <returns>A stream of a GPX (version 1.0) file.</returns>
511-
public async Task<TypedStream> GetTraceData(int id)
511+
public async Task<TypedStream> GetTraceData(long id)
512512
{
513513
var address = BaseAddress + $"0.6/gpx/{id}/data";
514514
var content = await Get(address, c => AddAuthentication(c, address));

src/OsmApiClient.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<TargetFramework>netstandard2.0</TargetFramework>
55
<PackageId>OsmApiClient</PackageId>
6-
<Version>0.0.1-beta.6</Version>
6+
<Version>0.0.1-beta.7</Version>
77
<RepositoryUrl>https://github.com/OsmSharp/osm-api-client/</RepositoryUrl>
88
<PackageReleaseNotes>Working toward the first release.</PackageReleaseNotes>
99
<PackageProjectUrl>https://github.com/OsmSharp/osm-api-client/</PackageProjectUrl>
@@ -20,7 +20,7 @@
2020
<ItemGroup>
2121
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="2.0.2" />
2222
<PackageReference Include="OAuth.DotNetCore" Version="3.0.1" />
23-
<PackageReference Include="OsmSharp" Version="7.0.0-pre001" />
23+
<PackageReference Include="OsmSharp" Version="7.0.0-pre006" />
2424
</ItemGroup>
2525

2626
</Project>

0 commit comments

Comments
 (0)