Criar um polígono-círculo SqlGeography de um centro e raio

Gostaria de salvar um círculo em um campo de geografia sql-server 2008, usando c #.

Em c # eu tenho uma latitude, uma longitude e um raio, mas eu simplesmente não consigo encontrar uma maneira de calcular o polígono que representaria o círculo e criar umSqlGeography a partir dele.

Eu tentei seguir a função para criar o polígono:

    private List<Coordinate> getCirclePoints(Coordinate center, int radius, int speed)  //speed 1: draws 360 sides, 2 draws 180 etc...
    {
        var centerLat = (center.Latitude * Math.PI) / 180.0;  //rad
        var centerLng = (center.Longitude * Math.PI) / 180.0; //rad
        var dist = (float)radius / 6371.0;             //d = angular distance covered on earth's surface
        var circlePoints = new List<Coordinate>();
        for (int x = 0; x <= 360; x += speed)
        {
            var brng = x * Math.PI / 180.0;         //rad
            var latitude = Math.Asin(Math.Sin(centerLat) * Math.Cos(dist) + Math.Cos(centerLat) * Math.Sin(dist) * Math.Cos(brng));
            var longitude = ((centerLng + Math.Atan2(Math.Sin(brng) * Math.Sin(dist) * Math.Cos(centerLat), Math.Cos(dist) - Math.Sin(centerLat) * Math.Sin(latitude))) * 180.0) / Math.PI;
            circlePoints.Add(new Coordinate((latitude * 180.0) / Math.PI, longitude));
        }
        return circlePoints;
    }

E então tente converter issoList<Coordinate> para uma string analisável:

        var s = "POLYGON((" + string.Join(",", points.ConvertAll(p => p.Longitude + " " + p.Latitude).ToArray()) + "))";
        var poly = SqlGeography.STPolyFromText(new System.Data.SqlTypes.SqlChars((SqlString)s), 4326);

Mas sempre reclama que o polígono tem que estar em um único hemisfério, onde tenho certeza que é o caso.

Estou no caminho certo? Existe alguma outra maneira (mais simples) de fazer isso?

questionAnswers(1)

yourAnswerToTheQuestion