diff --git a/src/Anywhere.ArcGIS/Operation/Query.cs b/src/Anywhere.ArcGIS/Operation/Query.cs index 9b06522..aa892d6 100644 --- a/src/Anywhere.ArcGIS/Operation/Query.cs +++ b/src/Anywhere.ArcGIS/Operation/Query.cs @@ -217,6 +217,26 @@ public string Time /// [DataMember(Name = "resultRecordCount")] public int? ResultRecordCount { get; set; } + + /// + /// The names of the fields to group by for output statistics. + /// + [IgnoreDataMember] + public List GroupByFields { get; set; } + + /// + /// The list of fields to be included in the group by clause. This list is a comma delimited list of field names. + /// + /// Default is '' + [DataMember(Name = "groupByFieldsForStatistics")] + public string GroupByFieldsValue { get { return GroupByFields == null || !GroupByFields.Any() ? "" : string.Join(",", GroupByFields); } } + + + /// + /// The list of output statistics. + /// + [DataMember(Name = "outStatistics")] + public List OutputStatistics { get; set; } } [DataContract] @@ -438,4 +458,28 @@ public static class FieldDataTypes public const string EsriDouble = "esriFieldTypeDouble"; public const string EsriDate = "esriFieldTypeDate"; } + + [DataContract] + public class OutputStatistic + { + [DataMember(Name = "statisticType")] + public string StatisticType { get; set; } + + [DataMember(Name = "onStatisticField")] + public string OnField { get; set; } + + [DataMember(Name = "outStatisticFieldName")] + public string OutField { get; set; } + } + + public static class StatisticTypes + { + public const string Count = "count"; + public const string Sum = "sum"; + public const string Min = "min"; + public const string Max = "max"; + public const string Average = "avg"; + public const string StandardDeviation = "stddev"; + public const string Variance = "var"; + } } diff --git a/tests/Anywhere.ArcGIS.Test.Integration/ArcGISGatewayTests.cs b/tests/Anywhere.ArcGIS.Test.Integration/ArcGISGatewayTests.cs index ab3e0b4..882704f 100644 --- a/tests/Anywhere.ArcGIS.Test.Integration/ArcGISGatewayTests.cs +++ b/tests/Anywhere.ArcGIS.Test.Integration/ArcGISGatewayTests.cs @@ -829,5 +829,39 @@ public async Task CanDownloadExportMapResponse(string rootUrl, string relativeUr Assert.NotNull(result.FullName); Assert.True(result.Exists); } + + [Fact] + public async Task QueryForOutputStatistics() + { + var gateway = new PortalGateway("http://services.arcgis.com/P3ePLMYs2RVChkJx/ArcGIS"); + var outStats = new List(); + outStats.Add(new OutputStatistic() + { + StatisticType = StatisticTypes.Average, + OnField = "MALES", + OutField = "AVE_MALES" + }); + outStats.Add(new OutputStatistic() + { + StatisticType = StatisticTypes.Sum, + OnField = "MALES", + OutField = "SUM_MALES" + }); + var query = new Query("USA_Major_Cities/FeatureServer/0") + { + GroupByFields = new List(new string[] { "ST" }), + OutputStatistics = outStats + }; + var result = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + { + return gateway.Query(query); + }); + + Assert.NotNull(result); + Assert.Null(result.Error); + Assert.True(result.Features.Any()); + Assert.NotNull(result.Fields); + Assert.True(result.Fields.Where(x => x.Name == "SUM_MALES").Any()); + } } }