/// <summary>
        /// Converts a native Sql Server geography to GeoJSON geometry
        /// </summary>
        /// <param name="sqlGeography">SQL Server geography to convert</param>
        /// <returns>GeoJSON geometry</returns>
        public static IGeometryObject ToGeoJSONGeometry(this SqlGeography sqlGeography)
        {
            if (sqlGeography == null || sqlGeography.IsNull)
            {
                return(null);
            }

            // Make valid if necessary
            sqlGeography = sqlGeography.MakeValidIfInvalid();
            if (sqlGeography.STIsValid().IsFalse)
            {
                throw new Exception("Invalid geometry : " + sqlGeography.IsValidDetailed());
            }

            // Conversion using geography sink
            SqlGeographyGeoJsonSink sink = new SqlGeographyGeoJsonSink();

            sqlGeography.Populate(sink);
            return(sink.ConstructedGeography);
        }
        /// <summary>
        /// Converts a native Sql Server geography to GeoJSON geometry
        /// </summary>
        /// <param name="sqlGeography">SQL Server geography to convert</param>
        /// <param name="withBoundingBox">Value indicating whether the feature's BoundingBox should be set.</param>
        /// <returns>GeoJSON geometry</returns>
        public static T ToGeoJSONObject <T>(this SqlGeography sqlGeography, bool withBoundingBox = true) where T : GeoJSONObject
        {
            if (sqlGeography == null || sqlGeography.IsNull)
            {
                return(null);
            }

            // Make valid if necessary
            sqlGeography = sqlGeography.MakeValidIfInvalid();
            if (sqlGeography.STIsValid().IsFalse)
            {
                throw new Exception("Invalid geometry : " + sqlGeography.IsValidDetailed());
            }

            // Conversion using geography sink
            T geoJSONobj = null;
            SqlGeographyGeoJsonSink sink = new SqlGeographyGeoJsonSink();

            sqlGeography.Populate(sink);
            geoJSONobj = sink.ConstructedGeography as T;
            geoJSONobj.BoundingBoxes = withBoundingBox ? sink.BoundingBox : null;

            return(geoJSONobj);
        }