日期:2014-05-16 浏览次数:20433 次
不多说了 直接上代码
?
package com.hjkj.action.infoAna.topicmap; import com.esri.arcgis.datasourcesfile.ShapefileWorkspaceFactory; import com.esri.arcgis.geodatabase.IFeature; import com.esri.arcgis.geodatabase.IFeatureClass; import com.esri.arcgis.geodatabase.IFeatureClassWrite; import com.esri.arcgis.geodatabase.IFeatureClassWriteProxy; import com.esri.arcgis.geodatabase.IFeatureCursor; import com.esri.arcgis.geodatabase.IFeatureWorkspace; import com.esri.arcgis.geodatabase.IFeatureWorkspaceProxy; import com.esri.arcgis.geodatabase.IFields; import com.esri.arcgis.geodatabase.IQueryFilter; import com.esri.arcgis.geodatabase.IWorkspaceFactory; import com.esri.arcgis.geodatabase.QueryFilter; import com.esri.arcgis.geometry.IPolyline; import com.hjkj.util.Configuration; public class ReadShape { // public void sfsdfs(String shapeFileName) { // 获取指定路径 C:\DIET\shape\temp Configuration config = new Configuration(); String targetPath = config.getValue("outShapeFile"); try { IWorkspaceFactory pWorkspaceFactory = new ShapefileWorkspaceFactory(); IFeatureWorkspace pFeatureWorkspace = new IFeatureWorkspaceProxy( pWorkspaceFactory.openFromFile(targetPath, 0)); IFeatureClass featureClass = pFeatureWorkspace .openFeatureClass(shapeFileName); IFeatureClassWrite pFeatureClassWrite = new IFeatureClassWriteProxy( featureClass);// IQueryFilter pQueryFilter = new QueryFilter(); IFeatureCursor pFCursor = featureClass.search(pQueryFilter, false); IFeature pFeature = pFCursor.nextFeature(); int i = 0; while (pFeature != null) { IPolyline polyline = (IPolyline) pFeature.getShapeCopy(); IFields ifds = pFeature.getFields();// 字段信息集合 for (int num = 0; num < ifds.getFieldCount(); num++) { String name = ifds.getField(num).getName();// 某个字段名字 pFeature.getValue(num);// 某字段值 System.out.println("某个字段的名字:" + name); System.out.println("某个字段的值:" + pFeature.getValue(num).toString()); } } } catch (Exception e) { e.printStackTrace(); } } }
?