public GeoJsonFeatureCursor(GeoJsonServiceFeatureClass fc, IEnumerable <IFeature> features, IQueryFilter filter) : base(fc?.SpatialReference, filter?.FeatureSpatialReference) { _features = features?.ToArray(); _queryFilter = filter; _spatialFilter = filter as ISpatialFilter; }
async public static Task <GeoJsonServiceFeatureClass> CreateInstance(GeoJsonServiceDataset dataset, geometryType geometryType) { var instance = new GeoJsonServiceFeatureClass(dataset); instance.SpatialReference = await dataset.GetSpatialReference(); instance.GeometryType = geometryType; instance.Name = $"{ dataset.DatasetName }-{ geometryType.ToString().ToLower() }"; #region Loop all features for Fields var fields = new Fields(); if (dataset.Source != null) { bool idIsInterger = false; var features = await dataset.Source.GetFeatures(geometryType); // mayby later... //if (features != null && features.Count() > 0) //{ // idIsInterger = features.Where(f => f != null && int.TryParse(f["id"]?.ToString(), out int intId)) // .Count() == features.Count(); //} foreach (var feature in features) { foreach (var fieldValue in feature.Fields) { if (fields.FindField(fieldValue.Name) == null) { var val = fieldValue.Value; if (fieldValue.Name == "id" && idIsInterger) { fields.Add(new Field(fieldValue.Name, FieldType.ID)); } else if (val?.GetType() == typeof(int)) { fields.Add(new Field(fieldValue.Name, FieldType.integer)); } else if (val?.GetType() == typeof(double)) { fields.Add(new Field(fieldValue.Name, FieldType.Double)); } else { // ToDo: Check for Date? fields.Add(new Field(fieldValue.Name, FieldType.String)); } } } } } instance.Fields = fields; #endregion return(instance); }
async public Task <List <IDatasetElement> > Elements() { if (_source != null && _layers.Count == 0) { _layers.Add(new DatasetElement(await GeoJsonServiceFeatureClass.CreateInstance(this, geometryType.Point))); _layers.Add(new DatasetElement(await GeoJsonServiceFeatureClass.CreateInstance(this, geometryType.Polyline))); _layers.Add(new DatasetElement(await GeoJsonServiceFeatureClass.CreateInstance(this, geometryType.Polygon))); } return(_layers); }