using System; using System.Collections.Generic; using System.Linq; using AxMapWinGIS; using MapWinGIS; namespace LP; public class MapData { public List mListX = null; public List mListY = null; public double mMinX = 0.0; public double mMaxX = 0.0; public double mMinY = 0.0; public double mMaxY = 0.0; public double mBS = 1.0; public MapData() { Init_ListX_ListY(); Clear_ListX_ListY(); } private void Init_ListX_ListY() { if (mListX == null) { mListX = new List(); } if (mListY == null) { mListY = new List(); } } private void Clear_ListX_ListY() { Init_ListX_ListY(); mListX.Clear(); mListY.Clear(); } public void SetXY_OneLine(List _listX, List _listY) { Clear_ListX_ListY(); int count = _listX.Count; int count2 = _listY.Count; int num = ((count < count2) ? count : count2); for (int i = 0; i < num; i++) { mListX.Add(_listX[i]); mListY.Add(_listY[i]); } } public void SetXY_OneLine(double[] _arrX, double[] _arrY) { Clear_ListX_ListY(); int num = _arrX.Length; int num2 = _arrY.Length; int num3 = ((num < num2) ? num : num2); for (int i = 0; i < num3; i++) { mListX.Add(_arrX[i]); mListY.Add(_arrY[i]); } } private void SenJi() { mBS = 1.0; if (mListX.Count == 0) { mMaxX = (mMinX = (mMaxY = (mMinY = 0.0))); return; } if (mListX.Count == 1) { mMaxX = (mMinX = mListX[0]); mMaxY = (mMinY = mListY[0]); return; } mMaxX = mListX.Max(); mMinX = mListX.Min(); mMaxY = mListY.Max(); mMinY = mListY.Min(); double num = Math.Abs(mMaxX - mMinX); double num2 = Math.Abs(mMaxY - mMinY); double num3 = num; if (num3 < num2) { num3 = num2; } if (!(num3 < 1E-20)) { mBS = 1000.0 / num3; } } public Shapefile CreateShapefile() { SenJi(); Shapefile shapefile = new ShapefileClass(); shapefile.CreateNew("", ShpfileType.SHP_POLYLINE); Shape shape = new ShapeClass(); shape.Create(ShpfileType.SHP_POLYLINE); Point point = null; int num = 0; for (int i = 0; i < mListX.Count; i++) { point = new PointClass(); point.x = (mListX[i] - mMinX) * mBS; point.y = (mListY[i] - mMinY) * mBS; num = shape.numPoints; shape.InsertPoint(point, ref num); } num = shapefile.NumShapes; shapefile.EditInsertShape(shape, ref num); return shapefile; } public Shapefile CreatePoints_forLine() { SenJi(); Shapefile shapefile = new ShapefileClass(); shapefile.CreateNew("", ShpfileType.SHP_POINTM); Shape shape = new ShapeClass(); shape.Create(ShpfileType.SHP_POINTM); Point point = null; int num = 0; for (int i = 0; i < mListX.Count; i++) { point = new PointClass(); point.x = (mListX[i] - mMinX) * mBS; point.y = (mListY[i] - mMinY) * mBS; num = shape.numPoints; shape.InsertPoint(point, ref num); } num = shapefile.NumShapes; shapefile.EditInsertShape(shape, ref num); return shapefile; } private void AddRing(bool clockWise, double x, double y, double radius, ref Shape shp) { int PartIndex = shp.NumParts; if (shp.numPoints > 0) { shp.InsertPart(shp.numPoints, ref PartIndex); } int num = 0; double num2 = 0.0; double num3 = 0.0; for (int i = 0; i < 37; i++) { num2 = radius * Math.Cos((double)i * Math.PI / 18.0); num3 = radius * Math.Sin((double)i * Math.PI / 18.0); num3 *= (double)((!clockWise) ? 1 : (-1)); Point point = new PointClass(); point.x = x + num2; point.y = y + num3; num = shp.numPoints; shp.InsertPoint(point, ref num); } } public Shapefile CreatePoints_forLine_Ring(int _currentZoom) { SenJi(); Shapefile shapefile = new ShapefileClass(); shapefile.CreateNewWithShapeID("", ShpfileType.SHP_POLYGON); double num = 0.0; double num2 = 0.0; double num3 = 6.0; switch (_currentZoom) { case 20: num3 = 2.0; break; case 19: num3 = 4.0; break; case 18: num3 = 5.0; break; case 17: num3 = 6.0; break; case 16: num3 = 8.0; break; case 15: num3 = 9.0; break; case 14: num3 = 10.0; break; case 13: num3 = 12.0; break; case 12: num3 = 14.0; break; case 11: num3 = 16.0; break; case 10: num3 = 18.0; break; case 9: num3 = 20.0; break; case 8: num3 = 25.0; break; case 7: num3 = 30.0; break; case 6: num3 = 40.0; break; case 5: num3 = 50.0; break; case 4: num3 = 60.0; break; case 3: num3 = 70.0; break; case 2: num3 = 80.0; break; case 1: num3 = 90.0; break; } num3 = (int)(num3 * 1.3); int num4 = 0; for (int i = 0; i < mListX.Count; i++) { Shape shp = new ShapeClass(); shp.Create(ShpfileType.SHP_POLYGON); num = (mListX[i] - mMinX) * mBS; num2 = (mListY[i] - mMinY) * mBS; AddRing(clockWise: true, num, num2, num3, ref shp); num4 = shapefile.NumShapes; shapefile.EditInsertShape(shp, ref num4); } return shapefile; } public void DrawLine(ref AxMap axMap) { int num = 0; Shapefile shapefile = CreateShapefile(); num = axMap.AddLayer(shapefile, visible: true); Utils utils = new UtilsClass(); axMap.ZoomToLayer(num); LinePattern linePattern = null; linePattern = new LinePatternClass(); linePattern.AddLine(utils.ColorByName(tkMapColor.Gray), 6f, tkDashStyle.dsSolid); linePattern.AddLine(utils.ColorByName(tkMapColor.LightGray), 4f, tkDashStyle.dsSolid); ShapefileCategory shapefileCategory = shapefile.Categories.Add("River"); shapefileCategory.DrawingOptions.LinePattern = linePattern; shapefileCategory.DrawingOptions.UseLinePattern = true; ((IShapefile)shapefile).set_ShapeCategory(0, 0); shapefile = CreatePoints_forLine_Ring(axMap.CurrentZoom); num = axMap.AddLayer(shapefile, visible: true); axMap.ZoomToLayer(num); } }