0

C# で 2 つのポイントを持つ Rect を作成しています。これらのポイントは、実際には地理的な境界です。私が抱えている問題は、長方形を作成するとy軸が反転することです。

たとえば、私のデータがwest="5.42194487004" south="46.407494" east="17.166386" north="55.056664"

私はそれを渡しますRect geoBounds = new Rect(new Point(west, north),new Point(east, south));

作成される Rectangle には、次のプロパティがあります。

    Bottom  55.056664          double
    Height  7.781945           double
    IsEmpty false              bool
    Left    5.864166           double
    Right   15.038887000000003 double
    Top     47.274719          double
    Width   9.1747210000000017 double
    X       5.864166           double
    Y       47.274719          double

Y 軸が反転します。呼び出しに送られるデータが正しいことを 3 回確認しました。なにが問題ですか?また、多くのコードを提供しなかったこともわかっていますが、それ以上必要だとは感じていませんでした。必要に応じてさらに提供します。

4

2 に答える 2

3

座標系は、画面の左上が 0,0 で、Y が下方向に増加します。これは、プロパティのサンプル ページで確認できRect.Bottomます: http://msdn.microsoft.com/en-us/library/system.windows.rect.bottom.aspx

そのページのこのコメントに注意してください:

// Bottom property gets the y-axis value of the bottom of the rectangle.  
// For this rectangle the value is 55.
rectInfo = rectInfo + "Bottom: " + myRectangle.Bottom;

そしてこれ:

// Top property gets the y-axis position of the top of the rectangle which is  
// equivalent to getting the rectangle's Y property. 
// For this rectangle the value is 5.
rectInfo = rectInfo + "| Top: " + myRectangle.Top;

Rectこれは、http : //msdn.microsoft.com/en-us/library/ms587929%28v=vs.95%29.aspxの明示的なコンストラクターによってさらにサポートされます

幅が右方向に伸び、高さが下に伸びる左上隅に注意してくださいxy

于 2013-01-18T00:36:08.343 に答える
0
Rect geoBounds = new Rect(west, north, (east - west), (north - south));
于 2013-01-18T00:41:11.493 に答える