原创 Geotools中手工创建Feature的方法收藏

Geotools中手工创建Feature的方法

package map;

import org.geotools.map.MapLayer;
import org.geotools.factory.FactoryRegistryException;
import org.geotools.feature.Feature;
import org.geotools.feature.type.GeometricAttributeType;
import org.geotools.feature.type.TextualAttributeType;
import org.geotools.filter.Filter;
import org.geotools.feature.FeatureTypeFactory;
import org.geotools.feature.FeatureType;
import org.geotools.feature.AttributeType;
import org.geotools.feature.IllegalAttributeException;
import org.geotools.feature.SchemaException;
import org.geotools.feature.Feature;
import org.geotools.feature.FeatureFactory;

import com.vividsolutions.jts.geom.Envelope;
import com.vividsolutions.jts.geom.Point;
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.GeometryFactory;

import org.opengis.referencing.crs.CoordinateReferenceSystem; 

public class MainClass {
    
    
public static void main(String args[]){
        System.out.println(
"begin");
        MainClass mainClass 
= new MainClass();
        mainClass.test();
        
//new TestMap().sichuan();
        
        System.out.println(
"end");
    }

    
    
public void test(){
        CoordinateReferenceSystem crs 
= null;
        GeometricAttributeType geoType 
= new GeometricAttributeType("the_geom",Point.class,true,1,1,null,crs,Filter.ALL);
        TextualAttributeType txtType 
= new TextualAttributeType("NAME",true,1,1,null,Filter.ALL);
        
try {
            GeometryFactory geometryFactory 
= new GeometryFactory();
            Coordinate c 
= new Coordinate(104.00,29.0);
            Point pt 
= geometryFactory.createPoint(c);
            String name 
= "beijing";
            FeatureType featureType 
= FeatureTypeFactory.newFeatureType(new AttributeType[]{geoType,txtType}"temp");
            Feature feature 
= featureType.create(new Object[]{pt,name});
            System.out.println(feature);
        }
 catch (FactoryRegistryException e) {
            
// TODO 自动生成 catch 块
            e.printStackTrace();
        }
 catch (SchemaException e) {
            
// TODO 自动生成 catch 块
            e.printStackTrace();
        }
 catch (IllegalAttributeException e) {
            
// TODO 自动生成 catch 块
            e.printStackTrace();
        }

        
        System.out.println(geoType);
        System.out.println(txtType);
    }

}

发表于 @ 2007年09月07日 15:14:00|评论(loading...)

 | 

用户操作
[即时聊天] [发私信] [加为好友]
马魁
订阅我的博客
XML聚合  FeedSky
订阅到鲜果
订阅到Google
订阅到抓虾
文章分类
    收藏
      存档
      软件项目交易
      Csdn Blog version 3.1a
      Copyright © 马魁