Feature对象:
地图图元是地图上的一个地图对象。图元只是一条包含制表数据【属性数据】和几何信息的记录。
Attribute
每个图元均有一个或者多个arrtibute对象。arrtibute对象表示用于该图元的制表数据列。此对象包含类型和值信息。
Geometrie
每一个图元都有一个Geometry对象. Geometry对象可以用来访问图元的所有几何信息。相应的几何信息有 Ve ct orGemoetry和PointGemoetry。Ve ct orGemoetry用于折线和区域图元PointGemoetry用于点
Feature对象的方法
7,
|
|
新建地图图元有两中方式:
【1】 使用FeatureFa ct ory对象来创建
//参数: // thePoint 图元的位置,rend 图元渲染样式【可以为nu ll 】,labelRend 与图元相关的标签渲染样式【可以为nu ll 】,attributrArray属性数组【可以为nu ll 】,主键【可以为nu ll 】
CreatePoint(DoublePoint thePoint ,Rendition rend ,Rendition labelRend ,Arrtibute [] attributrArray, PrimaryKey key )
FeatureFa
ct
ory ff = mapj.getFeatureFa
ct
ory();
DoublePoint pt = new DoublePoint(-100, 45);
Rendition labelRend = nu
ll
;
Rendition rend = new RenditionImpl();
rend.setValue(Rendition.SYMBOL_MODE, Rendition.SymbolMode.FONT);
rend.setValue(Rendition.FONT_FAMILY, "MapInfo Shields");
rend.setValue(Rendition.SYMBOL_STRING, "@");
rend.setValue(Rendition.FONT_SIZE, 16);
rend.setValue(Rendition.SYMBOL_FOREGROUND, Color.blue);
Attribute attrs[] = { new Attribute("Point"), new Attribute(2) };
PrimaryKey key = new PrimaryKey(attrs[0]);
Feature point = ff.createPoint(pt, rend, labelRend, attrs, key);
annotLayer.addFeature(point);
|
//参数: // thePoint 图元的位置【区域位置,xy轴坐标】,rend 图元渲染样式【可以为nu ll 】,labelRend 与图元相关的标签渲染样式【可以为nu ll 】,attributrArray属性数组【可以为nu ll 】,主键【可以为nu ll 】
CreatePoint(Double[][] thePoint ,Rendition rend ,Rendition labelRend ,Arrtibute [] attributrArray, PrimaryKey key )
|
【2】通过layer类的搜索方法检索现有图元来创建新图元
注意:新建完图元之后基本上是加入到注释图层中去的
<1>,对于tab文件而言,将在图元添加到图层时指定PrimaryKey。此外,主键不可以更改。 <2>创建了要添加到JDBC表图层的图元之后,该图元将最终存储位数据库表中的一行。提供给FeatureFa ct ory的Attributes数组将用于这一新行的列值。这些值必须完全从图层的TableInfo检索的列的顺序,即TableInfo列名数组中的每一个名称必须在图元的 Attributes数组中有相应的值对应。 <3> <4> <5> |
FeatureSet对象:
FeatureSet是Feature对象的集合。Layer对象的搜索方法从图层中返回FeatureSet集合
搜索图元:
QueryParams queryParams:表示搜素的参数。默认情况下,使用查询返回的是与图元相关的几何对象,样式,标注样式,首选标注位置和删格数据。使用QueryParams 可以限制某个图元返回的信息。
1,//参数;columns 返回的属性列,必须是String类型。Querypamrams查询参数,为nu ll 的时候,获取所有信息 Layer.searchA ll (List columns,QueryPamrams querypamrams );
2,//参数;columns 返回的属性列,必须是String类型。centerPoint 中心点。radius 半径。unit 距离单位。Querypamrams查询参数,为nu ll 的时候,获取所有信息:【搜索半径范围之类的图元集合】 Layer.searc hW ithinRadius(List columns,DoublePoint centerPoint,double radius,Unit unit,QueryParams queryParams)
3,//参数;columns 返回的属性列,必须是String类型。re ct 搜索的矩形区域。Querypamrams查询参数,为nu ll 的时候,获取所有信息:【搜索在矩形范围之类的图元集合】 Layer.searc hW ithinRe ct angle(List columns,DoubleRe ct re ct ,QueryParams queryParams)
4,//【获取指定点的图元集合】 public FeatureSet searchAtPoint(List columns, DoublePoint queryPoint, QueryParams queryParams)
5,//返回columnName所对应的值于给定的属性相匹配的FeatureSet集合 layer.searchByAttribute(List columns,String columnName,Attribute attribute,QueryParams queryParams);
6,layer.searchByAttributes(List columns,List AttrName,List attrOperater,List attrvalue,QueryParams queryParmas);
|