zoukankan      html  css  js  c++  java
  • Delphi ArcEngine 创建独立值专题

    type UniqueValueType = (uvtFillSymbol, uvtMarkerSymbol);

    function UniqueValueRenderer(pLayer: ILayer; sField: string; estyle: UniqueValueType; iDotSize: Integer = 25): Boolean;

    var
      pGeoLayer: IGeoFeatureLayer;
      pTable: ITable;
      iFieldIndex: Integer;
      pRenderer: IUniqueValueRenderer;
      pColorRamp: IRandomColorRamp;
      pEnumColors: IEnumColors;

      pQueryFilter: IQueryFilter;
      pCursor: ICursor;
      pRow: IRow;
      pColor: IColor;

      pFillSymbol: ISimpleFillSymbol;
      pMarkerSymbol: ISimpleMarkerSymbol;
      pSymbol: ISymbol;
      sValue: string;
      ok: WordBool;
    begin
      pGeoLayer := pLayer as IGeoFeatureLayer;
      pTable := pLayer as ITable;
      pRenderer := CoUniqueValueRenderer.Create as IUniqueValueRenderer;

      pRenderer.FieldCount := 1;
      pRenderer.Field[0] := sField;

      //创建随机色带
      pColorRamp := CoRandomColorRamp.Create as IRandomColorRamp;
      pColorRamp.StartHue := 0;
      pColorRamp.EndHue := 300;
      pColorRamp.MinSaturation := 0;
      pColorRamp.MaxSaturation := 100;
      pColorRamp.MinValue := 0;
      pColorRamp.MaxValue := 100;
      pColorRamp.Size := 255;
      pColorRamp.CreateRamp(ok);

      if ok then
      begin
        pEnumColors := pColorRamp.Colors;
        pQueryFilter := CoQueryFilter.Create as IQueryFilter;
        pQueryFilter.AddField(sField);

        pCursor := pTable.Search(pQueryFilter, True);
        pRow := pCursor.NextRow;
        iFieldIndex := pTable.FindField(sField); //获得指定指端的索引号
        while pRow <> nil do
        begin
          sValue := pRow.Value[iFieldIndex];
          pColor := pEnumColors.Next;
          if pColor = nil then
          begin
            pEnumColors.Reset;
            pColor := pEnumColors.Next;
          end;
          case estyle of
            uvtFillSymbol:
              begin
                pFillSymbol := CoSimpleFillSymbol.Create as ISimpleFillSymbol;
                pFillSymbol.Color := pColor;
                pSymbol := pFillSymbol as ISymbol;
              end;

            uvtMarkerSymbol:
              begin
                pMarkerSymbol := CoSimpleMarkerSymbol.Create as ISimpleMarkerSymbol;
                pMarkerSymbol.Color := pColor;
                pMarkerSymbol.Style := esriSMSCircle;
                pMarkerSymbol.Size := StrToIntDef(sValue, 1) * iDotSize;
                pSymbol := pMarkerSymbol as ISymbol;
              end;
          end;
          pRenderer.AddValue(sValue, '', pSymbol);
          pRow := pCursor.NextRow;
        end;
        pGeoLayer.Renderer := pRenderer as IFeatureRenderer;
        Result := True;
      end
      else
      begin
        Result := False;
      end;
    end;
  • 相关阅读:
    设计模式之访问者模式
    SecureCRT Win免安装版本,简单好用
    Java BAT大型公司面试必考技能视频-1.HashMap源码分析与实现
    最好用的百度云盘破解下载加速器
    博客系统学习关于应用架构的分层与设计
    博客系统实战——SprintBoot 集成Thymeleaf 实现用户增删查改(含源码)
    【设计模式】简单工厂模式
    快速开发平台全新升级,把时间留给自己,工作丢给力软平台
    快速开发平台全新升级,把时间留给自己,工作丢给力软平台
    The rapid development platform upgrade, leave the time to yourself, the work is lost to the soft platform
  • 原文地址:https://www.cnblogs.com/chinacodegear/p/1423291.html
Copyright © 2011-2022 走看看