Mapx寻找地物
GIS系统是将空间属性和其他属性结合起来的系统。所以从MapX的对象结构图来看,有两列分支是开始就必须涉及到的。一个是属性数据列:
Map-Datasets-Dataset-Rowvalues-Rowvalue
从地图对象一直到某个属性值。
另一个是空间信息列:
Map-Layers-Layer-Features-Feature-Parts-Points-Point
从地图对象一直到图元上某个节点。
寻找图元在MapX应用中非常重要,很多基本的应用中都要包含这个功能,必须最基本的点击查询属性功能,必须先找到这个地物才能察找到属性等信息。
从对象图上可以看出,要想寻找到feature,必须从他所在的层开始。那么Layer对象有那些属性方法支持寻找图元呢?
Layer.Find
Layer.Selection
Layer.AllFeatures
Layer.GetFeatureByID method
Layer.GetFeatureByKey method
Layer.SearchAtPoint method
Layer.SearchWithinDistance method
Layer.SearchWithinFeature method
Layer.SearchWithinRectangle method
Find方法从来没有用过,就不说了。
Selection是一个选中图元的集合。
AllFeatures是所有图元的集合。
GetFeatureByID,根据featureID得到图元
GetFeatureByKey,根据FeatureKey得到图元
Search方法:
[ Features collection= ]OBJECT.Search (strWhere, [Variables])
将strWhere设置成一个条件语句,比如例子中的:
Set ftrs = lyrUSA.Search("TOTPOP > 1000000")
这就得到一个Features集合,
怎么写条件语句,参考MapX的帮助Creating Expressions一节
SearchAtPoint:
以某一个点为基准进行搜索,可以设置搜索结果的类型,比如返回线状地物可以设置SearchResultFlag为miSearchResultLine
SearchWithinDistance:
OBJECT.SearchWithinDistance(Source, double Distance, short Units, short SearchType)
以某点或者某图元为基准,搜索一定范围内的地物,第一个参数设置一个点对象或者一个feature对象,第二个参数设置距离,地三个参数设置单位,第四个参数设置返回结果与基准及距离的位置
关系。
Set Ftrs = lyrUSA.SearchWithDistance(pt, 100, miUnitMillimeter, miSearchTypeCentroidWithin)
这个语句搜索在pt附近,100米范围内,中心在这个圈内的地物。
SearchWithinFeature:
OBJECT.SearchWithinFeature (Feature, SearchType)
基本原理同上,不过没有一个距离范围,这个范围就是图元本身。
SearchWithRectangle
OBJECT.SearchWithinRectangle (Rectangle, SearchType)
基本原理同上,只是这个图元是一个矩形。
|