登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
本帖最后由 zfvv 于 2012-6-27 18:19 编辑
前段时间发帖求助如何自动标注等值线中心值,后来思考了一下,查阅了相关啊文献,采用如下思路,可以初步解决标注问题,在此抛砖引玉,希望更好的解决这个问题。
存在问题:没能标注“高”“低'字符;
中心没能考虑风压定律,只是接近中心
代码如下:
MeteoInfoC.PointD td = new MeteoInfoC.PointD(); string fieldName = LName.Split(new char[] { '_' })[0]; DataColumn aField = new DataColumn { ColumnName = fieldName, DataType = typeof(double) }; layer.EditAddField(aField); for (int i = 0; i < GridData.YNum; i++) { for (int j = 0; j < GridData.XNum; j++) { double T0 = GridData.Data[i, j]; List<int> Xar = new List<int>(); List<int> Yar = new List<int>(); List<double> Vary = new List<double>(); int fw = 6; for (int idx = i-fw; idx <= i+fw; idx++) { for (int idy = j-fw; idy <=j+fw; idy++) { GetZhi(idx, idy, GridData, GridData.YNum - 1, GridData.XNum - 1, ref Xar, ref Yar, ref Vary); } } //----------------------------------------------------- if (T0<Vary.Min()|T0>Vary.Max()) { td.X = GridData.X[j]; td.Y = GridData.Y; PointShape aShape = new PointShape { Point = td, Value = GridData.Data[i, j] }; int shapeNum = layer.ShapeNum; if (layer.EditInsertShape(aShape, shapeNum)) { layer.EditCellValue(fieldName, shapeNum, GridData.Data[i, j]); } } else if (T0==Vary.Min()) { int idx=Vary.IndexOf(Vary.Min()); double x1 = GridData.X[Xar[idx]]; double y1 = GridData.Y[Yar[idx]]; td.X = (GridData.X[j] + x1) / 2; td.Y = (GridData.Y + y1) / 2; PointShape aShape = new PointShape { Point = td, Value = GridData.Data[i, j] }; int shapeNum = layer.ShapeNum; if (layer.EditInsertShape(aShape, shapeNum)) { layer.EditCellValue(fieldName, shapeNum, GridData.Data[i, j]); } } if (T0 == Vary.Max()) { int idx = Vary.IndexOf(Vary.Max()); double x1 = GridData.X[Xar[idx]]; double y1 = GridData.Y[Yar[idx]]; td.X = (GridData.X[j] + x1) / 2; td.Y = (GridData.Y + y1) / 2; PointShape aShape = new PointShape { Point = td, Value = GridData.Data[i, j] }; int shapeNum = layer.ShapeNum; if (layer.EditInsertShape(aShape, shapeNum)) { layer.EditCellValue(fieldName, shapeNum, GridData.Data[i, j]); } } //----------------------------------------------------- } } private static void GetZhi(int i, int j, GridData GridData, int iMax, int Jmax, ref List<int> Xar, ref List<int> Yar, ref List<double> Vary) { if (i >= 0 && j >= 0&&i<=iMax&&j<=Jmax) { Xar.Add(j); Yar.Add(i); Vary.Add(GridData.Data[i, j]); } }
|