/// <summary> /// Create the polyline feature class /// </summary> /// <param name="featWorkspace">IFeatureWorkspace</param> /// <param name="name">Name of the featureclass</param> /// <returns>IFeatureClass</returns> private IFeatureClass CreatePolylineFeatureClass(IFeatureWorkspace featWorkspace, string name) { IFieldsEdit pFldsEdt = new FieldsClass(); IFieldEdit pFldEdt = new FieldClass(); pFldEdt = new FieldClass(); pFldEdt.Type_2 = esriFieldType.esriFieldTypeOID; pFldEdt.Name_2 = "OBJECTID"; pFldEdt.AliasName_2 = "OBJECTID"; pFldsEdt.AddField(pFldEdt); IGeometryDefEdit pGeoDef; pGeoDef = new GeometryDefClass(); pGeoDef.GeometryType_2 = esriGeometryType.esriGeometryPolyline; pGeoDef.SpatialReference_2 = ArcMap.Document.FocusMap.SpatialReference; pFldEdt = new FieldClass(); pFldEdt.Name_2 = "SHAPE"; pFldEdt.AliasName_2 = "SHAPE"; pFldEdt.Type_2 = esriFieldType.esriFieldTypeGeometry; pFldEdt.GeometryDef_2 = pGeoDef; pFldsEdt.AddField(pFldEdt); IFeatureClass pFClass = featWorkspace.CreateFeatureClass(name, pFldsEdt, null, null, esriFeatureType.esriFTSimple, "SHAPE", ""); return pFClass; }
private static IFeatureClass EnsureFeatureClass(IFeatureWorkspace ws, esriGeometryType geometryType, string name, ISpatialReference sr) { try { IFeatureClass existing = DatasetUtils.OpenFeatureClass(ws, name); DatasetUtils.DeleteFeatureClass(existing); } catch (Exception e) { Console.WriteLine(e); } IFieldsEdit fields = new FieldsClass(); fields.AddField(FieldUtils.CreateOIDField()); fields.AddField(FieldUtils.CreateShapeField( "Shape", geometryType, sr, 1000, true)); IFeatureClass fc = DatasetUtils.CreateSimpleFeatureClass(ws, name, fields); if (fc is IVersionedTable) { DatasetUtils.RegisterAsVersioned(fc); } return(fc); }
public void CanCheckGuids() { IFieldsEdit fields = new FieldsClass(); fields.AddField(FieldUtils.CreateOIDField()); fields.AddField(FieldUtils.CreateField("UUID", esriFieldType.esriFieldTypeGUID)); ITable table = TestWorkspaceUtils.CreateSimpleTable(_fgdbWorkspace, "CanCheckGuids", fields); Guid latest = Guid.NewGuid(); IRow row; for (var i = 0; i < 10; i++) { latest = Guid.NewGuid(); row = table.CreateRow(); row.set_Value(1, latest.ToString("B")); row.Store(); } row = table.CreateRow(); row.set_Value(1, latest.ToString("B")); row.Store(); //IWorkspace ws = TestDataUtils.OpenTopgisTlm(); //ITable table = ((IFeatureWorkspace) ws).OpenTable("TOPGIS_TLM.TLM_STRASSE"); var test = new QaUnique(table, "UUID"); var runner = new QaTestRunner(test); runner.Execute(); Assert.AreEqual(2, runner.Errors.Count); }
public void MultipartTest() { IFeatureWorkspace workspace = TestWorkspaceUtils.CreateInMemoryWorkspace("MultipartTest"); IFieldsEdit fields = new FieldsClass(); fields.AddField(FieldUtils.CreateOIDField()); fields.AddField(FieldUtils.CreateShapeField( "Shape", esriGeometryType.esriGeometryPolyline, CreateLV95(), 1000)); IFeatureClass linesFc = DatasetUtils.CreateSimpleFeatureClass(workspace, "Flow", fields); AddFeature( linesFc, CurveConstruction.StartLine(0, 0).LineTo(4, 0).MoveTo(6, 0).LineTo(6, 10).Curve); AddFeature(linesFc, CurveConstruction.StartLine(4, 0).LineTo(6, 0).Curve); AddFeature(linesFc, CurveConstruction.StartLine(0, 20).LineTo(4, 20).Curve); AddFeature( linesFc, CurveConstruction.StartLine(0, 30).LineTo(4, 30).MoveTo(0, 32).LineTo(4, 30) .MoveTo(4, 30).LineTo(8, 30).Curve); // expect counter-clockwise: 0 errors var runner = new QaContainerTestRunner( 1000, new QaFlowLogic(linesFc)); Assert.AreEqual(3, runner.Execute()); }
static IFeatureClass CreateFeatureClass(IFeatureWorkspace workspace, string name, ISpatialReference outSR) { IFieldsEdit fields = new FieldsClass(); IFieldEdit field = new FieldClass(); field.Type_2 = esriFieldType.esriFieldTypeOID; field.Name_2 = "OBJECTID"; field.AliasName_2 = "OBJECTID"; fields.AddField(field); IGeometryDefEdit geom = new GeometryDefClass(); geom.GeometryType_2 = esriGeometryType.esriGeometryPolygon; geom.SpatialReference_2 = outSR; geom.HasM_2 = true; geom.HasZ_2 = false; field = new FieldClass(); field.Name_2 = "SHAPE"; field.AliasName_2 = "SHAPE"; field.Type_2 = esriFieldType.esriFieldTypeGeometry; field.GeometryDef_2 = geom; fields.AddField(field); return workspace.CreateFeatureClass(name, fields, null, null, esriFeatureType.esriFTSimple, "SHAPE", ""); }
public void MultipartTest() { IFeatureWorkspace workspace = TestWorkspaceUtils.CreateInMemoryWorkspace("MultipartTest"); IFieldsEdit fields = new FieldsClass(); fields.AddField(FieldUtils.CreateOIDField()); fields.AddField(FieldUtils.CreateShapeField( "Shape", esriGeometryType.esriGeometryPolyline, CreateLV95(), 1000)); IFeatureClass featureClass = DatasetUtils.CreateSimpleFeatureClass( workspace, "Border", fields); AddFeature(featureClass, CurveConstruction.StartLine(0, 0).LineTo(4, 0).MoveTo(6, 0).LineTo(6, 10) .Curve); AddFeature(featureClass, CurveConstruction.StartLine(6, 10).LineTo(4, 10).Curve); AddFeature(featureClass, CurveConstruction.StartLine(4, 0).LineTo(6, 0).MoveTo(4, 10).LineTo(0, 0) .Curve); // expect counter-clockwise: 0 errors var runnerCounterClockwise = new QaContainerTestRunner( 1000, new QaBorderSense(featureClass, false)); Assert.AreEqual(0, runnerCounterClockwise.Execute()); // expect clockwise: 1 error var runnerClockwise = new QaContainerTestRunner( 1000, new QaBorderSense(featureClass, true)); Assert.AreEqual(1, runnerClockwise.Execute()); }
/// <summary> /// Create a polygon feature class used to store buffer geometries for observer points /// </summary> /// <param name="featWorkspace">IFeatureWorkspace</param> /// <param name="spatialRef">ISpatialReference of selected surface</param> /// <param name="name">Name of the feature class</param> /// <returns>IFeatureClass</returns> private static IFeatureClass CreateMaskFeatureClass(IFeatureWorkspace featWorkspace, ISpatialReference spatialRef, string name) { IFieldsEdit pFldsEdt = new FieldsClass(); IFieldEdit pFldEdt = new FieldClass(); pFldEdt = new FieldClass(); pFldEdt.Type_2 = esriFieldType.esriFieldTypeOID; pFldEdt.Name_2 = "OBJECTID"; pFldEdt.AliasName_2 = "OBJECTID"; pFldsEdt.AddField(pFldEdt); IGeometryDefEdit pGeoDef; pGeoDef = new GeometryDefClass(); pGeoDef.GeometryType_2 = esriGeometryType.esriGeometryPolygon; pGeoDef.SpatialReference_2 = spatialRef; pFldEdt = new FieldClass(); pFldEdt.Name_2 = "SHAPE"; pFldEdt.AliasName_2 = "SHAPE"; pFldEdt.Type_2 = esriFieldType.esriFieldTypeGeometry; pFldEdt.GeometryDef_2 = pGeoDef; pFldsEdt.AddField(pFldEdt); IFeatureClass pFClass = featWorkspace.CreateFeatureClass(name, pFldsEdt, null, null, esriFeatureType.esriFTSimple, "SHAPE", ""); return(pFClass); }
private static void VerifyErrorHasZ(IFeatureWorkspace ws) { IFieldsEdit fields = new FieldsClass(); fields.AddField(FieldUtils.CreateOIDField()); fields.AddField(FieldUtils.CreateShapeField( "Shape", esriGeometryType.esriGeometryPolyline, SpatialReferenceUtils.CreateSpatialReference ((int)esriSRProjCS2Type.esriSRProjCS_CH1903Plus_LV95, true), 1000, true, false)); IFeatureClass featureClass = DatasetUtils.CreateSimpleFeatureClass(ws, "VerifyErrorHasZ", fields, null); // make sure the table is known by the workspace ((IWorkspaceEdit)ws).StartEditing(false); ((IWorkspaceEdit)ws).StopEditing(true); IPolycurve line1 = CurveConstruction.StartLine(0, 0, 5) .LineTo(2, 0, 5) .Curve; IFeature row1 = featureClass.CreateFeature(); row1.Shape = line1; row1.Store(); IPolycurve line2 = CurveConstruction.StartLine(-1, 0.02, 5) .LineTo(1, 0.02, 5) .Curve; IFeature row2 = featureClass.CreateFeature(); row2.Shape = line2; row2.Store(); var test = new QaNotNear(featureClass, 0.1, 0.5); var runners = new List <QaTestRunnerBase> { new QaTestRunner(test) { KeepGeometry = true }, new QaContainerTestRunner(1000, test) { KeepGeometry = true } }; foreach (QaTestRunnerBase runner in runners) { runner.Execute(); Assert.True(runner.ErrorGeometries.Count > 0); foreach (IGeometry errorGeometry in runner.ErrorGeometries) { Assert.AreEqual(5, errorGeometry.Envelope.ZMin); } } }
public void TestUniqueIntegers() { IFieldsEdit fields = new FieldsClass(); fields.AddField(FieldUtils.CreateOIDField()); fields.AddField(FieldUtils.CreateField("Unique", esriFieldType.esriFieldTypeInteger)); ITable table = TestWorkspaceUtils.CreateSimpleTable(_pgdbWorkspace, "Unique1", fields); for (var i = 0; i < 10; i++) { IRow row = table.CreateRow(); row.set_Value(1, i); row.Store(); } foreach (bool forceInMemoryTableSort in new[] { false, true }) { var test = new QaUnique(table, "Unique") { ForceInMemoryTableSorting = forceInMemoryTableSort }; var runner = new QaTestRunner(test); runner.Execute(); AssertUtils.NoError(runner); } }
/// <summary> /// Join Urban-rural Devide Table /// </summary> /// <param name="layer"></param> /// <param name="year"></param> /// <author>Shen Yongyuan</author> /// <date>20091111</date> public static void JoinDevideTable(ILayer layer, int year, string city) { //Add Fields IFieldsEdit allFields = new FieldsClass(); IFieldEdit field1 = new FieldClass(); field1.Name_2 = "ID"; field1.Type_2 = esriFieldType.esriFieldTypeString; allFields.AddField(field1); IFieldEdit field2 = new FieldClass(); field2.Name_2 = Town.Constant.Constant.TmpFieldName; field2.Type_2 = esriFieldType.esriFieldTypeString; allFields.AddField(field2); //Create Table IWorkspaceFactory workspaceFactory = new InMemoryWorkspaceFactoryClass(); IWorkspaceName workspaceName = workspaceFactory.Create("", "Temporary WorkSpace In Memory", null, 0); IFeatureWorkspace workspace = ((IName)workspaceName).Open() as IFeatureWorkspace; ITable table = workspace.CreateTable(Town.Constant.Constant.TmpTableDevide, allFields, null, null, ""); //Import Data IWorkspaceEdit workspaceEdit = workspace as IWorkspaceEdit; workspaceEdit.StartEditing(false); workspaceEdit.StartEditOperation(); ICursor cursor = table.Insert(true); int fldField1 = cursor.Fields.FindField("ID"); int fldField2 = cursor.Fields.FindField(Town.Constant.Constant.TmpFieldName); //Query and Import Dictionary <int, string> devideResult = DataLib.DA_Devide.GetDevideResult(year, city); foreach (KeyValuePair <int, string> d in devideResult) { IRowBuffer buffer = table.CreateRowBuffer(); buffer.set_Value(fldField1, d.Key.ToString()); buffer.set_Value(fldField2, d.Value); cursor.InsertRow(buffer); } cursor.Flush(); workspaceEdit.StartEditOperation(); workspaceEdit.StopEditing(true); System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor); //Join IMemoryRelationshipClassFactory pMemRelFact = new MemoryRelationshipClassFactory(); IFeatureLayer feaLayer = layer as IFeatureLayer; ITable originTable = feaLayer.FeatureClass as ITable; IRelationshipClass pRelClass = pMemRelFact.Open("Join", originTable as IObjectClass, "ID", table as IObjectClass, "ID", "forward", "backward", esriRelCardinality.esriRelCardinalityOneToOne); IDisplayRelationshipClass pDispRC = feaLayer as IDisplayRelationshipClass; pDispRC.DisplayRelationshipClass(null, esriJoinType.esriLeftOuterJoin); pDispRC.DisplayRelationshipClass(pRelClass, esriJoinType.esriLeftOuterJoin); }
/// <summary> /// Coder: 梁 爽 /// Date: 2008-10-16 /// Content:该函数实现要素类的创建,首先用接口IGeometryDefEdit设置要素类的类型,即是Point,Polylin还是Polygon /// 然后用接口IFieldEdit设置要素类的字段,这里设置了三个字段,分别是ID,OID和Shape。最后通过接口IFeatureWorkspace /// 的CreateFeatureClass方法创建要素类,函数返回IFeatureClass接口类型 /// </summary> /// <param name="pWorkspace">设置工作空间</param> /// <param name="pGeometryType">设置要素的类型,即是点,线,还是面</param> /// <param name="strFeatName">设置要素类的名称</param> /// <param name="ValCoordinatType">传递一个数值型参数,该参数为1-UnkownCoordinateSystem,2-GeographicCoordinateSystem /// 或3ProjectedCoordinateSystem</param> /// <returns></returns> private IFeatureClass CreateFeatureClass(esriGeometryType pesriGeometryType, string pstrLayerName, IWorkspace pWorkspace, IMapControl4 pm_mapControl, List <string> pstrFieldNameLt = null, List <esriFieldType> pesriFieldTypeLt = null) { //创建要素空间 IFeatureWorkspace pFeatureWorkspace = (IFeatureWorkspace)pWorkspace; IGeometryDef geometryDef = new GeometryDefClass(); IGeometryDefEdit pGeometryDefEdit = (IGeometryDefEdit)geometryDef; //_esriGeometryType could be: esriGeometryPoint, esriGeometryMultipoint, //esriGeometryPolyline, esriGeometryPolygon, and esriGeometryMultiPatch. pGeometryDefEdit.GeometryType_2 = pesriGeometryType; pGeometryDefEdit.SpatialReference_2 = pm_mapControl.SpatialReference; // Set the grid count to 1 and the grid size to 0 to allow ArcGIS to // determine a valid grid size. pGeometryDefEdit.GridCount_2 = 1; pGeometryDefEdit.set_GridSize(0, 0); //新建字段 IFieldsEdit pFieldsEdit = new FieldsClass(); //添加“Shape”字段 IFieldEdit pField; pField = new FieldClass(); pField.Type_2 = esriFieldType.esriFieldTypeGeometry; pField.GeometryDef_2 = geometryDef; pField.Name_2 = "Shape"; pFieldsEdit.AddField((IField)pField); //添加其它字段 if (pstrFieldNameLt != null) { //we don't need the first three FieldNames, i.e., "FID", "Shape", and "Id" for (int i = 0; i < pstrFieldNameLt.Count; i++) { pFieldsEdit.AddField((IField)GenerateFieldEdit(pesriFieldTypeLt[i], pstrFieldNameLt[i])); } } string strFullName = pWorkspace.PathName + "\\" + pstrLayerName; File.Delete(strFullName + ".dbf"); File.Delete(strFullName + ".lyr"); File.Delete(strFullName + ".prj"); File.Delete(strFullName + ".shp"); //File.Delete(strFullName + ".shp.PALANQUE.2296.5388.sr.lock"); File.Delete(strFullName + ".shx"); try { return(pFeatureWorkspace.CreateFeatureClass(pstrLayerName, (IFields)pFieldsEdit, null, null, esriFeatureType.esriFTSimple, "Shape"", "")); } catch { return(pFeatureWorkspace.CreateFeatureClass(pstrLayerName, (IFields)pFieldsEdit, null, null, esriFeatureType.esriFTSimple, "Shape", "")); } }
private void TestConnections(IFeatureWorkspace ws) { IFieldsEdit fields = new FieldsClass(); fields.AddField(FieldUtils.CreateOIDField()); fields.AddField(FieldUtils.CreateIntegerField("LineTyp", "LineTyp")); fields.AddField(FieldUtils.CreateShapeField( "Shape", esriGeometryType.esriGeometryPolyline, SpatialReferenceUtils.CreateSpatialReference ((int)esriSRProjCS2Type.esriSRProjCS_CH1903Plus_LV95, true), 1000, false, false)); IFeatureClass fc = DatasetUtils.CreateSimpleFeatureClass(ws, "TestConnections", fields, null); IList <ITable> tbls = new[] { (ITable)fc }; // make sure the table is known by the workspace ((IWorkspaceEdit)ws).StartEditing(false); ((IWorkspaceEdit)ws).StopEditing(true); { IFeature row = fc.CreateFeature(); row.set_Value(1, 1); row.Shape = CurveConstruction.StartLine(100, 100).LineTo(200, 200).Curve; row.Store(); } { IFeature row = fc.CreateFeature(); row.set_Value(1, 2); row.Shape = CurveConstruction.StartLine(100, 100.1).LineTo(100, 200).Curve; row.Store(); } IList <QaConnectionRule> rules = new[] { new QaConnectionRule(tbls, new[] { "LineTyp = 1" }), new QaConnectionRule(tbls, new[] { "LineTyp = 2" }) }; var test = new QaConnections(new[] { fc }, rules, 0); test.QaError += Test_QaError; _errorCount = 0; test.Execute(); Assert.AreEqual(0, _errorCount); test.QaError -= Test_QaError; var container = new TestContainer(); container.AddTest(test); container.QaError += Test_QaError; _errorCount = 0; container.Execute(); Assert.AreEqual(0, _errorCount); }
private static void TestReferencedGuid(IFeatureWorkspace ws) { IFieldsEdit fields1 = new FieldsClass(); fields1.AddField(FieldUtils.CreateOIDField()); fields1.AddField(FieldUtils.CreateField("Pk", esriFieldType.esriFieldTypeGUID)); ITable tbl1 = DatasetUtils.CreateTable(ws, "TestReferencedGuid1", null, fields1); IFieldsEdit fields2 = new FieldsClass(); fields2.AddField(FieldUtils.CreateOIDField()); fields2.AddField(FieldUtils.CreateTextField("Fk", 50)); ITable tbl2 = DatasetUtils.CreateTable(ws, "TestReferencedGuid2", null, fields2); IFieldsEdit fields3 = new FieldsClass(); fields3.AddField(FieldUtils.CreateOIDField()); fields3.AddField(FieldUtils.CreateField("Fk", esriFieldType.esriFieldTypeGUID)); ITable tbl3 = DatasetUtils.CreateTable(ws, "TestReferencedGuid3", null, fields3); // make sure the table is known by the workspace ((IWorkspaceEdit)ws).StartEditing(false); ((IWorkspaceEdit)ws).StopEditing(true); for (int i = 0; i < 5; i++) { Guid guid = Guid.NewGuid(); CreateRow(tbl1, guid.ToString("B")); if (i % 2 == 0) { CreateRow(tbl2, guid.ToString()); } else { CreateRow(tbl3, guid.ToString("B")); } } var test = new QaUnreferencedRows(tbl1, new[] { tbl2, tbl3 }, new[] { "pk,fk", "pk,fk" }); using (var r = new QaTestRunner(test)) { r.Execute(); Assert.AreEqual(0, r.Errors.Count); } var container = new QaContainerTestRunner(10000, test); container.Execute(); Assert.AreEqual(0, container.Errors.Count); }
private static void CanDetect1ToNUnique([NotNull] IFeatureWorkspace workspace) { const string uniqueFieldName = "Unique"; ITable tableOrig; { IFieldsEdit fields = new FieldsClass(); fields.AddField(FieldUtils.CreateOIDField()); fields.AddField(FieldUtils.CreateField( uniqueFieldName, esriFieldType.esriFieldTypeInteger)); ITable table = TestWorkspaceUtils.CreateSimpleTable( workspace, "Relate1NUnique1", fields); for (var i = 0; i < 10; i++) { IRow row = table.CreateRow(); row.set_Value(1, i); row.Store(); } tableOrig = table; } ITable tableRel; { IFieldsEdit fields = new FieldsClass(); fields.AddField(FieldUtils.CreateOIDField()); fields.AddField(FieldUtils.CreateField( "Ref", esriFieldType.esriFieldTypeInteger)); ITable table = TestWorkspaceUtils.CreateSimpleTable( workspace, "Relate1NUnique2", fields); for (var i = 0; i < 10; i++) { IRow row = table.CreateRow(); row.set_Value(1, i); row.Store(); } tableRel = table; } IRelationshipClass rel = TestWorkspaceUtils.CreateSimple1NRelationship(workspace, "rel1NUnique", tableOrig, tableRel, uniqueFieldName, "Ref"); ITable relTab = TableJoinUtils.CreateQueryTable(rel, JoinType.InnerJoin); foreach (bool forceInMemoryTableSort in new[] { true, false }) { var test = new QaUnique(relTab, "Relate1NUnique1." + uniqueFieldName) { ForceInMemoryTableSorting = forceInMemoryTableSort }; var runner = new QaTestRunner(test); runner.Execute(); AssertUtils.NoError(runner); } }
private static void TestReferenced(IFeatureWorkspace ws) { IFieldsEdit fields1 = new FieldsClass(); fields1.AddField(FieldUtils.CreateOIDField()); fields1.AddField(FieldUtils.CreateSmallIntegerField("Pk")); ITable tbl1 = DatasetUtils.CreateTable(ws, "TestReferenced1", null, fields1); IFieldsEdit fields2 = new FieldsClass(); fields2.AddField(FieldUtils.CreateOIDField()); fields2.AddField(FieldUtils.CreateSmallIntegerField("Fk")); ITable tbl2 = DatasetUtils.CreateTable(ws, "TestReferenced2", null, fields2); IFieldsEdit fields3 = new FieldsClass(); fields3.AddField(FieldUtils.CreateOIDField()); fields3.AddField(FieldUtils.CreateIntegerField("Fk")); ITable tbl3 = DatasetUtils.CreateTable(ws, "TestReferenced3", null, fields3); // make sure the table is known by the workspace ((IWorkspaceEdit)ws).StartEditing(false); ((IWorkspaceEdit)ws).StopEditing(true); CreateRow(tbl1, 1); CreateRow(tbl1, 2); CreateRow(tbl1, 3); CreateRow(tbl1, 4); CreateRow(tbl1, 5); CreateRow(tbl2, 1); CreateRow(tbl2, 3); CreateRow(tbl2, 5); CreateRow(tbl3, 2); CreateRow(tbl3, 4); var test = new QaUnreferencedRows(tbl1, new[] { tbl2, tbl3 }, new[] { "pk,fk", "pk,fk" }); using (var r = new QaTestRunner(test)) { r.Execute(); Assert.AreEqual(0, r.Errors.Count); } var container = new QaContainerTestRunner(10000, test); container.Execute(); Assert.AreEqual(0, container.Errors.Count); }
private static void TestNMRelation(IFeatureWorkspace ws) { IFieldsEdit fields1 = new FieldsClass(); fields1.AddField(FieldUtils.CreateOIDField()); fields1.AddField(FieldUtils.CreateIntegerField("Pk")); ITable tbl1 = DatasetUtils.CreateTable(ws, "TestNMRelation1", null, fields1); IFieldsEdit fields2 = new FieldsClass(); fields2.AddField(FieldUtils.CreateOIDField()); fields2.AddField(FieldUtils.CreateIntegerField("Fk")); ITable tbl2 = DatasetUtils.CreateTable(ws, "TestNMRelation2", null, fields2); IRelationshipClass rel = CreateSimpleMNRelationship(ws, "TestNMRelationRel", tbl1, tbl2, "Pk", "Fk"); ((IWorkspaceEdit)ws).StartEditing(false); IRow r11 = CreateRow(tbl1, 8); IRow r12 = CreateRow(tbl1, 12); IRow r13 = CreateRow(tbl1, 7); IRow r21 = CreateRow(tbl2, 9); IRow r22 = CreateRow(tbl2, 5); IRow r23 = CreateRow(tbl2, 4); Assert.NotNull(r12); // not used otherwise rel.CreateRelationship((IObject)r11, (IObject)r21); rel.CreateRelationship((IObject)r11, (IObject)r23); rel.CreateRelationship((IObject)r13, (IObject)r22); r22.set_Value(1, 6); r22.Store(); ((IWorkspaceEdit)ws).StopEditing(true); var test = new QaUnreferencedRows(tbl1, new[] { tbl2 }, new[] { "pk,pk,TestNMRelationRel,fk,fk" }); using (var r = new QaTestRunner(test)) { r.Execute(); Assert.AreEqual(2, r.Errors.Count); } var container = new QaContainerTestRunner(10000, test); container.Execute(); Assert.AreEqual(2, container.Errors.Count); }
private static void TestConditionCoincidence(IFeatureWorkspace ws) { IFieldsEdit fields = new FieldsClass(); fields.AddField(FieldUtils.CreateOIDField()); fields.AddField(FieldUtils.CreateIntegerField("LandId")); fields.AddField(FieldUtils.CreateIntegerField("OtherId")); fields.AddField(FieldUtils.CreateShapeField( "Shape", esriGeometryType.esriGeometryPolyline, SpatialReferenceUtils.CreateSpatialReference ((int)esriSRProjCS2Type.esriSRProjCS_CH1903Plus_LV95, true), 1000, false, false)); IFeatureClass fc1 = DatasetUtils.CreateSimpleFeatureClass(ws, "TestConditionCoincidence1", fields, null); IFeatureClass fc2 = DatasetUtils.CreateSimpleFeatureClass(ws, "TestConditionCoincidence2", fields, null); ((IWorkspaceEdit)ws).StartEditing(false); ((IWorkspaceEdit)ws).StopEditing(true); { IFeature row = fc1.CreateFeature(); row.set_Value(1, 1); row.Shape = CurveConstruction.StartLine(100, 100).LineTo(200, 200).Curve; row.Store(); } { IFeature row = fc2.CreateFeature(); row.set_Value(1, 1); row.Shape = CurveConstruction .StartLine(100.5, 100).LineTo(200.5, 200).Curve; row.Store(); } // test without ignore conditions --> line is near, but not coincident var test = new QaPartCoincidenceOther(fc1, fc2, 1, 10); var testRunner = new QaTestRunner(test); testRunner.Execute(); Assert.AreEqual(1, testRunner.Errors.Count); // Same test with ignore conditions --> nothing near test = new QaPartCoincidenceOther(fc1, fc2, 1, 10); test.IgnoreNeighborCondition = "G1.LandID = G2.LandID"; testRunner = new QaTestRunner(test); testRunner.Execute(); Assert.AreEqual(0, testRunner.Errors.Count); }
private static LinearNetworkGdbFeatureFinder CreateTestGdbSchema( string fgdbName, out IFeatureClass edgeClass, out IFeatureClass junctionClass) { const string unitTestDir = @"C:\Temp\UnitTestData"; try { FileSystemUtils.DeleteDirectory(Path.Combine(unitTestDir, fgdbName), true, true); } catch (Exception) { // ignored } IWorkspaceName workspaceName = WorkspaceUtils.CreateFileGdbWorkspace(unitTestDir, fgdbName); IWorkspace workspace = WorkspaceUtils.OpenWorkspace(workspaceName); ISpatialReference lv95 = SpatialReferenceUtils.CreateSpatialReference(WellKnownHorizontalCS.LV95); IFieldsEdit fieldsReference = new FieldsClass(); fieldsReference.AddField(FieldUtils.CreateOIDField()); fieldsReference.AddField( FieldUtils.CreateShapeField(esriGeometryType.esriGeometryPolyline, lv95)); edgeClass = DatasetUtils.CreateSimpleFeatureClass( (IFeatureWorkspace)workspace, "Edges", string.Empty, FieldUtils.CreateOIDField(), FieldUtils.CreateShapeField(esriGeometryType.esriGeometryPolyline, lv95)); junctionClass = DatasetUtils.CreateSimpleFeatureClass( (IFeatureWorkspace)workspace, "Junctions", string.Empty, FieldUtils.CreateOIDField(), FieldUtils.CreateShapeField(esriGeometryType.esriGeometryPoint, lv95)); List <LinearNetworkClassDef> networkClassDefinitions = new List <LinearNetworkClassDef> { new LinearNetworkClassDef(edgeClass), new LinearNetworkClassDef(junctionClass) }; LinearNetworkGdbFeatureFinder featureFinder = new LinearNetworkGdbFeatureFinder(networkClassDefinitions); return(featureFinder); }
private static IFeatureClass CreateLineClass([NotNull] IFeatureWorkspace ws, [NotNull] string name) { IFieldsEdit fields = new FieldsClass(); fields.AddField(FieldUtils.CreateOIDField()); fields.AddField(FieldUtils.CreateShapeField( "Shape", esriGeometryType.esriGeometryPolyline, SpatialReferenceUtils.CreateSpatialReference ((int)esriSRProjCS2Type.esriSRProjCS_CH1903Plus_LV95, true), 1000, true, false)); return(DatasetUtils.CreateSimpleFeatureClass(ws, name, fields)); }
public void TestMultipart() { IFeatureWorkspace ws = TestWorkspaceUtils.CreateInMemoryWorkspace("Testmultipart"); IFieldsEdit fields = new FieldsClass(); fields.AddField(FieldUtils.CreateOIDField()); fields.AddField(FieldUtils.CreateIntegerField("LineTyp", "LineTyp")); fields.AddField(FieldUtils.CreateShapeField( "Shape", esriGeometryType.esriGeometryPolyline, SpatialReferenceUtils.CreateSpatialReference ((int)esriSRProjCS2Type.esriSRProjCS_CH1903Plus_LV95, true), 1000, false, false)); IFeatureClass fc = DatasetUtils.CreateSimpleFeatureClass(ws, "TestConnections", fields, null); IList <ITable> tbls = new[] { (ITable)fc }; { IFeature row = fc.CreateFeature(); row.set_Value(1, 1); row.Shape = CurveConstruction.StartLine(1, 1).LineTo(2, 2).MoveTo(3, 2).LineTo(4, 2).Curve; row.Store(); } { IFeature row = fc.CreateFeature(); row.set_Value(1, 2); row.Shape = CurveConstruction.StartLine(1, 5).LineTo(2, 2).Curve; row.Store(); } IList <QaConnectionRule> rules = new List <QaConnectionRule> { new QaConnectionRule(tbls, new[] { "LineTyp = 1" }), new QaConnectionRule(tbls, new[] { "LineTyp = 2" }) }; var test = new QaConnections(new[] { fc }, rules, 0); test.UseMultiParts = false; var runner = new QaContainerTestRunner(1000, test); Assert.AreEqual(0, runner.Execute()); test.UseMultiParts = true; runner = new QaContainerTestRunner(1000, test); Assert.AreEqual(1, runner.Execute()); }
private IFeatureClass CreateFeatureClass([NotNull] string name, esriGeometryType geometryType) { IFieldsEdit fields = new FieldsClass(); fields.AddField(FieldUtils.CreateOIDField()); fields.AddField(FieldUtils.CreateShapeField( "Shape", geometryType, _spatialReference, 1000)); fields.AddField(FieldUtils.CreateTextField(_textFieldName, 200)); return(DatasetUtils.CreateSimpleFeatureClass( _testWs, name, fields)); }
/* * Called each time the user changes a parameter in the tool dialog or Command Line. * This updates the output data of the tool, which extremely useful for building models. * After returning from UpdateParameters(), geoprocessing calls its internal validation routine checkng that a given set of parameter values * are of the appropriate number, DataType, and value. * This method will update the output parameter value with the unique field. */ public void UpdateParameters(IArray paramvalues, IGPEnvironmentManager pEnvMgr) { m_Parameters = paramvalues; // Retrieve the input parameter value IGPValue parameterValue = m_GPUtilities.UnpackGPValue(m_Parameters.get_Element(0)); // Retrieve the unique field parameter value IGPParameter3 fieldNameParameter = (IGPParameter3)paramvalues.get_Element(3); // Get the output feature class schema and empty the additional fields. This will ensure // you don't get dublicate entries. IGPParameter3 outputFeatures = (IGPParameter3)paramvalues.get_Element(2); IGPFeatureSchema schema = (IGPFeatureSchema)outputFeatures.Schema; schema.AdditionalFields = null; // If we have an unique field value, create a new field based on the unique field name the user entered. if (fieldNameParameter.Value.IsEmpty() == false) { string fieldName = fieldNameParameter.Value.GetAsText(); IField uniqueField = m_GPUtilities.FindField(parameterValue, fieldName); IFieldsEdit fieldsEdit = new FieldsClass(); fieldsEdit.AddField(uniqueField); IFields fields = fieldsEdit as IFields; schema.AdditionalFields = fields; } }
// This method will update the output parameter value with the additional area field. public void UpdateParameters(IArray paramvalues, IGPEnvironmentManager pEnvMgr) { m_Parameters = paramvalues; // Retrieve the input parameter value IGPValue parameterValue = m_GPUtilities.UnpackGPValue(m_Parameters.get_Element(0)); // Get the derived output feature class schema and empty the additional fields. This will ensure you don't get duplicate entries. IGPParameter3 derivedFeatures = (IGPParameter3)paramvalues.get_Element(2); IGPFeatureSchema schema = (IGPFeatureSchema)derivedFeatures.Schema; schema.AdditionalFields = null; // If we have an input value, create a new field based on the field name the user entered. if (parameterValue.IsEmpty() == false) { IGPParameter3 fieldNameParameter = (IGPParameter3)paramvalues.get_Element(1); string fieldName = fieldNameParameter.Value.GetAsText(); // Check if the user's input field already exists IField areaField = m_GPUtilities.FindField(parameterValue, fieldName); if (areaField == null) { IFieldsEdit fieldsEdit = new FieldsClass(); IFieldEdit fieldEdit = new FieldClass(); fieldEdit.Name_2 = fieldName; fieldEdit.Type_2 = esriFieldType.esriFieldTypeDouble; fieldsEdit.AddField(fieldEdit); // Add an additional field for the area values to the derived output. IFields fields = fieldsEdit as IFields; schema.AdditionalFields = fields; } } }
private void CreateDatasetTable() { if (_workspace == null) { Connect(); } IFieldsEdit fieldsEdit = new FieldsClass(); IField pField = FieldHelper.CreateOIDField(); fieldsEdit.AddField(pField); IFieldEdit pFieldEdit = new FieldClass(); pFieldEdit.Name_2 = "Dataset"; pFieldEdit.Length_2 = 255; pFieldEdit.AliasName_2 = "数据集名称"; pFieldEdit.IsNullable_2 = false; pFieldEdit.Type_2 = esriFieldType.esriFieldTypeString; fieldsEdit.AddField(pFieldEdit); pFieldEdit = new FieldClass(); pFieldEdit.Name_2 = "BaseName"; pFieldEdit.Length_2 = 255; pFieldEdit.AliasName_2 = "基本名称"; pFieldEdit.IsNullable_2 = false; pFieldEdit.Type_2 = esriFieldType.esriFieldTypeString; fieldsEdit.AddField(pFieldEdit); pFieldEdit = new FieldClass(); pFieldEdit.Name_2 = "AliasName"; pFieldEdit.Length_2 = 255; pFieldEdit.AliasName_2 = "别名"; pFieldEdit.IsNullable_2 = true; pFieldEdit.Type_2 = esriFieldType.esriFieldTypeString; fieldsEdit.AddField(pFieldEdit); IObjectClassDescription ocDescription = new ObjectClassDescriptionClass(); _workspace.CreateTable("YT_TEMPLATE_DATASET", (IFields)fieldsEdit, ocDescription.InstanceCLSID, null, ""); return; }
private void CreateDomainTable() { if (_workspace == null) { Connect(); } IFieldsEdit fieldsEdit = new FieldsClass(); IField pField = FieldHelper.CreateOIDField(); fieldsEdit.AddField(pField); IFieldEdit pFieldEdit = new FieldClass(); pFieldEdit.Name_2 = "DomainName"; pFieldEdit.Length_2 = 255; pFieldEdit.AliasName_2 = "字典名称"; pFieldEdit.IsNullable_2 = false; pFieldEdit.Type_2 = esriFieldType.esriFieldTypeString; fieldsEdit.AddField(pFieldEdit); pFieldEdit = new FieldClass(); pFieldEdit.Name_2 = "DomainDescription"; pFieldEdit.Length_2 = 255; pFieldEdit.AliasName_2 = "字典说明"; pFieldEdit.IsNullable_2 = false; pFieldEdit.Type_2 = esriFieldType.esriFieldTypeString; fieldsEdit.AddField(pFieldEdit); pFieldEdit = new FieldClass(); pFieldEdit.Name_2 = "DomainValues"; pFieldEdit.Length_2 = 2147483647; pFieldEdit.AliasName_2 = "别名"; pFieldEdit.IsNullable_2 = true; pFieldEdit.Type_2 = esriFieldType.esriFieldTypeString; fieldsEdit.AddField(pFieldEdit); IObjectClassDescription ocDescription = new ObjectClassDescriptionClass(); _workspace.CreateTable("YT_TEMPLATE_DOMAIN", (IFields)fieldsEdit, ocDescription.InstanceCLSID, null, ""); return; }
public void TestExcludedFields() { IFeatureWorkspace initTestWs = _testWs; try { _testWs = TestWorkspaceUtils.CreateInMemoryWorkspace("QaRegularExpression"); IFieldsEdit fields = new FieldsClass(); fields.AddField(FieldUtils.CreateOIDField()); fields.AddField(FieldUtils.CreateIntegerField(_fkFieldName)); fields.AddField(FieldUtils.CreateTextField(_textFieldName, 200)); fields.AddField(FieldUtils.CreateTextField(_textFieldName2, 200)); const string tableName = "RegEx_table_excluded"; ITable table = TestWorkspaceUtils.CreateSimpleTable(_testWs, tableName, fields); ((IWorkspaceEdit)_testWs).StartEditing(false); AddRow(table, textFieldValue: "A", textFieldValue2: "X"); AddRow(table, textFieldValue: "B", textFieldValue2: "X"); AddRow(table, textFieldValue: "A", textFieldValue2: "X"); ((IWorkspaceEdit)_testWs).StopEditing(true); var test = new QaRegularExpression(table, "A", _textFieldName2) { FieldListType = FieldListType.IgnoredFields }; IList <QaError> errors = Run(test, 1000); AssertErrors(1, errors); IList <InvolvedRow> involvedRows = errors[0].InvolvedRows; Assert.AreEqual(1, involvedRows.Count); Assert.AreEqual($"{_textFieldName}", errors[0].AffectedComponent); Assert.AreEqual("RegularExpression.FieldValueDoesNotMatchRegularExpression", errors[0].IssueCode?.ID); } finally { _testWs = initTestWs; } }
/// <summary> /// this makes a copy of the fields that are inputted. /// if an x / y field is included, those are added as well /// </summary> /// <param name="pFlds">the fields to copy</param> /// <param name="sXFieldName">the name of the x field</param> /// <param name="sYFieldName">the name of the y field</param> /// <returns>IFields - the new fields collection</returns> /// <notes> /// Modified from Kirk Kuykendall's code from this post /// http://forums.esri.com/Thread.asp?c=93&f=993&t=210767&mc=12#msgid652601 /// </notes> /// <changelog> /// /// comments created. /// /// </changelog> private IFields copyFields(IFields pFlds, string sXFieldName, string sYFieldName) { IFieldsEdit pFldsEdit = new FieldsClass(); for (int i = 0; i < pFlds.FieldCount; i++) { char[] period = { '.' }; string[] v = pFlds.get_Field(i).Name.Split(period); IFieldEdit pFldEdit = (IFieldEdit)this.clone(pFlds.get_Field(i) as IClone); pFldEdit.Name_2 = v[v.GetUpperBound(0)].ToString(); pFldsEdit.AddField((IField)pFldEdit); } if (sXFieldName.Length > 0) { IField pFieldX = new FieldClass(); IFieldEdit pFieldEditX = (IFieldEdit)pFieldX; pFieldEditX.AliasName_2 = sXFieldName; pFieldEditX.Name_2 = sXFieldName; pFieldEditX.Type_2 = esriFieldType.esriFieldTypeDouble; pFieldEditX.Editable_2 = true; pFieldEditX.IsNullable_2 = true; pFldsEdit.AddField((IField)pFieldEditX); } if (sYFieldName.Length > 0) { IField pFieldY = new FieldClass(); IFieldEdit pFieldEditY = (IFieldEdit)pFieldY; pFieldEditY.AliasName_2 = sYFieldName; pFieldEditY.Name_2 = sYFieldName; pFieldEditY.Type_2 = esriFieldType.esriFieldTypeDouble; pFieldEditY.Editable_2 = true; pFieldEditY.IsNullable_2 = true; pFldsEdit.AddField((IField)pFieldEditY); } return(pFldsEdit); }
private void CreateTestFeatureClasses( string polygonsName, string pointsName, [NotNull] out IFeatureClass polygonFeatureClass, [NotNull] out IFeatureClass pointFeatureClass, IFeatureWorkspace ws = null, bool polygonAsClosedLines = false) { ws = ws ?? _testWs; ISpatialReference sref = SpatialReferenceUtils.CreateSpatialReference ((int)esriSRProjCS2Type.esriSRProjCS_CH1903Plus_LV95, true); var geomType = polygonAsClosedLines ? esriGeometryType.esriGeometryPolyline : esriGeometryType.esriGeometryPolygon; IFieldsEdit polygonFields = new FieldsClass(); polygonFields.AddField(FieldUtils.CreateOIDField()); polygonFields.AddField(FieldUtils.CreateShapeField( "Shape", geomType, sref, 1000, false, false)); polygonFeatureClass = DatasetUtils.CreateSimpleFeatureClass(ws, polygonsName, polygonFields, null); IFieldsEdit pointFields = new FieldsClass(); pointFields.AddField(FieldUtils.CreateOIDField()); pointFields.AddField(FieldUtils.CreateShapeField( "Shape", esriGeometryType.esriGeometryPoint, sref, 1000, false, false)); pointFeatureClass = DatasetUtils.CreateSimpleFeatureClass(ws, pointsName, pointFields, null); // make sure the table is known by the workspace ((IWorkspaceEdit)ws).StartEditing(false); ((IWorkspaceEdit)ws).StopEditing(true); }
/// <summary> /// 克隆 /// </summary> /// <param name="fields"></param> /// <param name="filter"></param> /// <returns></returns> public static IFields Clone(this IFields fields, bool filter = true) { IFields newFields = new FieldsClass(); for (int i = 0, l = fields.FieldCount; i < l; i++) { IField field = fields.Field[i].Clone(); newFields.AddField(field); } return(newFields); }
public static IFields CreateFields(TableInfo tInfo) { if (tInfo == null || tInfo.FieldsInfo == null || tInfo.FieldsInfo.Count == 0) return null; IFieldsEdit fields=new FieldsClass(); foreach (FieldInfo fInfo in tInfo.FieldsInfo) { fields.AddField(CreateField(fInfo)); } return fields; }
public static IFields CreateFields([NotNull] IEnumerable <IField> fields) { Assert.ArgumentNotNull(fields, nameof(fields)); IFieldsEdit result = new FieldsClass(); foreach (IField field in fields) { result.AddField(field); } return(result); }
private static IFeatureClass CreateFeatureClass( IFeatureWorkspace ws, string fcName) { IFieldsEdit fields = new FieldsClass(); fields.AddField(FieldUtils.CreateOIDField()); fields.AddField(FieldUtils.CreateShapeField( "Shape", esriGeometryType.esriGeometryMultiPatch, SpatialReferenceUtils.CreateSpatialReference ((int)esriSRProjCS2Type.esriSRProjCS_CH1903Plus_LV95, true), 1000, true, false)); IFeatureClass fc = DatasetUtils.CreateSimpleFeatureClass(ws, fcName, fields, null); // make sure the table is known by the workspace ((IWorkspaceEdit)ws).StartEditing(false); ((IWorkspaceEdit)ws).StopEditing(true); ((IWorkspaceEdit)ws).StartEditing(false); return(fc); }
private static IFeatureClass CreateLineClass([NotNull] IFeatureWorkspace ws) { IFieldsEdit fields = new FieldsClass(); fields.AddField(FieldUtils.CreateOIDField()); fields.AddField(FieldUtils.CreateIntegerField(_nrFieldName)); fields.AddField(FieldUtils.CreateShapeField( "Shape", esriGeometryType.esriGeometryPolyline, SpatialReferenceUtils.CreateSpatialReference ((int)esriSRProjCS2Type.esriSRProjCS_CH1903Plus_LV95, true), 1000, false, false)); Thread.Sleep(10); IFeatureClass featureClass = DatasetUtils.CreateSimpleFeatureClass( ws, "line_" + Environment.TickCount, fields, null); // make sure the table is known by the workspace ((IWorkspaceEdit)ws).StartEditing(false); ((IWorkspaceEdit)ws).StopEditing(true); return(featureClass); }
public void UpdateParameters(ESRI.ArcGIS.esriSystem.IArray paramvalues, ESRI.ArcGIS.Geoprocessing.IGPEnvironmentManager pEnvMgr) { IGPUtilities3 gpUtilities3 = new GPUtilitiesClass(); IGPParameter targetDatasetParameter = paramvalues.get_Element(out_targetDatasetNumber) as IGPParameter; IGPValue targetDatasetGPValue = gpUtilities3.UnpackGPValue(targetDatasetParameter); IDEFeatureDataset targetDEFeatureDataset = targetDatasetGPValue as IDEFeatureDataset; IGPParameter3 outPointsFeatureClassParameter = null; IGPValue outPointsFeatureClass = null; string outpointsPath = String.Empty; IGPParameter3 outLinesFeatureClassParameter = null; IGPValue outLinesFeatureClass = null; string outlinesPath = String.Empty; IGPParameter3 outPolygonFeatureClassParameter = null; IGPValue outPolygonFeatureClass = null; string outpolygonsPath = String.Empty; if (((IGPValue)targetDEFeatureDataset).GetAsText().Length != 0) { IDataElement dataElement = targetDEFeatureDataset as IDataElement; try { gpUtilities3.QualifyOutputDataElement(gpUtilities3.UnpackGPValue(targetDatasetParameter)); } catch { return; } string nameOfPointFeatureClass = dataElement.GetBaseName() + "_osm_pt"; string nameOfLineFeatureClass = dataElement.GetBaseName() + "_osm_ln"; string nameOfPolygonFeatureClass = dataElement.GetBaseName() + "_osm_ply"; try { outpointsPath = dataElement.CatalogPath + System.IO.Path.DirectorySeparatorChar + nameOfPointFeatureClass; } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } outPointsFeatureClassParameter = paramvalues.get_Element(out_osmPointsNumber) as IGPParameter3; outPointsFeatureClass = gpUtilities3.UnpackGPValue(outPointsFeatureClassParameter); outlinesPath = dataElement.CatalogPath + System.IO.Path.DirectorySeparatorChar + nameOfLineFeatureClass; outLinesFeatureClassParameter = paramvalues.get_Element(out_osmLinesNumber) as IGPParameter3; outLinesFeatureClass = gpUtilities3.UnpackGPValue(outLinesFeatureClassParameter); outpolygonsPath = dataElement.CatalogPath + System.IO.Path.DirectorySeparatorChar + nameOfPolygonFeatureClass; outPolygonFeatureClassParameter = paramvalues.get_Element(out_osmPolygonsNumber) as IGPParameter3; outPolygonFeatureClass = gpUtilities3.UnpackGPValue(outPolygonFeatureClassParameter); } // TE - 10/20/2014 if (((IGPParameter)paramvalues.get_Element(in_attributeSelector)).Altered) { IGPParameter tagCollectionParameter = paramvalues.get_Element(in_attributeSelector) as IGPParameter; IGPMultiValue tagCollectionGPValue = gpUtilities3.UnpackGPValue(tagCollectionParameter) as IGPMultiValue; IGPCodedValueDomain codedTagDomain = tagCollectionParameter.Domain as IGPCodedValueDomain; for (int attributeValueIndex = 0; attributeValueIndex < tagCollectionGPValue.Count; attributeValueIndex++) { string valueString = tagCollectionGPValue.get_Value(attributeValueIndex).GetAsText(); IGPValue testFieldValue = codedTagDomain.FindValue(valueString); if (testFieldValue == null) { codedTagDomain.AddStringCode(valueString, valueString); } } string illegalCharacters = "`~@#$%^&()-+=,{}.![];"; IFieldsEdit fieldsEdit = new FieldsClass(); for (int valueIndex = 0; valueIndex < tagCollectionGPValue.Count; valueIndex++) { string tagString = tagCollectionGPValue.get_Value(valueIndex).GetAsText(); if (tagString != "ALL") { // Check if the input field already exists. string cleanedTagKey = OSMToolHelper.convert2AttributeFieldName(tagString, illegalCharacters); IFieldEdit fieldEdit = new FieldClass(); fieldEdit.Name_2 = cleanedTagKey; fieldEdit.AliasName_2 = tagCollectionGPValue.get_Value(valueIndex).GetAsText(); fieldEdit.Type_2 = esriFieldType.esriFieldTypeString; fieldEdit.Length_2 = 100; fieldsEdit.AddField(fieldEdit); } } IFields fields = fieldsEdit as IFields; // Get the derived output feature class schema and empty the additional fields. This ensures // that you don't get dublicate entries. if (outPointsFeatureClassParameter != null) { IGPFeatureSchema polySchema = outPolygonFeatureClassParameter.Schema as IGPFeatureSchema; if (polySchema != null) { // Add the additional field to the polygon output. polySchema.AdditionalFields = fields; } else { polySchema = new GPFeatureSchemaClass(); polySchema.AdditionalFields = fields; polySchema.GeometryType = esriGeometryType.esriGeometryPolygon; polySchema.FeatureType = esriFeatureType.esriFTSimple; } } if (outLinesFeatureClassParameter != null) { IGPFeatureSchema lineSchema = outLinesFeatureClassParameter.Schema as IGPFeatureSchema; if (lineSchema != null) { // Add the additional field to the line output. lineSchema.AdditionalFields = fields; } else { lineSchema = new GPFeatureSchemaClass(); lineSchema.AdditionalFields = fields; lineSchema.GeometryType = esriGeometryType.esriGeometryPolyline; lineSchema.FeatureType = esriFeatureType.esriFTSimple; } } if (outPointsFeatureClassParameter != null) { IGPFeatureSchema pointSchema = outPointsFeatureClassParameter.Schema as IGPFeatureSchema; if (pointSchema != null) { // Add the additional field to the point output. pointSchema.AdditionalFields = fields; } else { pointSchema = new GPFeatureSchemaClass(); pointSchema.AdditionalFields = fields; pointSchema.GeometryType = esriGeometryType.esriGeometryPoint; pointSchema.FeatureType = esriFeatureType.esriFTSimple; } } } if (outPointsFeatureClassParameter != null) { outPointsFeatureClass.SetAsText(outpointsPath); gpUtilities3.PackGPValue(outPointsFeatureClass, outPointsFeatureClassParameter); } if (outLinesFeatureClassParameter != null) { outLinesFeatureClass.SetAsText(outlinesPath); gpUtilities3.PackGPValue(outLinesFeatureClass, outLinesFeatureClassParameter); } if (outPolygonFeatureClassParameter != null) { outPolygonFeatureClass.SetAsText(outpolygonsPath); gpUtilities3.PackGPValue(outPolygonFeatureClass, outPolygonFeatureClassParameter); } gpUtilities3.ReleaseInternals(); if (gpUtilities3 != null) ComReleaser.ReleaseCOMObject(gpUtilities3); }
/// <summary> /// Validates a field name /// </summary> /// <param name="name">The field name to validate</param> /// <param name="message">If field name fails then this variable will contain a description</param> /// <returns>True if passed. False if failed.</returns> public bool ValidateFieldName(string name, out string message) { // Validate Input Arguments if (string.IsNullOrEmpty(name)) { throw new NullReferenceException("<name> argument cannot be null"); } // Create Field Checker IFieldChecker fieldChecker = new FieldCheckerClass(); fieldChecker.ValidateWorkspace = this._workspace; // Create Field IFieldEdit fieldEdit = new FieldClass(); fieldEdit.Name_2 = name; fieldEdit.Type_2 = esriFieldType.esriFieldTypeInteger; // Create Fields IFieldsEdit fieldsEdit = new FieldsClass(); fieldsEdit.AddField((IField)fieldEdit); // Create Field Error Enumerator IEnumFieldError enumFieldError = null; IFields fieldsFixed = null; // Validate Field Name fieldChecker.ValidateField(0, (IFields)fieldsEdit, out enumFieldError, out fieldsFixed); // Get Validated Name (if any) string newName = null; if (fieldsFixed != null) { IField fieldFixed = fieldsFixed.get_Field(0); newName = fieldFixed.Name; } // Get Errors (if any) if (enumFieldError != null) { enumFieldError.Reset(); IFieldError fieldError = enumFieldError.Next(); if (fieldError != null) { switch (fieldError.FieldError) { case esriFieldNameErrorType.esriDuplicatedFieldName: message = "is duplicated"; return false; case esriFieldNameErrorType.esriInvalidCharacter: message = "contains one or more invalid characters"; return false; case esriFieldNameErrorType.esriInvalidFieldNameLength: message = "is too long"; return false; case esriFieldNameErrorType.esriNoFieldError: message = "has no field error"; return false; case esriFieldNameErrorType.esriSQLReservedWord: message = "contains one or more reserved word"; return false; default: message = "contains an unknown error"; return false; } } } // The FieldChecker may have renamed the field without returning an error. if (newName != null) { if (newName != name) { message = "has an invalid field name"; return false; } } // No Errors message = null; return true; }
public void UpdateParameters(ESRI.ArcGIS.esriSystem.IArray paramvalues, ESRI.ArcGIS.Geoprocessing.IGPEnvironmentManager pEnvMgr) { try { IGPUtilities3 gpUtilities3 = new GPUtilitiesClass(); IGPValue inputOSMGPValue = gpUtilities3.UnpackGPValue(paramvalues.get_Element(in_osmFeatureClass)); IFeatureClass osmFeatureClass = null; ITable osmInputTable = null; IQueryFilter osmQueryFilter = null; try { gpUtilities3.DecodeFeatureLayer(inputOSMGPValue, out osmFeatureClass, out osmQueryFilter); osmInputTable = osmFeatureClass as ITable; } catch { } try { if (osmInputTable == null) { gpUtilities3.DecodeTableView(inputOSMGPValue, out osmInputTable, out osmQueryFilter); } } catch { } if (osmInputTable == null) { return; } String illegalCharacters = String.Empty; ISQLSyntax sqlSyntax = ((IDataset)osmInputTable).Workspace as ISQLSyntax; if (sqlSyntax != null) { illegalCharacters = sqlSyntax.GetInvalidCharacters(); } // find the field that holds tag binary/xml field int osmTagCollectionFieldIndex = osmInputTable.FindField("osmTags"); // if the Field doesn't exist - wasn't found (index = -1) get out if (osmTagCollectionFieldIndex == -1) { return; } if (((IGPParameter)paramvalues.get_Element(in_attributeSelector)).Altered) { IGPParameter tagCollectionParameter = paramvalues.get_Element(in_attributeSelector) as IGPParameter; IGPMultiValue tagCollectionGPValue = gpUtilities3.UnpackGPValue(tagCollectionParameter) as IGPMultiValue; IGPCodedValueDomain codedTagDomain = tagCollectionParameter.Domain as IGPCodedValueDomain; for (int attributeValueIndex = 0; attributeValueIndex < tagCollectionGPValue.Count; attributeValueIndex++) { string valueString = tagCollectionGPValue.get_Value(attributeValueIndex).GetAsText(); IGPValue testFieldValue = codedTagDomain.FindValue(valueString); if (testFieldValue == null) { codedTagDomain.AddStringCode(valueString, valueString); } } // Get the derived output feature class schema and empty the additional fields. This ensures // that you don't get dublicate entries. // Derived output is the third parameter, so use index 2 for get_Element. IGPParameter3 derivedFeatures = (IGPParameter3)paramvalues.get_Element(out_osmFeatureClass); IGPFeatureSchema schema = (IGPFeatureSchema)derivedFeatures.Schema; schema.AdditionalFields = null; IFieldsEdit fieldsEdit = new FieldsClass(); for (int valueIndex = 0; valueIndex < tagCollectionGPValue.Count; valueIndex++) { string tagString = tagCollectionGPValue.get_Value(valueIndex).GetAsText(); if (tagString != "ALL") { // Check if the input field already exists. string cleanedTagKey = convert2AttributeFieldName(tagString, illegalCharacters); IField tagField = gpUtilities3.FindField(inputOSMGPValue, cleanedTagKey); if (tagField == null) { IFieldEdit fieldEdit = new FieldClass(); fieldEdit.Name_2 = cleanedTagKey; fieldEdit.AliasName_2 = tagCollectionGPValue.get_Value(valueIndex).GetAsText(); fieldEdit.Type_2 = esriFieldType.esriFieldTypeString; fieldEdit.Length_2 = 100; fieldsEdit.AddField(fieldEdit); } } } // Add the additional field to the derived output. IFields fields = fieldsEdit as IFields; schema.AdditionalFields = fields; } //if (inputOSMGPValue.IsEmpty() == false) //{ // if (((IGPParameter)paramvalues.get_Element(in_osmFeatureClass)).HasBeenValidated == false) // { // IGPParameter tagCollectionGPParameter = paramvalues.get_Element(in_attributeSelector) as IGPParameter; // IGPValue tagCollectionGPValue = gpUtilities3.UnpackGPValue(tagCollectionGPParameter); // IGPCodedValueDomain osmTagKeyCodedValues = new GPCodedValueDomainClass(); // if (((IGPMultiValue)tagCollectionGPValue).Count == 0) // { // if (osmTagKeyCodedValues == null) // extractAllTags(ref osmTagKeyCodedValues, osmInputTable, osmQueryFilter, osmTagCollectionFieldIndex, true); // if (osmTagKeyCodedValues != null) // { // tagsParameter = tagCollectionGPParameter as IGPParameterEdit; // tagsParameter.Domain = (IGPDomain)osmTagKeyCodedValues; // } // } // else // { // // let's take the given values and make then part of the domain -- if they are not already // // if we don't do this step then we won't pass the internal validation // IGPCodedValueDomain gpTagDomain = tagCollectionGPParameter.Domain as IGPCodedValueDomain; // if (gpTagDomain != null) // { // if (gpTagDomain.CodeCount == 0) // { // // let's add the value existing in the mentioned multi value to the domain // for (int i = 0; i < ((IGPMultiValue)tagCollectionGPValue).Count; i++) // { // string tagStringValue = ((IGPMultiValue)tagCollectionGPValue).get_Value(i).GetAsText(); // gpTagDomain.AddStringCode(tagStringValue, tagStringValue); // } // ((IGPParameterEdit)tagCollectionGPParameter).Domain = gpTagDomain as IGPDomain; // } // } // } // // Get the derived output feature class schema and empty the additional fields. This ensures // // that you don't get dublicate entries. // // Derived output is the third parameter, so use index 2 for get_Element. // IGPParameter3 derivedFeatures = (IGPParameter3)paramvalues.get_Element(out_osmFeatureClass); // IGPFeatureSchema schema = (IGPFeatureSchema)derivedFeatures.Schema; // schema.AdditionalFields = null; // // Area field name is the second parameter, so use index 1 for get_Element. // IGPMultiValue tagsGPMultiValue = gpUtilities3.UnpackGPValue(paramvalues.get_Element(in_attributeSelector)) as IGPMultiValue; // IFieldsEdit fieldsEdit = new FieldsClass(); // bool extractALLTags = false; // // check if the list contains the "ALL" keyword // for (int valueIndex = 0; valueIndex < tagsGPMultiValue.Count; valueIndex++) // { // if (tagsGPMultiValue.get_Value(valueIndex).GetAsText().Equals("ALL")) // { // extractALLTags = true; // } // } // if (extractALLTags) // { // if (osmTagKeyCodedValues == null) // { // extractAllTags(ref osmTagKeyCodedValues, osmInputTable, osmQueryFilter, osmTagCollectionFieldIndex, false); // } // if (osmTagKeyCodedValues != null) // { // for (int valueIndex = 0; valueIndex < osmTagKeyCodedValues.CodeCount; valueIndex++) // { // // Check if the input field already exists. // string cleanedTagKey = convert2AttributeFieldName(osmTagKeyCodedValues.get_Value(valueIndex).GetAsText(), illegalCharacters); // IField tagField = gpUtilities3.FindField(inputOSMGPValue, cleanedTagKey); // if (tagField == null) // { // IFieldEdit fieldEdit = new FieldClass(); // fieldEdit.Name_2 = cleanedTagKey; // fieldEdit.AliasName_2 = osmTagKeyCodedValues.get_Value(valueIndex).GetAsText(); // fieldEdit.Type_2 = esriFieldType.esriFieldTypeString; // fieldEdit.Length_2 = 100; // fieldsEdit.AddField(fieldEdit); // } // } // } // } // else // { // for (int valueIndex = 0; valueIndex < tagsGPMultiValue.Count; valueIndex++) // { // // Check if the input field already exists. // string cleanedTagKey = convert2AttributeFieldName(tagsGPMultiValue.get_Value(valueIndex).GetAsText(), illegalCharacters); // IField tagField = gpUtilities3.FindField(inputOSMGPValue, cleanedTagKey); // if (tagField == null) // { // IFieldEdit fieldEdit = new FieldClass(); // fieldEdit.Name_2 = cleanedTagKey; // fieldEdit.AliasName_2 = tagsGPMultiValue.get_Value(valueIndex).GetAsText(); // fieldEdit.Type_2 = esriFieldType.esriFieldTypeString; // fieldEdit.Length_2 = 100; // fieldsEdit.AddField(fieldEdit); // } // } // } // // Add the additional field to the derived output. // IFields fields = fieldsEdit as IFields; // schema.AdditionalFields = fields; // } //} } catch { } }
static void CopyAndLabel(IFeatureClass inFC, IFeatureWorkspace destination, String name) { IFieldsEdit outFields = new FieldsClass(); ISpatialReference outSR = null; for (int i = 0; i < inFC.Fields.FieldCount; i += 1) { IField field = inFC.Fields.get_Field(i); if (field.Type == esriFieldType.esriFieldTypeGeometry) { outSR = field.GeometryDef.SpatialReference; } else { outFields.AddField(field); } } outSR.SetMDomain(-137434824702, 137434824702); IGeometryDefEdit geom = new GeometryDefClass(); geom.GeometryType_2 = esriGeometryType.esriGeometryPolygon; geom.SpatialReference_2 = outSR; geom.HasM_2 = true; geom.HasZ_2 = false; IFieldEdit geomField = new FieldClass(); geomField.Name_2 = "SHAPE"; geomField.AliasName_2 = "SHAPE"; geomField.Type_2 = esriFieldType.esriFieldTypeGeometry; geomField.GeometryDef_2 = geom; outFields.AddField(geomField); IFeatureClass outFC = destination.CreateFeatureClass(name, outFields, null, null, esriFeatureType.esriFTSimple, "SHAPE", ""); // Start numbering from 1, because index 0 is used by clipping cell int vIndex = 1; IFeatureCursor featureCursor = inFC.Search(null, true); IFeature inFeature; while ((inFeature = featureCursor.NextFeature()) != null) { IFeature outFeature = outFC.CreateFeature(); for (int i = 0; i < outFields.FieldCount; i += 1) { IField field = outFields.Field[i]; if (field.Editable && (field.Type != esriFieldType.esriFieldTypeGeometry)) { outFeature.set_Value(i, inFeature.get_Value(i)); } } IPolygon4 inShape = inFeature.Shape as IPolygon4; PolygonClass outShape = new PolygonClass(); IGeometryBag extRingBag = inShape.ExteriorRingBag; IGeometryCollection extRings = extRingBag as IGeometryCollection; for (int i = 0; i < extRings.GeometryCount; i += 1) { IGeometry inExtRingGeom = extRings.get_Geometry(i); IPointCollection inExtRing = inExtRingGeom as IPointCollection; RingClass outExtRing = new RingClass(); for (int j = 0; j < inExtRing.PointCount; j += 1) { IPoint point = inExtRing.get_Point(j); point.M = vIndex; vIndex += 2; outExtRing.AddPoint(point); } outShape.AddGeometry(outExtRing); IGeometryBag intRingBag = inShape.get_InteriorRingBag(inExtRingGeom as IRing); IGeometryCollection intRings = intRingBag as IGeometryCollection; for (int j = 0; j < intRings.GeometryCount; j += 1) { IGeometry intRingGeom = intRings.get_Geometry(j); IPointCollection inIntRing = intRingGeom as IPointCollection; RingClass outIntRing = new RingClass(); for (int k = 0; k < inIntRing.PointCount; k += 1) { IPoint point = inExtRing.get_Point(k); point.M = vIndex; vIndex += 2; outIntRing.AddPoint(point); } outShape.AddGeometry(outIntRing); } } outFeature.Shape = outShape; outFeature.Store(); } }
// This method will update the output parameter value with the additional area field. public void UpdateParameters(IArray paramvalues, IGPEnvironmentManager pEnvMgr) { m_Parameters = paramvalues; IGPMultiValue inputValues = (IGPMultiValue)m_GPUtilities.UnpackGPValue(m_Parameters.get_Element(0)); // Get the derived output feature class schema and empty the additional fields. This will ensure you don't get duplicate entries. IGPParameter3 derivedFeatures = (IGPParameter3)paramvalues.get_Element(1); IGPValue derivedValue = m_GPUtilities.UnpackGPValue(derivedFeatures); IGPFeatureSchema schema = (IGPFeatureSchema)derivedFeatures.Schema; schema.AdditionalFields = null; // If we have an input value, create a new field based on the field name the user entered. if (!derivedValue.IsEmpty() && inputValues.Count > 0) { IFields inputFields = m_GPUtilities.GetFields(inputValues.get_Value(0)); IField shapeField = null; for(int i = 0; i < inputFields.FieldCount; i++) { if (inputFields.get_Field(i).Type == esriFieldType.esriFieldTypeGeometry) { shapeField = inputFields.get_Field(i); break; } } IFields fields = new FieldsClass(); fields.AddField("ObjectID", esriFieldType.esriFieldTypeOID); fields.AddField(FEATURE_SOURCE_FIELD_NAME, esriFieldType.esriFieldTypeString); fields.AddField(FEATURE_ID_FIELD_NAME, esriFieldType.esriFieldTypeInteger); fields.AddField(shapeField); schema.AdditionalFields = fields; } }
private ITable CreateArcTable(DataTable dt, bool regionIsInt) { IWorkspaceFactory workspaceFactory = new InMemoryWorkspaceFactoryClass(); IWorkspaceName workspaceName = workspaceFactory.Create("", "MyWorkspace", null, 0); IName name = (IName)workspaceName; IFeatureWorkspace workspace = (IFeatureWorkspace)name.Open(); IFieldsEdit fe; fe = new FieldsClass(); IField oid, key, measure; oid = createField("ObjectId", esriFieldType.esriFieldTypeOID); if (regionIsInt) { key = createField("Region", esriFieldType.esriFieldTypeInteger); } else { key = createField("Region", esriFieldType.esriFieldTypeString); } measure = createField("Measure", esriFieldType.esriFieldTypeDouble); fe.AddField(oid); fe.AddField(key); fe.AddField(measure); UID clsid = new UIDClass(); clsid.Value = "esriGeoDatabase.Object"; ITable table = workspace.CreateTable("joinedTable", (IFields)fe, clsid, null, null); IRowBuffer rowBuffer = table.CreateRowBuffer(); ICursor cursor = table.Insert(true); foreach (DataRow dr in dt.Rows) { /*Set the Region and the Measure fields The dataTable has 2 columns and the ArcTable has 3 columns. The first column in the OID field which is generated internally by the ArcGIS engine.*/ for (int x = 1; x <= dt.Columns.Count; x++) { rowBuffer.set_Value(x, dr[x-1]); } cursor.InsertRow(rowBuffer); } cursor.Flush(); return table; }
/// <summary> /// This initialises all of the different fields that are required for the locator to function /// It contains declarations for the Match and Candidate fields for the locator /// </summary> protected override void CreateFields() { IFieldsEdit fieldsEdit = new FieldsClass(); IFieldEdit shapeField = new FieldClass(); IFieldEdit statusField = new FieldClass(); IFieldEdit scoreField = new FieldClass(); IFieldEdit xField = new FieldClass(); IFieldEdit yField = new FieldClass(); IFieldEdit matchField = new FieldClass(); m_spatialReference = new SpatialReferenceEnvironmentClass().CreateProjectedCoordinateSystem((int)esriSRProjCSType.esriSRProjCS_BritishNationalGrid); SearchDistanceUnits = esriUnits.esriMeters; // Set up the spatial Reference and Geometry Definition IGeometryDefEdit geometryDefEdit = new GeometryDefClass(); geometryDefEdit.SpatialReference_2 = m_spatialReference; geometryDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPoint; // Create the matchFields shapeField.Name_2 = "Shape"; shapeField.Type_2 = esriFieldType.esriFieldTypeGeometry; shapeField.GeometryDef_2 = geometryDefEdit as IGeometryDef; fieldsEdit.AddField(shapeField); statusField.Name_2 = "Status"; statusField.Type_2 = esriFieldType.esriFieldTypeString; statusField.Length_2 = 1; fieldsEdit.AddField(statusField); scoreField.Name_2 = "Score"; scoreField.Type_2 = esriFieldType.esriFieldTypeSmallInteger; fieldsEdit.AddField(scoreField); matchField.Name_2 = "Match_addr"; matchField.Type_2 = esriFieldType.esriFieldTypeString; matchField.Length_2 = 50; fieldsEdit.AddField(matchField); xField.Name_2 = "X"; xField.Type_2 = esriFieldType.esriFieldTypeDouble; xField.Length_2 = 16; xField.Precision_2 = 10; fieldsEdit.AddField(xField); yField.Name_2 = "Y"; yField.Type_2 = esriFieldType.esriFieldTypeDouble; yField.Length_2 = 16; yField.Precision_2 = 10; fieldsEdit.AddField(yField); IFieldEdit XMinField = new FieldClass(); IFieldEdit YMinField = new FieldClass(); IFieldEdit XMaxField = new FieldClass(); IFieldEdit YMaxField = new FieldClass(); IFieldEdit addrType = new FieldClass(); XMinField.Name_2 = "XMin"; YMinField.Name_2 = "YMin"; XMaxField.Name_2 = "XMax"; YMaxField.Name_2 = "YMax"; addrType.Name_2 = "Addr_type"; XMinField.Type_2 = esriFieldType.esriFieldTypeDouble; YMinField.Type_2 = esriFieldType.esriFieldTypeDouble; XMaxField.Type_2 = esriFieldType.esriFieldTypeDouble; YMaxField.Type_2 = esriFieldType.esriFieldTypeDouble; addrType.Type_2 = esriFieldType.esriFieldTypeString; XMinField.Precision_2 = 8; YMinField.Precision_2 = 8; XMaxField.Precision_2 = 8; YMaxField.Precision_2 = 8; addrType.Length_2 = 20; fieldsEdit.AddField(XMinField); fieldsEdit.AddField(YMinField); fieldsEdit.AddField(XMaxField); fieldsEdit.AddField(YMaxField); fieldsEdit.AddField(addrType); m_matchFields = fieldsEdit as IFields; fieldsEdit = new FieldsClass(); shapeField = new FieldClass(); scoreField = new FieldClass(); xField = new FieldClass(); yField = new FieldClass(); matchField = new FieldClass(); // Create the CandidateFields shapeField.Name_2 = "Shape"; shapeField.Type_2 = esriFieldType.esriFieldTypeGeometry; shapeField.GeometryDef_2 = geometryDefEdit as GeometryDef; fieldsEdit.AddField(shapeField); scoreField.Name_2 = "Score"; scoreField.Type_2 = esriFieldType.esriFieldTypeSmallInteger; fieldsEdit.AddField(scoreField); matchField.Name_2 = "Match_addr"; matchField.Type_2 = esriFieldType.esriFieldTypeString; matchField.Length_2 = 50; fieldsEdit.AddField(matchField); xField.Name_2 = "X"; xField.Type_2 = esriFieldType.esriFieldTypeDouble; xField.Length_2 = 16; xField.Precision_2 = 10; fieldsEdit.AddField(xField); yField.Name_2 = "Y"; yField.Type_2 = esriFieldType.esriFieldTypeDouble; yField.Length_2 = 16; yField.Precision_2 = 10; fieldsEdit.AddField(yField); fieldsEdit.AddField(XMinField); fieldsEdit.AddField(YMinField); fieldsEdit.AddField(XMaxField); fieldsEdit.AddField(YMaxField); fieldsEdit.AddField(addrType); m_candidateFields = fieldsEdit as IFields; }
/// <summary> /// Create the point feature class for observer locations /// </summary> /// <param name="featWorkspace"></param> /// <param name="name"></param> /// <returns></returns> public static IFeatureClass CreateObserversFeatureClass(IFeatureWorkspace featWorkspace, string name) { IFieldsEdit pFldsEdt = new FieldsClass(); IFieldEdit pFldEdt = new FieldClass(); pFldEdt = new FieldClass(); pFldEdt.Type_2 = esriFieldType.esriFieldTypeOID; pFldEdt.Name_2 = "OBJECTID"; pFldEdt.AliasName_2 = "OBJECTID"; pFldsEdt.AddField(pFldEdt); IGeometryDefEdit pGeoDef; pGeoDef = new GeometryDefClass(); pGeoDef.GeometryType_2 = esriGeometryType.esriGeometryPoint; pGeoDef.SpatialReference_2 = ArcMap.Document.FocusMap.SpatialReference; pGeoDef.HasZ_2 = true; pFldEdt = new FieldClass(); pFldEdt.Name_2 = "SHAPE"; pFldEdt.AliasName_2 = "SHAPE"; pFldEdt.Type_2 = esriFieldType.esriFieldTypeGeometry; pFldEdt.GeometryDef_2 = pGeoDef; pFldsEdt.AddField(pFldEdt); pFldEdt = new FieldClass(); pFldEdt.Name_2 = "OFFSETA"; pFldEdt.AliasName_2 = "OFFSETA"; pFldEdt.Type_2 = esriFieldType.esriFieldTypeDouble; pFldsEdt.AddField(pFldEdt); pFldEdt = new FieldClass(); pFldEdt.Name_2 = "OFFSETB"; pFldEdt.AliasName_2 = "OFFSETB"; pFldEdt.Type_2 = esriFieldType.esriFieldTypeDouble; pFldsEdt.AddField(pFldEdt); pFldEdt = new FieldClass(); pFldEdt.Name_2 = "AZIMUTH1"; pFldEdt.AliasName_2 = "AZIMUTH1"; pFldEdt.Type_2 = esriFieldType.esriFieldTypeDouble; pFldsEdt.AddField(pFldEdt); pFldEdt = new FieldClass(); pFldEdt.Name_2 = "AZIMUTH2"; pFldEdt.AliasName_2 = "AZIMUTH2"; pFldEdt.Type_2 = esriFieldType.esriFieldTypeDouble; pFldsEdt.AddField(pFldEdt); pFldEdt = new FieldClass(); pFldEdt.Name_2 = "RADIUS1"; pFldEdt.AliasName_2 = "RADIUS1"; pFldEdt.Type_2 = esriFieldType.esriFieldTypeDouble; pFldsEdt.AddField(pFldEdt); pFldEdt = new FieldClass(); pFldEdt.Name_2 = "RADIUS2"; pFldEdt.AliasName_2 = "RADIUS2"; pFldEdt.Type_2 = esriFieldType.esriFieldTypeDouble; pFldsEdt.AddField(pFldEdt); pFldEdt = new FieldClass(); pFldEdt.Name_2 = "VERT1"; pFldEdt.AliasName_2 = "VERT1"; pFldEdt.Type_2 = esriFieldType.esriFieldTypeDouble; pFldsEdt.AddField(pFldEdt); pFldEdt = new FieldClass(); pFldEdt.Name_2 = "VERT2"; pFldEdt.AliasName_2 = "VERT2"; pFldEdt.Type_2 = esriFieldType.esriFieldTypeDouble; pFldsEdt.AddField(pFldEdt); IFeatureClass pFClass = featWorkspace.CreateFeatureClass(name, pFldsEdt, null, null, esriFeatureType.esriFTSimple, "SHAPE", ""); return pFClass; }