/// <summary> /// Read Surfer BLN map /// </summary> /// <param name="aFile">file path</param> /// <returns>vector layer</returns> public static VectorLayer ReadMapFile_BLN(string aFile) { StreamReader sr = new StreamReader(aFile); string aLine; string[] dataArray; int i, j, pNum; List <PointD> pList = new List <PointD>(); PointD aPoint; ArrayList dataList = new ArrayList(); bool IsTrue = false; string columnName = "Value"; VectorLayer aLayer = new VectorLayer(ShapeTypes.Polyline); //Read data aLayer.EditAddField(new DataColumn(columnName, typeof(int))); aLine = sr.ReadLine(); bool isComma = true; if (!aLine.Contains(",")) { isComma = false; } i = 0; while (aLine != null) { if (isComma) { pNum = int.Parse(aLine.Split(',')[0]); } else { pNum = int.Parse(MIMath.SplitBySpace(aLine)[0]); } pList = new List <PointD>(); for (j = 0; j < pNum; j++) { aLine = sr.ReadLine(); if (isComma) { dataArray = aLine.Split(','); } else { dataArray = MIMath.SplitBySpace(aLine); } aPoint = new PointD(); aPoint.X = Convert.ToDouble(dataArray[0]); aPoint.Y = Convert.ToDouble(dataArray[1]); pList.Add(aPoint); } PolylineShape aPLS = new PolylineShape(); aPLS.value = i; aPLS.Extent = MIMath.GetPointsExtent(pList); aPLS.Points = pList; i += 1; int sNum = aLayer.ShapeNum; if (aLayer.EditInsertShape(aPLS, sNum)) { aLayer.EditCellValue(columnName, sNum, i); } aLine = sr.ReadLine(); } aLayer.LayerName = Path.GetFileName(aFile); aLayer.FileName = aFile; aLayer.LayerDrawType = LayerDrawType.Map; aLayer.LegendScheme = LegendManage.CreateSingleSymbolLegendScheme(ShapeTypes.Polyline, Color.DarkGray, 1.0F); aLayer.Visible = true; IsTrue = true; sr.Close(); if (IsTrue) { return(aLayer); } else { return(null); } }