Skip to content

Commit

Permalink
Models renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
chubrik committed May 5, 2019
1 parent 1b8ec7f commit f122a46
Show file tree
Hide file tree
Showing 28 changed files with 105 additions and 105 deletions.
2 changes: 1 addition & 1 deletion OsmDataKit.Tests/OsmDataKit.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp2.2</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

Expand Down
7 changes: 3 additions & 4 deletions OsmDataKit.Tests/Tests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OsmDataKit.Services;
using OsmSharp;

namespace OsmDataKit.Tests
Expand Down Expand Up @@ -29,11 +28,11 @@ public void LoadRelationObject()

// https://www.openstreetmap.org/relation/2969204
var title = "Vega Island";
var osmId = 2969204;
var relationId = 2969204;

var relation = OsmObjectService.LoadRelationObject(SrcPath, cacheName: title, relationId: osmId);
var relation = OsmObjectService.LoadRelationObject(SrcPath, cacheName: title, relationId: relationId);
Assert.IsTrue(relation.Type == OsmGeoType.Relation);
Assert.IsTrue(relation.Id == osmId);
Assert.IsTrue(relation.Id == relationId);
Assert.IsTrue(relation.Title == title);
Assert.IsTrue(relation.Tags["type"] == "multipolygon");
Assert.IsTrue(relation.Tags["place"] == "island");
Expand Down
5 changes: 2 additions & 3 deletions OsmDataKit/Extensions/GeoCoordsCollectionExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using OsmDataKit.Models;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;

namespace OsmDataKit.Extensions
namespace OsmDataKit
{
public static class GeoCoordsCollectionExtensions
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using OsmDataKit.Models;
using OsmSharp;
using OsmSharp;
using System;
using System.Diagnostics;
using System.Linq;

namespace OsmDataKit.Extensions
namespace OsmDataKit.Internal
{
internal static class NodeExtensions
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using OsmDataKit.Models;
using System.Linq;
using System.Linq;

namespace OsmDataKit.Extensions
namespace OsmDataKit.Internal
{
internal static class OsmResponseExtensions
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using OsmDataKit.Models;
using OsmSharp;
using OsmSharp;
using System;
using System.Diagnostics;
using System.Linq;

namespace OsmDataKit.Extensions
namespace OsmDataKit.Internal
{
internal static class RelationExtensions
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using OsmDataKit.Models;
using OsmSharp;
using OsmSharp;

namespace OsmDataKit.Extensions
namespace OsmDataKit.Internal
{
internal static class RelationMemberExtensions
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using OsmDataKit.Models;
using OsmSharp;
using OsmSharp;
using System;
using System.Diagnostics;
using System.Linq;

namespace OsmDataKit.Extensions
namespace OsmDataKit.Internal
{
internal static class WayExtensions
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Newtonsoft.Json;

namespace OsmDataKit.Models
namespace OsmDataKit.Internal
{
[JsonObject]
internal class NodeData : OsmGeoData
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Newtonsoft.Json;
using System.Collections.Generic;

namespace OsmDataKit.Models
namespace OsmDataKit.Internal
{
[JsonObject]
internal abstract class OsmGeoData
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Newtonsoft.Json;
using System.Collections.Generic;

namespace OsmDataKit.Models
namespace OsmDataKit.Internal
{
[JsonObject]
internal class OsmResponseData
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Newtonsoft.Json;
using System.Collections.Generic;

namespace OsmDataKit.Models
namespace OsmDataKit.Internal
{
[JsonObject]
internal class RelationData : OsmGeoData
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Newtonsoft.Json;
using OsmSharp;

namespace OsmDataKit.Models
namespace OsmDataKit.Internal
{
[JsonObject]
internal class RelationMemberData
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Newtonsoft.Json;
using System.Collections.Generic;

namespace OsmDataKit.Models
namespace OsmDataKit.Internal
{
[JsonObject]
internal class WayData : OsmGeoData
Expand Down
2 changes: 1 addition & 1 deletion OsmDataKit/Models/GeoCoords.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace OsmDataKit.Models
namespace OsmDataKit
{
public class GeoCoords : IGeoCoords
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
using Kit;
using OsmDataKit.Internal;
using OsmSharp;
using System;
using System.Collections.Generic;
using System.Diagnostics;

namespace OsmDataKit.Models
namespace OsmDataKit
{
#if DEBUG
[DebuggerDisplay("{" + nameof(DebugInfo) + ",nq}")]
#endif
public abstract class OsmObject
public abstract class GeoObject
{
public long Id { get; }
public IReadOnlyDictionary<string, string> Tags { get; }
Expand Down Expand Up @@ -55,7 +56,7 @@ public string Title
#endregion

// protected
internal OsmObject(OsmGeoData data)
internal GeoObject(OsmGeoData data)
{
Debug.Assert(data != null);

Expand All @@ -66,7 +67,7 @@ internal OsmObject(OsmGeoData data)
Tags = data.Tags;
}

protected OsmObject(
protected GeoObject(
long id,
IReadOnlyDictionary<string, string> tags,
IReadOnlyDictionary<string, string> data)
Expand Down
2 changes: 1 addition & 1 deletion OsmDataKit/Models/IGeoCoords.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace OsmDataKit.Models
namespace OsmDataKit
{
public interface IGeoCoords
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using OsmSharp;
using OsmDataKit.Internal;
using OsmSharp;
using System;
using System.Collections.Generic;
using System.Diagnostics;

namespace OsmDataKit.Models
namespace OsmDataKit
{
public class OsmNode : OsmObject, IGeoCoords
public class NodeObject : GeoObject, IGeoCoords
{
public double Latitude { get; }
public double Longitude { get; }
Expand All @@ -14,7 +15,7 @@ public class OsmNode : OsmObject, IGeoCoords
public override bool IsBroken => false;
public override IGeoCoords AverageCoords => this;

internal OsmNode(NodeData data) : base(data)
internal NodeObject(NodeData data) : base(data)
{
Debug.Assert(data?.Coords?.Length == 2);

Expand All @@ -25,7 +26,7 @@ internal OsmNode(NodeData data) : base(data)
Longitude = data.Coords[1];
}

public OsmNode(
public NodeObject(
long id, IReadOnlyDictionary<string, string> tags,
IGeoCoords coords,
IReadOnlyDictionary<string, string> data = null)
Expand Down
16 changes: 0 additions & 16 deletions OsmDataKit/Models/Objects/OsmObjectResponse.cs

This file was deleted.

16 changes: 16 additions & 0 deletions OsmDataKit/Models/OsmObjectResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System.Collections.Generic;

namespace OsmDataKit
{
public class OsmObjectResponse
{
public IReadOnlyList<NodeObject> Nodes { get; set; }
public IReadOnlyList<WayObject> Ways { get; set; }
public IReadOnlyList<RelationObject> Relations { get; set; }
public IReadOnlyList<WayObject> BrokenWays { get; set; }
public IReadOnlyList<RelationObject> BrokenRelations { get; set; }
public IReadOnlyDictionary<long, NodeObject> AllNodesDict { get; set; }
public IReadOnlyDictionary<long, WayObject> AllWaysDict { get; set; }
public IReadOnlyDictionary<long, RelationObject> AllRelationsDict { get; set; }
}
}
2 changes: 1 addition & 1 deletion OsmDataKit/Models/OsmRequest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.Generic;

namespace OsmDataKit.Models
namespace OsmDataKit
{
public class OsmRequest
{
Expand Down
5 changes: 3 additions & 2 deletions OsmDataKit/Models/OsmResponse.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using OsmSharp;
using OsmDataKit.Internal;
using OsmSharp;
using OsmSharp.Tags;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace OsmDataKit.Models
namespace OsmDataKit
{
public class OsmResponse
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
using Kit;
using OsmDataKit.Internal;
using System;
using System.Diagnostics;

namespace OsmDataKit.Models
namespace OsmDataKit
{
#if DEBUG
[DebuggerDisplay("{" + nameof(DebugInfo) + ",nq}")]
#endif
public class OsmMember
public class RelationMemberObject
{
public string Role { get; }
public OsmObject Geo { get; }
public GeoObject Geo { get; }

internal OsmMember(RelationMemberData data, OsmObject geo)
internal RelationMemberObject(RelationMemberData data, GeoObject geo)
{
Debug.Assert(data != null);

Expand All @@ -28,7 +29,7 @@ internal OsmMember(RelationMemberData data, OsmObject geo)
Geo = geo;
}

public OsmMember(string role, OsmObject geo)
public RelationMemberObject(string role, GeoObject geo)
{
Debug.Assert(!role.IsNullOrEmpty());
Debug.Assert(geo != null);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
using OsmDataKit.Extensions;
using OsmDataKit.Internal;
using OsmSharp;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace OsmDataKit.Models
namespace OsmDataKit
{
public class OsmRelation : OsmObject
public class RelationObject : GeoObject
{
public IReadOnlyList<OsmMember> Members { get; internal set; }
public IReadOnlyList<RelationMemberObject> Members { get; internal set; }

#region Extensions

public IEnumerable<OsmNode> Nodes =>
public IEnumerable<NodeObject> Nodes =>
Members.Where(i => i.Geo.Type == OsmGeoType.Node)
.Select(i => (OsmNode)i.Geo);
.Select(i => (NodeObject)i.Geo);

public IEnumerable<OsmWay> Ways =>
public IEnumerable<WayObject> Ways =>
Members.Where(i => i.Geo.Type == OsmGeoType.Way)
.Select(i => (OsmWay)i.Geo);
.Select(i => (WayObject)i.Geo);

public IEnumerable<OsmRelation> Relations =>
public IEnumerable<RelationObject> Relations =>
Members.Where(i => i.Geo.Type == OsmGeoType.Relation)
.Select(i => (OsmRelation)i.Geo);
.Select(i => (RelationObject)i.Geo);

public IEnumerable<OsmNode> AllNodes =>
public IEnumerable<NodeObject> AllNodes =>
Nodes.Concat(Ways.SelectMany(i => i.Nodes))
.Concat(Relations.SelectMany(i => i.AllNodes));

Expand All @@ -47,20 +47,20 @@ public class OsmRelation : OsmObject

#endregion

public void SetMembers(IReadOnlyList<OsmMember> members)
public void SetMembers(IReadOnlyList<RelationMemberObject> members)
{
Debug.Assert(members != null);
Members = members ?? throw new ArgumentNullException(nameof(members));
_isBroken = null;
_averageCoords = null;
}

internal OsmRelation(RelationData data) : base(data) { }
internal RelationObject(RelationData data) : base(data) { }

public OsmRelation(
public RelationObject(
long id,
IReadOnlyDictionary<string, string> tags,
IReadOnlyList<OsmMember> members,
IReadOnlyList<RelationMemberObject> members,
IReadOnlyDictionary<string, string> data = null)
: base(id, tags, data)
{
Expand Down
Loading

0 comments on commit f122a46

Please sign in to comment.