336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.


import org.geotools.data.FeatureSource;
import org.geotools.feature.AttributeType;
import org.geotools.feature.Feature;
import org.geotools.feature.FeatureCollection;
import org.geotools.feature.FeatureIterator;
import org.geotools.feature.FeatureType;
import org.geotools.filter.text.cql2.CQL;
import org.opengis.filter.Filter;

public class TestProgram {

 private FeatureSource source = null;
 private FeatureCollection fc = null;
 private FeatureType ft = null;
 private Tick tick = null;
 
 public TestProgram()
 {
  tick = Tick.getInstance();
 }
 
 public void loadShapeFile()
 {
  LoaderShapeFile loader = new LoaderShapeFile("E:/gis_data/Shape/bda2.shp");
  loader.setTableName("BDA2");
  
  source = loader.loadFeatureSource();
 }
 
 public void loadArcSDE()
 {
  String tableName = "GISADMIN.BDA2";
  
  LoaderArcSDE sde = new LoaderArcSDE("arcsde", "brian", "5151", "", "gisadmin", "gisadmin");
  sde.setTableName(tableName);
  source = sde.loadFeatureSource();
  
 }
 
 public void showFeatures()
 {
  FeatureIterator fi = fc.features();
  
  while(fi.hasNext())
  {
   Feature ft = fi.next();
   System.out.println("ID: " + ft.getAttribute(0));
  }
 }
 
 public void run()
 {
  Tick.start();
  
  try{
   
//   Filter filter = CQL.toFilter("BBOX(the_geom, 128,34,129,35)");
//   
//   fc = source.getFeatures( filter );
   fc = source.getFeatures();
   int size = fc.size();
   
   ft = source.getSchema();
   
   System.out.print("Type: ");
   
   AttributeType[] types = ft.getAttributeTypes();
   for (AttributeType type: types)
    System.out.print(type.getLocalName() + "|") ;
   
   System.out.println("");
   System.out.println("Size: " + size);
   
  }catch(Exception e){e.printStackTrace();}
  
  Tick.printlab();
 }
 
 public void run(String geomid)
 {
  Tick.start();
  
  try{
   
   Filter filter = CQL.toFilter("BBOX(" + geomid+ ", 128,34,129,35)");
   
   fc = source.getFeatures( filter );
//   fc = source.getFeatures();
   int size = fc.size();
   
   ft = source.getSchema();
   
   System.out.print("Type: ");
   
   AttributeType[] types = ft.getAttributeTypes();
   for (AttributeType type: types)
    System.out.print(type.getLocalName() + "|") ;
   
   System.out.println("");
   System.out.println("Size: " + size);
   
  }catch(Exception e){e.printStackTrace();}
  
  Tick.printlab();
 }
 
 /**
  * @param args
  */
 public static void main(String[] args) throws Exception{
  // TODO Auto-generated method stub

  TestProgram test = new TestProgram();
  System.out.println("<<< ArcSDE >>> ");
  test.loadArcSDE();
  test.run();
//  System.out.println("<<< Shape >>> ");
//  test.loadShapeFile();
//  test.run("the_geom");
  test.showFeatures();
  
 }

}

+ Recent posts