Esempio n. 1
0
 public BuildingPart(string id, Polygon footprint, PartData body, RoofData roof, Color color)
     : base(id, color)
 {
     Footprint = footprint;
     Body      = body;
     Roof      = roof;
 }
Esempio n. 2
0
        /// <summary>
        /// Parse building data
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        protected PartData ParsePart(XElement node)
        {
            // Part data in node
            PartData part = default(PartData);

            part.volume        = true;
            part.shape         = BuildingShape.None;
            part.surface       = default(Surface);
            part.surface.color = DefaultBuildingColor;
            Parse(node, ref part);
            return(part);
        }
Esempio n. 3
0
        /// <summary>
        /// Parse Part data ref
        /// </summary>
        /// <param name="node"></param>
        /// <param name="part"></param>
        protected void Parse(XElement node, ref PartData part)
        {
            foreach (var tag in node.Descendants("tag"))
            {
                switch (filter(tag.Attribute("k").Value))
                {
                case "name":
                    part.name = tag.Attribute("v").Value;
                    break;

                case "height":
                case "building:height":
                    MatchFloat(tag.Attribute("v").Value, out part.height);
                    break;

                case "min_height":
                case "building:min_height":
                    MatchFloat(tag.Attribute("v").Value, out part.min_height);
                    break;

                case "levels":
                case "building:levels":
                case "building:levels:aboveground":
                    MatchShort(tag.Attribute("v").Value, out part.levels);
                    break;

                case "min_levels":
                case "building:min_levels":
                    MatchShort(tag.Attribute("v").Value, out part.min_level);
                    break;

                case "building:colour":
                case "building:facade:colour":
                    part.surface.color = MatchColor(tag.Attribute("v").Value);
                    break;

                case "building:material":
                    part.surface.material = tag.Attribute("v").Value;
                    break;

                case "building:shape":
                    Enum.TryParse(tag.Attribute("v").Value, true, out part.shape);
                    break;
                }
            }

            // Height estimation rule
            if (part.volume && part.height == 0)
            {
                var levels = part.min_level + part.levels;
                if (levels > 0)
                {
                    part.height = levels * DefaultFloorHeight;
                }
                else
                {
                    var rnd = new Random();
                    part.height = rnd.Next((int)(DefaultBuildingHeight - DefaultFloorHeight), (int)(DefaultBuildingHeight + DefaultFloorHeight));
                }
            }
        }