Represents the base class for all geometry types that are supported by ArcGIS Rest API.
Beispiel #1
0
        /// <summary>
        /// Downloads records and yields them as a lazy sequence of features of the specified type.  Possibly throws RestException.
        /// </summary>
        /// <typeparam name="T">The type the record should be mapped to.</typeparam>
        /// <param name="layerId">The layer ID of the feature layer or table.</param>
        /// <param name="whereClause">The where clause.  If set to null, returns all features.</param>
        /// <param name="geometry">The geometry used to spatially filter the records.</param>
        /// <param name="spatialRel">The spatial relationship used for filtering.</param>
        /// <param name="extraParameters">The query string that describes any additional query parameters (i.e. outSR=4326).  Each parameter must be url encoded.</param>
        /// <param name="keepQuerying">If set to true, repetitively queries the server until all features have been returned.</param>
        /// <param name="degreeOfParallelism">The maximum number of concurrent requests.</param>
        /// <returns></returns>
        public IEnumerable <T> Download <T>(int layerId, string whereClause, GeometryBase geometry, SpatialRel spatialRel, string extraParameters = null, bool keepQuerying = false, int degreeOfParallelism = 1) where T : Feature
        {
            if (geometry == null)
            {
                return(Download <T>(layerId, whereClause, extraParameters, keepQuerying, degreeOfParallelism));
            }

            string geometryType;

            if (geometry is Point)
            {
                geometryType = "esriGeometryPoint";
            }
            else if (geometry is Multipoint)
            {
                geometryType = "esriGeometryMultipoint";
            }
            else if (geometry is Polyline)
            {
                geometryType = "esriGeometryPolyline";
            }
            else if (geometry is Polygon)
            {
                geometryType = "esriGeometryPolygon";
            }
            else if (geometry is Envelope)
            {
                geometryType = "esriGeometryEnvelope";
            }
            else
            {
                throw new ArgumentException("This geometry type is not supported.", nameof(geometry));
            }

            var spatialFilter = $"geometry={Compatibility.UrlEncode(geometry.ToString())}&geometryType={geometryType}&spatialRel=esriSpatialRel{spatialRel}";

            return(Download <T>(layerId, whereClause, string.IsNullOrEmpty(extraParameters) ? spatialFilter : (extraParameters + "&" + spatialFilter), keepQuerying, degreeOfParallelism));
        }
Beispiel #2
0
 /// <summary>
 /// Returns the JSON representation of the geometry.
 /// </summary>
 /// <param name="geometry"></param>
 /// <returns></returns>
 public static string ToJson(this GeometryBase geometry)
 {
     return(geometry?.ToString());
 }
Beispiel #3
0
 /// <summary>
 /// Downloads and yields features whose attributes and geometry are dynamically accessed at runtime.  Possibly throws RestException.
 /// </summary>
 /// <param name="layerName">The name of the feature layer or table.  If the service contains two or more layers with this name, use the overload that takes the layer ID rather than the name.</param>
 /// <param name="whereClause">The where clause.  If set to null, returns all features.</param>
 /// <param name="geometry">The geometry used to spatially filter the records.</param>
 /// <param name="spatialRel">The spatial relationship used for filtering.</param>
 /// <param name="extraParameters">The query string that describes any additional query parameters (i.e. outSR=4326).  Each parameter must be url encoded.</param>
 /// <param name="keepQuerying">If set to true, repetitively queries the server until all features have been returned.</param>
 /// <param name="degreeOfParallelism">The maximum number of concurrent requests.</param>
 /// <returns></returns>
 public IEnumerable <DynamicFeature> Download(string layerName, string whereClause, GeometryBase geometry, SpatialRel spatialRel, string extraParameters = null, bool keepQuerying = false, int degreeOfParallelism = 1)
 {
     return(Download <DynamicFeature>(layerName, whereClause, geometry, spatialRel, extraParameters, keepQuerying, degreeOfParallelism));
 }
Beispiel #4
0
 /// <summary>
 /// Downloads records and yields them as a lazy sequence of features of the specified type.  Possibly throws RestException.
 /// </summary>
 /// <typeparam name="T">The type the record should be mapped to.</typeparam>
 /// <param name="layerName">The name of the feature layer or table.  If the service contains two or more layers with this name, use the overload that takes the layer ID rather than the name.</param>
 /// <param name="whereClause">The where clause.  If set to null, returns all features.</param>
 /// <param name="geometry">The geometry used to spatially filter the records.</param>
 /// <param name="spatialRel">The spatial relationship used for filtering.</param>
 /// <param name="extraParameters">The query string that describes any additional query parameters (i.e. outSR=4326).  Each parameter must be url encoded.</param>
 /// <param name="keepQuerying">If set to true, repetitively queries the server until all features have been returned.</param>
 /// <param name="degreeOfParallelism">The maximum number of concurrent requests.</param>
 /// <returns></returns>
 public IEnumerable <T> Download <T>(string layerName, string whereClause, GeometryBase geometry, SpatialRel spatialRel, string extraParameters = null, bool keepQuerying = false, int degreeOfParallelism = 1) where T : Feature
 {
     return(Download <T>(GetLayer(layerName).id, whereClause, geometry, spatialRel, extraParameters, keepQuerying, degreeOfParallelism));
 }