async static internal Task <GeoServicesFeatureClass> CreateAsync(GeoServicesDataset dataset, JsonLayer jsonLayer)
        {
            var featureClass = new GeoServicesFeatureClass();

            featureClass._dataaset = dataset;

            featureClass.ID   = jsonLayer.Id.ToString();
            featureClass.Name = jsonLayer.Name;

            var fields = featureClass.Fields as Fields;

            if (fields != null && jsonLayer.Fields != null)
            {
                foreach (var jsonField in jsonLayer.Fields)
                {
                    var fieldType = RestHelper.FType(jsonField.Type);

                    if (fieldType == FieldType.String)
                    {
                        fields.Add(new Field(jsonField.Name, fieldType, 1024)
                        {
                            aliasname = jsonField.Alias ?? jsonField.Name
                        });
                    }
                    else
                    {
                        fields.Add(new Field(jsonField.Name, fieldType)
                        {
                            aliasname = jsonField.Alias ?? jsonField.Name
                        });
                    }

                    if (fieldType == FieldType.ID)
                    {
                        featureClass.IDFieldName = jsonField.Name;
                    }
                }
            }

            featureClass.GeometryType = jsonLayer.GetGeometryType();

            if (jsonLayer.Extent != null)
            {
                featureClass.Envelope = new Envelope(jsonLayer.Extent.Xmin,
                                                     jsonLayer.Extent.Ymin,
                                                     jsonLayer.Extent.Xmax,
                                                     jsonLayer.Extent.Ymax);
            }

            featureClass.SpatialReference = await dataset.GetSpatialReference();

            return(featureClass);
        }
 public GeoServicesFeatureCursor(GeoServicesDataset dataset,
                                 GeoServicesFeatureClass featureClass,
                                 string queryUrl,
                                 string postData,
                                 string where)
 {
     _dataset      = dataset;
     _featureClass = featureClass;
     _queryUrl     = queryUrl;
     _postData     = postData;
     _where        = where;
 }
Example #3
0
        async public Task <bool> Open(IServiceRequestContext context)
        {
            if (_class == null)
            {
                _class = new GeoServicesClass(this);
            }
            _class.Themes.Clear();

            _themes = new List <IWebServiceTheme>();

            string serviceUrl = ServiceUrl();
            string user       = ConfigTextStream.ExtractValue(ConnectionString, "user");
            string pwd        = ConfigTextStream.ExtractValue(ConnectionString, "pwd");

            var jsonMapService = await TryPostAsync <JsonMapService>($"{serviceUrl}?f=json");

            var jsonLayers = await TryPostAsync <JsonLayers>($"{serviceUrl}/layers?f=json");

            if (jsonMapService != null)
            {
                _class.Name = jsonMapService.MapName;

                if (jsonMapService.FullExtent != null)
                {
                    _class.Envelope = new Envelope(
                        jsonMapService.FullExtent.XMin,
                        jsonMapService.FullExtent.YMin,
                        jsonMapService.FullExtent.XMax,
                        jsonMapService.FullExtent.YMax);
                }

                if (jsonMapService.SpatialReferenceInstance != null &&
                    jsonMapService.SpatialReferenceInstance.Wkid > 0)
                {
                    var sRef = gView.Framework.Geometry.SpatialReference.FromID("epsg:" + jsonMapService.SpatialReferenceInstance.Wkid);
                    this.SetSpatialReference(sRef);
                    _class.SpatialReference = sRef;
                }

                if (jsonLayers?.Layers != null)
                {
                    foreach (var jsonLayer in jsonLayers.Layers)
                    {
                        IClass           themeClass = null;
                        IWebServiceTheme theme      = null;

                        if (jsonLayer.Type.ToLower() == "feature layer")
                        {
                            themeClass = await GeoServicesFeatureClass.CreateAsync(this, jsonLayer);

                            theme = LayerFactory.Create(themeClass, _class as IWebServiceClass) as IWebServiceTheme;
                            if (theme == null)
                            {
                                continue;
                            }
                        }
                        // ToDo Raster classes

                        if (themeClass == null)
                        {
                            continue;
                        }

                        theme.Visible = true; //false;

                        _class.Themes.Add(theme);
                    }
                }
            }

            return(true);
        }
Example #4
0
 public GeoServicesServiceLayerExplorerObject(IExplorerObject parent, GeoServicesFeatureClass featureClass)
     : base(parent, typeof(GeoServicesFeatureClass), 1)
 {
     _parent = parent;
     _fc     = featureClass;
 }