2

SQL Server 2008 R2 で楕円を表す空間オブジェクトを作成したいと考えています。

ポイント座標と、最小軸と長軸の値があります。

私が見つけることができる最も近い組み込み関数は、STBuffer です。これは、ポイントの周りにバッファーされた半径を作成します。

DECLARE @g geography;
SET @g = geography::STGeomFromText('POINT(-122.360 47.656)', 4326);
SELECT @g.STBuffer(5);

何か不足していますか?これは非常に基本的なようです。

この形状を表現するために一連のポリゴン座標を作成したくありません。やり過ぎのようです。

前もって感謝します。

4

1 に答える 1

2

これは不可能でした。C# で WKT Polygon 文字列表現を作成することで、この問題を解決しました。

式の要約は次のとおりです。

var step = 2*Math.PI/40; // creates 40 points (1 for each "step")
var radians = 5.868;
var semiMajMetres = 400;
var semiMinMetres = 200;
var latMetres = latVal*110575; // converts degree value to metres value
var lonMetres = lonVal*111303; // assumes you have variables with these known values

for(double theta = 0; theta <= 2 * Math.PI; theta += step)
{
    var lon = lonMetres + semiMajMetres * Math.Cos(theta) * Math.Cos(radians) - semiMinMetres * Math.Sin(theta) * Math.Sin(radians);
    var lat = latMetres + semiMajMetres * Math.Cos(theta) * Math.Sin(radians) + semiMinMetres * Math.Sin(theta) * Math.Cos(radians);

    lat /= 110575; // convert metres back to degrees
    lon /= 111303;

    // Create your POLYGON string with these values in format POLYGON((lon lat, lon lat, lon lat, lon lat))
    // Note that the last coordinate set MUST be identical to the first coordinate set - confirm this and rectify the last coordinate double precision, if required
}

geography オブジェクトを作成します。

DECLARE @g geography;
SET @g = geography::STPolyFromText('POLYGON(([lonValue] [latValue], POINT([lonValue] [latValue], POINT([lonValue] [latValue], POINT([lonValue] [latValue]))', 4326);
SELECT @g;
于 2015-02-27T10:18:14.260 に答える