/// <summary> /// Returns two overlapping square polygons: /// /// _____________ /// | | /// | target | /// ______|______ | /// | | | | /// | | | | /// | |______|______| /// | | /// | source | /// |_____________| /// /// </summary> /// <param name="sourceFeature"></param> /// <param name="targetFeature"></param> /// <returns></returns> private static void GetOverlappingPolygons(out GdbFeature sourceFeature, out GdbFeature targetFeature) { var fClass = new GdbFeatureClass(123, "TestFC", esriGeometryType.esriGeometryPolygon); var sr = SpatialReferenceUtils.CreateSpatialReference( WellKnownHorizontalCS.LV95, WellKnownVerticalCS.LN02); fClass.SpatialReference = sr; IPolygon polygon1 = GeometryFactory.CreatePolygon( GeometryFactory.CreatePoint(2600000, 1200000, sr), GeometryFactory.CreatePoint(2601000, 1201000, sr)); polygon1.SpatialReference = sr; sourceFeature = new GdbFeature(42, fClass) { Shape = polygon1 }; IPolygon polygon2 = GeometryFactory.CreatePolygon( GeometryFactory.CreatePoint(2600500, 1200500, sr), GeometryFactory.CreatePoint(2601500, 1201500, sr)); polygon2.SpatialReference = sr; targetFeature = new GdbFeature(43, fClass) { Shape = polygon2 }; }
public void CanConvertToFromFeature() { var sr = SpatialReferenceUtils.CreateSpatialReference( WellKnownHorizontalCS.LV95, WellKnownVerticalCS.LN02); var fClass = new GdbFeatureClass(123, "TestFC", esriGeometryType.esriGeometryPolygon); fClass.SpatialReference = sr; GdbFeature featureWithNoShape = new GdbFeature(41, fClass); AssertCanConvertToDtoAndBack(featureWithNoShape); IPolygon polygon = GeometryFactory.CreatePolygon( GeometryFactory.CreatePoint(2600000, 1200000, sr), GeometryFactory.CreatePoint(2601000, 1201000, sr)); polygon.SpatialReference = sr; GdbFeature featureWithShape = new GdbFeature(42, fClass) { Shape = polygon }; AssertCanConvertToDtoAndBack(featureWithShape); }
public void CanCreateFeatureWithoutTableSchema() { ISpatialReference sr = SpatialReferenceUtils.CreateSpatialReference(WellKnownHorizontalCS.LV95); IPolygon shape = GeometryFactory.CreatePolygon( GeometryFactory.CreatePoint(2600000, 1200000, sr), GeometryFactory.CreatePoint(2600050, 1200080, sr)); GdbObjectMsg featureMsg = new GdbObjectMsg { ClassHandle = -1, ObjectId = 42, Shape = ProtobufGeometryUtils.ToShapeMsg(shape) }; GdbFeatureClass fClass = new GdbFeatureClass(1, "Test", esriGeometryType.esriGeometryPolygon); GdbRow gdbRow = ProtobufConversionUtils.FromGdbObjectMsg(featureMsg, fClass); GdbFeature feature = (GdbFeature)gdbRow; Assert.AreEqual(42, feature.OID); Assert.True(GeometryUtils.AreEqual(shape, feature.Shape)); Assert.AreEqual(1, feature.Class.ObjectClassID); }
public void CanGetOpenJawReshapeLineReplaceEndPoint() { var fClass = new GdbFeatureClass(123, "TestFC", esriGeometryType.esriGeometryPolyline); var sr = SpatialReferenceUtils.CreateSpatialReference( WellKnownHorizontalCS.LV95, WellKnownVerticalCS.LN02); fClass.SpatialReference = sr; IPath sourcePath = GeometryFactory.CreatePath( GeometryFactory.CreatePoint(2600500, 1200000, sr), GeometryFactory.CreatePoint(2600500, 1200500, sr), GeometryFactory.CreatePoint(2601000, 1200500, sr)); sourcePath.SpatialReference = sr; IPolyline sourcePolyline = GeometryFactory.CreatePolyline(sourcePath); GdbFeature sourceFeature = new GdbFeature(42, fClass) { Shape = sourcePolyline }; IPath reshapePath = GeometryFactory.CreatePath( GeometryFactory.CreatePoint(2600500, 1200500, sr), GeometryFactory.CreatePoint(2600500, 1201000, sr)); reshapePath.SpatialReference = sr; IPolyline reshapePolyline = GeometryFactory.CreatePolyline(reshapePath); var sourceFeatureMsg = ProtobufGdbUtils.ToGdbObjectMsg(sourceFeature); var reshapePathMsg = ProtobufGeometryUtils.ToShapeMsg(reshapePolyline); var request = new OpenJawReshapeLineReplacementRequest { Feature = sourceFeatureMsg, ReshapePath = reshapePathMsg }; ShapeMsg response = AdvancedReshapeServiceUtils.GetOpenJawReshapeReplaceEndPoint(request); IPoint resultPoint = (IPoint)ProtobufGeometryUtils.FromShapeMsg(response); Assert.IsTrue(GeometryUtils.AreEqual(sourcePolyline.ToPoint, resultPoint)); // Non-default side: request.UseNonDefaultReshapeSide = true; response = AdvancedReshapeServiceUtils.GetOpenJawReshapeReplaceEndPoint(request); resultPoint = (IPoint)ProtobufGeometryUtils.FromShapeMsg(response); Assert.IsTrue(GeometryUtils.AreEqual(sourcePolyline.FromPoint, resultPoint)); }
public void CanCreateGdbFeatureClass() { // An in-memory backing dataset is created automatically, if no factory method is provided GdbFeatureClass gdbFeatureClass = new GdbFeatureClass(41, "TESTABLE", esriGeometryType.esriGeometryPoint, "Test table"); IFeatureClass featureClass = gdbFeatureClass; Assert.AreEqual(41, featureClass.ObjectClassID); Assert.AreEqual("TESTABLE", DatasetUtils.GetName(featureClass)); Assert.AreEqual("Test table", DatasetUtils.GetAliasName(featureClass)); Assert.AreEqual(esriGeometryType.esriGeometryPoint, featureClass.ShapeType); Assert.False(featureClass.HasOID); Assert.Null(featureClass.OIDFieldName); Assert.AreEqual(0, GdbQueryUtils.Count(featureClass, "")); // Add OID field gdbFeatureClass.AddField(FieldUtils.CreateOIDField()); // Add Shape field gdbFeatureClass.AddField( FieldUtils.CreateShapeField( esriGeometryType.esriGeometryPoint, SpatialReferenceUtils.CreateSpatialReference(WellKnownHorizontalCS.LV95))); Assert.True(featureClass.HasOID); Assert.AreEqual("OBJECTID", featureClass.OIDFieldName); Assert.AreEqual("SHAPE", featureClass.ShapeFieldName); IQueryFilter queryFilter = GdbQueryUtils.CreateQueryFilter("OBJECTID"); queryFilter.WhereClause = "OBJECTID < 0"; Assert.AreEqual(0, GdbQueryUtils.Count(featureClass, queryFilter)); var backingDataset = gdbFeatureClass.BackingDataset as InMemoryDataset; Assert.NotNull(backingDataset); backingDataset.AllRows.Add(new GdbRow(1, gdbFeatureClass)); Assert.AreEqual(0, GdbQueryUtils.Count(featureClass, queryFilter)); queryFilter.WhereClause = "OBJECTID > 0"; Assert.AreEqual(1, GdbQueryUtils.Count(featureClass, queryFilter)); }
public void CanConvertToFromFeatureList() { var sr = SpatialReferenceUtils.CreateSpatialReference( WellKnownHorizontalCS.LV95, WellKnownVerticalCS.LN02); var fClass1 = new GdbFeatureClass(123, "TestFC", esriGeometryType.esriGeometryPolygon); fClass1.SpatialReference = sr; GdbFeature featureWithNoShape = new GdbFeature(41, fClass1); IPolygon polygon = GeometryFactory.CreatePolygon( GeometryFactory.CreatePoint(2600000, 1200000, sr), GeometryFactory.CreatePoint(2601000, 1201000, sr)); polygon.SpatialReference = sr; GdbFeature featureWithShape = new GdbFeature(42, fClass1) { Shape = polygon }; var fClass2 = new GdbFeatureClass(124, "TestClass2", esriGeometryType.esriGeometryMultipoint); fClass2.SpatialReference = sr; GdbFeature multipointFeature = new GdbFeature(41, fClass2); AssertCanConvertToDtoAndBack(new List <IFeature> { featureWithNoShape, multipointFeature, featureWithShape }); }
public void CanCalculateOverlaps() { var fClass = new GdbFeatureClass(123, "TestFC", esriGeometryType.esriGeometryPolygon); var sr = SpatialReferenceUtils.CreateSpatialReference( WellKnownHorizontalCS.LV95, WellKnownVerticalCS.LN02); fClass.SpatialReference = sr; IPolygon polygon1 = GeometryFactory.CreatePolygon( GeometryFactory.CreatePoint(2600000, 1200000, sr), GeometryFactory.CreatePoint(2601000, 1201000, sr)); polygon1.SpatialReference = sr; GdbFeature sourceFeature = new GdbFeature(42, fClass) { Shape = polygon1 }; IPolygon polygon2 = GeometryFactory.CreatePolygon( GeometryFactory.CreatePoint(2600500, 1200500, sr), GeometryFactory.CreatePoint(2601500, 1201500, sr)); polygon2.SpatialReference = sr; GdbFeature targetFeature = new GdbFeature(43, fClass) { Shape = polygon2 }; var sourceFeatureMsg = ProtobufGdbUtils.ToGdbObjectMsg(sourceFeature); var targetFeatureMsg = ProtobufGdbUtils.ToGdbObjectMsg(targetFeature); var objectClassMsg = ProtobufGdbUtils.ToObjectClassMsg(sourceFeature.Class); CalculateOverlapsRequest calculationRequest = new CalculateOverlapsRequest() { ClassDefinitions = { objectClassMsg }, SourceFeatures = { sourceFeatureMsg }, TargetFeatures = { targetFeatureMsg } }; CalculateOverlapsResponse response = RemoveOverlapsServiceUtils.CalculateOverlaps(calculationRequest, null); Assert.AreEqual(1, response.Overlaps.Count); List <ShapeMsg> shapeBufferList = response.Overlaps.SelectMany(kvp => kvp.Overlaps).ToList(); List <IPolygon> resultPolys = ProtobufGeometryUtils.FromShapeMsgList <IPolygon>(shapeBufferList); Assert.AreEqual(1, resultPolys.Count); Assert.AreEqual(1000 * 1000 / 4, ((IArea)resultPolys[0]).Area); // Now the removal: RemoveOverlapsRequest removeRequest = new RemoveOverlapsRequest(); removeRequest.ClassDefinitions.AddRange(calculationRequest.ClassDefinitions); removeRequest.SourceFeatures.AddRange(calculationRequest.SourceFeatures); removeRequest.Overlaps.Add(response.Overlaps); RemoveOverlapsResponse removeResponse = RemoveOverlapsServiceUtils.RemoveOverlaps(removeRequest); Assert.AreEqual(1, removeResponse.ResultsByFeature.Count); ResultGeometriesByFeature resultByFeature = removeResponse.ResultsByFeature[0]; GdbObjectReference originalObjRef = new GdbObjectReference( resultByFeature.OriginalFeatureRef.ClassHandle, resultByFeature.OriginalFeatureRef.ObjectId); Assert.AreEqual(new GdbObjectReference(sourceFeature), originalObjRef); var updatedGeometry = ProtobufGeometryUtils.FromShapeMsg(resultByFeature.UpdatedGeometry); Assert.IsNotNull(updatedGeometry); Assert.AreEqual(1000 * 1000 * 3 / 4, ((IArea)updatedGeometry).Area); Assert.AreEqual(0, resultByFeature.NewGeometries.Count); }
public void CanRemoveOverlaps() { var fClass = new GdbFeatureClass(123, "TestFC", esriGeometryType.esriGeometryPolygon); var sr = SpatialReferenceUtils.CreateSpatialReference( WellKnownHorizontalCS.LV95, WellKnownVerticalCS.LN02); IPolygon polygon1 = GeometryFactory.CreatePolygon( GeometryFactory.CreatePoint(2600000, 1200000, sr), GeometryFactory.CreatePoint(2601000, 1201000, sr)); polygon1.SpatialReference = sr; GdbFeature sourceFeature = new GdbFeature(42, fClass) { Shape = polygon1 }; IPolygon polygon2 = GeometryFactory.CreatePolygon( GeometryFactory.CreatePoint(2600500, 1200500, sr), GeometryFactory.CreatePoint(2601500, 1201500, sr)); polygon2.SpatialReference = sr; GdbFeature targetFeature = new GdbFeature(43, fClass) { Shape = polygon2 }; IPolygon overlap = GeometryFactory.CreatePolygon( GeometryFactory.CreatePoint(2600500, 1200500, sr), GeometryFactory.CreatePoint(2601000, 1201000, sr)); overlap.SpatialReference = sr; var sourceFeatureMsg = ProtobufGdbUtils.ToGdbObjectMsg(sourceFeature); var targetFeatureMsg = ProtobufGdbUtils.ToGdbObjectMsg(targetFeature); var objectClassMsg = ProtobufGdbUtils.ToObjectClassMsg(sourceFeature.Class); var removeRequest = new RemoveOverlapsRequest() { ClassDefinitions = { objectClassMsg }, SourceFeatures = { sourceFeatureMsg }, UpdatableTargetFeatures = { targetFeatureMsg } }; var overlapsMsg = new OverlapMsg(); overlapsMsg.OriginalFeatureRef = new GdbObjRefMsg() { ClassHandle = sourceFeatureMsg.ClassHandle, ObjectId = sourceFeatureMsg.ObjectId }; overlapsMsg.Overlaps.Add(ProtobufGeometryUtils.ToShapeMsg(overlap)); removeRequest.Overlaps.Add(overlapsMsg); RemoveOverlapsResponse removeResponse = RemoveOverlapsServiceUtils.RemoveOverlaps(removeRequest); Assert.AreEqual(1, removeResponse.ResultsByFeature.Count); ResultGeometriesByFeature resultByFeature = removeResponse.ResultsByFeature[0]; GdbObjectReference originalObjRef = new GdbObjectReference( resultByFeature.OriginalFeatureRef.ClassHandle, resultByFeature.OriginalFeatureRef.ObjectId); Assert.AreEqual(new GdbObjectReference(sourceFeature), originalObjRef); IGeometry updatedGeometry = ProtobufGeometryUtils.FromShapeMsg(resultByFeature.UpdatedGeometry); Assert.IsNotNull(updatedGeometry); Assert.AreEqual(1000 * 1000 * 3 / 4, ((IArea)updatedGeometry).Area); Assert.AreEqual(0, resultByFeature.NewGeometries.Count); IFeature updatedTarget = ProtobufConversionUtils.FromGdbObjectMsgList(removeResponse.TargetFeaturesToUpdate, removeRequest.ClassDefinitions) .Single(); int pointCount = GeometryUtils.GetPointCount(updatedTarget.Shape); Assert.AreEqual(5 + 2, pointCount); }
public void CanCreateGdbFeatureClassWithBackingDataset() { IWorkspace ws = TestUtils.OpenUserWorkspaceOracle(); const string tlmStrasse = "TOPGIS_TLM.TLM_STRASSE"; IFeatureClass realFeatureClass = DatasetUtils.OpenFeatureClass(ws, tlmStrasse); var rowCache = GdbQueryUtils.GetRows((ITable)realFeatureClass, false) .Take(100) .ToList(); Assert.AreEqual(100, rowCache.Count); GdbTable tableWithBackingData = new GdbFeatureClass(41, "TESTABLE", esriGeometryType.esriGeometryPoint, "Test table", table => new InMemoryDataset(table, rowCache)); IFeatureClass featureClassWithBackingData = (IFeatureClass)tableWithBackingData; Assert.AreEqual(41, featureClassWithBackingData.ObjectClassID); Assert.AreEqual("TESTABLE", DatasetUtils.GetName(featureClassWithBackingData)); Assert.AreEqual("Test table", DatasetUtils.GetAliasName(featureClassWithBackingData)); Assert.AreEqual(esriGeometryType.esriGeometryPoint, featureClassWithBackingData.ShapeType); Assert.False(featureClassWithBackingData.HasOID); Assert.Null(featureClassWithBackingData.OIDFieldName); for (int i = 0; i < realFeatureClass.Fields.FieldCount; i++) { featureClassWithBackingData.AddField(realFeatureClass.Fields.Field[i]); } Assert.AreEqual("OBJECTID", featureClassWithBackingData.OIDFieldName); Assert.AreEqual("SHAPE", featureClassWithBackingData.ShapeFieldName); Assert.AreEqual(100, GdbQueryUtils.Count(featureClassWithBackingData, "")); IQueryFilter queryFilter = GdbQueryUtils.CreateQueryFilter("OBJECTID"); queryFilter.WhereClause = "OBJECTID < 0"; Assert.AreEqual(0, GdbQueryUtils.Count(featureClassWithBackingData, queryFilter)); var backingDataset = tableWithBackingData.BackingDataset as InMemoryDataset; Assert.NotNull(backingDataset); backingDataset.AllRows.Add(new GdbRow(1, tableWithBackingData)); Assert.AreEqual(0, GdbQueryUtils.Count(featureClassWithBackingData, queryFilter)); queryFilter.WhereClause = "OBJECTID >= 0"; Assert.AreEqual(101, GdbQueryUtils.Count(featureClassWithBackingData, queryFilter)); }
public void CanAdvancedReshapePolygon() { var fClass = new GdbFeatureClass(123, "TestFC", esriGeometryType.esriGeometryPolygon); var sr = SpatialReferenceUtils.CreateSpatialReference( WellKnownHorizontalCS.LV95, WellKnownVerticalCS.LN02); fClass.SpatialReference = sr; IPolygon polygon1 = GeometryFactory.CreatePolygon( GeometryFactory.CreatePoint(2600000, 1200000, sr), GeometryFactory.CreatePoint(2601000, 1201000, sr)); polygon1.SpatialReference = sr; GdbFeature sourceFeature = new GdbFeature(42, fClass) { Shape = polygon1 }; IPath reshapePath = GeometryFactory.CreatePath( GeometryFactory.CreatePoint(2600500, 1200000, sr), GeometryFactory.CreatePoint(2600500, 1200500, sr), GeometryFactory.CreatePoint(2601000, 1200500, sr)); reshapePath.SpatialReference = sr; IPolyline reshapePolyline = GeometryFactory.CreatePolyline(reshapePath); var sourceFeatureMsg = ProtobufGdbUtils.ToGdbObjectMsg(sourceFeature); var reshapePaths = ProtobufGeometryUtils.ToShapeMsg(reshapePolyline); var objectClassMsg = ProtobufGdbUtils.ToObjectClassMsg(sourceFeature.Class); AdvancedReshapeRequest request = new AdvancedReshapeRequest() { ClassDefinitions = { objectClassMsg }, Features = { sourceFeatureMsg }, ReshapePaths = reshapePaths }; AdvancedReshapeResponse response = AdvancedReshapeServiceUtils.Reshape(request); Assert.AreEqual(1, response.ResultFeatures.Count); GdbObjectMsg resultFeatureMsg = response.ResultFeatures[0].UpdatedFeature; Assert.AreEqual(sourceFeature.OID, resultFeatureMsg.ObjectId); Assert.AreEqual(sourceFeature.Class.ObjectClassID, resultFeatureMsg.ClassHandle); var resultPoly = (IPolygon)ProtobufGeometryUtils.FromShapeMsg(resultFeatureMsg.Shape); Assert.NotNull(resultPoly); double oneQuarter = 1000d * 1000d / 4d; Assert.AreEqual(3 * oneQuarter, ((IArea)resultPoly).Area); // Non-default side: request.UseNonDefaultReshapeSide = true; response = AdvancedReshapeServiceUtils.Reshape(request); Assert.AreEqual(1, response.ResultFeatures.Count); resultFeatureMsg = response.ResultFeatures[0].UpdatedFeature; resultPoly = (IPolygon)ProtobufGeometryUtils.FromShapeMsg(resultFeatureMsg.Shape); Assert.NotNull(resultPoly); Assert.AreEqual(oneQuarter, ((IArea)resultPoly).Area); }
public void CanAdvancedReshapePolyline() { var fClass = new GdbFeatureClass(123, "TestFC", esriGeometryType.esriGeometryPolyline); var sr = SpatialReferenceUtils.CreateSpatialReference( WellKnownHorizontalCS.LV95, WellKnownVerticalCS.LN02); fClass.SpatialReference = sr; IPolyline sourcePolyline = CreatePolyline( GeometryFactory.CreatePoint(2600500, 1200000, sr), GeometryFactory.CreatePoint(2600500, 1200500, sr), GeometryFactory.CreatePoint(2601000, 1200500, sr)); GdbFeature sourceFeature = new GdbFeature(42, fClass) { Shape = sourcePolyline }; IPolyline sourceAdjacentPolyline = CreatePolyline( GeometryFactory.CreatePoint(2601000, 1200500, sr), GeometryFactory.CreatePoint(2601500, 1200500, sr), GeometryFactory.CreatePoint(2601500, 1200000, sr)); GdbFeature sourceAdjacentFeature = new GdbFeature(43, fClass) { Shape = sourceAdjacentPolyline }; IPolyline reshapePolyline = CreatePolyline( GeometryFactory.CreatePoint(2600500, 1200500, sr), GeometryFactory.CreatePoint(2600500, 1201000, sr)); var sourceFeatureMsg = ProtobufGdbUtils.ToGdbObjectMsg(sourceFeature); var reshapePaths = ProtobufGeometryUtils.ToShapeMsg(reshapePolyline); var sourceAdjacentFeatureMsg = ProtobufGdbUtils.ToGdbObjectMsg(sourceAdjacentFeature); var objectClassMsg = ProtobufGdbUtils.ToObjectClassMsg(sourceFeature.Class); AdvancedReshapeRequest request = new AdvancedReshapeRequest() { ClassDefinitions = { objectClassMsg }, Features = { sourceFeatureMsg }, ReshapePaths = reshapePaths, AllowOpenJawReshape = true, MoveOpenJawEndJunction = true, PotentiallyConnectedFeatures = { sourceAdjacentFeatureMsg } }; AdvancedReshapeResponse response = AdvancedReshapeServiceUtils.Reshape(request); Assert.AreEqual(2, response.ResultFeatures.Count); GdbObjectMsg resultFeatureMsg = response.ResultFeatures[1].UpdatedFeature; Assert.AreEqual(sourceFeature.OID, resultFeatureMsg.ObjectId); Assert.AreEqual(sourceFeature.Class.ObjectClassID, resultFeatureMsg.ClassHandle); var resultPolyline = (IPolyline)ProtobufGeometryUtils.FromShapeMsg(resultFeatureMsg.Shape); Assert.NotNull(resultPolyline); Assert.IsTrue(GeometryUtils.AreEqual(resultPolyline.ToPoint, reshapePolyline.ToPoint)); GdbObjectMsg resultAdjacentFeatureMsg = response.ResultFeatures[0].UpdatedFeature; var resultAdjacentPolyline = (IPolyline)ProtobufGeometryUtils.FromShapeMsg(resultAdjacentFeatureMsg.Shape); Assert.NotNull(resultAdjacentPolyline); Assert.IsTrue( GeometryUtils.AreEqual(resultAdjacentPolyline.FromPoint, reshapePolyline.ToPoint)); // Non-default side: request.UseNonDefaultReshapeSide = true; response = AdvancedReshapeServiceUtils.Reshape(request); Assert.AreEqual(1, response.ResultFeatures.Count); resultFeatureMsg = response.ResultFeatures[0].UpdatedFeature; resultPolyline = (IPolyline)ProtobufGeometryUtils.FromShapeMsg(resultFeatureMsg.Shape); Assert.NotNull(resultPolyline); Assert.IsTrue( GeometryUtils.AreEqual(resultPolyline.FromPoint, reshapePolyline.ToPoint)); }
public static GdbTable FromObjectClassMsg( [NotNull] ObjectClassMsg objectClassMsg, [CanBeNull] IWorkspace workspace, [CanBeNull] Func <ITable, BackingDataset> createBackingDataset = null) { esriGeometryType geometryType = (esriGeometryType)objectClassMsg.GeometryType; GdbTable result; if (geometryType == esriGeometryType.esriGeometryNull) { result = new GdbTable(objectClassMsg.ClassHandle, objectClassMsg.Name, objectClassMsg.Alias, createBackingDataset, workspace); } else { result = new GdbFeatureClass( objectClassMsg.ClassHandle, objectClassMsg.Name, (esriGeometryType)objectClassMsg.GeometryType, objectClassMsg.Alias, createBackingDataset, workspace) { SpatialReference = ProtobufGeometryUtils.FromSpatialReferenceMsg( objectClassMsg.SpatialReference) }; } if (objectClassMsg.Fields == null || objectClassMsg.Fields.Count <= 0) { return(result); } foreach (FieldMsg fieldMsg in objectClassMsg.Fields) { IField field = FieldUtils.CreateField(fieldMsg.Name, (esriFieldType)fieldMsg.Type, fieldMsg.AliasName); if (field.Type == esriFieldType.esriFieldTypeString) { ((IFieldEdit)field).Length_2 = fieldMsg.Length; } else if (field.Type == esriFieldType.esriFieldTypeGeometry) { var sr = ProtobufGeometryUtils.FromSpatialReferenceMsg( objectClassMsg.SpatialReference); field = FieldUtils.CreateShapeField(geometryType, sr, 1000, true, false); } if (result.Fields.FindField(field.Name) < 0) { result.AddField(field); } else { _msg.DebugFormat("Field {0} is duplicate or has been added previously", field.Name); } } return(result); }