Skip to content

Commit

Permalink
Merge pull request #71 from davetimmins/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
davetimmins authored Sep 27, 2020
2 parents 238c106 + aecc031 commit 45a105c
Show file tree
Hide file tree
Showing 39 changed files with 215 additions and 148 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: csharp
sudo: required
dist: trusty
dotnet: 2.0.0
dist: xenial
dotnet: 3.1.300
os:
- linux
branches:
Expand Down
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 = "1.12.0";
var version = "2.0.0";
var versionSuffix = Environment.GetEnvironmentVariable("VERSION_SUFFIX");

//////////////////////////////////////////////////////////////////////
Expand Down
4 changes: 2 additions & 2 deletions src/Anywhere.ArcGIS/Anywhere.ArcGIS.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>netstandard2.1</TargetFramework>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>Dave Timmins</Authors>
<Company>Dave Timmins</Company>
Expand All @@ -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>1.12.0</Version>
<Version>2.0.0</Version>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/Anywhere.ArcGIS/AttachmentWorker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ protected async Task<T> Post<T, TRequest>(TRequest requestObject, CancellationTo
throw new InvalidOperationException(result.Error.ToString());
}

requestObject.AfterRequest?.Invoke();
requestObject.AfterRequest?.Invoke(resultString);

return result;
}
Expand Down
25 changes: 25 additions & 0 deletions src/Anywhere.ArcGIS/Common/IGeometry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

/// <summary>
/// Spatial reference used for operations. If WKT is set then other properties are nulled
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Anywhere.ArcGIS/Common/IHttpOperation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ public interface IHttpOperation

Action BeforeRequest { get; }

Action AfterRequest { get; }
Action<string> AfterRequest { get; }
}
}
4 changes: 2 additions & 2 deletions src/Anywhere.ArcGIS/Extensions/FeatureCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static FeatureCollection<IGeoJsonGeometry> ToFeatureCollection<TGeometry>
}

var featureCollection = new FeatureCollection<IGeoJsonGeometry> { Features = new List<GeoJsonFeature<IGeoJsonGeometry>>() };
if (features.First().Geometry.SpatialReference != null)
if (features?.First()?.Geometry?.SpatialReference != null)
{
featureCollection.CoordinateReferenceSystem = new Crs
{
Expand All @@ -76,7 +76,7 @@ public static FeatureCollection<IGeoJsonGeometry> ToFeatureCollection<TGeometry>

foreach (var feature in features)
{
var geoJsonGeometry = feature.Geometry.ToGeoJson();
var geoJsonGeometry = feature?.Geometry?.ToGeoJson();
if (geoJsonGeometry == null)
{
continue;
Expand Down
2 changes: 1 addition & 1 deletion src/Anywhere.ArcGIS/Operation/Admin/PublicKey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> afterRequest = null)
: base(new ArcGISServerAdminEndpoint(Operations.PublicKey), beforeRequest, afterRequest)
{ }
}
Expand Down
2 changes: 1 addition & 1 deletion src/Anywhere.ArcGIS/Operation/Admin/ServiceReport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public IEnumerable<ServiceReportResponse> ServiceReports

public class ServiceReport : ArcGISServerOperation
{
public ServiceReport(string path, Action beforeRequest = null, Action afterRequest = null)
public ServiceReport(string path, Action beforeRequest = null, Action<string> afterRequest = null)
: base(new ArcGISServerAdminEndpoint(string.Format(Operations.ServiceReport, path.Replace("/", "")).Replace("//", "/")), beforeRequest, afterRequest)
{ }
}
Expand Down
2 changes: 1 addition & 1 deletion src/Anywhere.ArcGIS/Operation/Admin/ServiceStatistics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> afterRequest = null)
: base(new ArcGISServerAdminEndpoint(string.Format(Operations.ServiceStatistics, serviceDescription.Name, serviceDescription.Type)), beforeRequest, afterRequest)
{ }
}
Expand Down
2 changes: 1 addition & 1 deletion src/Anywhere.ArcGIS/Operation/Admin/ServiceStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> afterRequest = null)
: base (new ArcGISServerAdminEndpoint(string.Format(Operations.ServiceStatus, serviceDescription.Name, serviceDescription.Type)), beforeRequest, afterRequest)
{ }
}
Expand Down
4 changes: 2 additions & 2 deletions src/Anywhere.ArcGIS/Operation/Admin/StartStop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ 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<string> afterRequest = null)
: base(new ArcGISServerAdminEndpoint(string.Format(Operations.StartService, serviceDescription.Name, serviceDescription.Type)), beforeRequest, afterRequest)
{ }
}

[DataContract]
public class StopService : ArcGISServerOperation
{
public StopService(ServiceDescription serviceDescription, Action beforeRequest = null, Action afterRequest = null)
public StopService(ServiceDescription serviceDescription, Action beforeRequest = null, Action<string> afterRequest = null)
: base(new ArcGISServerAdminEndpoint(string.Format(Operations.StopService, serviceDescription.Name, serviceDescription.Type)), beforeRequest, afterRequest)
{ }
}
Expand Down
4 changes: 2 additions & 2 deletions src/Anywhere.ArcGIS/Operation/ApplyEdits.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ namespace Anywhere.ArcGIS.Operation
public class ApplyEdits<T> : ArcGISServerOperation
where T : IGeometry
{
public ApplyEdits(string relativeUrl, Action beforeRequest = null, Action afterRequest = null)
public ApplyEdits(string relativeUrl, Action beforeRequest = null, Action<string> 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<string> afterRequest = null)
: base(endpoint.RelativeUrl.Trim('/') + "/" + Operations.ApplyEdits, beforeRequest, afterRequest)
{
Adds = new List<Feature<T>>();
Expand Down
6 changes: 3 additions & 3 deletions src/Anywhere.ArcGIS/Operation/ArcGISServerOperation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@ namespace Anywhere.ArcGIS.Operation
/// </summary>
public class ArcGISServerOperation : CommonParameters, IHttpOperation
{
public ArcGISServerOperation(IEndpoint endpoint, Action beforeRequest = null, Action afterRequest = null)
public ArcGISServerOperation(IEndpoint endpoint, Action beforeRequest = null, Action<string> 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<string> afterRequest = null)
: this(new ArcGISServerEndpoint(endpoint), beforeRequest, afterRequest)
{ }

[IgnoreDataMember]
public Action BeforeRequest { get; }

[IgnoreDataMember]
public Action AfterRequest { get; }
public Action<string> AfterRequest { get; }

[IgnoreDataMember]
public IEndpoint Endpoint { get; }
Expand Down
8 changes: 4 additions & 4 deletions src/Anywhere.ArcGIS/Operation/CreateReplica.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> 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<string> afterRequest = null)
: base(endpoint.RelativeUrl.Trim('/') + "/" + Operations.CreateReplica, beforeRequest, afterRequest)
{
ReturnAttachments = false;
Expand Down Expand Up @@ -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<string> 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<string> afterRequest = null)
: base(endpoint.RelativeUrl.Trim('/') + "/" + Operations.UnregisterReplica, beforeRequest, afterRequest)
{ }

Expand Down
4 changes: 2 additions & 2 deletions src/Anywhere.ArcGIS/Operation/CustomGeocode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> 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<string> afterRequest = null)
: base(endpoint.RelativeUrl.Trim('/') + "/" + Operations.SingleInputCustomGeocode, beforeRequest, afterRequest)
{ }

Expand Down
12 changes: 6 additions & 6 deletions src/Anywhere.ArcGIS/Operation/DeleteAttachments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> 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<string> afterRequest = null)
: this((endpoint.RelativeUrl.Trim('/') + string.Format("/{0}", objectID)).AsEndpoint(), beforeRequest, afterRequest)
{
AttachmentIds = new List<long>();
}

public DeleteAttachments(string relativeUrl, Action beforeRequest = null, Action afterRequest = null)
public DeleteAttachments(string relativeUrl, Action beforeRequest = null, Action<string> 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<string> afterRequest = null)
: base(endpoint.RelativeUrl.Trim('/') + "/" + Operations.DeleteAttachments, beforeRequest, afterRequest)
{
AttachmentIds = new List<long>();
Expand Down Expand Up @@ -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<string> 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<string> afterRequest = null)
: base(endpoint.RelativeUrl.Trim('/') + string.Format("/{0}/{1}", objectID, isUpdate ? "updateAttachment" : "addAttachment"), beforeRequest, afterRequest)
{
ObjectID = objectID;
Expand Down
4 changes: 2 additions & 2 deletions src/Anywhere.ArcGIS/Operation/DeleteFeatures.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> 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<string> afterRequest = null)
: base(endpoint.RelativeUrl.Trim('/') + "/" + Operations.DeleteFeatures, beforeRequest, afterRequest)
{
SpatialRelationship = SpatialRelationshipTypes.Intersects;
Expand Down
4 changes: 2 additions & 2 deletions src/Anywhere.ArcGIS/Operation/ExportMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ 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<string> afterRequest = null)
: this(relativeUrl.AsEndpoint(), beforeRequest, afterRequest)
{ }

/// <summary>
/// Requests an export of the map resources. Returns the image link in the response
/// </summary>
/// <param name="endpoint">Resource to apply the export against</param>
public ExportMap(ArcGISServerEndpoint endpoint, Action beforeRequest = null, Action afterRequest = null)
public ExportMap(ArcGISServerEndpoint endpoint, Action beforeRequest = null, Action<string> afterRequest = null)
: base(endpoint.RelativeUrl.Trim('/') + "/" + Operations.ExportMap, beforeRequest, afterRequest)
{
Size = new List<int> { 400, 400 };
Expand Down
4 changes: 2 additions & 2 deletions src/Anywhere.ArcGIS/Operation/Find.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ 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<string> afterRequest = null)
: this(relativeUrl.AsEndpoint(), beforeRequest, afterRequest)
{ }

/// <summary>
/// Represents a request for a find against a service resource
/// </summary>
/// <param name="endpoint">Resource to apply the query against</param>
public Find(ArcGISServerEndpoint endpoint, Action beforeRequest = null, Action afterRequest = null)
public Find(ArcGISServerEndpoint endpoint, Action beforeRequest = null, Action<string> afterRequest = null)
: base(endpoint.RelativeUrl.Trim('/') + "/" + Operations.Find, beforeRequest, afterRequest)
{
FuzzySearch = true;
Expand Down
10 changes: 5 additions & 5 deletions src/Anywhere.ArcGIS/Operation/GeometryServerOperation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class GeometryOperationResponse<T> : PortalResponse
public class SimplifyGeometry<T> : ArcGISServerOperation
where T : IGeometry
{
public SimplifyGeometry(IEndpoint endpoint, List<Feature<T>> features = null, SpatialReference spatialReference = null, Action beforeRequest = null, Action afterRequest = null)
public SimplifyGeometry(IEndpoint endpoint, List<Feature<T>> features = null, SpatialReference spatialReference = null, Action beforeRequest = null, Action<string> afterRequest = null)
: base((endpoint is AbsoluteEndpoint)
? (IEndpoint)new AbsoluteEndpoint(endpoint.RelativeUrl.Trim('/') + "/" + Operations.Simplify)
: (IEndpoint)new ArcGISServerEndpoint(endpoint.RelativeUrl.Trim('/') + "/" + Operations.Simplify),
Expand Down Expand Up @@ -150,7 +150,7 @@ public GeometryOperation(IEndpoint endpoint,
List<Feature<T>> features,
SpatialReference outputSpatialReference,
string operation,
Action beforeRequest = null, Action afterRequest = null)
Action beforeRequest = null, Action<string> afterRequest = null)
: base((endpoint is AbsoluteEndpoint)
? (IEndpoint)new AbsoluteEndpoint(endpoint.RelativeUrl.Trim('/') + "/" + operation)
: (IEndpoint)new ArcGISServerEndpoint(endpoint.RelativeUrl.Trim('/') + "/" + operation),
Expand All @@ -161,8 +161,8 @@ public GeometryOperation(IEndpoint endpoint,
{
Geometries = new GeometryCollection<T> { Geometries = new List<T>(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;
}
Expand All @@ -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
/// </summary>
[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; } }

/// <summary>
/// The spatial reference of the returned geometry.
Expand Down
Loading

0 comments on commit 45a105c

Please sign in to comment.