- 积分
- 42
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2018-8-7
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
在画数据等值线的时候,发现等值线的间距是不可控制的,通过看了论坛http://bbs.06climate.com/forum.p ... =9928&extra=&page=1,其中发现 里面的CreateColors及添加标注 LayerLabelSet函数都没找到。所以本人的解决办法如下: 1、 public static LegendScheme CreateGraduatedLegendScheme(double[] CValues, Color[] colors, ShapeTypes aST, double min, double max, bool hasNodata, double unDef);通过该函数可以发现第二个参数是一个Color[],虽然找不到CreateColors这个函数,我就人为的去构造一个Color[]数组,
for (int i = 0; i < cNum; i++)
{
if (isnum == false)
{
colors = new Color[cNum];
isnum = true;
}
colors = Color.FromArgb(255, 0, 0);
}
到此第一个问题解决了。
2、添加LayerLabelSet这个函数没有,我的方法通过LabelSet来修改。
aMeteoDataInfo.OpenLonLatData(path);//打开CSV数据
aMeteoDataInfo.DimensionSet = PlotDimension.Lat_Lon;//设置为经纬度信息
StationData aStationData = new StationData();//创建站点数据变量
_stationinfo.Add((LonLatStationDataInfo)aMeteoDataInfo.DataInfo);
aStationData = aMeteoDataInfo.GetStationData( “ps”);//需要读取哪里咧的值
GridDataSetting aGDP = _interpolationsetting.GridDataSet;
aGDP.DataExtent = aExtent;
aGDP.XNum =xmax;//间距
aGDP.YNum =ymax;
_interpolationsetting.GridDataSet = aGDP;
_interpolationsetting.InterpolationMethod = InterpolationMethods.IDW_Radius;
_interpolationsetting.Radius =radius;
_interpolationsetting.MinPointNum = 0;
ContourDraw.CreateGridXY(_interpolationsetting.GridDataSet, ref m_x, ref m_y);//设定X,Y坐标最大值及搜索半径
GridData aGridData = new GridData();
double[,] S = aStationData.Data;
double[] X = new double[0];
double[] Y = new double[0];
ContourDraw.CreateGridXY(_interpolationsetting.GridDataSet, ref X, ref Y); S=ContourDraw.FilterDiscreteData_Radius(S,_interpolationsetting.Radius,_interpolationsetting.GridDataSet.DataExtent,aStationData.UNDEF) aGridData=ContourDraw.InterpolateDiscreteData_Radius(S,X,Y,_interpolationsetting.MinPointNum,_interpolationsetting.Radius,aStationData.UNDEF);
VectorLayer m_layer = new VectorLayer(MeteoInfoC.Shape.ShapeTypes.Polyline);
double interval = 3;//等值线间隔
double[] cValues = LegendManage.CreateContourValuesInterval(aGridData.GetMinValue(), aGridData.GetMaxValue(), interval);
int cNum = Convert.ToInt32((aGridData.GetMaxValue() - aGridData.GetMinValue()) / interval);
Color[] colors = null;
Boolean isnum = false;
for (int i = 0; i < cNum; i++)
{
if (isnum == false)
{
colors = new Color[cNum];
isnum = true;
}
colors = Color.FromArgb(255, 0, 0);
}
LegendScheme aLS=LegendManage.CreateGraduatedLegendScheme(cValues,colors,MeteoInfoC.Shape.ShapeTypes.Polyline,aGridData.GetMinValue(), aGridData.GetMaxValue(), false, -9999);
m_layer=DrawMeteoData.CreateContourLayer(aGridData,aLS,“ps”,“ps”);
//添加标题
m_layer.LabelSet.DrawShadow=false;
m_layer.LabelSet.DynamicContourLabel = false;
m_layer.LabelSet.AutoDecimal = false;
m_layer.LabelSet.DecimalDigits = 0;
m_layer.LabelSet.LabelFont = new Font("宋体",10);
m_layer.AddLabels();
mapLayout1.PaintGraphics();
mapLayout1.Refresh();
红字代码是我修改的,有不对之处请多多指教。
|
|