ArcGIS 文件地理数据库的表记录添加、删除

//获得工作空间,打开要素类、表(Util类)

public class BtsUtils
{
 public static String tinPath;
 
 public static IFeatureWorkspace featureWorkspace;
 
 public static ITable baseTable;
 
 public static ISpatialReference spatialReference;
 /**
  *
  * @param path "E:\\eclipse\\workspace\\Debug\\gis.gdb";(文件地理数据库)
  * @return
  * @throws UnknownHostException
  * @throws IOException
  */
 public static IFeatureWorkspace getWorkspace(String path) throws UnknownHostException, IOException
 {
        IWorkspaceFactory factory = new FileGDBWorkspaceFactory();
        IWorkspace workspace = factory.openFromFile(path, 0);
        featureWorkspace = new IFeatureWorkspaceProxy(workspace);
//        featureWorkspace = (IFeatureWorkspace)workspace;
        return featureWorkspace;
 }
 /**
  *
  * @param name
  * @return
  * @throws AutomationException
  * @throws IOException
  */
 public static IFeatureClass openFeatureClass(String name) throws AutomationException, IOException
 {
  IFeatureClass fc = featureWorkspace.openFeatureClass(name);
  spatialReference = new IGeoDatasetProxy(fc).getSpatialReference();
  return fc;
 }
 
 /**
  *
  * @param tableName
  * @return
  * @throws AutomationException
  * @throws IOException
  */
 public static ITable openTable(String tableName) throws AutomationException, IOException
 {
  baseTable = featureWorkspace.openTable(tableName);
  return baseTable;
 }
 
}

 

 

//for eg:tableName = 小区数据表

ITable itable = BtsUtils.openTable(tableName);

itable.deleteSearchedRows(null);//删除表中所有数据

 

//向表添加一行数据

IRow row = itable.createRow();

row.setValue(itable.findField("cellId"), cell.getObjectId());

row.store();

 itable.insert(true);



欢迎访问本店:http://shop107558950.taobao.com/index.htm
新店开张,0利润销售,只为挣信誉,欢迎大家选购,还可以代充话费!!!

你可能感兴趣的:(eclipse,数据库,String,Class,Path)