Example #1
0
    public async IAsyncEnumerable <T> DownloadAsync(string?whereClause = null, string?extraParameters = null, bool keepQuerying = false)
    {
        var featureSet = await Esri.GetFeatureSet(Url, Token, typeof(T).HasGeometry(), LayerInfo.hasZ, whereClause, extraParameters, null);

        foreach (var graphic in featureSet.features)
        {
            yield return(graphic.ToFeature <T>(LayerInfo));
        }

        var objectIds = featureSet.features.Select(g => g.attributes[LayerInfo.GetObjectIdFieldName()].GetInt32()).ToArray();

        if (!keepQuerying || objectIds.Length == 0)
        {
            yield break;
        }

        var oidSet = await Esri.GetOIDSet(Url, Token, whereClause, extraParameters);

        var remainingObjectIds = oidSet.objectIds.Except(objectIds);

        await foreach (var feature in DownloadAsync(remainingObjectIds, whereClause, extraParameters, LayerInfo.maxRecordCount ?? objectIds.Length))
        {
            yield return(feature);
        }
    }
Example #2
0
    private IEnumerable <T> Download(IEnumerable <int> objectIds, string?whereClause, string?extraParameters, int batchSize, int degreeOfParallelism, CancellationToken?cancellationToken)
    {
        var returnGeometry = typeof(T).HasGeometry();

        return(objectIds.Chunk(batchSize)
               .AsParallel()
               .AsOrdered()
               .WithDegreeOfParallelism(degreeOfParallelism < 1 ? 1 : degreeOfParallelism)
               .WithCancellation(cancellationToken ?? CancellationToken.None)
               .SelectMany(ids => Esri.GetFeatureSet(Url, Token, returnGeometry, LayerInfo.hasZ, whereClause, extraParameters, ids).Result.features
                           .Select(g => g.ToFeature <T>(LayerInfo))));
    }
Example #3
0
    private async IAsyncEnumerable <T> DownloadAsync(IEnumerable <int> objectIds, string?whereClause, string?extraParameters, int batchSize)
    {
        var returnGeometry = typeof(T).HasGeometry();

        foreach (var ids in objectIds.Chunk(batchSize))
        {
            var featureSet = await Esri.GetFeatureSet(Url, Token, returnGeometry, LayerInfo.hasZ, whereClause, extraParameters, ids);

            foreach (var graphic in featureSet.features)
            {
                yield return(graphic.ToFeature <T>(LayerInfo));
            }
        }
    }
Example #4
0
    public IEnumerable <T> Download(string?whereClause = null, string?extraParameters = null, bool keepQuerying = false, int degreeOfParallelism = 1, CancellationToken?cancellationToken = null)
    {
        var featureSet = Esri.GetFeatureSet(Url, Token, typeof(T).HasGeometry(), LayerInfo.hasZ, whereClause, extraParameters, null).Result;

        foreach (var g in featureSet.features)
        {
            yield return(g.ToFeature <T>(LayerInfo));
        }

        var objectIds = featureSet.features.Select(g => g.attributes[LayerInfo.GetObjectIdFieldName()].GetInt32()).ToArray();

        if (!keepQuerying || objectIds.Length == 0)
        {
            yield break;
        }

        var remainingObjectIds = Esri.GetOIDSet(Url, Token, whereClause, extraParameters).Result.objectIds.Except(objectIds);

        foreach (var f in Download(remainingObjectIds, whereClause, extraParameters, LayerInfo.maxRecordCount ?? objectIds.Length, degreeOfParallelism, cancellationToken))
        {
            yield return(f);
        }
    }