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

新店开张,0利润销售,只为挣信誉,欢迎大家选购,还可以代充话费!!!


转载自:https://blog.csdn.net/jiaoyu12/article/details/7946056

You may also like...