Example #1
0
        public static IEnumerable <IFeature> GetDerivedTableGeometryFeatures(
            [NotNull] IObject obj,
            [NotNull] ObjectDataset dataset,
            [NotNull] IModelContext modelContext)
        {
            Assert.ArgumentNotNull(obj, nameof(obj));
            Assert.ArgumentNotNull(dataset, nameof(dataset));
            Assert.ArgumentNotNull(modelContext, nameof(modelContext));

            // TODO move elsewhere - domain? IObjectDataset? use objectrepository (moved from AE)?

            var relationList = new List <IRelationshipClass>();

            IWorkspaceContext workspaceContext = null;

            foreach (AssociationEnd associationEnd in dataset.GetAssociationEnds())
            {
                if (!(associationEnd.OppositeDataset is VectorDataset) ||
                    associationEnd.Association.NotUsedForDerivedTableGeometry)
                {
                    continue;
                }

                // make sure to open the relationship class from the same workspace context as the dataset
                if (workspaceContext == null)
                {
                    workspaceContext = modelContext.GetWorkspaceContext(dataset);
                    Assert.NotNull(workspaceContext,
                                   "Unable to determine workspace context for dataset {0}",
                                   dataset);
                }

                IRelationshipClass relationshipClass =
                    workspaceContext.OpenRelationshipClass(associationEnd.Association);

                if (relationshipClass != null)
                {
                    relationList.Add(relationshipClass);
                }
            }

            return(GdbQueryUtils.GetRelatedObjectList(obj, relationList).Cast <IFeature>());
        }