shijibao01
路人甲
路人甲
  • 注册日期2004-10-08
  • 发帖数44
  • QQ
  • 铜币250枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1467回复:0

请教版主在AE中实现数据符号化的问题(续)

楼主#
更多 发布于:2005-08-16 22:52
<P ><FONT face="Times New Roman">版主老大,麻烦你帮我看看这段代码,尤其是代码的红色部分</FONT></P>
<P ><FONT face="Times New Roman"></FONT> </P>
<P ><FONT face="Times New Roman">歧中红色部分中的绿色代码是程序的错误所在</FONT></P>
<P ><FONT face="Times New Roman">出现  automation error </FONT></P>
<P ><FONT face="Times New Roman"></FONT> </P>
<P ><FONT face="Times New Roman">Private Sub RendererLayers()</FONT></P>
<P ><FONT face="Times New Roman">'On Error Resume Next</FONT></P>
<P ><FONT face="Times New Roman">Dim pFeatureCount As Long</FONT></P>
<P ><FONT face="Times New Roman">Dim pFeature As IFeature</FONT></P>
<P ><FONT face="Times New Roman">Dim pGeoLayer As IGeoFeatureLayer</FONT></P>
<P ><FONT face="Times New Roman">Dim pStyleStorage As IStyleGalleryStorage</FONT></P>
<P ><FONT face="Times New Roman">Dim pStyleGalleryItem As IStyleGalleryItem</FONT></P>
<P ><FONT face="Times New Roman">Dim pEnumStyleGalleryItem As IEnumStyleGalleryItem</FONT></P>
<P ><FONT face="Times New Roman">Dim pStyleGallery As IStyleGallery</FONT></P>
<P ><FONT face="Times New Roman">Dim pDefaultStyle As IStyleGalleryItem</FONT></P>
<P ><FONT face="Times New Roman">Dim SymPointColor As IRgbColor</FONT></P>
<P ><FONT face="Times New Roman">Dim SymLineColor As IRgbColor</FONT></P>
<P ><FONT face="Times New Roman">Dim SymFillColor As IRgbColor</FONT></P>
<P ><FONT face="Times New Roman">Dim pdefaultsymbol As ISimpleMarkerSymbol</FONT></P>
<P ><FONT face="Times New Roman">Dim pdefaultsymbol1 As ISimpleLineSymbol</FONT></P>
<P ><FONT face="Times New Roman">Dim pdefaultsymbol2 As ISimpleFillSymbol</FONT></P>
<P ><FONT face="Times New Roman">Dim pGeoFeaLayer As IGeoFeatureLayer</FONT></P>
<P ><FONT face="Times New Roman">Dim pQueryFilter As IQueryFilter</FONT></P>
<P ><FONT face="Times New Roman">Dim pFeaCursor As IFeatureCursor</FONT></P>
<P ><FONT face="Times New Roman">Dim StylePath As String</FONT></P>
<P ><FONT face="Times New Roman">Dim PrendererValue As String</FONT></P>
<P ><FONT face="Times New Roman">Dim i, j, k, L, Flag As Integer</FONT></P>
<P ><FONT face="Times New Roman">Dim StyleFlag, ValExit As Boolean</FONT></P>
<P ><FONT face="Times New Roman">Dim pUVRenderer As IUniqueValueRenderer</FONT></P>
<P ><FONT face="Times New Roman">Dim pSymbolType As ISymbol</FONT></P>
<P ><FONT face="Times New Roman">    </FONT></P>
<P ><FONT face="Times New Roman">  If pFeatureLayers(0) Is Nothing Then Exit Sub</FONT></P>
<P ><p><FONT face="Times New Roman"> </FONT></p></P>
<P ><FONT face="Times New Roman">    Set pStyleGallery = New ServerStyleGallery</FONT></P>
<P ><FONT face="Times New Roman">       ' pStyleGallery.ImportStyle "D:\Program Files\ArcGIS\Styles\Esri.ServerStyle"</FONT></P>
<P ><FONT face="Times New Roman">    Set pStyleStorage = pStyleGallery</FONT></P>
<P ><FONT face="Times New Roman">    'MsgBox pStyleStorage.FileCount</FONT></P>
<P ><FONT face="Times New Roman">        pStyleStorage.TargetFile = "D:\Program Files\ArcGIS\Styles\symbol.ServerStyle"</FONT></P>
<P ><FONT face="Times New Roman">    '''''''''''''''''</FONT>查找符号库</P>
<P ><FONT face="Times New Roman">    For j = 0 To pStyleStorage.FileCount - 1</FONT></P>
<P ><FONT face="Times New Roman">         If UCase(pStyleStorage.File(j)) = UCase(App.Path) ; "\SYMBOL.SERVERSTYLE" Then</FONT></P>
<P ><FONT face="Times New Roman">            StyleFlag = True</FONT></P>
<P ><FONT face="Times New Roman">         Else</FONT></P>
<P ><FONT face="Times New Roman">         'MsgBox pStyleStorage.File(j)</FONT></P>
<P ><FONT face="Times New Roman">            StyleFlag = False</FONT></P>
<P ><FONT face="Times New Roman">        End If</FONT></P>
<P ><FONT face="Times New Roman">    Next j</FONT></P>
<P ><FONT face="Times New Roman">    ''''''''''''''''''''''''''''</FONT>设置默认符号</P>
<P ><FONT face="Times New Roman">    Set pDefaultStyle = New ServerStyleGalleryItem</FONT></P>
<P ><FONT face="Times New Roman">    Set pdefaultsymbol = New SimpleMarkerSymbol</FONT></P>
<P ><FONT face="Times New Roman">    Set pdefaultsymbol1 = New SimpleLineSymbol</FONT></P>
<P ><FONT face="Times New Roman">    Set pdefaultsymbol2 = New SimpleFillSymbol</FONT></P>
<P ><FONT face="Times New Roman">'  If Not StyleFlag Then</FONT></P>
<P ><FONT face="Times New Roman">'     StylePath = App.Path ; "\symbol.ServerStyle"</FONT></P>
<P ><FONT face="Times New Roman">'     pStyleStorage.AddFile StylePath</FONT></P>
<P ><FONT face="Times New Roman">'  End If</FONT></P>
<P ><FONT face="Times New Roman">    ''''''''''''''''</FONT>设置以那个字段来作为符号化的标准,以及字段的数量</P>
<P ><FONT face="Times New Roman">  Set pUVRenderer = New UniqueValueRenderer</FONT></P>
<P ><FONT face="Times New Roman">      pUVRenderer.FieldCount = 1</FONT></P>
<P ><FONT face="Times New Roman">      pUVRenderer.Field(0) = "</FONT>名称<FONT face="Times New Roman">"</FONT></P>
<P ><FONT face="Times New Roman">    </FONT></P>
<P ><FONT face="Times New Roman">    </FONT></P>
<P ><FONT face="Times New Roman">    </FONT></P>
<P ><FONT face="Times New Roman">  Dim pFeatureLayer As IFeatureLayer</FONT></P>
<P ><FONT face="Times New Roman">  Dim pFeatureClass As IFeatureClass</FONT></P>
<P ><FONT face="Times New Roman">  </FONT></P>
<P ><FONT face="Times New Roman">  For i = 0 To UBound(pFeatureLayers)</FONT></P>
<P ><FONT face="Times New Roman">      Set pFeatureLayer = pFeatureLayers(i)</FONT></P>
<P ><FONT face="Times New Roman">      Set pFeatureClass = pFeatureLayer.FeatureClass</FONT></P>
<P ><FONT face="Times New Roman">      </FONT></P>
<P ><FONT face="Times New Roman">      Select Case UCase(pFeatureClass.AliasName)</FONT></P>
<P ><p><FONT face="Times New Roman"> </FONT></p></P>
<P ><FONT face="Times New Roman">                          </FONT></P>
<P ><FONT face="Times New Roman">                 '/////////////////</FONT>改进</P>
<P ><FONT face="Times New Roman">                 Case "SDE.DBO.WNNJS"</FONT></P>
<P ><FONT face="Times New Roman">                       Set pUVRenderer = New UniqueValueRenderer</FONT></P>
<P ><FONT face="Times New Roman">                       pUVRenderer.FieldCount = 1</FONT></P>
<P ><FONT face="Times New Roman">                       pUVRenderer.Field(0) = "JLX"</FONT></P>
<P ><FONT face="Times New Roman">                 Case "SDE.DBO.WPPGD"</FONT></P>
<P ><FONT face="Times New Roman">                       Set pUVRenderer = New UniqueValueRenderer</FONT></P>
<P ><FONT face="Times New Roman">                       pUVRenderer.FieldCount = 1</FONT></P>
<P ><FONT face="Times New Roman">                       pUVRenderer.Field(0) = "GXLX"</FONT></P>
<P ><FONT face="Times New Roman">                 Case Else</FONT></P>
<P ><FONT face="Times New Roman">                      Set pUVRenderer = New UniqueValueRenderer</FONT></P>
<P ><FONT face="Times New Roman">                       pUVRenderer.FieldCount = 1</FONT></P>
<P ><FONT face="Times New Roman">                       pUVRenderer.Field(0) = "JDLX"</FONT></P>
<P ><FONT face="Times New Roman">                ''/////////////////////////////////</FONT></P>
<P ><FONT face="Times New Roman">                          </FONT></P>
<P ><FONT face="Times New Roman">      End Select</FONT></P>
<P ><FONT face="Times New Roman">      '////////////////////</FONT>确定当前图层是用那种符号类型</P>
<P ><FONT face="Times New Roman">      'Set pEnumStyleGalleryItem = New EnumServerStyleGalleryItem</FONT></P>
<P ><p><FONT face="Times New Roman"> </FONT></p></P>
<P ><FONT face="Times New Roman">      </FONT></P>
<P ><FONT face="Times New Roman">      Select Case pFeatureClass.ShapeType</FONT></P>
<P ><FONT face="Times New Roman">           Case 1</FONT></P>
<P ><FONT face="Times New Roman">                Set pSymbolType = New SimpleMarkerSymbol</FONT></P>
<P ><FONT face="Times New Roman">                    Flag = 0</FONT></P>
<P ><FONT face="Times New Roman">                Set pEnumStyleGalleryItem = pStyleGallery.Items("marker symbols", "", "")</FONT></P>
<P ><FONT face="Times New Roman">           Case 3</FONT></P>
<P ><FONT face="Times New Roman">                Set pSymbolType = New SimpleLineSymbol</FONT></P>
<P ><FONT face="Times New Roman">                    Flag = 1</FONT></P>
<P ><FONT face="Times New Roman">                Set pEnumStyleGalleryItem = pStyleGallery.Items("line symbols", "", "")</FONT></P>
<P ><FONT face="Times New Roman">           Case 4</FONT></P>
<P ><FONT face="Times New Roman">               GoTo 30000</FONT></P>
<P ><FONT face="Times New Roman">                Set pSymbolType = New SimpleFillSymbol</FONT></P>
<P ><FONT face="Times New Roman">                Set pEnumStyleGalleryItem = pStyleGallery.Items("fill symbols", "", "")</FONT></P>
<P ><FONT face="Times New Roman">                </FONT></P>
<P ><FONT face="Times New Roman">      End Select</FONT></P>
<P ><FONT face="Times New Roman">         </FONT></P>
<P ><FONT face="Times New Roman">         </FONT></P>
<P ><FONT face="Times New Roman">      </FONT></P>
<P ><FONT face="Times New Roman">       Set pGeoLayer = pFeatureLayer</FONT></P>
<P ><FONT face="Times New Roman">   </FONT></P>
<P ><FONT face="Times New Roman">           pFeatureCount = pFeatureClass.FeatureCount(Nothing)</FONT></P>
<P ><FONT face="Times New Roman">    </FONT></P>
<P ><FONT face="Times New Roman">   </FONT></P>
<P ><FONT face="Times New Roman">       Set pFeaCursor = pFeatureClass.Search(Nothing, False)</FONT></P>
<P ><FONT face="Times New Roman">      </FONT></P>
<P ><FONT face="Times New Roman">      </FONT></P>
<P ><FONT face="Times New Roman">       For k = 0 To pFeatureCount - 1</FONT></P>
<P ><FONT face="Times New Roman">          Dim tempval As String</FONT></P>
<P ><FONT face="Times New Roman">          Set pFeature = pFeaCursor.NextFeature</FONT></P>
<P ><FONT face="Times New Roman">              If UCase(pFeature.Class.AliasName) = "SDE.DBO.WPPGD" Then</FONT></P>
<P ><FONT face="Times New Roman">                     If Not IsNull(pFeature.Value(pFeature.Fields.FindField("GXLX"))) Then</FONT></P>
<P ><FONT face="Times New Roman">                          PrendererValue = Trim(pFeature.Value(pFeature.Fields.FindField("GXLX")))</FONT></P>
<P ><FONT face="Times New Roman">                     Else</FONT></P>
<P ><FONT face="Times New Roman">                          PrendererValue = ""</FONT></P>
<P ><FONT face="Times New Roman">                     End If</FONT></P>
<P ><FONT face="Times New Roman">              ElseIf UCase(pFeature.Class.AliasName) = "SDE.DBO.WNNJS" Then</FONT></P>
<P ><FONT face="Times New Roman">                     If Not IsNull(pFeature.Value(pFeature.Fields.FindField("JLX"))) Then</FONT></P>
<P ><FONT face="Times New Roman">                          PrendererValue = Trim(pFeature.Value(pFeature.Fields.FindField("JLX")))</FONT></P>
<P ><FONT face="Times New Roman">                     Else</FONT></P>
<P ><FONT face="Times New Roman">                          PrendererValue = ""</FONT></P>
<P ><FONT face="Times New Roman">                     End If</FONT></P>
<P ><FONT face="Times New Roman">              Else</FONT></P>
<P ><FONT face="Times New Roman">                     If Not IsNull(pFeature.Value(pFeature.Fields.FindField("JDLX"))) Then</FONT></P>
<P ><FONT face="Times New Roman">                           PrendererValue = Trim(pFeature.Value(pFeature.Fields.FindField("JDLX")))</FONT></P>
<P ><FONT face="Times New Roman">                     Else</FONT></P>
<P ><FONT face="Times New Roman">                           PrendererValue = ""</FONT></P>
<P ><FONT face="Times New Roman">                     End If</FONT></P>
<P ><FONT face="Times New Roman">              End If</FONT></P>
<P ><FONT face="Times New Roman">              </FONT></P>
<P ><FONT face="Times New Roman">          If tempval <> PrendererValue Then</FONT></P>
<P ><FONT face="Times New Roman">             tempval = PrendererValue</FONT></P>
<P ><FONT face="Times New Roman">             ValExit = False</FONT></P>
<P ><FONT face="Times New Roman">          Else</FONT></P>
<P ><FONT face="Times New Roman">             ValExit = True</FONT></P>
<P ><FONT face="Times New Roman">         End If</FONT></P>
<P ><FONT face="Times New Roman">         Dim pValueCount As Integer</FONT></P>
<P ><FONT face="Times New Roman">             pValueCount = 0</FONT></P>
<P ><FONT face="Times New Roman">         For pValueCount = 0 To pUVRenderer.ValueCount - 1</FONT></P>
<P ><FONT face="Times New Roman">             If pUVRenderer.Value(pValueCount) = PrendererValue Then</FONT></P>
<P ><FONT face="Times New Roman">                 ValExit = True</FONT></P>
<P ><FONT face="Times New Roman">                 Exit For</FONT></P>
<P ><FONT face="Times New Roman">             End If</FONT></P>
<P ><FONT face="Times New Roman">         Next pValueCount</FONT></P>
<P ><FONT face="Times New Roman">         </FONT></P>
<P ><FONT face="Times New Roman">         If Not ValExit Then</FONT></P>
<P ><FONT face="Times New Roman">            ' pUVRenderer.AddValue</FONT></P>
<P ><FONT face="Times New Roman">             pUVRenderer.AddValue PrendererValue, "</FONT>类型<FONT face="Times New Roman">", pSymbolType</FONT></P>
<P ><FONT face="Times New Roman">             pUVRenderer.Label(PrendererValue) = PrendererValue</FONT></P>
<P ><FONT face="Times New Roman">             pUVRenderer.Symbol(PrendererValue) = pSymbolType</FONT></P>
<P ><FONT face="Times New Roman">         End If</FONT></P>
<P ><FONT face="Times New Roman">      Next k</FONT></P>
<P ><FONT face="Times New Roman">        </FONT></P>
<P ><FONT face="Times New Roman">      <FONT color=#ff0033>For L = 0 To pUVRenderer.ValueCount - 1</FONT></FONT></P>
<P ><FONT face="Times New Roman"><FONT color=#ff0033>        Dim val As String</FONT></FONT></P>
<P ><FONT face="Times New Roman"><FONT color=#ff0033>        val = pUVRenderer.Value(L)</FONT></FONT></P>
<P ><FONT face="Times New Roman"><FONT color=#ff0033>              If val <> "" Then</FONT></FONT></P>
<P ><FONT face="Times New Roman"><FONT color=#ff0033>                    pEnumStyleGalleryItem.Reset</FONT></FONT></P>
<P ><FONT face="Times New Roman"><FONT color=#ff0033>                   <FONT color=#00ff33> </FONT></FONT><FONT color=#00ff33>Set pStyleGalleryItem = pEnumStyleGalleryItem.Next</FONT></FONT></P>
<P ><FONT face="Times New Roman"><FONT color=#ff0033>                   Do While Not pStyleGalleryItem Is Nothing</FONT></FONT></P>
<P ><FONT face="Times New Roman"><FONT color=#ff0033>                            If pStyleGalleryItem.Name = val Then</FONT></FONT></P>
<P ><FONT face="Times New Roman"><FONT color=#ff0033>                               pUVRenderer.Symbol(val) = pStyleGalleryItem.Item</FONT></FONT></P>
<P ><FONT face="Times New Roman"><FONT color=#ff0033>                               'Set pGeoLayer = pFeatureLayer</FONT></FONT></P>
<P ><FONT face="Times New Roman"><FONT color=#ff0033>                               'Set pGeoLayer.Renderer = pUVRenderer</FONT></FONT></P>
<P ><FONT face="Times New Roman"><FONT color=#ff0033>                               Exit Do</FONT></FONT></P>
<P ><FONT face="Times New Roman"><FONT color=#ff0033>                            Else</FONT></FONT></P>
<P ><FONT face="Times New Roman">                            Select Case Flag</FONT></P>
<P ><FONT face="Times New Roman">                                   Case 0</FONT></P>
<P ><FONT face="Times New Roman">                                        Set pGeoLayer = pFeatureLayer</FONT></P>
<P ><FONT face="Times New Roman">                                        Set SymPointColor = New RgbColor</FONT></P>
<P ><FONT face="Times New Roman">                                        SymPointColor.RGB = vbGreen</FONT></P>
<P ><FONT face="Times New Roman">                                        Set pDefaultStyle = New ServerStyleGalleryItem</FONT></P>
<P ><FONT face="Times New Roman">                          </FONT></P>
<P ><FONT face="Times New Roman">                                        Set pdefaultsymbol = New SimpleMarkerSymbol</FONT></P>
<P ><FONT face="Times New Roman">                                        pdefaultsymbol.Color = SymPointColor</FONT></P>
<P ><FONT face="Times New Roman">                                        pdefaultsymbol.Size = 4</FONT></P>
<P ><FONT face="Times New Roman">                                        pdefaultsymbol.Style = esriSMSCircle</FONT></P>
<P ><FONT face="Times New Roman">                                        pDefaultStyle.Item = pdefaultsymbol</FONT></P>
<P ><FONT face="Times New Roman">                            </FONT></P>
<P ><FONT face="Times New Roman">                                        pUVRenderer.Symbol(val) = pdefaultsymbol</FONT></P>
<P ><FONT face="Times New Roman">                      </FONT></P>
<P ><FONT face="Times New Roman">                                   Case 1</FONT></P>
<P ><FONT face="Times New Roman">                                        Set pGeoLayer = pFeatureLayer</FONT></P>
<P ><FONT face="Times New Roman">                                        Set SymLineColor = New RgbColor</FONT></P>
<P ><FONT face="Times New Roman">                                        SymLineColor.RGB = vbGreen</FONT></P>
<P ><FONT face="Times New Roman">                                        Set pDefaultStyle = New ServerStyleGalleryItem</FONT></P>
<P ><FONT face="Times New Roman">                          </FONT></P>
<P ><FONT face="Times New Roman">                                        Set pdefaultsymbol1 = New SimpleLineSymbol</FONT></P>
<P ><FONT face="Times New Roman">                                        pdefaultsymbol1.Color = SymLineColor</FONT></P>
<P ><FONT face="Times New Roman">                                        pdefaultsymbol1.Width = 1</FONT></P>
<P ><FONT face="Times New Roman">                                        pdefaultsymbol1.Style = esriSLSSolid</FONT></P>
<P ><FONT face="Times New Roman">                                        pDefaultStyle.Item = pdefaultsymbol1</FONT></P>
<P ><FONT face="Times New Roman">                            </FONT></P>
<P ><FONT face="Times New Roman">                                        pUVRenderer.Symbol(val) = pdefaultsymbol1</FONT></P>
<P ><FONT face="Times New Roman">                            End Select</FONT></P>
<P ><FONT face="Times New Roman">                            End If</FONT></P>
<P ><FONT face="Times New Roman">                          Set pStyleGalleryItem = pEnumStyleGalleryItem.Next</FONT></P>
<P ><FONT face="Times New Roman">                   <st1:place w:st="on">Loop</st1:place></FONT></P>
<P ><FONT face="Times New Roman">              End If</FONT></P>
<P ><FONT face="Times New Roman">        </FONT></P>
<P ><FONT face="Times New Roman">    Next L</FONT></P>
<P ><FONT face="Times New Roman">       Set pGeoLayer.Renderer = pUVRenderer</FONT></P>
<P ><FONT face="Times New Roman">       Set pUVRenderer = Nothing</FONT></P>
<P ><FONT face="Times New Roman">      </FONT></P>
<P ><FONT face="Times New Roman">30000: Next i</FONT></P>
<P ><FONT face="Times New Roman">  frmmain.MapControl1.ActiveView.ContentsChanged</FONT></P>
<P ><FONT face="Times New Roman">  </FONT></P>
<P ><FONT face="Times New Roman">  frmmain.MapControl1.ActiveView.Refresh</FONT></P>
<P ><FONT face="Times New Roman">  frmmain.MapControl1.ActiveView.PartialRefresh esriViewGeography, Nothing, Nothing</FONT></P>
喜欢0 评分0
游客

返回顶部