Example #1
0
        async static public Task <IFeatureClass> Create(SdeDataset dataset, string name, string multiVersionedViewName)
        {
            var featureClass = new SdeFeatureClass();

            if (dataset.RepoProvider == null)
            {
                throw new Exception("FeatureClass: Repository not initialized");
            }

            featureClass._name = name;

            featureClass._geomType = await dataset.RepoProvider.FeatureClassGeometryType(featureClass);

            featureClass._fields = await dataset.RepoProvider.FeatureClassFields(featureClass);

            featureClass._idfield = featureClass._fields.ToEnumerable()
                                    .Where(f => f.type == FieldType.ID)
                                    .FirstOrDefault()?.name;

            featureClass._shapefield = featureClass._fields.ToEnumerable()
                                       .Where(f => f.type == FieldType.Shape)
                                       .FirstOrDefault()?.name;

            if (!String.IsNullOrEmpty(featureClass._shapefield))
            {
                switch (featureClass._geomType)
                {
                case geometryType.Polygon:
                    featureClass._fields.Add(new Field($"{ featureClass._shapefield }.STArea()", FieldType.Double));
                    featureClass._fields.Add(new Field($"{ featureClass._shapefield }.STLength()", FieldType.Double));
                    break;

                case geometryType.Polyline:
                    featureClass._fields.Add(new Field($"{ featureClass._shapefield }.STLength()", FieldType.Double));
                    break;
                }
            }

            featureClass._dataset = dataset;

            if (featureClass._sRef == null && await dataset.RepoProvider.FeatureClassSpatialReference(featureClass) > 0)
            {
                featureClass._sRef = gView.Framework.Geometry.SpatialReference.FromID("epsg:" + await dataset.RepoProvider.FeatureClassSpatialReference(featureClass));
            }

            featureClass.MultiVersionedViewName = multiVersionedViewName;

            return(featureClass);
        }
Example #2
0
        async public override Task <IDatasetElement> Element(string title)
        {
            if (RepoProvider == null)
            {
                throw new Exception("Repository not initialized");
            }

            title = title.ToLower();
            var sdeLayer = RepoProvider.Layers.Where(l => (l.Owner + "." + l.TableName).ToLower() == title).FirstOrDefault();

            if (sdeLayer != null)
            {
                return(new DatasetElement(await SdeFeatureClass.Create(this,
                                                                       sdeLayer.Owner + "." + sdeLayer.TableName,
                                                                       String.IsNullOrWhiteSpace(sdeLayer.MultiVersionedViewName) ? null : sdeLayer.Owner + "." + sdeLayer.MultiVersionedViewName)));
            }

            return(null);
        }
Example #3
0
        async public override Task <List <IDatasetElement> > Elements()
        {
            if (RepoProvider == null)
            {
                throw new Exception("Repository not initialized");
            }

            if (_layers == null || _layers.Count == 0)
            {
                List <IDatasetElement> layers = new List <IDatasetElement>();

                foreach (var sdeLayer in RepoProvider.Layers)
                {
                    layers.Add(new DatasetElement(
                                   await SdeFeatureClass.Create(this, sdeLayer.Owner + "." + sdeLayer.TableName,
                                                                String.IsNullOrWhiteSpace(sdeLayer.MultiVersionedViewName) ? null : sdeLayer.Owner + "." + sdeLayer.MultiVersionedViewName)));
                }

                _layers = layers;
            }
            return(_layers);
        }