I am a civilization, the article comes from the practice of the project, which represents the identity and my personal opinion, there are different views can leave a message Ha, thank you for reading the article there is a typo or error codes please correct me, thank you oh.
1, ARCGIS two-dimensional points, has no elevation data line default value z; elevation action is mainly displayed in three-dimensional data is added;
(1) a method of adding an elevation: GP operation:
Input parameters to: add a field to the line height can be terminated;
Operation above gp gp converted to self-Code: Slightly
(2) a method of adding elevation of 2: code for the AE:
Methods to create a point having IFeatureWorkspace.CreateFeatureClass elevation values, line data; The following is the core:
//创建要素类的关键字段shape字段支持类型设置。
IField field = new ESRI.ArcGIS.Geodatabase.FieldClass();
IFieldEdit fieldEdit = field as ESRI.ArcGIS.Geodatabase.IFieldEdit;
ESRI.ArcGIS.Geodatabase.IGeometryDef geoDef = new ESRI.ArcGIS.Geodatabase.GeometryDefClass();
ESRI.ArcGIS.Geodatabase.IGeometryDefEdit geoDefEdit = (ESRI.ArcGIS.Geodatabase.IGeometryDefEdit)geoDef;
ESRI.ArcGIS.Geometry.ISpatialReferenceFactory spatialRefFactory = new ESRI.ArcGIS.Geometry.SpatialReferenceEnvironmentClass();
ESRI.ArcGIS.Geometry.ISpatialReference spatialReference = spatialRefFactory.CreateESRISpatialReferenceFromPRJFile(foldprj);//设置空间参考
geoDefEdit.SpatialReference_2 = spatialReference;
geoDefEdit.AvgNumPoints_2 = 5;
geoDefEdit.GeometryType_2 = ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint;
geoDefEdit.GridCount_2 = 1;
geoDefEdit.HasM_2 = true;//支持M字段
geoDefEdit.HasZ_2 = true;//设置为true以支持存储高程
fieldEdit.Name_2 = "SHAPE";
fieldEdit.Type_2 = ESRI.ArcGIS.Geodatabase.esriFieldType.esriFieldTypeGeometry;
fieldEdit.GeometryDef_2 = geoDef;
fieldEdit.IsNullable_2 = true;
fieldEdit.Required_2 = true;
fieldsEdit.AddField(field);//添加字段
To set the z value is stored after setting the following code to create a good feature class:
//设置线的z值存储,点设置同*(略)
IPolyline polyline = m_Feature.Shape as IPolyline;
IPoint pFromPoint = new PointClass();
pFromPoint.PutCoords(polyline.FromPoint.X, polyline.FromPoint.Y);
pFromPoint.Z = ZFrom;//起点高程
IZAware fromZAware = pFromPoint as IZAware;
fromZAware.ZAware = true;
IPoint pToPoint = new PointClass();
pToPoint.PutCoords(polyline.ToPoint.X, polyline.ToPoint.Y);
pToPoint.Z = ZTo;//终点高程
IZAware toZAware = pToPoint as IZAware;
toZAware.ZAware = true;
IPolyline pPolyline = new PolylineClass();
IZAware iPolylineAware = (IZAware)pPolyline;
iPolylineAware.ZAware = true;
pPolyline.FromPoint = pFromPoint;
pPolyline.ToPoint = pToPoint;
m_Feature.Shape = pPolyline;
Found after the above code;
Method 3: shap field modified directly
For the ability to directly modify shap field, the test will be the wrong type z input is not supported. Specific self-test.
Cause: For shap field that already exists, can not modify the value of z GeometryDef.