diff --git a/build.cake b/build.cake
index 2770fa4..0da54b6 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.8.0";
+var version = "1.8.1";
var versionSuffix = Environment.GetEnvironmentVariable("VERSION_SUFFIX");
//////////////////////////////////////////////////////////////////////
diff --git a/src/Anywhere.ArcGIS/Anywhere.ArcGIS.csproj b/src/Anywhere.ArcGIS/Anywhere.ArcGIS.csproj
index d8fe952..cf89490 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
- 1.8.0
+ 1.8.1
@@ -23,14 +23,17 @@
-
+
+ all
+ runtime; build; native; contentfiles; analyzers
+
-
-
-
+
+
+
diff --git a/src/Anywhere.ArcGIS/Common/IGeometry.cs b/src/Anywhere.ArcGIS/Common/IGeometry.cs
index c30e5b8..94ef66b 100644
--- a/src/Anywhere.ArcGIS/Common/IGeometry.cs
+++ b/src/Anywhere.ArcGIS/Common/IGeometry.cs
@@ -314,11 +314,19 @@ public Extent GetExtent()
foreach (PointCollection path in Paths)
{
if (extent == null)
+ {
extent = path.CalculateExtent(SpatialReference);
+ }
else
+ {
extent = extent.Union(path.CalculateExtent(SpatialReference));
+ }
+ }
+
+ if (extent != null)
+ {
+ extent.SpatialReference = SpatialReference;
}
- if (extent != null) extent.SpatialReference = SpatialReference;
return extent;
}
@@ -398,23 +406,43 @@ public Extent CalculateExtent(SpatialReference spatialReference)
foreach (var point in Points.Where(p => p != null))
{
- if (point.X < x || double.IsNaN(x)) x = point.X;
+ if (point.X < x || double.IsNaN(x))
+ {
+ x = point.X;
+ }
- if (point.Y < y || double.IsNaN(y)) y = point.Y;
+ if (point.Y < y || double.IsNaN(y))
+ {
+ y = point.Y;
+ }
- if (point.X > x1 || double.IsNaN(x1)) x1 = point.X;
+ if (point.X > x1 || double.IsNaN(x1))
+ {
+ x1 = point.X;
+ }
- if (point.Y > y1 || double.IsNaN(y1)) y1 = point.Y;
+ if (point.Y > y1 || double.IsNaN(y1))
+ {
+ y1 = point.Y;
+ }
}
+
if (double.IsNaN(x) || double.IsNaN(y) || double.IsNaN(x1) || double.IsNaN(y1))
+ {
return null;
+ }
return new Extent { XMin = x, YMin = y, XMax = x1, YMax = y1, SpatialReference = spatialReference };
}
public List Points
{
- get { return this.Select(point => point != null ? new Point { X = point.First(), Y = point.Last() } : null).ToList(); }
+ get
+ {
+ return this.Select(point => point != null ? new Point { X = point.First(), Y = point.Last() } : null)
+ .Where(p => p != null)
+ .ToList();
+ }
}
public List Clone()
@@ -452,11 +480,19 @@ public Extent GetExtent()
foreach (var ring in Rings.Where(r => r != null))
{
if (extent == null)
+ {
extent = ring.CalculateExtent(SpatialReference);
+ }
else
+ {
extent = extent.Union(ring.CalculateExtent(SpatialReference));
+ }
+ }
+
+ if (extent != null && extent.SpatialReference == null)
+ {
+ extent.SpatialReference = SpatialReference;
}
- if (extent != null && extent.SpatialReference == null) extent.SpatialReference = SpatialReference;
return extent;
}
@@ -540,38 +576,68 @@ public Point GetCenter()
public Extent Union(Extent extent)
{
- if (extent == null) extent = this;
+ if (extent == null)
+ {
+ extent = this;
+ }
+
if (!SpatialReference.Equals(extent.SpatialReference))
+ {
throw new ArgumentException("Spatial references must match for union operation.");
+ }
var envelope = new Extent { SpatialReference = SpatialReference ?? extent.SpatialReference };
if (double.IsNaN(XMin))
+ {
envelope.XMin = extent.XMin;
+ }
else if (!double.IsNaN(extent.XMin))
+ {
envelope.XMin = Math.Min(extent.XMin, XMin);
+ }
else
+ {
envelope.XMin = XMin;
+ }
if (double.IsNaN(XMax))
+ {
envelope.XMax = extent.XMax;
+ }
else if (!double.IsNaN(extent.XMax))
+ {
envelope.XMax = Math.Max(extent.XMax, XMax);
+ }
else
+ {
envelope.XMax = XMax;
+ }
if (double.IsNaN(YMin))
+ {
envelope.YMin = extent.YMin;
+ }
else if (!double.IsNaN(extent.YMin))
+ {
envelope.YMin = Math.Min(extent.YMin, YMin);
+ }
else
+ {
envelope.YMin = YMin;
+ }
if (double.IsNaN(YMax))
+ {
envelope.YMax = extent.YMax;
+ }
else if (!double.IsNaN(extent.YMax))
+ {
envelope.YMax = Math.Max(extent.YMax, YMax);
+ }
else
+ {
envelope.YMax = YMax;
+ }
return envelope;
}
diff --git a/src/Anywhere.ArcGIS/Extensions/FeatureCollectionExtensions.cs b/src/Anywhere.ArcGIS/Extensions/FeatureCollectionExtensions.cs
index 8310d7f..c1c2f84 100644
--- a/src/Anywhere.ArcGIS/Extensions/FeatureCollectionExtensions.cs
+++ b/src/Anywhere.ArcGIS/Extensions/FeatureCollectionExtensions.cs
@@ -30,14 +30,20 @@ public static class FeatureCollectionExtensions
public static List> ToFeatures(this FeatureCollection featureCollection)
where TGeometry : IGeoJsonGeometry
{
- if (featureCollection == null || featureCollection.Features == null || !featureCollection.Features.Any()) return null;
+ if (featureCollection == null || featureCollection.Features == null || !featureCollection.Features.Any())
+ {
+ return null;
+ }
var features = new List>();
foreach (var geoJson in featureCollection.Features)
{
var geometry = geoJson.Geometry.ToGeometry(_typeMap[geoJson.Geometry.Type]());
- if (geometry == null) continue;
+ if (geometry == null)
+ {
+ continue;
+ }
features.Add(new Feature { Geometry = geometry, Attributes = geoJson.Properties });
}
@@ -53,15 +59,20 @@ public static List> ToFeatures(this FeatureCollect
public static FeatureCollection ToFeatureCollection(this List> features)
where TGeometry : IGeometry
{
- if (features == null || !features.Any()) return null;
+ if (features == null || !features.Any())
+ {
+ return null;
+ }
var featureCollection = new FeatureCollection { Features = new List>() };
if (features.First().Geometry.SpatialReference != null)
+ {
featureCollection.CoordinateReferenceSystem = new Crs
{
Type = "EPSG",
Properties = new CrsProperties { Wkid = (int)features.First().Geometry.SpatialReference.Wkid }
};
+ }
foreach (var feature in features)
{
@@ -96,11 +107,16 @@ public static List> UpdateGeometries(this List> feature
{
var attr = i < features.Count ? features[i].Attributes : null;
var feature = new Feature { Attributes = attr };
- if (i < geometries.Count) feature.Geometry = geometries[i];
+ if (i < geometries.Count)
+ {
+ feature.Geometry = geometries[i];
+ }
result.Insert(i, feature);
}
if (geometries.Count > features.Count)
+ {
result.InsertRange(features.Count, geometries.Skip(features.Count).Select(g => new Feature { Geometry = g }));
+ }
return result;
}
diff --git a/src/Anywhere.ArcGIS/Extensions/StringExtensions.cs b/src/Anywhere.ArcGIS/Extensions/StringExtensions.cs
index eeb6664..18db8c3 100644
--- a/src/Anywhere.ArcGIS/Extensions/StringExtensions.cs
+++ b/src/Anywhere.ArcGIS/Extensions/StringExtensions.cs
@@ -72,7 +72,10 @@ public static string UrlEncode(this string text)
/// Byte representation of the hex-encoded input
public static byte[] HexToBytes(this string hex)
{
- if (string.IsNullOrWhiteSpace(hex)) return null;
+ if (string.IsNullOrWhiteSpace(hex))
+ {
+ return null;
+ }
int length = hex.Length;
diff --git a/src/Anywhere.ArcGIS/Operation/PortalResponse.cs b/src/Anywhere.ArcGIS/Operation/PortalResponse.cs
index bac5b71..d2d8834 100644
--- a/src/Anywhere.ArcGIS/Operation/PortalResponse.cs
+++ b/src/Anywhere.ArcGIS/Operation/PortalResponse.cs
@@ -45,7 +45,7 @@ public class ArcGISError
public override string ToString()
{
- return string.Format("Code {0}: {1}.{2}\n{3}", Code, Message, Description, Details == null ? "" : string.Join(" ", Details));
+ return string.Format("Code {0}: {1}. {2}\n{3}", Code, Message, Description, Details == null ? "" : string.Join(" ", Details));
}
}
diff --git a/src/Anywhere.ArcGIS/Operation/Token.cs b/src/Anywhere.ArcGIS/Operation/Token.cs
index 04de1b9..9d73b67 100644
--- a/src/Anywhere.ArcGIS/Operation/Token.cs
+++ b/src/Anywhere.ArcGIS/Operation/Token.cs
@@ -112,7 +112,10 @@ public string RelativeUrl
public string BuildAbsoluteUrl(string rootUrl)
{
- if (string.IsNullOrWhiteSpace(rootUrl)) throw new ArgumentNullException("rootUrl", "rootUrl is null.");
+ if (string.IsNullOrWhiteSpace(rootUrl))
+ {
+ throw new ArgumentNullException("rootUrl", "rootUrl is null.");
+ }
return IsFederated
? (DontForceHttps ? rootUrl.Replace("sharing/rest/", "").Replace("sharing/", "") + "sharing/rest/" : rootUrl.Replace("http://", "https://").Replace("sharing/rest/", "").Replace("sharing/", "") + "sharing/rest/") + RelativeUrl.Replace("tokens/", "")
@@ -202,7 +205,10 @@ public string RelativeUrl
public string BuildAbsoluteUrl(string rootUrl)
{
- if (string.IsNullOrWhiteSpace(rootUrl)) throw new ArgumentNullException("rootUrl", "rootUrl is null.");
+ if (string.IsNullOrWhiteSpace(rootUrl))
+ {
+ throw new ArgumentNullException("rootUrl", "rootUrl is null.");
+ }
return (DontForceHttps ?
rootUrl.Replace("sharing/rest/", "").Replace("sharing/", "") + "sharing/rest/" :
diff --git a/src/Anywhere.ArcGIS/TokenProvider.cs b/src/Anywhere.ArcGIS/TokenProvider.cs
index 2236e26..98da508 100644
--- a/src/Anywhere.ArcGIS/TokenProvider.cs
+++ b/src/Anywhere.ArcGIS/TokenProvider.cs
@@ -31,7 +31,7 @@ public class TokenProvider : ITokenProvider, IDisposable
/// Referer url to use for the token generation
/// Used to encrypt the token reuqest. If not set it will use the default from CryptoProviderFactory
public TokenProvider(string rootUrl, string username, string password, ISerializer serializer = null, string referer = "", ICryptoProvider cryptoProvider = null, Func httpClientFunc = null)
- : this (() => LogProvider.For(), rootUrl, username, password, serializer, referer, cryptoProvider)
+ : this (() => LogProvider.For(), rootUrl, username, password, serializer, referer, cryptoProvider, httpClientFunc)
{ }
internal TokenProvider(Func log, string rootUrl, string username, string password, ISerializer serializer = null, string referer = "", ICryptoProvider cryptoProvider = null, Func httpClientFunc = null)
diff --git a/tests/Anywhere.ArcGIS.Test.Integration/ArcGISGatewayTests.cs b/tests/Anywhere.ArcGIS.Test.Integration/ArcGISGatewayTests.cs
index 9e32c5a..21c267d 100644
--- a/tests/Anywhere.ArcGIS.Test.Integration/ArcGISGatewayTests.cs
+++ b/tests/Anywhere.ArcGIS.Test.Integration/ArcGISGatewayTests.cs
@@ -436,7 +436,7 @@ public async Task QueryOrderByIsHonored(string rootUrl, string relativeUrl, stri
}
[Theory]
- [InlineData("http://services.arcgis.com/hMYNkrKaydBeWRXE/arcgis", "TestReturnExtentOnly/FeatureServer/0")]
+ [InlineData("https://services.arcgis.com/hMYNkrKaydBeWRXE/arcgis", "TestReturnExtentOnly/FeatureServer/0")]
public async Task CanQueryExtent(string rootUrl, string relativeUrl)
{
var gateway = new PortalGateway(rootUrl);
@@ -456,7 +456,7 @@ public async Task CanQueryExtent(string rootUrl, string relativeUrl)
}
[Theory]
- [InlineData("http://services.arcgis.com/hMYNkrKaydBeWRXE/arcgis", "TestReturnExtentOnly/FeatureServer/0", 1, 2)]
+ [InlineData("https://services.arcgis.com/hMYNkrKaydBeWRXE/arcgis", "TestReturnExtentOnly/FeatureServer/0", 1, 2)]
public async Task CanPagePointQuery(string rootUrl, string relativeUrl, int start, int numberToReturn)
{
var gateway = new PortalGateway(rootUrl);