Skip to content

Commit

Permalink
added include raw response option
Browse files Browse the repository at this point in the history
  • Loading branch information
davetimmins committed Sep 25, 2021
1 parent fda6fd9 commit fdac065
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 15 deletions.
2 changes: 1 addition & 1 deletion build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
var solution = "./Anywhere.ArcGIS.sln";

var version = "2.0.0";
var version = "2.0.1";
var versionSuffix = Environment.GetEnvironmentVariable("VERSION_SUFFIX");

//////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion src/Anywhere.ArcGIS/Anywhere.ArcGIS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<RepositoryUrl>https://github.com/davetimmins/Anywhere.ArcGIS</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>ArcGIS ArcGISServer ArcGISOnline Esri REST netstandard anywhere GIS Mapping Map Location GeoLocation OAuth</PackageTags>
<Version>2.0.0</Version>
<Version>2.0.1</Version>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
</PropertyGroup>

Expand Down
5 changes: 5 additions & 0 deletions src/Anywhere.ArcGIS/Operation/PortalResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ public interface IPortalResponse

[DataMember(Name = "_links")]
List<Link> Links { get; set; }

[DataMember(Name = "_raw")]
string RawResult { get; set; }
}

/// <summary>
Expand All @@ -26,6 +29,8 @@ public class PortalResponse : IPortalResponse

[DataMember(Name = "_links")]
public List<Link> Links { get; set; }
[DataMember(Name = "_raw")]
public string RawResult { get; set; }
}

[DataContract]
Expand Down
2 changes: 1 addition & 1 deletion src/Anywhere.ArcGIS/PortalGateway.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public PortalGateway(string rootUrl, string username, string password, ISerializ
{
var result = new SiteDescription();

result.Resources.AddRange(await DescribeEndpoint(new ArcGISServerOperation("/".AsEndpoint()), ct).ConfigureAwait(false));
result?.Resources?.AddRange(await DescribeEndpoint(new ArcGISServerOperation("/".AsEndpoint()), ct).ConfigureAwait(false));

return result;
}
Expand Down
22 changes: 17 additions & 5 deletions src/Anywhere.ArcGIS/PortalGatewayBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ public void Dispose()

public bool IncludeHypermediaWithResponse { get; set; }

public bool IncludeRawResultWithResponse { get; set; }

public string RootUrl { get; private set; }

public ITokenProvider TokenProvider { get; private set; }
Expand Down Expand Up @@ -389,7 +391,7 @@ public TimeSpan HttpRequestTimeout
where T : IGeometry
{
var result = await Post<ApplyEditsResponse, ApplyEdits<T>>(edits, ct);
result.SetExpected(edits);
result?.SetExpected(edits);
return result;
}

Expand All @@ -410,7 +412,7 @@ public TimeSpan HttpRequestTimeout
if (ct.IsCancellationRequested) return null;

var result = features.UpdateGeometries(projected.Geometries);
if (result.First().Geometry.SpatialReference == null)
if (result != null && result.Any() && result?.First() != null && result.First().Geometry != null && result?.First()?.Geometry?.SpatialReference == null)
{
result.First().Geometry.SpatialReference = outputSpatialReference;
}
Expand All @@ -425,7 +427,7 @@ public TimeSpan HttpRequestTimeout
if (ct.IsCancellationRequested) return null;

var result = operation.Features.UpdateGeometries<T>(projected.Geometries);
if (result.First().Geometry.SpatialReference == null)
if (result != null && result.Any() && result?.First() != null && result.First().Geometry != null && result?.First()?.Geometry?.SpatialReference == null)
{
result.First().Geometry.SpatialReference = operation.OutputSpatialReference;
}
Expand All @@ -450,7 +452,7 @@ public TimeSpan HttpRequestTimeout
if (ct.IsCancellationRequested) return null;

var result = features.UpdateGeometries<T>(buffered.Geometries);
if (result.Any() && result?.First() != null && result.First().Geometry != null && result?.First()?.Geometry?.SpatialReference == null)
if (result != null && result.Any() && result?.First() != null && result.First().Geometry != null && result?.First()?.Geometry?.SpatialReference == null)
{
result.First().Geometry.SpatialReference = spatialReference;
}
Expand All @@ -474,7 +476,7 @@ public TimeSpan HttpRequestTimeout
if (ct.IsCancellationRequested) return null;

var result = features.UpdateGeometries<T>(simplified.Geometries);
if (result.First().Geometry.SpatialReference == null)
if (result != null && result.Any() && result?.First() != null && result.First().Geometry != null && result?.First()?.Geometry?.SpatialReference == null)
{
result.First().Geometry.SpatialReference = spatialReference;
}
Expand Down Expand Up @@ -773,6 +775,11 @@ protected async Task<T> Get<T, TRequest>(TRequest requestObject, CancellationTok
result.Links = new List<Link> { new Link(uri.AbsoluteUri) };
}

if (IncludeRawResultWithResponse)
{
result.RawResult = resultString;
}

requestObject.AfterRequest?.Invoke(resultString);

return result;
Expand Down Expand Up @@ -874,6 +881,11 @@ protected async Task<T> Post<T, TRequest>(TRequest requestObject, CancellationTo
result.Links = new List<Link> { new Link(uri.AbsoluteUri, requestObject) };
}

if (IncludeRawResultWithResponse)
{
result.RawResult = resultString;
}

requestObject.AfterRequest?.Invoke(resultString);

return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="Polly" Version="7.2.1" />
<PackageReference Include="Serilog" Version="2.9.0" />
<PackageReference Include="Serilog" Version="2.10.0" />
<PackageReference Include="System.Reactive.Linq" Version="4.4.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
Expand Down
10 changes: 6 additions & 4 deletions tests/Anywhere.ArcGIS.Test.Integration/ArcGISGatewayTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,11 @@ public async Task CanGetServiceTileInfo(string rootUrl, string serviceId)
}

[Theory]
[InlineData("http://sampleserver3.arcgisonline.com/ArcGIS/", "Petroleum/KSWells/MapServer/0")]
[InlineData("http://sampleserver3.arcgisonline.com/ArcGIS/", "Petroleum/KSWells/MapServer/1")]
[InlineData("http://services.arcgisonline.co.nz/arcgis", "Canvas/Light/MapServer/0")]
[InlineData("https://services1.arcgis.com/dOFzdrPdRgtU4fRo/ArcGIS", "ServiceDefDouble/FeatureServer/0")]
//[InlineData("http://sampleserver3.arcgisonline.com/ArcGIS/", "Petroleum/KSWells/MapServer/0")]
//[InlineData("http://sampleserver3.arcgisonline.com/ArcGIS/", "Petroleum/KSWells/MapServer/1")]
//[InlineData("http://services.arcgisonline.co.nz/arcgis", "Canvas/Light/MapServer/0")]
//[InlineData("https://services1.arcgis.com/dOFzdrPdRgtU4fRo/ArcGIS", "ServiceDefDouble/FeatureServer/0")]
[InlineData("https://services2.arcgis.com/dEKgZETqwmDAh1rP/ArcGIS", "superseded_cp2014_v18_2020_Neighbourhood_Plan_boundaries/FeatureServer/0")]
public async Task CanDescribeLayer(string rootUrl, string layerUrl)
{
var gateway = new PortalGateway(rootUrl);
Expand All @@ -172,6 +173,7 @@ public async Task CanDescribeLayer(string rootUrl, string layerUrl)
Assert.Null(layerResponse.Error);
Assert.NotNull(layerResponse.GeometryType);
}

[Theory]
[InlineData("http://sampleserver3.arcgisonline.com/ArcGIS/", "Petroleum/KSWells/MapServer")]
[InlineData("http://services.arcgisonline.co.nz/arcgis", "Canvas/Light/MapServer")]
Expand Down
2 changes: 1 addition & 1 deletion tests/Anywhere.ArcGIS.Test/Anywhere.ArcGIS.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
Expand Down

0 comments on commit fdac065

Please sign in to comment.