diff --git a/.travis.yml b/.travis.yml index 18e2f30..a30a88a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: csharp sudo: required -dist: trusty -dotnet: 2.0.0 +dist: xenial +dotnet: 3.1.300 os: - linux branches: diff --git a/build.cake b/build.cake index 0f79a14..642175b 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 = "1.12.0"; +var version = "2.0.0"; var versionSuffix = Environment.GetEnvironmentVariable("VERSION_SUFFIX"); ////////////////////////////////////////////////////////////////////// diff --git a/src/Anywhere.ArcGIS/Anywhere.ArcGIS.csproj b/src/Anywhere.ArcGIS/Anywhere.ArcGIS.csproj index c37ace3..1382080 100644 --- a/src/Anywhere.ArcGIS/Anywhere.ArcGIS.csproj +++ b/src/Anywhere.ArcGIS/Anywhere.ArcGIS.csproj @@ -1,7 +1,7 @@  - netstandard2.0 + netstandard2.1 true Dave Timmins Dave Timmins @@ -15,7 +15,7 @@ https://github.com/davetimmins/Anywhere.ArcGIS git ArcGIS ArcGISServer ArcGISOnline Esri REST netstandard anywhere GIS Mapping Map Location GeoLocation OAuth - 1.12.0 + 2.0.0 LICENSE diff --git a/src/Anywhere.ArcGIS/AttachmentWorker.cs b/src/Anywhere.ArcGIS/AttachmentWorker.cs index 417b25e..4512c87 100644 --- a/src/Anywhere.ArcGIS/AttachmentWorker.cs +++ b/src/Anywhere.ArcGIS/AttachmentWorker.cs @@ -185,7 +185,7 @@ protected async Task Post(TRequest requestObject, CancellationTo throw new InvalidOperationException(result.Error.ToString()); } - requestObject.AfterRequest?.Invoke(); + requestObject.AfterRequest?.Invoke(resultString); return result; } diff --git a/src/Anywhere.ArcGIS/Common/IGeometry.cs b/src/Anywhere.ArcGIS/Common/IGeometry.cs index 99685d0..20bdad8 100644 --- a/src/Anywhere.ArcGIS/Common/IGeometry.cs +++ b/src/Anywhere.ArcGIS/Common/IGeometry.cs @@ -42,6 +42,31 @@ public interface IGeometry : ICloneable IGeoJsonGeometry ToGeoJson(); } + public class NoGeometry : IGeometry + { + public SpatialReference SpatialReference { get; set; } + + public object Clone() + { + return new NoGeometry(); + } + + public Point GetCenter() + { + return null; + } + + public Extent GetExtent() + { + return null; + } + + public IGeoJsonGeometry ToGeoJson() + { + return null; + } + } + /// /// Spatial reference used for operations. If WKT is set then other properties are nulled /// diff --git a/src/Anywhere.ArcGIS/Common/IHttpOperation.cs b/src/Anywhere.ArcGIS/Common/IHttpOperation.cs index cfdd4ac..691d447 100644 --- a/src/Anywhere.ArcGIS/Common/IHttpOperation.cs +++ b/src/Anywhere.ArcGIS/Common/IHttpOperation.cs @@ -8,6 +8,6 @@ public interface IHttpOperation Action BeforeRequest { get; } - Action AfterRequest { get; } + Action AfterRequest { get; } } } diff --git a/src/Anywhere.ArcGIS/Extensions/FeatureCollectionExtensions.cs b/src/Anywhere.ArcGIS/Extensions/FeatureCollectionExtensions.cs index c1c2f84..82de49d 100644 --- a/src/Anywhere.ArcGIS/Extensions/FeatureCollectionExtensions.cs +++ b/src/Anywhere.ArcGIS/Extensions/FeatureCollectionExtensions.cs @@ -65,7 +65,7 @@ public static FeatureCollection ToFeatureCollection } var featureCollection = new FeatureCollection { Features = new List>() }; - if (features.First().Geometry.SpatialReference != null) + if (features?.First()?.Geometry?.SpatialReference != null) { featureCollection.CoordinateReferenceSystem = new Crs { @@ -76,7 +76,7 @@ public static FeatureCollection ToFeatureCollection foreach (var feature in features) { - var geoJsonGeometry = feature.Geometry.ToGeoJson(); + var geoJsonGeometry = feature?.Geometry?.ToGeoJson(); if (geoJsonGeometry == null) { continue; diff --git a/src/Anywhere.ArcGIS/Operation/Admin/PublicKey.cs b/src/Anywhere.ArcGIS/Operation/Admin/PublicKey.cs index be6b9c1..76ea0de 100644 --- a/src/Anywhere.ArcGIS/Operation/Admin/PublicKey.cs +++ b/src/Anywhere.ArcGIS/Operation/Admin/PublicKey.cs @@ -7,7 +7,7 @@ namespace Anywhere.ArcGIS.Operation.Admin [DataContract] public class PublicKey : ArcGISServerOperation { - public PublicKey(Action beforeRequest = null, Action afterRequest = null) + public PublicKey(Action beforeRequest = null, Action afterRequest = null) : base(new ArcGISServerAdminEndpoint(Operations.PublicKey), beforeRequest, afterRequest) { } } diff --git a/src/Anywhere.ArcGIS/Operation/Admin/ServiceReport.cs b/src/Anywhere.ArcGIS/Operation/Admin/ServiceReport.cs index cfdc1b6..e8d65d9 100644 --- a/src/Anywhere.ArcGIS/Operation/Admin/ServiceReport.cs +++ b/src/Anywhere.ArcGIS/Operation/Admin/ServiceReport.cs @@ -34,7 +34,7 @@ public IEnumerable ServiceReports public class ServiceReport : ArcGISServerOperation { - public ServiceReport(string path, Action beforeRequest = null, Action afterRequest = null) + public ServiceReport(string path, Action beforeRequest = null, Action afterRequest = null) : base(new ArcGISServerAdminEndpoint(string.Format(Operations.ServiceReport, path.Replace("/", "")).Replace("//", "/")), beforeRequest, afterRequest) { } } diff --git a/src/Anywhere.ArcGIS/Operation/Admin/ServiceStatistics.cs b/src/Anywhere.ArcGIS/Operation/Admin/ServiceStatistics.cs index 3067540..06ac8ce 100644 --- a/src/Anywhere.ArcGIS/Operation/Admin/ServiceStatistics.cs +++ b/src/Anywhere.ArcGIS/Operation/Admin/ServiceStatistics.cs @@ -8,7 +8,7 @@ namespace Anywhere.ArcGIS.Operation.Admin [DataContract] public class ServiceStatistics : ArcGISServerOperation { - public ServiceStatistics(ServiceDescription serviceDescription, Action beforeRequest = null, Action afterRequest = null) + public ServiceStatistics(ServiceDescription serviceDescription, Action beforeRequest = null, Action afterRequest = null) : base(new ArcGISServerAdminEndpoint(string.Format(Operations.ServiceStatistics, serviceDescription.Name, serviceDescription.Type)), beforeRequest, afterRequest) { } } diff --git a/src/Anywhere.ArcGIS/Operation/Admin/ServiceStatus.cs b/src/Anywhere.ArcGIS/Operation/Admin/ServiceStatus.cs index 1909cfc..e73dffc 100644 --- a/src/Anywhere.ArcGIS/Operation/Admin/ServiceStatus.cs +++ b/src/Anywhere.ArcGIS/Operation/Admin/ServiceStatus.cs @@ -7,7 +7,7 @@ namespace Anywhere.ArcGIS.Operation.Admin [DataContract] public class ServiceStatus : ArcGISServerOperation { - public ServiceStatus(ServiceDescription serviceDescription, Action beforeRequest = null, Action afterRequest = null) + public ServiceStatus(ServiceDescription serviceDescription, Action beforeRequest = null, Action afterRequest = null) : base (new ArcGISServerAdminEndpoint(string.Format(Operations.ServiceStatus, serviceDescription.Name, serviceDescription.Type)), beforeRequest, afterRequest) { } } diff --git a/src/Anywhere.ArcGIS/Operation/Admin/StartStop.cs b/src/Anywhere.ArcGIS/Operation/Admin/StartStop.cs index 3ec22ae..9d59d97 100644 --- a/src/Anywhere.ArcGIS/Operation/Admin/StartStop.cs +++ b/src/Anywhere.ArcGIS/Operation/Admin/StartStop.cs @@ -7,7 +7,7 @@ namespace Anywhere.ArcGIS.Operation.Admin [DataContract] public class StartService : ArcGISServerOperation { - public StartService(ServiceDescription serviceDescription, Action beforeRequest = null, Action afterRequest = null) + public StartService(ServiceDescription serviceDescription, Action beforeRequest = null, Action afterRequest = null) : base(new ArcGISServerAdminEndpoint(string.Format(Operations.StartService, serviceDescription.Name, serviceDescription.Type)), beforeRequest, afterRequest) { } } @@ -15,7 +15,7 @@ public StartService(ServiceDescription serviceDescription, Action beforeRequest [DataContract] public class StopService : ArcGISServerOperation { - public StopService(ServiceDescription serviceDescription, Action beforeRequest = null, Action afterRequest = null) + public StopService(ServiceDescription serviceDescription, Action beforeRequest = null, Action afterRequest = null) : base(new ArcGISServerAdminEndpoint(string.Format(Operations.StopService, serviceDescription.Name, serviceDescription.Type)), beforeRequest, afterRequest) { } } diff --git a/src/Anywhere.ArcGIS/Operation/ApplyEdits.cs b/src/Anywhere.ArcGIS/Operation/ApplyEdits.cs index df03adc..3ca6fa5 100644 --- a/src/Anywhere.ArcGIS/Operation/ApplyEdits.cs +++ b/src/Anywhere.ArcGIS/Operation/ApplyEdits.cs @@ -15,11 +15,11 @@ namespace Anywhere.ArcGIS.Operation public class ApplyEdits : ArcGISServerOperation where T : IGeometry { - public ApplyEdits(string relativeUrl, Action beforeRequest = null, Action afterRequest = null) + public ApplyEdits(string relativeUrl, Action beforeRequest = null, Action afterRequest = null) : this(relativeUrl.AsEndpoint(), beforeRequest, afterRequest) { } - public ApplyEdits(ArcGISServerEndpoint endpoint, Action beforeRequest = null, Action afterRequest = null) + public ApplyEdits(ArcGISServerEndpoint endpoint, Action beforeRequest = null, Action afterRequest = null) : base(endpoint.RelativeUrl.Trim('/') + "/" + Operations.ApplyEdits, beforeRequest, afterRequest) { Adds = new List>(); diff --git a/src/Anywhere.ArcGIS/Operation/ArcGISServerOperation.cs b/src/Anywhere.ArcGIS/Operation/ArcGISServerOperation.cs index 052e7fc..b0f385f 100644 --- a/src/Anywhere.ArcGIS/Operation/ArcGISServerOperation.cs +++ b/src/Anywhere.ArcGIS/Operation/ArcGISServerOperation.cs @@ -9,14 +9,14 @@ namespace Anywhere.ArcGIS.Operation /// public class ArcGISServerOperation : CommonParameters, IHttpOperation { - public ArcGISServerOperation(IEndpoint endpoint, Action beforeRequest = null, Action afterRequest = null) + public ArcGISServerOperation(IEndpoint endpoint, Action beforeRequest = null, Action afterRequest = null) { Endpoint = endpoint ?? throw new ArgumentNullException(nameof(endpoint)); BeforeRequest = beforeRequest; AfterRequest = afterRequest; } - public ArcGISServerOperation(string endpoint, Action beforeRequest = null, Action afterRequest = null) + public ArcGISServerOperation(string endpoint, Action beforeRequest = null, Action afterRequest = null) : this(new ArcGISServerEndpoint(endpoint), beforeRequest, afterRequest) { } @@ -24,7 +24,7 @@ public ArcGISServerOperation(string endpoint, Action beforeRequest = null, Actio public Action BeforeRequest { get; } [IgnoreDataMember] - public Action AfterRequest { get; } + public Action AfterRequest { get; } [IgnoreDataMember] public IEndpoint Endpoint { get; } diff --git a/src/Anywhere.ArcGIS/Operation/CreateReplica.cs b/src/Anywhere.ArcGIS/Operation/CreateReplica.cs index 6c50557..d300b38 100644 --- a/src/Anywhere.ArcGIS/Operation/CreateReplica.cs +++ b/src/Anywhere.ArcGIS/Operation/CreateReplica.cs @@ -18,11 +18,11 @@ [DataContract] public class CreateReplica : ArcGISServerOperation { - public CreateReplica(string relativeUrl, Action beforeRequest = null, Action afterRequest = null) + public CreateReplica(string relativeUrl, Action beforeRequest = null, Action afterRequest = null) : this(relativeUrl.AsEndpoint(), beforeRequest, afterRequest) { } - public CreateReplica(ArcGISServerEndpoint endpoint, Action beforeRequest = null, Action afterRequest = null) + public CreateReplica(ArcGISServerEndpoint endpoint, Action beforeRequest = null, Action afterRequest = null) : base(endpoint.RelativeUrl.Trim('/') + "/" + Operations.CreateReplica, beforeRequest, afterRequest) { ReturnAttachments = false; @@ -227,11 +227,11 @@ public LayerQuery() [DataContract] public class UnregisterReplica : ArcGISServerOperation { - public UnregisterReplica(string relativeUrl, Action beforeRequest = null, Action afterRequest = null) + public UnregisterReplica(string relativeUrl, Action beforeRequest = null, Action afterRequest = null) : this(relativeUrl.AsEndpoint(), beforeRequest, afterRequest) { } - public UnregisterReplica(ArcGISServerEndpoint endpoint, Action beforeRequest = null, Action afterRequest = null) + public UnregisterReplica(ArcGISServerEndpoint endpoint, Action beforeRequest = null, Action afterRequest = null) : base(endpoint.RelativeUrl.Trim('/') + "/" + Operations.UnregisterReplica, beforeRequest, afterRequest) { } diff --git a/src/Anywhere.ArcGIS/Operation/CustomGeocode.cs b/src/Anywhere.ArcGIS/Operation/CustomGeocode.cs index 0637e2e..b944ee8 100644 --- a/src/Anywhere.ArcGIS/Operation/CustomGeocode.cs +++ b/src/Anywhere.ArcGIS/Operation/CustomGeocode.cs @@ -11,11 +11,11 @@ namespace Anywhere.ArcGIS.Operation [DataContract] public class SingleInputCustomGeocode : ArcGISServerOperation { - public SingleInputCustomGeocode(string relativeUrl, Action beforeRequest = null, Action afterRequest = null) + public SingleInputCustomGeocode(string relativeUrl, Action beforeRequest = null, Action afterRequest = null) : this(relativeUrl.AsEndpoint(), beforeRequest, afterRequest) { } - public SingleInputCustomGeocode(ArcGISServerEndpoint endpoint, Action beforeRequest = null, Action afterRequest = null) + public SingleInputCustomGeocode(ArcGISServerEndpoint endpoint, Action beforeRequest = null, Action afterRequest = null) : base(endpoint.RelativeUrl.Trim('/') + "/" + Operations.SingleInputCustomGeocode, beforeRequest, afterRequest) { } diff --git a/src/Anywhere.ArcGIS/Operation/DeleteAttachments.cs b/src/Anywhere.ArcGIS/Operation/DeleteAttachments.cs index d17f146..1ebc6e6 100644 --- a/src/Anywhere.ArcGIS/Operation/DeleteAttachments.cs +++ b/src/Anywhere.ArcGIS/Operation/DeleteAttachments.cs @@ -10,21 +10,21 @@ namespace Anywhere.ArcGIS.Operation [DataContract] public class DeleteAttachments : ArcGISServerOperation { - public DeleteAttachments(string relativeUrl, long objectID, Action beforeRequest = null, Action afterRequest = null) + public DeleteAttachments(string relativeUrl, long objectID, Action beforeRequest = null, Action afterRequest = null) : this(relativeUrl.AsEndpoint(), objectID, beforeRequest, afterRequest) { } - public DeleteAttachments(ArcGISServerEndpoint endpoint, long objectID, Action beforeRequest = null, Action afterRequest = null) + public DeleteAttachments(ArcGISServerEndpoint endpoint, long objectID, Action beforeRequest = null, Action afterRequest = null) : this((endpoint.RelativeUrl.Trim('/') + string.Format("/{0}", objectID)).AsEndpoint(), beforeRequest, afterRequest) { AttachmentIds = new List(); } - public DeleteAttachments(string relativeUrl, Action beforeRequest = null, Action afterRequest = null) + public DeleteAttachments(string relativeUrl, Action beforeRequest = null, Action afterRequest = null) : this(relativeUrl.AsEndpoint(), beforeRequest, afterRequest) { } - public DeleteAttachments(ArcGISServerEndpoint endpoint, Action beforeRequest = null, Action afterRequest = null) + public DeleteAttachments(ArcGISServerEndpoint endpoint, Action beforeRequest = null, Action afterRequest = null) : base(endpoint.RelativeUrl.Trim('/') + "/" + Operations.DeleteAttachments, beforeRequest, afterRequest) { AttachmentIds = new List(); @@ -85,11 +85,11 @@ public AttachmentToPost(ArcGISServerEndpoint endpoint, long objectID, byte[] att AttachmentBase64Encoded = Convert.ToBase64String(Attachment); } - AttachmentToPost(string relativeUrl, long objectID, string fileName, string contentType, bool isUpdate = false, Action beforeRequest = null, Action afterRequest = null) + AttachmentToPost(string relativeUrl, long objectID, string fileName, string contentType, bool isUpdate = false, Action beforeRequest = null, Action afterRequest = null) : this(relativeUrl.AsEndpoint(), objectID, fileName, contentType, isUpdate, beforeRequest, afterRequest) { } - AttachmentToPost(ArcGISServerEndpoint endpoint, long objectID, string fileName, string contentType, bool isUpdate = false, Action beforeRequest = null, Action afterRequest = null) + AttachmentToPost(ArcGISServerEndpoint endpoint, long objectID, string fileName, string contentType, bool isUpdate = false, Action beforeRequest = null, Action afterRequest = null) : base(endpoint.RelativeUrl.Trim('/') + string.Format("/{0}/{1}", objectID, isUpdate ? "updateAttachment" : "addAttachment"), beforeRequest, afterRequest) { ObjectID = objectID; diff --git a/src/Anywhere.ArcGIS/Operation/DeleteFeatures.cs b/src/Anywhere.ArcGIS/Operation/DeleteFeatures.cs index c49e105..01b2af9 100644 --- a/src/Anywhere.ArcGIS/Operation/DeleteFeatures.cs +++ b/src/Anywhere.ArcGIS/Operation/DeleteFeatures.cs @@ -10,11 +10,11 @@ namespace Anywhere.ArcGIS.Operation [DataContract] public class DeleteFeatures : ArcGISServerOperation { - public DeleteFeatures(string relativeUrl, Action beforeRequest = null, Action afterRequest = null) + public DeleteFeatures(string relativeUrl, Action beforeRequest = null, Action afterRequest = null) : this(relativeUrl.AsEndpoint(), beforeRequest, afterRequest) { } - public DeleteFeatures(ArcGISServerEndpoint endpoint, Action beforeRequest = null, Action afterRequest = null) + public DeleteFeatures(ArcGISServerEndpoint endpoint, Action beforeRequest = null, Action afterRequest = null) : base(endpoint.RelativeUrl.Trim('/') + "/" + Operations.DeleteFeatures, beforeRequest, afterRequest) { SpatialRelationship = SpatialRelationshipTypes.Intersects; diff --git a/src/Anywhere.ArcGIS/Operation/ExportMap.cs b/src/Anywhere.ArcGIS/Operation/ExportMap.cs index 97b1355..692f5ff 100644 --- a/src/Anywhere.ArcGIS/Operation/ExportMap.cs +++ b/src/Anywhere.ArcGIS/Operation/ExportMap.cs @@ -10,7 +10,7 @@ namespace Anywhere.ArcGIS.Operation [DataContract] public class ExportMap : ArcGISServerOperation { - public ExportMap(string relativeUrl, Action beforeRequest = null, Action afterRequest = null) + public ExportMap(string relativeUrl, Action beforeRequest = null, Action afterRequest = null) : this(relativeUrl.AsEndpoint(), beforeRequest, afterRequest) { } @@ -18,7 +18,7 @@ public ExportMap(string relativeUrl, Action beforeRequest = null, Action afterRe /// Requests an export of the map resources. Returns the image link in the response /// /// Resource to apply the export against - public ExportMap(ArcGISServerEndpoint endpoint, Action beforeRequest = null, Action afterRequest = null) + public ExportMap(ArcGISServerEndpoint endpoint, Action beforeRequest = null, Action afterRequest = null) : base(endpoint.RelativeUrl.Trim('/') + "/" + Operations.ExportMap, beforeRequest, afterRequest) { Size = new List { 400, 400 }; diff --git a/src/Anywhere.ArcGIS/Operation/Find.cs b/src/Anywhere.ArcGIS/Operation/Find.cs index 8091e09..5302bdb 100644 --- a/src/Anywhere.ArcGIS/Operation/Find.cs +++ b/src/Anywhere.ArcGIS/Operation/Find.cs @@ -11,7 +11,7 @@ namespace Anywhere.ArcGIS.Operation [DataContract] public class Find : ArcGISServerOperation { - public Find(string relativeUrl, Action beforeRequest = null, Action afterRequest = null) + public Find(string relativeUrl, Action beforeRequest = null, Action afterRequest = null) : this(relativeUrl.AsEndpoint(), beforeRequest, afterRequest) { } @@ -19,7 +19,7 @@ public Find(string relativeUrl, Action beforeRequest = null, Action afterRequest /// Represents a request for a find against a service resource /// /// Resource to apply the query against - public Find(ArcGISServerEndpoint endpoint, Action beforeRequest = null, Action afterRequest = null) + public Find(ArcGISServerEndpoint endpoint, Action beforeRequest = null, Action afterRequest = null) : base(endpoint.RelativeUrl.Trim('/') + "/" + Operations.Find, beforeRequest, afterRequest) { FuzzySearch = true; diff --git a/src/Anywhere.ArcGIS/Operation/GeometryServerOperation.cs b/src/Anywhere.ArcGIS/Operation/GeometryServerOperation.cs index 302ae29..6aa68fc 100644 --- a/src/Anywhere.ArcGIS/Operation/GeometryServerOperation.cs +++ b/src/Anywhere.ArcGIS/Operation/GeometryServerOperation.cs @@ -18,7 +18,7 @@ public class GeometryOperationResponse : PortalResponse public class SimplifyGeometry : ArcGISServerOperation where T : IGeometry { - public SimplifyGeometry(IEndpoint endpoint, List> features = null, SpatialReference spatialReference = null, Action beforeRequest = null, Action afterRequest = null) + public SimplifyGeometry(IEndpoint endpoint, List> features = null, SpatialReference spatialReference = null, Action beforeRequest = null, Action afterRequest = null) : base((endpoint is AbsoluteEndpoint) ? (IEndpoint)new AbsoluteEndpoint(endpoint.RelativeUrl.Trim('/') + "/" + Operations.Simplify) : (IEndpoint)new ArcGISServerEndpoint(endpoint.RelativeUrl.Trim('/') + "/" + Operations.Simplify), @@ -150,7 +150,7 @@ public GeometryOperation(IEndpoint endpoint, List> features, SpatialReference outputSpatialReference, string operation, - Action beforeRequest = null, Action afterRequest = null) + Action beforeRequest = null, Action afterRequest = null) : base((endpoint is AbsoluteEndpoint) ? (IEndpoint)new AbsoluteEndpoint(endpoint.RelativeUrl.Trim('/') + "/" + operation) : (IEndpoint)new ArcGISServerEndpoint(endpoint.RelativeUrl.Trim('/') + "/" + operation), @@ -161,8 +161,8 @@ public GeometryOperation(IEndpoint endpoint, { Geometries = new GeometryCollection { Geometries = new List(features.Select(f => f.Geometry)) }; - if (Geometries.Geometries.First().SpatialReference == null && features.First().Geometry.SpatialReference != null) - Geometries.Geometries.First().SpatialReference = new SpatialReference { Wkid = features.First().Geometry.SpatialReference.Wkid }; + if (Geometries.Geometries.First()?.SpatialReference == null && features?.First()?.Geometry?.SpatialReference != null) + Geometries.Geometries.First().SpatialReference = new SpatialReference { Wkid = features?.First()?.Geometry?.SpatialReference?.Wkid }; } OutputSpatialReference = outputSpatialReference; } @@ -177,7 +177,7 @@ public GeometryOperation(IEndpoint endpoint, /// Taken from the spatial reference of the first geometry, if that is null then assumed to be using Wgs84 /// [DataMember(Name = "inSR")] - public SpatialReference InputSpatialReference { get { return Geometries.Geometries.First().SpatialReference ?? SpatialReference.WGS84; } } + public SpatialReference InputSpatialReference { get { return Geometries.Geometries.First()?.SpatialReference ?? SpatialReference.WGS84; } } /// /// The spatial reference of the returned geometry. diff --git a/src/Anywhere.ArcGIS/Operation/LayerFeature.cs b/src/Anywhere.ArcGIS/Operation/LayerFeature.cs index c4ed0bf..8562f2e 100644 --- a/src/Anywhere.ArcGIS/Operation/LayerFeature.cs +++ b/src/Anywhere.ArcGIS/Operation/LayerFeature.cs @@ -7,11 +7,11 @@ namespace Anywhere.ArcGIS.Operation [DataContract] public class LayerFeature : ArcGISServerOperation { - public LayerFeature(string relativeUrl, long featureId, Action beforeRequest = null, Action afterRequest = null) + public LayerFeature(string relativeUrl, long featureId, Action beforeRequest = null, Action afterRequest = null) : this(relativeUrl.AsEndpoint(), featureId, beforeRequest, afterRequest) { } - public LayerFeature(ArcGISServerEndpoint endpoint, long featureId, Action beforeRequest = null, Action afterRequest = null) + public LayerFeature(ArcGISServerEndpoint endpoint, long featureId, Action beforeRequest = null, Action afterRequest = null) : base($"{endpoint.RelativeUrl.Trim('/')}/{featureId}", beforeRequest, afterRequest) { } diff --git a/src/Anywhere.ArcGIS/Operation/LegendsDescription.cs b/src/Anywhere.ArcGIS/Operation/LegendsDescription.cs index 9d0cf45..518f61e 100644 --- a/src/Anywhere.ArcGIS/Operation/LegendsDescription.cs +++ b/src/Anywhere.ArcGIS/Operation/LegendsDescription.cs @@ -11,7 +11,7 @@ public class LegendsDescription : ArcGISServerOperation { public LegendsDescription(string relativeUrl, Action beforeRequest = null, - Action afterRequest = null) + Action afterRequest = null) : this(relativeUrl.AsEndpoint(), beforeRequest, afterRequest) { } @@ -26,7 +26,7 @@ public LegendsDescription(string relativeUrl, /// Resource to apply the export against public LegendsDescription(IEndpoint endpoint, Action beforeRequest = null, - Action afterRequest = null) + Action afterRequest = null) : base(endpoint.RelativeUrl.Trim('/') + "/" + Operations.Legend, beforeRequest, afterRequest) { } diff --git a/src/Anywhere.ArcGIS/Operation/Query.cs b/src/Anywhere.ArcGIS/Operation/Query.cs index 6bc1894..aaf8988 100644 --- a/src/Anywhere.ArcGIS/Operation/Query.cs +++ b/src/Anywhere.ArcGIS/Operation/Query.cs @@ -12,7 +12,7 @@ namespace Anywhere.ArcGIS.Operation [DataContract] public class Query : ArcGISServerOperation { - public Query(string relativeUrl, Action beforeRequest = null, Action afterRequest = null) + public Query(string relativeUrl, Action beforeRequest = null, Action afterRequest = null) : this(relativeUrl.AsEndpoint(), beforeRequest, afterRequest) { } @@ -20,7 +20,7 @@ public Query(string relativeUrl, Action beforeRequest = null, Action afterReques /// Represents a request for a query against a service resource /// /// Resource to apply the query against - public Query(ArcGISServerEndpoint endpoint, Action beforeRequest = null, Action afterRequest = null) + public Query(ArcGISServerEndpoint endpoint, Action beforeRequest = null, Action afterRequest = null) : base(endpoint.RelativeUrl.Trim('/') + "/" + Operations.Query, beforeRequest, afterRequest) { Where = "1=1"; @@ -348,12 +348,12 @@ public class Field [DataContract] public class QueryForIds : Query { - public QueryForIds(string relativeUrl, Action beforeRequest = null, Action afterRequest = null) + public QueryForIds(string relativeUrl, Action beforeRequest = null, Action afterRequest = null) : this(relativeUrl.AsEndpoint(), beforeRequest, afterRequest) { } // TODO : make these work with or without input geometry - public QueryForIds(ArcGISServerEndpoint endpoint, Action beforeRequest = null, Action afterRequest = null) + public QueryForIds(ArcGISServerEndpoint endpoint, Action beforeRequest = null, Action afterRequest = null) : base(endpoint, beforeRequest, afterRequest) { ReturnGeometry = false; @@ -379,11 +379,11 @@ public class QueryForIdsResponse : PortalResponse [DataContract] public class QueryForCount : Query { - public QueryForCount(string relativeUrl, Action beforeRequest = null, Action afterRequest = null) + public QueryForCount(string relativeUrl, Action beforeRequest = null, Action afterRequest = null) : this(relativeUrl.AsEndpoint(), beforeRequest, afterRequest) { } - public QueryForCount(ArcGISServerEndpoint endpoint, Action beforeRequest = null, Action afterRequest = null) + public QueryForCount(ArcGISServerEndpoint endpoint, Action beforeRequest = null, Action afterRequest = null) : base(endpoint, beforeRequest, afterRequest) { ReturnGeometry = false; @@ -406,11 +406,11 @@ public class QueryForCountResponse : PortalResponse [DataContract] public class QueryForExtent : QueryForCount { - public QueryForExtent(string relativeUrl, Action beforeRequest = null, Action afterRequest = null) + public QueryForExtent(string relativeUrl, Action beforeRequest = null, Action afterRequest = null) : this(relativeUrl.AsEndpoint(), beforeRequest, afterRequest) { } - public QueryForExtent(ArcGISServerEndpoint endpoint, Action beforeRequest = null, Action afterRequest = null) + public QueryForExtent(ArcGISServerEndpoint endpoint, Action beforeRequest = null, Action afterRequest = null) : base(endpoint, beforeRequest, afterRequest) { } @@ -433,7 +433,8 @@ public static class GeometryTypes { typeof(MultiPoint), () => GeometryTypes.MultiPoint }, { typeof(Extent), () => GeometryTypes.Envelope }, { typeof(Polygon), () => GeometryTypes.Polygon }, - { typeof(Polyline), () => GeometryTypes.Polyline } + { typeof(Polyline), () => GeometryTypes.Polyline }, + { typeof(NoGeometry), () => string.Empty } }; public readonly static Dictionary> ToTypeMap = new Dictionary> diff --git a/src/Anywhere.ArcGIS/Operation/QueryAttachments.cs b/src/Anywhere.ArcGIS/Operation/QueryAttachments.cs index 13b52f1..26a4a2a 100644 --- a/src/Anywhere.ArcGIS/Operation/QueryAttachments.cs +++ b/src/Anywhere.ArcGIS/Operation/QueryAttachments.cs @@ -16,11 +16,11 @@ namespace Anywhere.ArcGIS.Operation [DataContract] public class QueryAttachments : ArcGISServerOperation { - public QueryAttachments(string relativeUrl, Action beforeRequest = null, Action afterRequest = null) + public QueryAttachments(string relativeUrl, Action beforeRequest = null, Action afterRequest = null) : this(relativeUrl.AsEndpoint(), beforeRequest, afterRequest) { } - public QueryAttachments(ArcGISServerEndpoint endpoint, Action beforeRequest = null, Action afterRequest = null) + public QueryAttachments(ArcGISServerEndpoint endpoint, Action beforeRequest = null, Action afterRequest = null) : base(endpoint.RelativeUrl.Trim('/') + "/" + Operations.QueryAttachments, beforeRequest, afterRequest) { ObjectIds = new List(); diff --git a/src/Anywhere.ArcGIS/Operation/QueryDomains.cs b/src/Anywhere.ArcGIS/Operation/QueryDomains.cs index 186fdac..61a74a3 100644 --- a/src/Anywhere.ArcGIS/Operation/QueryDomains.cs +++ b/src/Anywhere.ArcGIS/Operation/QueryDomains.cs @@ -10,11 +10,11 @@ namespace Anywhere.ArcGIS.Operation [DataContract] public class QueryDomains : ArcGISServerOperation { - public QueryDomains(string relativeUrl, Action beforeRequest = null, Action afterRequest = null) + public QueryDomains(string relativeUrl, Action beforeRequest = null, Action afterRequest = null) : this(relativeUrl.AsEndpoint(), beforeRequest, afterRequest) { } - public QueryDomains(ArcGISServerEndpoint endpoint, Action beforeRequest = null, Action afterRequest = null) + public QueryDomains(ArcGISServerEndpoint endpoint, Action beforeRequest = null, Action afterRequest = null) : base(endpoint.RelativeUrl.Trim('/') + "/" + Operations.QueryDomains, beforeRequest, afterRequest) { LayerIdsToSearch = new List(); diff --git a/src/Anywhere.ArcGIS/Operation/ReverseGeocode.cs b/src/Anywhere.ArcGIS/Operation/ReverseGeocode.cs index 7be71d0..97efe35 100644 --- a/src/Anywhere.ArcGIS/Operation/ReverseGeocode.cs +++ b/src/Anywhere.ArcGIS/Operation/ReverseGeocode.cs @@ -7,7 +7,7 @@ namespace Anywhere.ArcGIS.Operation [DataContract] public abstract class GeocodeOperation : ArcGISServerOperation { - public GeocodeOperation(IEndpoint endpoint, Action beforeRequest = null, Action afterRequest = null) + public GeocodeOperation(IEndpoint endpoint, Action beforeRequest = null, Action afterRequest = null) : base(endpoint, beforeRequest, afterRequest) { } @@ -56,11 +56,11 @@ public GeocodeOperation(IEndpoint endpoint, Action beforeRequest = null, Action [DataContract] public class ReverseGeocode : GeocodeOperation { - public ReverseGeocode(string relativeUrl, Action beforeRequest = null, Action afterRequest = null) + public ReverseGeocode(string relativeUrl, Action beforeRequest = null, Action afterRequest = null) : this(relativeUrl.AsEndpoint(), beforeRequest, afterRequest) { } - public ReverseGeocode(ArcGISServerEndpoint endpoint, Action beforeRequest = null, Action afterRequest = null) + public ReverseGeocode(ArcGISServerEndpoint endpoint, Action beforeRequest = null, Action afterRequest = null) : base(new ArcGISServerEndpoint(endpoint.RelativeUrl.Trim('/') + "/" + Operations.ReverseGeocode), beforeRequest, afterRequest) { Distance = 100; diff --git a/src/Anywhere.ArcGIS/Operation/SearchHostedFeatureServices.cs b/src/Anywhere.ArcGIS/Operation/SearchHostedFeatureServices.cs index d21841b..6fb28bd 100644 --- a/src/Anywhere.ArcGIS/Operation/SearchHostedFeatureServices.cs +++ b/src/Anywhere.ArcGIS/Operation/SearchHostedFeatureServices.cs @@ -35,7 +35,7 @@ public class SearchArcGISOnline : ArcGISServerOperation /// SSearch against ArcGISOnline / Portal /// /// The search query to execute - public SearchArcGISOnline(string query, Action beforeRequest = null, Action afterRequest = null) + public SearchArcGISOnline(string query, Action beforeRequest = null, Action afterRequest = null) : base(new ArcGISOnlineEndpoint(Operations.ArcGISOnlineSearch), beforeRequest, afterRequest) { Query = query; diff --git a/src/Anywhere.ArcGIS/Operation/ServerInfo.cs b/src/Anywhere.ArcGIS/Operation/ServerInfo.cs index 3320472..848f887 100644 --- a/src/Anywhere.ArcGIS/Operation/ServerInfo.cs +++ b/src/Anywhere.ArcGIS/Operation/ServerInfo.cs @@ -10,7 +10,7 @@ [DataContract] public class ServerInfo : ArcGISServerOperation { - public ServerInfo(Action beforeRequest = null, Action afterRequest = null) + public ServerInfo(Action beforeRequest = null, Action afterRequest = null) : base(new RootServerEndpoint(Operations.ServerInfoRoute), beforeRequest, afterRequest) { } } @@ -61,7 +61,7 @@ public class AuthInfo [DataContract] public class HealthCheck : ArcGISServerOperation { - public HealthCheck(Action beforeRequest = null, Action afterRequest = null) + public HealthCheck(Action beforeRequest = null, Action afterRequest = null) : base(new RootServerEndpoint(Operations.ServerHealthCheckRoute), beforeRequest, afterRequest) { } } diff --git a/src/Anywhere.ArcGIS/Operation/ServiceDescriptionDetails.cs b/src/Anywhere.ArcGIS/Operation/ServiceDescriptionDetails.cs index 579d8f2..fc59b37 100644 --- a/src/Anywhere.ArcGIS/Operation/ServiceDescriptionDetails.cs +++ b/src/Anywhere.ArcGIS/Operation/ServiceDescriptionDetails.cs @@ -16,7 +16,7 @@ public class ServiceDescriptionDetails : ArcGISServerOperation /// Request for the details of an ArcGIS Server service /// /// A from a previous call to DescribeSite - public ServiceDescriptionDetails(ServiceDescription serviceDescription, Action beforeRequest = null, Action afterRequest = null) + public ServiceDescriptionDetails(ServiceDescription serviceDescription, Action beforeRequest = null, Action afterRequest = null) : base(serviceDescription.ArcGISServerEndpoint, beforeRequest, afterRequest) { if (serviceDescription == null) @@ -29,7 +29,7 @@ public ServiceDescriptionDetails(ServiceDescription serviceDescription, Action b /// Request for the details of an ArcGIS Server service /// /// - public ServiceDescriptionDetails(IEndpoint serviceEndpoint, Action beforeRequest = null, Action afterRequest = null) + public ServiceDescriptionDetails(IEndpoint serviceEndpoint, Action beforeRequest = null, Action afterRequest = null) : base(serviceEndpoint, beforeRequest, afterRequest) { } } diff --git a/src/Anywhere.ArcGIS/Operation/ServiceLayerDescription.cs b/src/Anywhere.ArcGIS/Operation/ServiceLayerDescription.cs index 48673d4..55a8b5d 100644 --- a/src/Anywhere.ArcGIS/Operation/ServiceLayerDescription.cs +++ b/src/Anywhere.ArcGIS/Operation/ServiceLayerDescription.cs @@ -16,7 +16,7 @@ public class ServiceLayerDescription : ArcGISServerOperation /// Request for the details of an ArcGIS Server service layer /// /// - public ServiceLayerDescription(IEndpoint serviceEndpoint, Action beforeRequest = null, Action afterRequest = null) + public ServiceLayerDescription(IEndpoint serviceEndpoint, Action beforeRequest = null, Action afterRequest = null) : base(serviceEndpoint, beforeRequest, afterRequest) { } } diff --git a/src/Anywhere.ArcGIS/Operation/SingleInputGeocode.cs b/src/Anywhere.ArcGIS/Operation/SingleInputGeocode.cs index 3ca0016..f69d9e1 100644 --- a/src/Anywhere.ArcGIS/Operation/SingleInputGeocode.cs +++ b/src/Anywhere.ArcGIS/Operation/SingleInputGeocode.cs @@ -11,11 +11,11 @@ namespace Anywhere.ArcGIS.Operation [DataContract] public class SingleInputGeocode : GeocodeOperation { - public SingleInputGeocode(string relativeUrl, Action beforeRequest = null, Action afterRequest = null) + public SingleInputGeocode(string relativeUrl, Action beforeRequest = null, Action afterRequest = null) : this(relativeUrl.AsEndpoint(), beforeRequest, afterRequest) { } - public SingleInputGeocode(ArcGISServerEndpoint endpoint, Action beforeRequest = null, Action afterRequest = null) + public SingleInputGeocode(ArcGISServerEndpoint endpoint, Action beforeRequest = null, Action afterRequest = null) : base(new ArcGISServerEndpoint(endpoint.RelativeUrl.Trim('/') + "/" + Operations.SingleInputGeocode), beforeRequest, afterRequest) { MaxResults = 1; @@ -102,11 +102,11 @@ public class Location [DataContract] public class SuggestGeocode : GeocodeOperation { - public SuggestGeocode(string relativeUrl, Action beforeRequest = null, Action afterRequest = null) + public SuggestGeocode(string relativeUrl, Action beforeRequest = null, Action afterRequest = null) : this(relativeUrl.AsEndpoint(), beforeRequest, afterRequest) { } - public SuggestGeocode(ArcGISServerEndpoint endpoint, Action beforeRequest = null, Action afterRequest = null) + public SuggestGeocode(ArcGISServerEndpoint endpoint, Action beforeRequest = null, Action afterRequest = null) : base(new ArcGISServerEndpoint(endpoint.RelativeUrl.Trim('/') + "/" + Operations.SuggestGeocode), beforeRequest, afterRequest) { Distance = null; diff --git a/src/Anywhere.ArcGIS/PortalGatewayBase.cs b/src/Anywhere.ArcGIS/PortalGatewayBase.cs index d04ccc1..cffc2d6 100644 --- a/src/Anywhere.ArcGIS/PortalGatewayBase.cs +++ b/src/Anywhere.ArcGIS/PortalGatewayBase.cs @@ -67,8 +67,8 @@ public static async Task Create( new ServerFederatedWithPortalTokenProvider(info.AuthenticationInfo.TokenServicesUrl.Replace("/generateToken", ""), username, password, serializer: serializer, httpClientFunc: httpClientFunc), info.AuthenticationInfo.TokenServicesUrl.Replace("/generateToken", ""), gateway.RootUrl, - referer: info.AuthenticationInfo.TokenServicesUrl.Replace("/sharing/rest/generateToken", "/rest"), - serializer: serializer, + referer: info.AuthenticationInfo.TokenServicesUrl.Replace("/sharing/rest/generateToken", "/rest"), + serializer: serializer, httpClientFunc: httpClientFunc); } else @@ -214,12 +214,12 @@ public TimeSpan HttpRequestTimeout /// The legend descriptions details public virtual Task DescribeLegends(IEndpoint mapServiceEndpoint, CancellationToken ct = default(CancellationToken)) { - if (mapServiceEndpoint == null) - { - throw new ArgumentNullException(nameof(mapServiceEndpoint)); - } + if (mapServiceEndpoint == null) + { + throw new ArgumentNullException(nameof(mapServiceEndpoint)); + } - return DescribeLegends(new LegendsDescription(mapServiceEndpoint), ct); + return DescribeLegends(new LegendsDescription(mapServiceEndpoint), ct); } /// @@ -228,22 +228,22 @@ public TimeSpan HttpRequestTimeout /// The legend descriptions details public virtual Task DescribeLegends(LegendsDescription legendDescriptionRequest, CancellationToken ct = default(CancellationToken)) { - if (legendDescriptionRequest == null) - { - throw new ArgumentNullException(nameof(legendDescriptionRequest)); - } + if (legendDescriptionRequest == null) + { + throw new ArgumentNullException(nameof(legendDescriptionRequest)); + } - return Get(legendDescriptionRequest, ct); + return Get(legendDescriptionRequest, ct); } - /// - /// The feature resource represents a single feature in a layer in a map service. - /// - /// - /// - /// - /// - public virtual Task> GetFeature(LayerFeature layerFeature, CancellationToken ct = default(CancellationToken)) + /// + /// The feature resource represents a single feature in a layer in a map service. + /// + /// + /// + /// + /// + public virtual Task> GetFeature(LayerFeature layerFeature, CancellationToken ct = default(CancellationToken)) where T : IGeometry { return Get, LayerFeature>(layerFeature, ct); @@ -262,6 +262,22 @@ public TimeSpan HttpRequestTimeout return Get, Query>(queryOptions, ct); } + /// + /// Call the query operation + /// + /// Query filter parameters + /// Optional cancellation token to cancel pending request + /// The matching features for the query + public virtual Task> Query(Query queryOptions, CancellationToken ct = default(CancellationToken)) + { + if (queryOptions != null) + { + queryOptions.ReturnGeometry = false; + } + + return Get, Query>(queryOptions, ct); + } + public virtual async Task> BatchQuery(Query queryOptions, CancellationToken ct = default(CancellationToken)) where T : IGeometry { @@ -302,8 +318,8 @@ public TimeSpan HttpRequestTimeout { oidList = oidList.Concat(innerResult.Features.Select(x => x.ObjectID.ToString())); result.Features = result.Features.Concat(innerResult.Features); - exceeded = result.ExceededTransferLimit.HasValue - && innerResult.ExceededTransferLimit.HasValue + exceeded = result.ExceededTransferLimit.HasValue + && innerResult.ExceededTransferLimit.HasValue && innerResult.ExceededTransferLimit.Value; } else @@ -394,7 +410,10 @@ public TimeSpan HttpRequestTimeout if (ct.IsCancellationRequested) return null; var result = features.UpdateGeometries(projected.Geometries); - if (result.First().Geometry.SpatialReference == null) result.First().Geometry.SpatialReference = outputSpatialReference; + if (result.First().Geometry.SpatialReference == null) + { + result.First().Geometry.SpatialReference = outputSpatialReference; + } return result; } @@ -406,7 +425,10 @@ public TimeSpan HttpRequestTimeout if (ct.IsCancellationRequested) return null; var result = operation.Features.UpdateGeometries(projected.Geometries); - if (result.First().Geometry.SpatialReference == null) result.First().Geometry.SpatialReference = operation.OutputSpatialReference; + if (result.First().Geometry.SpatialReference == null) + { + result.First().Geometry.SpatialReference = operation.OutputSpatialReference; + } return result; } @@ -452,7 +474,10 @@ public TimeSpan HttpRequestTimeout if (ct.IsCancellationRequested) return null; var result = features.UpdateGeometries(simplified.Geometries); - if (result.First().Geometry.SpatialReference == null) result.First().Geometry.SpatialReference = spatialReference; + if (result.First().Geometry.SpatialReference == null) + { + result.First().Geometry.SpatialReference = spatialReference; + } return result; } @@ -617,7 +642,7 @@ public virtual async Task DownloadExportMapToLocal(ExportMapResponse e { throw new ArgumentNullException(nameof(exportMapResponse)); } - + if (string.IsNullOrWhiteSpace(exportMapResponse.ImageUrl)) { throw new ArgumentNullException(nameof(exportMapResponse.ImageUrl)); @@ -680,7 +705,7 @@ protected async Task Get(TRequest requestObject, CancellationTok var endpoint = requestObject.Endpoint; var url = endpoint.BuildAbsoluteUrl(RootUrl) + AsRequestQueryString(Serializer, requestObject); - + var token = await CheckGenerateToken(ct).ConfigureAwait(false); if (ct.IsCancellationRequested) { @@ -710,11 +735,11 @@ protected async Task Get(TRequest requestObject, CancellationTok } if (url.Length > MaximumGetRequestLength) - { + { _logger.DebugFormat("Url length {0} is greater than maximum configured {1}, switching to POST.", url.Length, MaximumGetRequestLength); return await Post(requestObject, ct).ConfigureAwait(false); } - + _logger.DebugFormat("GET {0}", uri.AbsoluteUri); requestObject.BeforeRequest?.Invoke(); @@ -748,7 +773,7 @@ protected async Task Get(TRequest requestObject, CancellationTok result.Links = new List { new Link(uri.AbsoluteUri) }; } - requestObject.AfterRequest?.Invoke(); + requestObject.AfterRequest?.Invoke(resultString); return result; } @@ -849,7 +874,7 @@ protected async Task Post(TRequest requestObject, CancellationTo result.Links = new List { new Link(uri.AbsoluteUri, requestObject) }; } - requestObject.AfterRequest?.Invoke(); + 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 89cb997..873a30d 100644 --- a/tests/Anywhere.ArcGIS.Test.Integration/Anywhere.ArcGIS.Test.Integration.csproj +++ b/tests/Anywhere.ArcGIS.Test.Integration/Anywhere.ArcGIS.Test.Integration.csproj @@ -5,12 +5,12 @@ - + - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/tests/Anywhere.ArcGIS.Test.Integration/ArcGISGatewayTests.cs b/tests/Anywhere.ArcGIS.Test.Integration/ArcGISGatewayTests.cs index 2445ee8..0d9f4c9 100644 --- a/tests/Anywhere.ArcGIS.Test.Integration/ArcGISGatewayTests.cs +++ b/tests/Anywhere.ArcGIS.Test.Integration/ArcGISGatewayTests.cs @@ -83,7 +83,7 @@ public async Task CanGetServerInfo(string rootUrl) } [Theory] - [InlineData("http://mapserv.utah.gov/arcgis/")] + //[InlineData("http://mapserv.utah.gov/arcgis/")] [InlineData("https://services.arcgisonline.com/arcgis")] public async Task CanDescribeSite(string rootUrl) { @@ -159,7 +159,7 @@ public async Task CanGetServiceTileInfo(string rootUrl, string serviceId) [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("http://services1.arcgis.com/dOFzdrPdRgtU4fRo/ArcGIS", "ServiceDefDouble/FeatureServer/0")] + [InlineData("https://services1.arcgis.com/dOFzdrPdRgtU4fRo/ArcGIS", "ServiceDefDouble/FeatureServer/0")] public async Task CanDescribeLayer(string rootUrl, string layerUrl) { var gateway = new PortalGateway(rootUrl); @@ -596,6 +596,23 @@ public async Task CanQueryForIds() Assert.True(resultFiltered.ObjectIds.Count() == queryFiltered.ObjectIds.Count); } + [Fact] + public async Task CanQueryWithNoGeometryResponse() + { + var gateway = new PortalGateway("http://services.arcgisonline.com/arcgis/"); + + var query = new Query(@"/Specialty/Soil_Survey_Map/MapServer/2"); + var result = await IntegrationTestFixture.TestPolicy.Execute(() => + { + return gateway.Query(query); + }); + + Assert.NotNull(result); + Assert.Null(result.Error); + Assert.NotNull(result.Features); + Assert.True(result.Features.All(x => x.Geometry == null)); + } + /// /// Performs unfiltered query, then filters by Extent and Polygon to SE quadrant of globe and verifies both filtered /// results contain same number of features as each other, and that both filtered resultsets contain fewer features than unfiltered resultset. @@ -858,7 +875,7 @@ public async Task FindCanReturnResultsAndNoGeometry() [Fact] public async Task CanQueryAttachments() { - var gateway = new PortalGateway("http://services1.arcgis.com/YFRZ5T5eRL3tLQNK/ArcGIS/"); + var gateway = new PortalGateway("https://services1.arcgis.com/YFRZ5T5eRL3tLQNK/ArcGIS/"); var queryAttachments = new QueryAttachments(@"test_sync/FeatureServer/0") { @@ -880,24 +897,24 @@ public async Task CanQueryAttachments() Assert.Equal(group.AttachmentInfos.First().ContentType, queryAttachments.AttachmentTypes); } - [Fact] - public async Task CanQueryDomains() - { - var gateway = new PortalGateway("http://gis.stlouiscountymn.gov/arcgis"); - - var queryDomains = new QueryDomains(@"PublicWorks/SignInventory/MapServer/") - { - LayerIdsToSearch = new List { 0 } - }; - var result = await IntegrationTestFixture.TestPolicy.Execute(() => - { - return gateway.QueryDomains(queryDomains); - }); - - Assert.NotNull(result); - Assert.Null(result.Error); - Assert.True(result.Domains.Any()); - } + //[Fact] + //public async Task CanQueryDomains() + //{ + // var gateway = new PortalGateway("http://gis.stlouiscountymn.gov/arcgis"); + + // var queryDomains = new QueryDomains(@"PublicWorks/SignInventory/MapServer/") + // { + // LayerIdsToSearch = new List { 0 } + // }; + // var result = await IntegrationTestFixture.TestPolicy.Execute(() => + // { + // return gateway.QueryDomains(queryDomains); + // }); + + // Assert.NotNull(result); + // Assert.Null(result.Error); + // Assert.True(result.Domains.Any()); + //} [Theory] [InlineData("https://services.arcgisonline.co.nz/arcgis")] diff --git a/tests/Anywhere.ArcGIS.Test.Integration/GeocodeTests.cs b/tests/Anywhere.ArcGIS.Test.Integration/GeocodeTests.cs index 95b13bc..606de8d 100644 --- a/tests/Anywhere.ArcGIS.Test.Integration/GeocodeTests.cs +++ b/tests/Anywhere.ArcGIS.Test.Integration/GeocodeTests.cs @@ -84,21 +84,21 @@ public async Task CanReverseGeocodePoint(string rootUrl, string relativeUrl, dou Assert.NotNull(response.Location); } - [Theory] - [InlineData("https://energovgis-dev.tylerhost.net/arcgis", "SLO/Crisco/GeocodeServer/", "052-201-003")] - public async Task CanCustomGeocodePolygon(string rootUrl, string relativeUrl, string searchText) - { - var gateway = new PortalGateway(rootUrl); - var customGeocode = new SingleInputCustomGeocode(relativeUrl) { Text = searchText }; - var response = await IntegrationTestFixture.TestPolicy.Execute(() => - { - return gateway.CustomGeocode(customGeocode); - }); + //[Theory] + //[InlineData("https://energovgis-dev.tylerhost.net/arcgis", "SLO/Crisco/GeocodeServer/", "052-201-003")] + //public async Task CanCustomGeocodePolygon(string rootUrl, string relativeUrl, string searchText) + //{ + // var gateway = new PortalGateway(rootUrl); + // var customGeocode = new SingleInputCustomGeocode(relativeUrl) { Text = searchText }; + // var response = await IntegrationTestFixture.TestPolicy.Execute(() => + // { + // return gateway.CustomGeocode(customGeocode); + // }); - Assert.Null(response.Error); - Assert.NotNull(response.Candidates); - Assert.True(response.Candidates.Any()); - Assert.NotNull(response.Candidates.FirstOrDefault().Location); - } + // Assert.Null(response.Error); + // Assert.NotNull(response.Candidates); + // Assert.True(response.Candidates.Any()); + // Assert.NotNull(response.Candidates.FirstOrDefault().Location); + //} } } diff --git a/tests/Anywhere.ArcGIS.Test/Anywhere.ArcGIS.Test.csproj b/tests/Anywhere.ArcGIS.Test/Anywhere.ArcGIS.Test.csproj index 57163a4..293819f 100644 --- a/tests/Anywhere.ArcGIS.Test/Anywhere.ArcGIS.Test.csproj +++ b/tests/Anywhere.ArcGIS.Test/Anywhere.ArcGIS.Test.csproj @@ -5,9 +5,9 @@ - + - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/tests/Anywhere.ArcGIS.Test/SecureGISGatewayTests.cs b/tests/Anywhere.ArcGIS.Test/SecureGISGatewayTests.cs index 3c433c5..3195e4c 100644 --- a/tests/Anywhere.ArcGIS.Test/SecureGISGatewayTests.cs +++ b/tests/Anywhere.ArcGIS.Test/SecureGISGatewayTests.cs @@ -3,14 +3,13 @@ using Anywhere.ArcGIS; using System; using System.Linq; - using System.Threading; using System.Threading.Tasks; using Xunit; public class SecureGISGatewayTests { [Fact] - public void TokenIsExpiredHasCorrectValue() + public async Task TokenIsExpiredHasCorrectValue() { var expiry = DateTime.UtcNow.AddSeconds(1).ToUnixTime(); var token = new Anywhere.ArcGIS.Operation.Token { Value = "blah", Expiry = expiry }; @@ -18,7 +17,7 @@ public void TokenIsExpiredHasCorrectValue() Assert.NotNull(token); Assert.NotNull(token.Value); Assert.False(token.IsExpired); - Thread.Sleep(TimeSpan.FromSeconds(2)); + await Task.Delay(TimeSpan.FromSeconds(2)); Assert.True(token.IsExpired); } diff --git a/tools/packages.config b/tools/packages.config index 747e13e..8bfcb25 100644 --- a/tools/packages.config +++ b/tools/packages.config @@ -1,4 +1,4 @@ - +