从MapX到MapXtreme2004[3]-搜索图元Feature
一、根据名称搜索图元 1、Mapxtreme的架构和Mapx有所变化,Mapx中,Layer包含Features,而Mapxtreme中则不是 2、Mapxtreme的例子中的查找,是通过Find对象来实现的,而Find对象的构造,需要指定Table和Colume,Table好办,FeatureLayer.table即可,而Colume通过FeatureLayer.table.tableinfo.colums["列名"]来指定。但是,关键问题,大多数的地图,并未设计过多的字段来供查询,查的其实就是个标题和label而已。 3、要用笨办法,遍历图层的features,通过这个方法
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方法可以按条件搜索图元(第一个图元)
// also uses search for feature
Feature fDEU = _catalog.SearchForFeature("europe", MapInfo.Data.SearchInfoFactory.SearchWhere
("Country='DEU'"));
2、先利用SearchInfoFactory构造一个SearchInfo对象,指定其搜索属性:
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,可以通过枚举器来遍历访问
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);
- Leetcode-Easy 234. Palindrome Linked List
- 为什么是link-visited-hover-active
- 51Nod 1051 最大子矩阵和
- Javascript之创建对象
- Leetcode-Easy 136. Single Number
- 2017.10.25水题大作战题解
- Angular开发实践(四):组件之间的交互
- Leetcode-Easy 70. Climbing Stairs
- Angular开发实践(八): 使用ng-content进行组件内容投射
- Angular开发实践(六):服务端渲染
- Leetcode-Easy 657. Judge Route Circle
- 洛谷P1138 第k小整数
- Leetcode-Easy 796. Rotate String
- 2017.10.23解题报告
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法