前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >从MapX到MapXtreme2004[3]-搜索图元Feature

从MapX到MapXtreme2004[3]-搜索图元Feature

作者头像
用户1075292
发布2018-01-23 11:10:50
7440
发布2018-01-23 11:10:50
举报
文章被收录于专栏:听雨堂

一、根据名称搜索图元   1、Mapxtreme的架构和Mapx有所变化,Mapx中,Layer包含Features,而Mapxtreme中则不是   2、Mapxtreme的例子中的查找,是通过Find对象来实现的,而Find对象的构造,需要指定Table和Colume,Table好办,FeatureLayer.table即可,而Colume通过FeatureLayer.table.tableinfo.colums["列名"]来指定。但是,关键问题,大多数的地图,并未设计过多的字段来供查询,查的其实就是个标题和label而已。   3、要用笨办法,遍历图层的features,通过这个方法

代码语言:js
复制
           foreach(Feature feature in lyr.table)
           {
           }

  4、Feature派生自Object,包含一个Geometry属性,这个属性是各种几何图形对象的基类       Geometry classes that derive from FeatureGeometry include: Point, MultiPoint, MultiCurve, MultiPolygon, FeatureGeometryCollection, Rectangle, RoundedRectangle, Ellipse, LegacyArc, and LegacyText.   5、通过如下方式引用feature对象             ((MapInfo.Geometry.LegacyText)feature.Geometry).Caption 二、通过search方法搜索   1、catalog的search方法可以按条件搜索图元(第一个图元)

代码语言:js
复制
        // also uses search for feature
        Feature fDEU = _catalog.SearchForFeature("europe", MapInfo.Data.SearchInfoFactory.SearchWhere
("Country='DEU'"));

  2、先利用SearchInfoFactory构造一个SearchInfo对象,指定其搜索属性: 

代码语言:js
复制
            SearchAll: Returns all the rows.
            SearchNearest: Returns the rows with table geometries that are closest to the given search point.
            SearchWhere: Returns the rows specified by the given where Clause.
            SearchWithinDistance: Returns the rows where the table geometry is contained within a buffer of the search point, rectangle or geometry.
            SearchWithinFeature: Returns the rows where the table geometry is contained within the search features's geometry.
            SearchWithinGeometry: Returns the rows where the table geometry is contained within the search geometry.
            SearchWithinRect: Returns the rows where the table geometry intersects the given rectangle.
            SearchIntersectsFeature: Returns the rows where the table geometry intersects with the search features's geometry.
            SearchIntersectsGeometry: Returns the rows where the table geometry intersects with the search geometry.
            SearchWithinScreenRadius: Creates a SearchInfo that returns the rows where the table geometry intersects a screen circle.
            SearchWithinScreenRect:Returns the rows where the table geometry intersects the given screen rectangle

    3、再调用search方法,将结果放到      MultiResultSetFeatureCollection       IResultSetFeatureCollection   4、或许还要设置视图        MapInfo.Engine.Session.Current.MapFactory[0].SetView(fc.Envelope); 三、通过选择工具来选择一个范围         1、需要控制选择的图层         2、选择的结果,通过MapInfo.Engine.Session.Current.Selections.DefaultSelection得到一个Selection对象         3、Selection对象,是一个IResultSetFeatureCollection的集合,每个对应一个表         4、对每一个IResultSetFeatureCollection,可以通过枚举器来遍历访问

代码语言:js
复制
   Selection sl =MapInfo.Engine.Session.Current.Selections.DefaultSelection;
   IResultSetFeatureCollection fc=sl[0];
   IFeatureEnumerator fn=fc.GetFeatureEnumerator();
   ListBox1.Items.Clear();
   while(fn.MoveNext())
    if(fn.Current.Geometry.GetType().ToString()=="MapInfo.Geometry.LegacyText")
    ListBox1.Items.Add(((MapInfo.Geometry.LegacyText)fn.Current.Geometry).Caption);
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2005-07-21 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档