lilysunny
路人甲
路人甲
  • 注册日期2003-08-18
  • 发帖数160
  • QQ
  • 铜币499枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:3709回复:12

一个查询过滤的问题!

楼主#
更多 发布于:2004-05-26 11:44
<P>环境:vb.net下的独立开发,ArcGis 8.3</P>
<P>问题:想实现ArcMap下的Query功能,即不是要查询并选中出符合条件的要素,而是希望能把MapControl的一个图层只显示其中符合条件的要素,并不要求选中</P>
<P>不知道用什么接口可以实现,我在论坛里找到了一个pLayer.setFilterObject(QueryFilter)可是怎么我在帮助里没有找到咧?请高手指点!</P><img src="images/post/smile/dvbbs/em02.gif" />
喜欢0 评分0
黑夜给了你黑色的眼睛,你却拿它来翻白眼!
destnity
路人甲
路人甲
  • 注册日期2004-03-25
  • 发帖数341
  • QQ
  • 铜币272枚
  • 威望0点
  • 贡献值0点
  • 银元0个
1楼#
发布于:2004-05-26 12:50
你说的setFilterObject是不是arcims里面的接口呀。
签 名: 不能超过 250 个字符 文字将出现在您发表的文章的结尾处。
举报 回复(0) 喜欢(0)     评分
lilysunny
路人甲
路人甲
  • 注册日期2003-08-18
  • 发帖数160
  • QQ
  • 铜币499枚
  • 威望0点
  • 贡献值0点
  • 银元0个
2楼#
发布于:2004-05-26 13:11
<P>有可能,我说我怎么在AO里找不到呢!</P><P>那我在AO中象实现咋弄咧?多谢!</P>
黑夜给了你黑色的眼睛,你却拿它来翻白眼!
举报 回复(0) 喜欢(0)     评分
destnity
路人甲
路人甲
  • 注册日期2004-03-25
  • 发帖数341
  • QQ
  • 铜币272枚
  • 威望0点
  • 贡献值0点
  • 银元0个
3楼#
发布于:2004-05-26 13:35
<P>我想是不是可以通过Symbology的方式实现,你的图层可以专门建立一个字段用于控制是否显示,选中的要素该字段值为true,未选中的为False (或是1,0,其它的也可以), 在 match to symbols in a style 里设置,就可以只看到符合条件的要素集。</P><P>我想应该可以通过编代码实现。只是一个思路。</P>
签 名: 不能超过 250 个字符 文字将出现在您发表的文章的结尾处。
举报 回复(0) 喜欢(0)     评分
lilysunny
路人甲
路人甲
  • 注册日期2003-08-18
  • 发帖数160
  • QQ
  • 铜币499枚
  • 威望0点
  • 贡献值0点
  • 银元0个
4楼#
发布于:2004-05-26 13:45
<P>那么复杂啊?比如我的图层有3个feature字段Name分别为a、b、c,我想通过查询只显示a,而不显示b、c,就是ArcMap中的图层的Definition Query功能!</P><P>match to symbols in a style ?是什么意思啊?</P><img src="images/post/smile/dvbbs/em02.gif" />
黑夜给了你黑色的眼睛,你却拿它来翻白眼!
举报 回复(0) 喜欢(0)     评分
destnity
路人甲
路人甲
  • 注册日期2004-03-25
  • 发帖数341
  • QQ
  • 铜币272枚
  • 威望0点
  • 贡献值0点
  • 银元0个
5楼#
发布于:2004-05-26 13:55
<P>哈。图层名称->右键->属性->symbology Tab</P><P>categories - match to symbols in a style .</P><P>我上面是在arcmap中手工实现的,主要是根据某一字段的值,来设定哪些要素显示,哪些要不比不显示。</P><P>不一定满足你的要求。</P>
签 名: 不能超过 250 个字符 文字将出现在您发表的文章的结尾处。
举报 回复(0) 喜欢(0)     评分
destnity
路人甲
路人甲
  • 注册日期2004-03-25
  • 发帖数341
  • QQ
  • 铜币272枚
  • 威望0点
  • 贡献值0点
  • 银元0个
6楼#
发布于:2004-05-26 13:59
<P>过滤是比较简单的了,可以将满足要求的要素过滤出来。主要是过滤出来的要素显示,而不符合过滤条件的要素不显示。</P><P>我这方面了解得不多,除了将过滤的要素提取到新的图层外,或(可能)通过symbol方式控制显示与不显示外,我还想不到其它的办法。</P><P>也不清楚AO里是否有现成的接口。</P>
签 名: 不能超过 250 个字符 文字将出现在您发表的文章的结尾处。
举报 回复(0) 喜欢(0)     评分
destnity
路人甲
路人甲
  • 注册日期2004-03-25
  • 发帖数341
  • QQ
  • 铜币272枚
  • 威望0点
  • 贡献值0点
  • 银元0个
7楼#
发布于:2004-05-26 14:03
图层名称->右键->属性->symbology Tab
<P>categories 里那三个选项都可以的。不一定非得match to symbols in a style .</P>

<P>如果你想试下这种方法可以参照帮助中的:</P>
<H1>IUniqueValueRenderer Example</H1>
<P><B>UniqueValueRenderer Example </B></P>
<P>Paste this VBA code into a map with at least one feature layer:  Creates a <B>UniqueValueRenderer</B>, sets its properties, applies it to the <b>GeoFeatureLayer</b>, and refreshes the the map. </P><CODE><PRE>Option Explicit

Sub CreateAndApplyUVRenderer()
    
     '** Paste into VBA
     '** Creates a UniqueValuesRenderer and applies it to first layer in the map.
     '** Layer must have "Name" field
 
     Dim pApp As esriMx.Application
     Dim pDoc As IMxDocument
     Set pDoc = ThisDocument
     Dim pMap As IMap
     Set pMap = pDoc.FocusMap
 
     Dim pLayer As ILayer
     Set pLayer = pMap.Layer(0)
     Dim pFLayer As IFeatureLayer
     Set pFLayer = pLayer
     Dim pLyr As IGeoFeatureLayer
     Set pLyr = pFLayer
    
     Dim pFeatCls As IFeatureClass
     Set pFeatCls = pFLayer.FeatureClass
     Dim pQueryFilter As IQueryFilter
     Set pQueryFilter = New QueryFilter 'empty supports: SELECT *
     Dim pFeatCursor As IFeatureCursor
     Set pFeatCursor = pFeatCls.Search(pQueryFilter, False)
 
     '** Make the color ramp we will use for the symbols in the renderer
     Dim rx As IRandomColorRamp
     Set rx = New RandomColorRamp
     rx.MinSaturation = 20
     rx.MaxSaturation = 40
     rx.MinValue = 85
     rx.MaxValue = 100
     rx.StartHue = 76
     rx.EndHue = 188
     rx.UseSeed = True
     rx.Seed = 43
    
     '** Make the renderer
     Dim pRender As IUniqueValueRenderer, n As Long
     Set pRender = New UniqueValueRenderer
    
     Dim symd As ISimpleFillSymbol
     Set symd = New SimpleFillSymbol
     symd.Style = esriSFSSolid
     symd.Outline.Width = 0.4
    
     '** These properties should be set prior to adding values
     pRender.FieldCount = 1
     pRender.Field(0) = "Name"
     pRender.DefaultSymbol = symd
     pRender.UseDefaultSymbol = True
    
     Dim pFeat As IFeature
     n = pFeatCls.FeatureCount(pQueryFilter)
     '** Loop through the features
     Dim i As Integer
     i = 0
     Dim ValFound As Boolean
     Dim NoValFound As Boolean
     Dim uh As Integer
     Dim pFields As IFields
     Dim iField As Integer
     Set pFields = pFeatCursor.Fields
     iField = pFields.FindField("Name")
     Do Until i = n
         Dim symx As ISimpleFillSymbol
         Set symx = New SimpleFillSymbol
         symx.Style = esriSFSSolid
         symx.Outline.Width = 0.4
         Set pFeat = pFeatCursor.NextFeature
         Dim x As String
         x = pFeat.Value(iField) '*new Cory*
         '** Test to see if we've already added this value
         '** to the renderer, if not, then add it.
         ValFound = False
         For uh = 0 To (pRender.ValueCount - 1)
           If pRender.Value(uh) = x Then
             NoValFound = True
             Exit For
           End If
         Next uh
         If Not ValFound Then
             pRender.AddValue x, "Name", symx
             pRender.Label(x) = x
             pRender.Symbol(x) = symx
         End If
         i = i + 1
     Loop
    
     '** now that we know how many unique values there are
     '** we can size the color ramp and assign the colors.
     rx.Size = pRender.ValueCount
     rx.CreateRamp (True)
     Dim RColors As IEnumColors, ny As Long
     Set RColors = rx.Colors
     RColors.Reset
     For ny = 0 To (pRender.ValueCount - 1)
         Dim xv As String
         xv = pRender.Value(ny)
         If xv <> "" Then
             Dim jsy As ISimpleFillSymbol
             Set jsy = pRender.Symbol(xv)
             jsy.Color = RColors.Next
             pRender.Symbol(xv) = jsy
         End If
     Next ny
 
     '** If you didn't use a color ramp that was predefined
     '** in a style, you need to use "Custom" here, otherwise
     '** use the name of the color ramp you chose.
     pRender.ColorScheme = "Custom"
     pRender.FieldType(0) = True
     Set pLyr.Renderer = pRender
     pLyr.DisplayField = "Name"
 
     '** This makes the layer properties symbology tab show
     '** show the correct interface.
     Dim hx As IRendererPropertyPage
     Set hx = New UniqueValuePropertyPage
     pLyr.RendererPropertyPageClassID = hx.ClassID
 
     '** Refresh the TOC
     pDoc.ActiveView.ContentsChanged
     pDoc.UpdateContents
    
     '** Draw the map
     pDoc.ActiveView.Refresh
    
End Sub</PRE></CODE>
[此贴子已经被作者于2004-5-26 14:04:42编辑过]
签 名: 不能超过 250 个字符 文字将出现在您发表的文章的结尾处。
举报 回复(0) 喜欢(0)     评分
lilysunny
路人甲
路人甲
  • 注册日期2003-08-18
  • 发帖数160
  • QQ
  • 铜币499枚
  • 威望0点
  • 贡献值0点
  • 银元0个
8楼#
发布于:2004-05-26 14:29
多谢提示,IUniqueValueRenderer我已经用过了,用于地图的自动分块上色,没有想到的是它其中的pQueryFilter 可以起到我要的作用!现在功能已经实现了,但是我总是怀疑是不是弄得太复杂了!呵呵!<img src="images/post/smile/dvbbs/em07.gif" /><img src="images/post/smile/dvbbs/em12.gif" />
黑夜给了你黑色的眼睛,你却拿它来翻白眼!
举报 回复(0) 喜欢(0)     评分
destnity
路人甲
路人甲
  • 注册日期2004-03-25
  • 发帖数341
  • QQ
  • 铜币272枚
  • 威望0点
  • 贡献值0点
  • 银元0个
9楼#
发布于:2004-05-26 14:47
<P>实现就好。哈。。</P><P>处理问题的原则是先解决问题,再找解决问题更好的办法。</P><P>AO里面的接口太多了。</P><img src="images/post/smile/dvbbs/em03.gif" />
签 名: 不能超过 250 个字符 文字将出现在您发表的文章的结尾处。
举报 回复(0) 喜欢(0)     评分
上一页
游客

返回顶部