• Delphi版 创建ClassBreaks专题地图


    function ClassBreaksRenderer(pLayer: ILayer; sField: string; pColor: IColor; PColorFrom: IColor;
       pColorTo: IColor; eStyle: TOleEnum; iBreakCount: Integer): Boolean;
    var
       pGeoLayer: IGeoFeatureLayer;
       pTable   : ITable;
       pRenderer: IClassBreaksRenderer;
       pTableHistogram: ITableHistogram;
       pBasicHistogram: IBasicHistogram;
       values   : OleVariant;
       vFrequency: OleVariant;
       ClassResult: OleVariant;
       pClassifyGen: IClassifyGEN;

       pColorRamp: IAlgorithmicColorRamp;
       pEnumColors: IEnumColors;
       pFillSymbol: ISimpleFillSymbol;

       ok       : WordBool; //创建色带成功标志
       I        : Integer;
    begin
       pGeoLayer := pLayer as IGeoFeatureLayer;
       pTable := pLayer as ITable;

       //按照 数值字段分级
       pTableHistogram := CoBasicTableHistogram.Create as ITableHistogram;
       pTableHistogram.Field := sField;
       pTableHistogram.Table := pTable;

       pBasicHistogram := pTableHistogram as IBasicHistogram;

       //先统计每个值和各个值出现的次数
       pBasicHistogram.GetHistogram(values, vfrequency);

       //创建平均分级对象
       pClassifyGen := CoEqualInterval.Create as IClassifyGEN;

       //用统计结果进行分级 ,级别数目为 iBreakcount
       pClassifyGen.Classify(values, vFrequency, iBreakCount);

       //获得分级结果,是个 双精度类型数组

       ClassResult := pClassifyGen.ClassBreaks;

       pRenderer := CoClassBreaksRenderer.Create as IClassBreaksRenderer;
       pRenderer.Field := sField;
       pRenderer.BreakCount := VarArrayHighBound(ClassResult, 1); 

       //创建色带
       pColorRamp := CoAlgorithmicColorRamp.Create as IAlgorithmicColorRamp;
       pColorRamp.FromColor := PColorFrom;
       pColorRamp.ToColor := pColorTo;
       pColorRamp.Size := VarArrayHighBound(ClassResult, 1);
       pColorRamp.CreateRamp(ok);

       pEnumColors := pColorRamp.Colors;
       pEnumColors.Reset;

       pFillSymbol := CoSimpleFillSymbol.Create as ISimpleFillSymbol;
       for I := 0 to VarArrayHighBound(ClassResult, 1) - 1 do
       begin
          pFillSymbol.Color := pEnumColors.Next;
          pFillSymbol.Style := esriSFSSolid;
          pRenderer.Symbol[I] := pFillSymbol as ISymbol;
          pRenderer.Break[I] := ClassResult[i + 1];
       end;

       //格式化标签 根据需要设定
       for I := 0 to iBreakCount - 1 do
       begin
          if I > 0 then
             pRenderer.Label_[I] := FormatFloat('#.000', pRenderer.Break[I - 1]) + '--' +
                                    FormatFloat('#.000', pRenderer.Break[I])
          else
             pRenderer.Label_[I] :=  '<=  ' +  FormatFloat('#.000', pRenderer.Break[I]);
       end;

       pGeoLayer.Renderer := pRenderer as IFeatureRenderer;

       Result := true;
    end;
  • 相关阅读:
    automatic preferred max layout width
    UIActivityIndicatorView
    collectionview不能拖动
    消除找不到文件路径的警告
    保存图片到本地和相册
    svn上传.a文件
    UILabel copyWithZone:]: unrecognized selector sent to instance 0x7fd662d8f9b0
    NSString NSURL
    iOS 定位功能
    前端实现左右翻页功能Demo
  • 原文地址:https://www.cnblogs.com/chinacodegear/p/1404340.html
Copyright © 2020-2023  润新知