// ----------------------------------------------------------------------- // // TODO: Update copyright text. // // ----------------------------------------------------------------------- namespace OsmReader.OsmData.Elements { using System; using System.Drawing; using System.Collections.Generic; using System.Linq; using System.Text; using System.Xml.Serialization; /// /// TODO: Update summary. /// public class OsmWay : AbstractTaggedOsmElement { [XmlAttribute(AttributeName = "id")] public long id { get; set; } [XmlAttribute(AttributeName = "user")] public string user { get; set; } [XmlAttribute(AttributeName = "uid")] public int uid { get; set; } [XmlAttribute(AttributeName = "visible")] public bool visible { get; set; } [XmlAttribute(AttributeName = "version")] public int version { get; set; } [XmlAttribute(AttributeName = "changeset")] public long changeset { get; set; } [XmlAttribute(AttributeName = "timestamp")] public string timestamp { get; set; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1002:DoNotExposeGenericLists")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] [XmlElement(ElementName = "nd")] public List nd { get; set; } [XmlIgnore] public string WayType { get { return getTagValue("highway"); } } [XmlIgnore] public string Ref { get { return getTagValue("ref"); } } private int maxSpeed = 0; [XmlIgnore] public int Maxspeed { get { if (this.maxSpeed == 0) { this.maxSpeed = getIntTagValue("maxspeed"); if (this.maxSpeed == 0) { this.maxSpeed = getMaxSpeedByRoadType(); } // Last resort. if (this.maxSpeed == 0) { this.maxSpeed = 49; } } return this.maxSpeed; } } private Color drawColor=Color.Transparent; public Color DrawColor { get { if (this.drawColor == Color.Transparent) { this.drawColor = getColorByRoadType(); } return this.drawColor; } } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase")] private Color getColorByRoadType() { Color drawColor1 = Color.Transparent; string roadType = getTagValue("highway"); if (!string.IsNullOrEmpty(roadType)) { switch (roadType.ToLowerInvariant()) { case "living_street": case "trunk": case "trunk_link": drawColor1 = Color.Blue; break; case "tertiary": case "tertiary_link": case "residential": drawColor1 = Color.Yellow; break; case "secondary": case "secondary_link": drawColor1 = Color.Orange; break; case "primary": case "primary_link": case "mini_roundabout": case "motorway": case "motorway_junction": case "motorway_link": drawColor1 = Color.Red; break; case "road": case "unclassified": drawColor1 = Color.Black; break; default: drawColor1 = Color.Black; break; } } return drawColor1; } private int getMaxSpeedByRoadType() { int maxSpeed1 = 0; string roadType = getTagValue("highway"); if (!string.IsNullOrEmpty(roadType)) { switch (roadType.ToUpperInvariant()) { case "MOTORWAY": maxSpeed1 = 110; break; case "MOTORWAY_LINK": maxSpeed1 = 90; break; case "TERTIARY": maxSpeed1 = 70; break; case "UNCLASSIFIED": maxSpeed1 = 50; break; default: maxSpeed1 = 69; break; } } return maxSpeed1; } [XmlIgnore] public bool Oneway { get { return getBoolTagValue("oneway"); } } } }