tags adding TryAdd instead of Add
This commit is contained in:
parent
f868f5ba2d
commit
2c18162398
@ -32,40 +32,47 @@ namespace OSMDatastructure
|
|||||||
{
|
{
|
||||||
case "highway":
|
case "highway":
|
||||||
if(Enum.TryParse(value, out highwayType hwType))
|
if(Enum.TryParse(value, out highwayType hwType))
|
||||||
this._tags.Add(key: tagType.highway, hwType);
|
this._tags.TryAdd(key: tagType.highway, hwType);
|
||||||
break;
|
break;
|
||||||
case "footway":
|
case "footway":
|
||||||
if(Enum.TryParse(value, out footwayType fwType))
|
if(Enum.TryParse(value, out footwayType fwType))
|
||||||
this._tags.Add(tagType.footway, fwType);
|
this._tags.TryAdd(tagType.footway, fwType);
|
||||||
break;
|
break;
|
||||||
case "oneway":
|
case "oneway":
|
||||||
if (value.Equals("yes", StringComparison.CurrentCultureIgnoreCase))
|
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))
|
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))
|
else if (value.Equals("reversible", StringComparison.CurrentCultureIgnoreCase))
|
||||||
{
|
{
|
||||||
this._tags.Add(tagType.oneway, (byte)1);
|
this._tags.TryAdd(tagType.oneway, (byte)1);
|
||||||
this._tags.Add(tagType.forward, (byte)0);
|
this._tags.TryAdd(tagType.forward, (byte)0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "sidewalk":
|
case "sidewalk":
|
||||||
if(Enum.TryParse(value, out sidewalkSide swType))
|
if(Enum.TryParse(value, out sidewalkSide swType))
|
||||||
this._tags.Add(tagType.footway, swType);
|
this._tags.TryAdd(tagType.footway, swType);
|
||||||
break;
|
break;
|
||||||
case "cycleway":
|
case "cycleway":
|
||||||
if(Enum.TryParse(value, out cyclewayType cwType))
|
if(Enum.TryParse(value, out cyclewayType cwType))
|
||||||
this._tags.Add(tagType.footway, cwType);
|
this._tags.TryAdd(tagType.footway, cwType);
|
||||||
break;
|
break;
|
||||||
case "busway":
|
case "busway":
|
||||||
//TODO
|
//TODO
|
||||||
break;
|
break;
|
||||||
case "maxspeed":
|
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;
|
break;
|
||||||
case "name":
|
case "name":
|
||||||
//TODO
|
//TODO
|
||||||
@ -93,25 +100,40 @@ namespace OSMDatastructure
|
|||||||
switch ((tagType)tag)
|
switch ((tagType)tag)
|
||||||
{
|
{
|
||||||
case tagType.highway:
|
case tagType.highway:
|
||||||
this._tags.Add(tagType.highway, (highwayType)value);
|
this._tags.TryAdd(tagType.highway, (highwayType)value);
|
||||||
break;
|
break;
|
||||||
case tagType.footway:
|
case tagType.footway:
|
||||||
this._tags.Add(tagType.footway, (footwayType)value);
|
this._tags.TryAdd(tagType.footway, (footwayType)value);
|
||||||
break;
|
break;
|
||||||
case tagType.oneway:
|
case tagType.oneway:
|
||||||
this._tags.Add(tagType.oneway, value);
|
this._tags.TryAdd(tagType.oneway, value);
|
||||||
break;
|
break;
|
||||||
case tagType.sidewalk:
|
case tagType.sidewalk:
|
||||||
this._tags.Add(tagType.sidewalk, (sidewalkSide)value);
|
this._tags.TryAdd(tagType.sidewalk, (sidewalkSide)value);
|
||||||
break;
|
break;
|
||||||
case tagType.cycleway:
|
case tagType.cycleway:
|
||||||
this._tags.Add(tagType.cycleway, (cyclewayType)value);
|
this._tags.TryAdd(tagType.cycleway, (cyclewayType)value);
|
||||||
break;
|
break;
|
||||||
case tagType.busway:
|
case tagType.busway:
|
||||||
//TODO
|
//TODO
|
||||||
break;
|
break;
|
||||||
case tagType.maxspeed:
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user