Skip to content

Commit

Permalink
Merge pull request #2 from davetimmins/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
davetimmins authored Oct 27, 2017
2 parents b08baed + 4c5ca43 commit bf317db
Show file tree
Hide file tree
Showing 15 changed files with 520 additions and 225 deletions.
11 changes: 11 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Why the change? Well there are 2 main reasons, the first is that this is now a netstandard library rather than a portable class library (PCL), so the old naming didn't really apply. Secondly, NuGet now has package Id reservations and so I can't use ArcGIS as the suffix anymore.

To migrate from ArcGIS.PCL to Anywhere.ArcGIS the following breaking changes need to be done / reviewed:

- All namespaces have changed from `ArcGIS.ServiceModel.*` to `Anywhere.ArcGIS.*`.

- You no longer need to call the static `ISerializer` `Init()` method as JSON.NET is now baked in.

- `SecurePortalGateway` has been renamed to just `PortalGateway`.

- Internally all requests now use an `ArcGISServerOperation` type, this allows before and after actions to be invoked for the HTTP request.
56 changes: 56 additions & 0 deletions NUGET-DOC.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
If you are calling a REST operation you will need to create a gateway to manage the request. There are a few different ones but the most basic is called `PortalGateway` and this can be used for connecting directly to services with ArcGIS Server.

Create an instance of that by specifying the root url of your server. The format of the root url is _scheme_://_host_:_port_/_instance_ so a typical default ArcGIS Server for your local machine would be _http://localhost:6080/arcgis_, note that you do not need to include `rest/services` in either the root url or your relative urls as it gets added automatically. One thing to look out for is that the url is case sensitive so make sure you enter it correctly.

```c#
var gateway = new PortalGateway("https://sampleserver3.arcgisonline.com/ArcGIS/");
```

Now you have access to the various operations supported by it. For example to call a query against a service

```c#
var query = new Query("Earthquakes/EarthquakesFromLastSevenDays/MapServer/0".AsEndpoint())
{
Where = "magnitude > 4.0"
};
var result = await gateway.Query<Point>(query);
```

### Capabilities

Supports the following as typed operations:

- `CheckGenerateToken` create a token automatically via an `ITokenProvider`
- `Query` query a layer by attribute and / or spatial filters, also possible to do `BatchQuery`
- `QueryForCount` only return the number of results for the query operation
- `QueryForIds` only return the ObjectIds for the results of the query operation
- `QueryForExtent` return the bounding extent for the result of the query operation
- `Find` search across _n_ layers and fields in a service
- `ApplyEdits` post adds, updates and deletes to a feature service layer
- `Geocode` single line of input to perform a geocode using a custom locator or the Esri world 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
- `Project` convert geometries to a different spatial reference
- `Buffer` buffers geometries by the distance requested
- `DescribeSite` returns a url for every service discovered
- `CreateReplica` create a replica for a layer
- `UnregisterReplica` unregister a replica based on the Id
- `DeleteAttachments` delete attachments that are associated with a feature
- `Ping` verify that the server can be accessed
- `Info` return the server information such as version and token authentication settings
- `DescribeServices` return services information (name, sublayers etc.)
- `DescribeService` return service information (name, sublayers etc.)
- `DescribeLayer` return layer information

REST admin operations:

- `PublicKey` - admin operation to get public key used for encryption of token requests
- `ServiceStatus` - admin operation to get the configured and actual status of a service
- `ServiceReport` - admin operation to get the service report
- `StartService` - admin operation to start a service
- `StopService` - admin operation to stop a service

There are also methods to add / update and download attachments for a feature and you can extend this library by writing your own operations.

Refer to the integration test project for more examples.s
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Use ArcGIS Server REST resources without an official SDK. Ths is a netstandard 2

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.
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.

### Quickstart

Expand Down Expand Up @@ -73,7 +73,7 @@ Refer to the integration test project for more examples.

Absolutely! Please feel free to raise issues, fork the source code, send pull requests, etc.

No pull request is too small. Even whitespace fixes are appreciated. Before you contribute anything make sure you read [CONTRIBUTING](https://github.com/davetimmins/Anywhere.ArcGIS/CONTRIBUTING.md).
No pull request is too small. Even whitespace fixes are appreciated. Before you contribute anything make sure you read [CONTRIBUTING](https://github.com/davetimmins/Anywhere.ArcGIS/blob/master/CONTRIBUTING.md).

### Installation

Expand All @@ -97,5 +97,5 @@ Anywhere.ArcGIS uses [Semantic Versioning](http://semver.org/).

### Icon

Icon made by [Freepik](http://www.freepik.com) from [www.flaticon.com](http://www.flaticon.com/free-icon/triangle-of-triangles_32915)
Icon made by [Freepik](http://www.freepik.com) from [www.flaticon.com](https://www.flaticon.com/free-icon/triangle-of-triangles_32915)

2 changes: 1 addition & 1 deletion src/Anywhere.ArcGIS/Anywhere.ArcGIS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<RepositoryType>git</RepositoryType>
<PackageTags>ArcGIS ArcGISServer ArcGISOnline Esri REST netstandard anywhere GIS Mapping Map Location GeoLocation OAuth</PackageTags>
<PackageReleaseNotes>Initial port of ArcGIS.PCL to netstandard</PackageReleaseNotes>
<Version>1.0.0-beta.1</Version>
<Version>1.0.0-beta.2</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Anywhere.ArcGIS/Common/Feature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Anywhere.ArcGIS.Common
/// <typeparam name="T">Type of geometry that the feature represents.</typeparam>
/// <remarks>All properties are optional.</remarks>
[DataContract]
public class Feature<T> : IEquatable<Feature<T>> where T : IGeometry<T>
public class Feature<T> : IEquatable<Feature<T>> where T : IGeometry
{
const string ObjectIDName = "objectid";
const string GlobalIDName = "globalid";
Expand Down
117 changes: 46 additions & 71 deletions src/Anywhere.ArcGIS/Common/IGeometry.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using Anywhere.ArcGIS.GeoJson;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
Expand All @@ -14,10 +15,10 @@ namespace Anywhere.ArcGIS.Common
/// Envelopes
/// </summary>
/// <remarks>Starting at ArcGIS Server 10.1, geometries containing m and z values are supported</remarks>
public interface IGeometry<out T>
public interface IGeometry
{
/// <summary>
/// The spatial reference can be defined using a well-known ID (wkid) or well-known text (wkt)
/// The spatial reference can be defined using a well-known ID (wkid) or well-known text (wkt)
/// </summary>
[DataMember(Name = "spatialReference")]
SpatialReference SpatialReference { get; set; }
Expand All @@ -35,10 +36,10 @@ public interface IGeometry<out T>
Point GetCenter();

/// <summary>
/// Get the associated geometry
/// Converts the geometry to its GeoJSON representation
/// </summary>
/// <returns>The geometry object</returns>
T GetGeometry();
/// <returns>The corresponding GeoJSON for the geometry</returns>
IGeoJsonGeometry ToGeoJson();
}

/// <summary>
Expand Down Expand Up @@ -138,7 +139,7 @@ public override int GetHashCode()
}

[DataContract]
public class Point : IGeometry<Point>, IEquatable<Point>
public class Point : IGeometry, IEquatable<Point>
{
[DataMember(Name = "spatialReference", Order = 5)]
public SpatialReference SpatialReference { get; set; }
Expand All @@ -165,12 +166,6 @@ public Point GetCenter()
return new Point { X = X, Y = Y, SpatialReference = SpatialReference };
}

public Point GetGeometry()
{
// TODO : make immutable?
return this;
}

public bool Equals(Point other)
{
if (ReferenceEquals(null, other)) return false;
Expand Down Expand Up @@ -199,14 +194,14 @@ public override bool Equals(object obj)
return Equals((Point)obj);
}

//public IGeoJsonGeometry ToGeoJson()
//{
// return new GeoJsonPoint { Type = "Point", Coordinates = new[] { X, Y } };
//}
public IGeoJsonGeometry ToGeoJson()
{
return new GeoJsonPoint { Type = "Point", Coordinates = new[] { X, Y } };
}
}

[DataContract]
public class MultiPoint : IGeometry<MultiPoint>, IEquatable<MultiPoint>
public class MultiPoint : IGeometry, IEquatable<MultiPoint>
{
[DataMember(Name = "spatialReference", Order = 4)]
public SpatialReference SpatialReference { get; set; }
Expand All @@ -230,11 +225,6 @@ public Point GetCenter()
return GetExtent().GetCenter();
}

public MultiPoint GetGeometry()
{
return this;
}

public bool Equals(MultiPoint other)
{
if (ReferenceEquals(null, other)) return false;
Expand Down Expand Up @@ -262,14 +252,14 @@ public override bool Equals(object obj)
return Equals((MultiPoint)obj);
}

//public IGeoJsonGeometry ToGeoJson()
//{
// return new GeoJsonLineString { Type = "MultiPoint", Coordinates = Points };
//}
public IGeoJsonGeometry ToGeoJson()
{
return new GeoJsonLineString { Type = "MultiPoint", Coordinates = Points };
}
}

[DataContract]
public class Polyline : IGeometry<Polyline>, IEquatable<Polyline>
public class Polyline : IGeometry, IEquatable<Polyline>
{
[DataMember(Name = "spatialReference", Order = 4)]
public SpatialReference SpatialReference { get; set; }
Expand Down Expand Up @@ -303,11 +293,6 @@ public Point GetCenter()
return GetExtent().GetCenter();
}

public Polyline GetGeometry()
{
return this;
}

public bool Equals(Polyline other)
{
if (ReferenceEquals(null, other)) return false;
Expand Down Expand Up @@ -335,10 +320,10 @@ public override bool Equals(object obj)
return Equals((Polyline)obj);
}

//public IGeoJsonGeometry<GeoJsonLineString> ToGeoJson()
//{
// return Paths.Any() ? new GeoJsonLineString { Type = "LineString", Coordinates = Paths.First() } : null;
//}
public IGeoJsonGeometry ToGeoJson()
{
return Paths.Any() ? new GeoJsonLineString { Type = "LineString", Coordinates = Paths.First() } : null;
}
}

public class PointCollection : List<double[]>
Expand Down Expand Up @@ -377,7 +362,7 @@ public class PointCollectionList : List<PointCollection>
{ }

[DataContract]
public class Polygon : IGeometry<Polygon>, IEquatable<Polygon>
public class Polygon : IGeometry, IEquatable<Polygon>
{
[DataMember(Name = "spatialReference", Order = 4)]
public SpatialReference SpatialReference { get; set; }
Expand Down Expand Up @@ -411,11 +396,6 @@ public Point GetCenter()
return GetExtent().GetCenter();
}

public Polygon GetGeometry()
{
return this;
}

public bool Equals(Polygon other)
{
if (ReferenceEquals(null, other)) return false;
Expand Down Expand Up @@ -443,14 +423,14 @@ public override bool Equals(object obj)
return Equals((Polygon)obj);
}

//public IGeoJsonGeometry ToGeoJson()
//{
// return new GeoJsonPolygon { Type = "Polygon", Coordinates = Rings };
//}
public IGeoJsonGeometry ToGeoJson()
{
return new GeoJsonPolygon { Type = "Polygon", Coordinates = Rings };
}
}

[DataContract]
public class Extent : IGeometry<Extent>, IEquatable<Extent>
public class Extent : IGeometry, IEquatable<Extent>
{
[DataMember(Name = "spatialReference", Order = 5)]
public SpatialReference SpatialReference { get; set; }
Expand All @@ -477,11 +457,6 @@ public Point GetCenter()
return new Point { X = ((XMin + XMax) / 2), Y = ((YMin + YMax) / 2), SpatialReference = SpatialReference };
}

public Extent GetGeometry()
{
return this;
}

public Extent Union(Extent extent)
{
if (extent == null) extent = this;
Expand Down Expand Up @@ -548,23 +523,23 @@ public override bool Equals(object obj)
return Equals((Extent)obj);
}

//public IGeoJsonGeometry ToGeoJson()
//{
// return new GeoJsonPolygon
// {
// Type = "Polygon",
// Coordinates = new PointCollectionList
// {
// new PointCollection
// {
// new[]{ XMin, YMin },
// new[]{ XMax, YMin },
// new[]{ XMax, YMax },
// new[]{ XMin, YMax },
// new[]{ XMin, YMin }
// }
// }
// };
//}
public IGeoJsonGeometry ToGeoJson()
{
return new GeoJsonPolygon
{
Type = "Polygon",
Coordinates = new PointCollectionList
{
new PointCollection
{
new[]{ XMin, YMin },
new[]{ XMax, YMin },
new[]{ XMax, YMax },
new[]{ XMin, YMax },
new[]{ XMin, YMin }
}
}
};
}
}
}
Loading

0 comments on commit bf317db

Please sign in to comment.