internal GeoLine ToGeoLine() { if (this.Parts != null) { List<Point2DCollection> pss = new List<Point2DCollection>(); Point2DCollection copy = new Point2DCollection(); foreach (Point2D item in this.Points) { copy.Add(item); } for (int i = 0; i < this.Parts.Count; i++) { Point2DCollection temp = new Point2DCollection(); for (int j = 0; j < this.Parts[i]; j++) { temp.Add(copy[j]); } pss.Add(temp); copy.RemoveRange(0, this.Parts[i]); } GeoLine line = new GeoLine(); foreach (Point2DCollection item in pss) { line.Parts.Add(item); } return line; } return null; }
internal GeoRegion ToGeoRegion() { if (this.Parts != null) { List<Point2DCollection> pss = new List<Point2DCollection>(); Point2DCollection copy = new Point2DCollection(); foreach (Point2D item in this.Point2Ds) { copy.Add(item); } for (int i = 0; i < this.Parts.Count; i++) { Point2DCollection temp = new Point2DCollection(); for (int j = 0; j < this.Parts[i]; j++) { temp.Add(copy[j]); } temp.Add(copy[0]); //面的话把第一个点作为最后一个点 pss.Add(temp); copy.RemoveRange(0, this.Parts[i]);//把前面的删除 } //把Point2Ds根据Parts分成一段一段的 GeoRegion region = new GeoRegion(); foreach (Point2DCollection item in pss) { region.Parts.Add(item); } return region; } return null; }