Skip to content

Commit

Permalink
Merge pull request #34 from mgayheart1/33
Browse files Browse the repository at this point in the history
  • Loading branch information
davetimmins authored Aug 2, 2018
2 parents 23c1b12 + 9e9a21f commit 12fc6f7
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
44 changes: 44 additions & 0 deletions src/Anywhere.ArcGIS/Operation/Query.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,26 @@ public string Time
/// </summary>
[DataMember(Name = "resultRecordCount")]
public int? ResultRecordCount { get; set; }

/// <summary>
/// The names of the fields to group by for output statistics.
/// </summary>
[IgnoreDataMember]
public List<string> GroupByFields { get; set; }

/// <summary>
/// The list of fields to be included in the group by clause. This list is a comma delimited list of field names.
/// </summary>
/// <remarks>Default is ''</remarks>
[DataMember(Name = "groupByFieldsForStatistics")]
public string GroupByFieldsValue { get { return GroupByFields == null || !GroupByFields.Any() ? "" : string.Join(",", GroupByFields); } }


/// <summary>
/// The list of output statistics.
/// </summary>
[DataMember(Name = "outStatistics")]
public List<OutputStatistic> OutputStatistics { get; set; }
}

[DataContract]
Expand Down Expand Up @@ -439,4 +459,28 @@ public static class FieldDataTypes
public const string EsriDate = "esriFieldTypeDate";
public const string EsriOID = "esriFieldTypeOID";
}

[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";
}
}
34 changes: 34 additions & 0 deletions tests/Anywhere.ArcGIS.Test.Integration/ArcGISGatewayTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -853,5 +853,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<OutputStatistic>();
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<string>(new string[] { "ST" }),
OutputStatistics = outStats
};
var result = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() =>
{
return gateway.Query<Point>(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());
}
}
}

0 comments on commit 12fc6f7

Please sign in to comment.