Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #27

Merged
merged 3 commits into from
Jun 13, 2018
Merged

Dev #27

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NUGET-DOC.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Supports the following as typed operations:
- `ApplyEdits` post adds, updates and deletes to a feature service layer
- `DeleteFeatures` delete features in a feature layer or table
- `Geocode` single line of input to perform a geocode using a custom locator or the Esri world locator
- `CustomGeocode` single line of input to perform a geocode using a custom locator
- `Suggest` lightweight geocode operation that only returns text results, commonly used for predictive searching
- `ReverseGeocode` find location candidates for a input point location
- `Simplify` alter geometries to be topologically consistent
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ This is a netstandard 2.0 library, it was ported from [ArcGIS.PCL](https://githu

A typical use case would be the need to call some ArcGIS REST resource from server .NET code or maybe a console app. The features that this returns can be used directly as Esri JSON in JavaScript apps using the Esri JS API.

Works with secure and non-secure ArcGIS Server on premise / in the cloud, Portal for ArcGIS and ArcGIS Online. Also supports converting GeoJSON <-> ArcGIS Features.
Works with secure and non-secure ArcGIS Server on premise / in the cloud, Portal for ArcGIS and ArcGIS Online. Also supports converting GeoJSON :left_right_arrow: ArcGIS Features.

### Quickstart

Expand Down Expand Up @@ -57,6 +57,7 @@ Supports the following as typed operations:
- `ApplyEdits` post adds, updates and deletes to a feature service layer
- `DeleteFeatures` delete features in a feature layer or table
- `Geocode` single line of input to perform a geocode using a custom locator or the Esri world locator
- `CustomGeocode` single line of input to perform a geocode using a custom locator
- `Suggest` lightweight geocode operation that only returns text results, commonly used for predictive searching
- `ReverseGeocode` find location candidates for a input point location
- `Simplify` alter geometries to be topologically consistent
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.5.0";
var version = "1.6.0";
var versionSuffix = Environment.GetEnvironmentVariable("VERSION_SUFFIX");

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

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down
12 changes: 6 additions & 6 deletions src/Anywhere.ArcGIS/Operation/CustomGeocode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,25 +51,25 @@ public SingleInputCustomGeocode(ArcGISServerEndpoint endpoint, Action beforeRequ
[DataMember(Name = "outFields")]
public string OutFieldsValue { get { return OutFields == null ? string.Empty : string.Join(",", OutFields); } }
}

[DataContract]
public class SingleInputCustomGeocodeResponse : PortalResponse
public class SingleInputCustomGeocodeResponse<T> : PortalResponse where T : IGeometry
{
[DataMember(Name = "spatialReference")]
public SpatialReference SpatialReference { get; set; }

[DataMember(Name = "candidates")]
public Candidate[] Candidates { get; set; }
public Candidate<T>[] Candidates { get; set; }
}

[DataContract]
public class Candidate
public class Candidate<T> where T : IGeometry
{
[DataMember(Name = "address")]
public string Address { get; set; }

[DataMember(Name = "location")]
public Point Location { get; set; }
public T Location { get; set; }

[DataMember(Name = "score")]
public double Score { get; set; }
Expand Down
27 changes: 26 additions & 1 deletion src/Anywhere.ArcGIS/PortalGateway.cs
Original file line number Diff line number Diff line change
Expand Up @@ -346,10 +346,35 @@ public PortalGateway(string rootUrl, string username, string password, ISerializ
/// <param name="ct">Optional cancellation token to cancel pending request</param>
/// <returns></returns>
public virtual Task<SingleInputGeocodeResponse> Geocode(SingleInputGeocode geocode, CancellationToken ct = default(CancellationToken))
{
{
return Get<SingleInputGeocodeResponse, SingleInputGeocode>(geocode, ct);
}

/// <summary>
/// The CustomGeocode (FindAddressCandidates) operation supports searching for places and addresses in single-field format.
/// This method assumes the results are points.
/// </summary>
/// <param name="geocode"></param>
/// <param name="ct"></param>
/// <returns></returns>
public virtual Task<SingleInputCustomGeocodeResponse<Point>> CustomGeocode(SingleInputCustomGeocode geocode, CancellationToken ct = default(CancellationToken))
{
return CustomGeocode<Point>(geocode, ct);
}

/// <summary>
/// The CustomGeocode (FindAddressCandidates) operation supports searching for places and addresses in single-field format
/// </summary>
/// <typeparam name="T">The geometry type for the result set</typeparam>
/// <param name="geocode"></param>
/// <param name="ct"></param>
/// <returns></returns>
public virtual Task<SingleInputCustomGeocodeResponse<T>> CustomGeocode<T>(SingleInputCustomGeocode geocode, CancellationToken ct = default(CancellationToken))
where T : IGeometry
{
return Get<SingleInputCustomGeocodeResponse<T>, SingleInputCustomGeocode>(geocode, ct);
}

/// <summary>
/// Call the suggest geocode operation.
/// </summary>
Expand Down
17 changes: 17 additions & 0 deletions tests/Anywhere.ArcGIS.Test.Integration/GeocodeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,22 @@ public async Task CanReverseGeocodePoint(string rootUrl, string relativeUrl, dou
Assert.NotNull(response.Address);
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.ExecuteAsync(() =>
{
return gateway.CustomGeocode<Polygon>(customGeocode);
});

Assert.Null(response.Error);
Assert.NotNull(response.Candidates);
Assert.True(response.Candidates.Any());
Assert.NotNull(response.Candidates.FirstOrDefault().Location);
}
}
}