Added TagTypes
This commit is contained in:
parent
58aac549c7
commit
9ce3bc4a9d
101
OSMImporter/Connection.cs
Normal file
101
OSMImporter/Connection.cs
Normal file
@ -0,0 +1,101 @@
|
||||
namespace OSMImporter
|
||||
{
|
||||
public class Connection
|
||||
{
|
||||
public ulong endNodeId { get; }
|
||||
|
||||
private readonly Dictionary<tagType, object> _tags = new Dictionary<tagType, object>();
|
||||
|
||||
public enum tagType
|
||||
{
|
||||
highway, oneway, footway, sidewalk, cycleway, busway, forward, maxspeed, unknown
|
||||
}
|
||||
|
||||
public Connection(ulong endNodeId)
|
||||
{
|
||||
this.endNodeId = endNodeId;
|
||||
}
|
||||
|
||||
public Connection(ulong endNodeId, Dictionary<string, string> tags)
|
||||
{
|
||||
this.endNodeId = endNodeId;
|
||||
ImportTags(tags);
|
||||
}
|
||||
|
||||
public void AddTag(string key, string value)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case "highway":
|
||||
if(Enum.TryParse(value, out highwayType hwType))
|
||||
this._tags.Add(key: tagType.highway, hwType);
|
||||
break;
|
||||
case "footway":
|
||||
if(Enum.TryParse(value, out footwayType fwType))
|
||||
this._tags.Add(tagType.footway, fwType);
|
||||
break;
|
||||
case "oneway":
|
||||
if (value.Equals("yes", StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
this._tags.Add(tagType.oneway, true);
|
||||
}
|
||||
else if (value.Equals("no", StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
this._tags.Add(tagType.oneway, false);
|
||||
}
|
||||
else if (value.Equals("reversible", StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
this._tags.Add(tagType.oneway, true);
|
||||
this._tags.Add(tagType.forward, false);
|
||||
}
|
||||
break;
|
||||
case "sidewalk":
|
||||
if(Enum.TryParse(value, out sidewalkSide swType))
|
||||
this._tags.Add(tagType.footway, swType);
|
||||
break;
|
||||
case "cycleway":
|
||||
if(Enum.TryParse(value, out cyclewayType cwType))
|
||||
this._tags.Add(tagType.footway, cwType);
|
||||
break;
|
||||
case "busway":
|
||||
if(Enum.TryParse(value, out buswayType bwType))
|
||||
this._tags.Add(tagType.footway, bwType);
|
||||
break;
|
||||
case "maxspeed":
|
||||
this._tags.Add(tagType.maxspeed, Convert.ToByte(value));
|
||||
break;
|
||||
default:
|
||||
this._tags.Add(tagType.unknown, value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void ImportTags(Dictionary<string, string> tags)
|
||||
{
|
||||
foreach (KeyValuePair<string, string> tag in tags)
|
||||
{
|
||||
this.AddTag(tag.Key, tag.Value);
|
||||
}
|
||||
}
|
||||
|
||||
public object? GetTag(string key)
|
||||
{
|
||||
if (Enum.TryParse(key, out tagType tag))
|
||||
{
|
||||
return this._tags.ContainsKey(tag) ? this._tags[tag] : null;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] ToByte() //TODO Current Size sizeof(ulong)
|
||||
{
|
||||
//TODO Tags
|
||||
byte[] ret = new byte[sizeof(ulong)];
|
||||
Buffer.BlockCopy(new []{ this.endNodeId }, 0, ret, 0, ret.Length );
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
67
OSMImporter/highwayType.cs
Normal file
67
OSMImporter/highwayType.cs
Normal file
@ -0,0 +1,67 @@
|
||||
namespace OSMImporter
|
||||
{
|
||||
public enum highwayType
|
||||
{
|
||||
motorway,
|
||||
trunk,
|
||||
primary,
|
||||
secondary,
|
||||
tertiary,
|
||||
unclassified,
|
||||
residential,
|
||||
motorway_link,
|
||||
trunk_link,
|
||||
primary_link,
|
||||
secondary_link,
|
||||
tertiary_link,
|
||||
living_street,
|
||||
service,
|
||||
pedestrian,
|
||||
track,
|
||||
bus_guideway,
|
||||
escape,
|
||||
raceway,
|
||||
road,
|
||||
busway,
|
||||
footway,
|
||||
bridleway,
|
||||
steps,
|
||||
corridor,
|
||||
path,
|
||||
via_ferratsa,
|
||||
cycleway,
|
||||
proposed,
|
||||
construction
|
||||
}
|
||||
|
||||
public enum footwayType
|
||||
{
|
||||
sidewalk,
|
||||
crossing
|
||||
}
|
||||
|
||||
public enum cyclewayType
|
||||
{
|
||||
lane,
|
||||
opposite,
|
||||
opposite_lane,
|
||||
track,
|
||||
opposite_track,
|
||||
share_busway,
|
||||
opposite_share_busway,
|
||||
shared_lane
|
||||
}
|
||||
|
||||
public enum sidewalkSide
|
||||
{
|
||||
both,
|
||||
left,
|
||||
right,
|
||||
no
|
||||
}
|
||||
|
||||
public enum buswayType
|
||||
{
|
||||
lane
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user