ToString() public method

Returns the JSON representation of the geometry.
public ToString ( ) : string
return string
コード例 #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));
        }
コード例 #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());
 }