tags adding TryAdd instead of Add

This commit is contained in:
C9Glax 2023-02-05 20:45:53 +01:00
parent f868f5ba2d
commit 2c18162398

View File

@ -32,40 +32,47 @@ namespace OSMDatastructure
{
case "highway":
if(Enum.TryParse(value, out highwayType hwType))
this._tags.Add(key: tagType.highway, hwType);
this._tags.TryAdd(key: tagType.highway, hwType);
break;
case "footway":
if(Enum.TryParse(value, out footwayType fwType))
this._tags.Add(tagType.footway, fwType);
this._tags.TryAdd(tagType.footway, fwType);
break;
case "oneway":
if (value.Equals("yes", StringComparison.CurrentCultureIgnoreCase))
{
this._tags.Add(tagType.oneway, (byte)1);
this._tags.TryAdd(tagType.oneway, (byte)1);
}
else if (value.Equals("no", StringComparison.CurrentCultureIgnoreCase))
{
this._tags.Add(tagType.oneway, (byte)0);
this._tags.TryAdd(tagType.oneway, (byte)0);
}
else if (value.Equals("reversible", StringComparison.CurrentCultureIgnoreCase))
{
this._tags.Add(tagType.oneway, (byte)1);
this._tags.Add(tagType.forward, (byte)0);
this._tags.TryAdd(tagType.oneway, (byte)1);
this._tags.TryAdd(tagType.forward, (byte)0);
}
break;
case "sidewalk":
if(Enum.TryParse(value, out sidewalkSide swType))
this._tags.Add(tagType.footway, swType);
this._tags.TryAdd(tagType.footway, swType);
break;
case "cycleway":
if(Enum.TryParse(value, out cyclewayType cwType))
this._tags.Add(tagType.footway, cwType);
this._tags.TryAdd(tagType.footway, cwType);
break;
case "busway":
//TODO
break;
case "maxspeed":
this._tags.Add(tagType.maxspeed, Convert.ToByte(value));
try
{
this._tags.TryAdd(tagType.maxspeed, Convert.ToByte(value));
}
catch (FormatException e)
{
Console.WriteLine("maxspeed '{0}' is not a number", value);
}
break;
case "name":
//TODO
@ -93,25 +100,40 @@ namespace OSMDatastructure
switch ((tagType)tag)
{
case tagType.highway:
this._tags.Add(tagType.highway, (highwayType)value);
this._tags.TryAdd(tagType.highway, (highwayType)value);
break;
case tagType.footway:
this._tags.Add(tagType.footway, (footwayType)value);
this._tags.TryAdd(tagType.footway, (footwayType)value);
break;
case tagType.oneway:
this._tags.Add(tagType.oneway, value);
this._tags.TryAdd(tagType.oneway, value);
break;
case tagType.sidewalk:
this._tags.Add(tagType.sidewalk, (sidewalkSide)value);
this._tags.TryAdd(tagType.sidewalk, (sidewalkSide)value);
break;
case tagType.cycleway:
this._tags.Add(tagType.cycleway, (cyclewayType)value);
this._tags.TryAdd(tagType.cycleway, (cyclewayType)value);
break;
case tagType.busway:
//TODO
break;
case tagType.maxspeed:
this._tags.Add(tagType.maxspeed, value);
this._tags.TryAdd(tagType.maxspeed, value);
break;
case tagType.name:
//TODO
break;
case tagType.surface:
//TODO
break;
case tagType.lanes:
//TODO
break;
case tagType.access:
//TODO
break;
case tagType.tracktype:
//TODO
break;
}
}