From fda6fd93dca35d5302ce63091451aa2220f093f0 Mon Sep 17 00:00:00 2001 From: Dave Timmins Date: Sat, 25 Sep 2021 12:00:35 +1200 Subject: [PATCH 1/2] #74 --- src/Anywhere.ArcGIS/Operation/ServiceDescriptionDetails.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Anywhere.ArcGIS/Operation/ServiceDescriptionDetails.cs b/src/Anywhere.ArcGIS/Operation/ServiceDescriptionDetails.cs index fc59b37..d927337 100644 --- a/src/Anywhere.ArcGIS/Operation/ServiceDescriptionDetails.cs +++ b/src/Anywhere.ArcGIS/Operation/ServiceDescriptionDetails.cs @@ -114,7 +114,7 @@ public class TimeInfo public string TimeRelation { get; set; } [DataMember(Name = "defaultTimeInterval")] - public int DefaultTimeInterval { get; set; } + public double DefaultTimeInterval { get; set; } [DataMember(Name = "defaultTimeIntervalUnits")] public string DefaultTimeIntervalUnits { get; set; } From fdac0653bf6f020f74499ae6d537463d2c9093dd Mon Sep 17 00:00:00 2001 From: Dave Timmins Date: Sat, 25 Sep 2021 12:01:15 +1200 Subject: [PATCH 2/2] added include raw response option --- build.cake | 2 +- src/Anywhere.ArcGIS/Anywhere.ArcGIS.csproj | 2 +- .../Operation/PortalResponse.cs | 5 +++++ src/Anywhere.ArcGIS/PortalGateway.cs | 2 +- src/Anywhere.ArcGIS/PortalGatewayBase.cs | 22 ++++++++++++++----- .../Anywhere.ArcGIS.Test.Integration.csproj | 4 ++-- .../ArcGISGatewayTests.cs | 10 +++++---- .../Anywhere.ArcGIS.Test.csproj | 2 +- 8 files changed, 34 insertions(+), 15 deletions(-) diff --git a/build.cake b/build.cake index 642175b..8a89232 100644 --- a/build.cake +++ b/build.cake @@ -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"); ////////////////////////////////////////////////////////////////////// diff --git a/src/Anywhere.ArcGIS/Anywhere.ArcGIS.csproj b/src/Anywhere.ArcGIS/Anywhere.ArcGIS.csproj index 1382080..afe9e7a 100644 --- a/src/Anywhere.ArcGIS/Anywhere.ArcGIS.csproj +++ b/src/Anywhere.ArcGIS/Anywhere.ArcGIS.csproj @@ -15,7 +15,7 @@ https://github.com/davetimmins/Anywhere.ArcGIS git ArcGIS ArcGISServer ArcGISOnline Esri REST netstandard anywhere GIS Mapping Map Location GeoLocation OAuth - 2.0.0 + 2.0.1 LICENSE diff --git a/src/Anywhere.ArcGIS/Operation/PortalResponse.cs b/src/Anywhere.ArcGIS/Operation/PortalResponse.cs index d2d8834..0ceabf7 100644 --- a/src/Anywhere.ArcGIS/Operation/PortalResponse.cs +++ b/src/Anywhere.ArcGIS/Operation/PortalResponse.cs @@ -10,6 +10,9 @@ public interface IPortalResponse [DataMember(Name = "_links")] List Links { get; set; } + + [DataMember(Name = "_raw")] + string RawResult { get; set; } } /// @@ -26,6 +29,8 @@ public class PortalResponse : IPortalResponse [DataMember(Name = "_links")] public List Links { get; set; } + [DataMember(Name = "_raw")] + public string RawResult { get; set; } } [DataContract] diff --git a/src/Anywhere.ArcGIS/PortalGateway.cs b/src/Anywhere.ArcGIS/PortalGateway.cs index f25fe4c..f38cb5e 100644 --- a/src/Anywhere.ArcGIS/PortalGateway.cs +++ b/src/Anywhere.ArcGIS/PortalGateway.cs @@ -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; } diff --git a/src/Anywhere.ArcGIS/PortalGatewayBase.cs b/src/Anywhere.ArcGIS/PortalGatewayBase.cs index cffc2d6..a89aa3d 100644 --- a/src/Anywhere.ArcGIS/PortalGatewayBase.cs +++ b/src/Anywhere.ArcGIS/PortalGatewayBase.cs @@ -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; } @@ -389,7 +391,7 @@ public TimeSpan HttpRequestTimeout where T : IGeometry { var result = await Post>(edits, ct); - result.SetExpected(edits); + result?.SetExpected(edits); return result; } @@ -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; } @@ -425,7 +427,7 @@ public TimeSpan HttpRequestTimeout if (ct.IsCancellationRequested) return null; var result = operation.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 = operation.OutputSpatialReference; } @@ -450,7 +452,7 @@ public TimeSpan HttpRequestTimeout if (ct.IsCancellationRequested) return null; var result = features.UpdateGeometries(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; } @@ -474,7 +476,7 @@ public TimeSpan HttpRequestTimeout if (ct.IsCancellationRequested) return null; var result = features.UpdateGeometries(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; } @@ -773,6 +775,11 @@ protected async Task Get(TRequest requestObject, CancellationTok result.Links = new List { new Link(uri.AbsoluteUri) }; } + if (IncludeRawResultWithResponse) + { + result.RawResult = resultString; + } + requestObject.AfterRequest?.Invoke(resultString); return result; @@ -874,6 +881,11 @@ protected async Task Post(TRequest requestObject, CancellationTo result.Links = new List { new Link(uri.AbsoluteUri, requestObject) }; } + if (IncludeRawResultWithResponse) + { + result.RawResult = resultString; + } + requestObject.AfterRequest?.Invoke(resultString); return result; diff --git a/tests/Anywhere.ArcGIS.Test.Integration/Anywhere.ArcGIS.Test.Integration.csproj b/tests/Anywhere.ArcGIS.Test.Integration/Anywhere.ArcGIS.Test.Integration.csproj index 873a30d..700dc39 100644 --- a/tests/Anywhere.ArcGIS.Test.Integration/Anywhere.ArcGIS.Test.Integration.csproj +++ b/tests/Anywhere.ArcGIS.Test.Integration/Anywhere.ArcGIS.Test.Integration.csproj @@ -5,9 +5,9 @@ - + - + diff --git a/tests/Anywhere.ArcGIS.Test.Integration/ArcGISGatewayTests.cs b/tests/Anywhere.ArcGIS.Test.Integration/ArcGISGatewayTests.cs index 0d9f4c9..25e9648 100644 --- a/tests/Anywhere.ArcGIS.Test.Integration/ArcGISGatewayTests.cs +++ b/tests/Anywhere.ArcGIS.Test.Integration/ArcGISGatewayTests.cs @@ -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); @@ -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")] diff --git a/tests/Anywhere.ArcGIS.Test/Anywhere.ArcGIS.Test.csproj b/tests/Anywhere.ArcGIS.Test/Anywhere.ArcGIS.Test.csproj index 293819f..7befaa0 100644 --- a/tests/Anywhere.ArcGIS.Test/Anywhere.ArcGIS.Test.csproj +++ b/tests/Anywhere.ArcGIS.Test/Anywhere.ArcGIS.Test.csproj @@ -5,7 +5,7 @@ - + all