/// <summary> /// Gets blocks from a KML file. /// </summary> /// <returns>The blocks.</returns> /// <param name="kml">Path to the KML file.</param> /// <param name="treeTypes">Existing Tree types.</param> public static List <Block> GetBlocks(string kml, List <TreeType> treeTypes) { var allTreeTypes = new List <TreeType>(); allTreeTypes.AddRange(treeTypes); var xml = XDocument.Parse(kml); var ns = xml.Root.Name.Namespace; var blocks = xml.Descendants(ns + "Placemark"); var resultList = new List <Block>(); foreach (var item in blocks) { var resultBlock = new Block(); resultBlock.BoundingCoordinates = new List <Position>(); var treetypeName = item.Descendants(ns + "SimpleData").FirstOrDefault(); var treetypeNameString = treetypeName != null ? treetypeName.Value : "NOTDEFINED"; if (allTreeTypes.All(treeType => treeType.Name != treetypeNameString)) { var gayTreeType = new TreeType(treetypeNameString, NewTreeTypeColor(allTreeTypes)); resultBlock.TreeType = gayTreeType; allTreeTypes.Add(gayTreeType); } else { resultBlock.TreeType = allTreeTypes[allTreeTypes.IndexOf(new TreeType(treetypeNameString))]; } var cords = item.Descendants(ns + "coordinates"); resultBlock.BoundingCoordinates = GetCoordinates(cords); resultList.Add(resultBlock); } return(resultList); }
/// <summary> /// Initializes a new instance of the <see cref="TreeWatch.Block"/> class. /// </summary> /// <param name="boundingCoordinates">Bounding coordinates of the block.</param> /// <param name="treeType">TreeType of the block.</param> public Block(List <Position> boundingCoordinates, TreeType treeType) { this.BoundingCoordinates = boundingCoordinates; this.TreeType = treeType; }
public Row(Position StartingPoint, Position EndPoint, TreeType TreeType) { this.StartingPoint = StartingPoint; this.EndPoint = EndPoint; this.TreeType = TreeType; }