/// <summary>
        /// Encodes a polygon for use in OData filters.
        /// <seealso cref="EncodePolygon(GeographyLineStringProxy)"/>
        /// </summary>
        /// <param name="polygon">The <see cref="GeographyPolygonProxy"/> to encode.</param>
        /// <returns>The OData filter-encoded POLYGON string.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="polygon"/> or <see cref="GeographyPolygonProxy.Rings"/> is null.</exception>
        public static string EncodePolygon(GeographyPolygonProxy polygon)
        {
            Argument.AssertNotNull(polygon, nameof(polygon));
            Argument.AssertNotNull(polygon.Rings, $"{nameof(polygon)}.{nameof(polygon.Rings)}");

            if (polygon.Rings.Count != 1)
            {
                throw new ArgumentException(
                          $"A GeographyPolygon must have exactly one Rings to form a searchable polygon.",
                          $"{nameof(polygon)}.{nameof(polygon.Rings)}");
            }

            return(EncodePolygon(polygon.Rings[0]));
        }
Пример #2
0
        /// <summary>
        /// Encodes a polygon for use in OData filters.
        /// <seealso cref="EncodePolygon(GeographyLineStringProxy)"/>
        /// </summary>
        /// <param name="polygon">The <see cref="GeographyPolygonProxy"/> to encode.</param>
        /// <returns>The OData filter-encoded POLYGON string.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="polygon"/> or <see cref="GeographyPolygonProxy.Rings"/> is null.</exception>
        public static string EncodePolygon(GeographyPolygonProxy polygon)
        {
            Argument.AssertNotNull(polygon, nameof(polygon));
            Argument.AssertNotNull(polygon.Rings, $"{nameof(polygon)}.{nameof(polygon.Rings)}");

            if (polygon.Rings.Count != 1)
            {
#pragma warning disable CA2208 // Instantiate argument exceptions correctly
                throw new ArgumentException(
                          $"A GeographyPolygon must have exactly one Rings to form a searchable polygon.",
                          $"{nameof(polygon)}.{nameof(polygon.Rings)}");
#pragma warning restore CA2208 // Instantiate argument exceptions correctly
            }

            return(EncodePolygon(polygon.Rings[0]));
        }