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;
  • 相关阅读:
    L1-047 装睡 (10分)
    QT 文件的读写,将txt中的数据存储到QVector
    C++Primer第五版 第十二章 动态内存
    C++Primer第五版 第十一章 关联容器
    从《上瘾》到 《不被干扰》
    MySQL模糊查询用法(正则、通配符、内置函数等)
    MySQL-SQL优化总结
    MySQL中特别实用的几种SQL语句
    public、private、protected 和 default
    DO,DTO,VO,POJO详解
  • 原文地址:https://www.cnblogs.com/chinacodegear/p/1423291.html
Copyright © 2011-2022 走看看