图元和图层搜索

 

Feature对象:

地图图元是地图上的一个地图对象。图元只是一条包含制表数据【属性数据】和几何信息的记录。

 

Attribute

每个图元均有一个或者多个arrtibute对象。arrtibute对象表示用于该图元的制表数据列。此对象包含类型和值信息。

 

 

Geometrie

每一个图元都有一个Geometry对象. Geometry对象可以用来访问图元的所有几何信息。相应的几何信息有 Ve ct orGemoetryPointGemoetryVe ct orGemoetry用于折线和区域图元PointGemoetry用于点

 

Feature对象的方法

1,  getAttribute(int columnIndex)指定列的属性值。索引值从0开始

2,  getAttributeCount()获取于该图元相关的属性数量

3,  getGeometry()获取图元相关的几何对象,如果图元没有几何对象返回nu ll

4,  getLabelRendition()获取此图元的标注样式

5,  getPrimaryKey()获取此图元的Primarykey[唯一ID]对象。

6,  getRaster()返回此图元的删格对象

7,  getRendition()返回此图元的 样式

 

 

新建地图图元有两中方式:

【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
       
       ;
       
       

      
      
       
        
      
      
// Create a "sparse" rendition with just the symbol font, char, size, and color set
       
       
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);
       
       

      
      
       
        
      
      
// Create an array of Attributes to associate with the point
       
       
Attribute attrs[] = { new Attribute("Point"), new Attribute(2) };
       
       

      
      
       
        
      
      
// Make the first Attribute the PrimaryKey
       
       
PrimaryKey key = new PrimaryKey(attrs[0]);
       
       

      
      
       
        
      
      
// Create the point
       
       
Feature point = ff.createPoint(pt, rend, labelRend, attrs, key);
       
       

      
      
       
        
      
      
// add the Feature to our previously created annotation layer - see
        
        
// Adding an Annotation Layer
      
      
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 oryAttributes数组将用于这一新行的列值。这些值必须完全从图层的TableInfo检索的列的顺序,即TableInfo列名数组中的每一个名称必须在图元的 Attributes数组中有相应的值对应。

<3>

<4>

<5>

 

 

FeatureSet对象:

FeatureSetFeature对象的集合。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 unitQueryParams queryParams)

 

3//参数;columns 返回的属性列,必须是String类型。re ct   搜索的矩形区域。Querypamrams查询参数,为nu ll 的时候,获取所有信息:【搜索在矩形范围之类的图元集合】

Layer.searc hW ithinRe ct angle(List columnsDoubleRe 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);
       
       

      
      
       
        
      
      

Attribute mySerachAttr=new Attribute100000);

Sting seaColumn=”income”;

Layer.searchByAttribute(columns,seaColumn, mySerachAttr, queryParams)

 

6,layer.searchByAttributes(List columns,List AttrName,List attrOperater,List attrvalueQueryParams queryParmas);

                 

// The columns to be returned
           
           
ArrayList columns = new ArrayList();
           
           
columns.add("Capital");
           
           
columns.add("Pop_1994");
           
           
columns.add("Country");
           
           
columns.add("MapInfo_ID");
           
           

          
          
           
            
          
          
// These identify the columns to look for
           
           
ArrayList attNames = new ArrayList();
           
           
attNames.add("Capital");
           
           
attNames.add("Country");
           
           

          
          
           
            
          
          
// List of operators - "equals" is only a
            
            
             
             ll
            
            owed currently
           
           
ArrayList attOperators = new ArrayList();
           
           
attOperators.add(AttOperator.eq);
           
           
attOperators.add(AttOperator.eq);
           
           

          
          
           
            
          
          
Attribute att1 = new Attribute("
           
           
           
           
            
            
             
             Dublin
            
            
           
           ");
           
           
Attribute att2 = new Attribute("
           
           
            
            
             
             Ireland
            
            
           
           ");
           
           
Attribute att3 = new Attribute("
           
           
            
            
             
             Paris
            
            
           
           ");
           
           
Attribute att4 = new Attribute("
           
           
            
            
             
             France
            
            
           
           ");
           
           

          
          
           
            
          
          
// The aggregate of capital/country values
           
           
AttTuple v1 = new AttTuple(att1, att2);
           
           
AttTuple v2 = new AttTuple(att3, att4);
           
           

          
          
           
            
          
          
// The sele
            
            
             
             ct
            
            ion conditions that are checked against each feature
           
           
ArrayList attValues = new ArrayList();
           
           
attValues.add(v1);
           
           
attValues.add(v2);
           
           

          
          
           
            
          
          
FeatureSet fs = regionLayer.searchByAttributes(columns, attNames, attOperators,
           
           
      attValues, QueryParams.EMPTY_PARAMS);
           
           
Feature feat = fs.getNextFeature();
           
           
int i = 0;
           
           
while ( feat != nu
           
           
            
            ll
           
            )
           
           
{
           
           
   Attribute result = feat.getAttribute(0);
           
           
   System.out.println("Result is for capital column feature(" + i + "): " +
           
           
         result.getString());
           
           

          
          
           
            
          
          
   Attribute result1 = feat.getAttribute(1);
           
           
   System.out.println("Result is for cap_pop column feature(" + i + ") : " +
           
           
         result1.getString());
           
           

          
          
           
            
          
          
   feat = fs.getNextFeature();
           
           
   i++;
           
           
}
           
           

          
          
           
            
          
          
// Always dispose of the FeatureSet once you're done with it!
           
           
fs.dispose();
           
           

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值