コード例 #1
0
ファイル: WorldFileTest.cs プロジェクト: Deltares/Riskeer
        public void BoundingOrdinatesToWorldCoordinates_ForVariousArguments_ReturnPolygonInWorldCoordinates(int width, int height)
        {
            // Setup
            var worldFile = new WorldFile(1.1, 2.2, 3.3, 4.4, 5.5, 6.6);

            // Call
            IPolygon polygon = worldFile.BoundingOrdinatesToWorldCoordinates(width, height);

            // Assert
            Coordinate p1 = worldFile.ToWorldCoordinates(0, 0);
            Coordinate p2 = worldFile.ToWorldCoordinates(0, height);
            Coordinate p3 = worldFile.ToWorldCoordinates(width, 0);
            Coordinate p4 = worldFile.ToWorldCoordinates(width, height);

            CollectionAssert.IsEmpty(polygon.Holes);
            CollectionAssert.AreEqual(new[]
            {
                p1,
                p2,
                p3,
                p4,
                p1
            }, polygon.Shell.Coordinates);
        }
コード例 #2
0
ファイル: WorldFileTest.cs プロジェクト: Deltares/Riskeer
        public void ToWorldCoordinates_InitializedForSimpleTransformation_ReturnExpectedLocation(double scaleFactorX, double scaleFactorY, double translationX, double translationY)
        {
            // Setup
            var worldFile = new WorldFile(scaleFactorX, 0.0, 0.0, scaleFactorY, translationX, translationY);

            const int x = 1;
            const int y = 2;

            // Call
            Coordinate worldPoint = worldFile.ToWorldCoordinates(x, y);

            // Assert
            double expectedX = scaleFactorX * x + translationX;
            double expectedY = scaleFactorY * y + translationY;

            Assert.AreEqual(expectedX, worldPoint.X);
            Assert.AreEqual(expectedY, worldPoint.Y);
        }
コード例 #3
0
ファイル: WorldFileTest.cs プロジェクト: Deltares/Riskeer
        public void GivenScreenSpaceCoordinate_WhenDoingRoundtripTransformation_ThenScreenSpaceCoordinateRemainsUnchanged()
        {
            // Given
            const double a11             = 1.1;
            const double a21             = 2.2;
            const double a12             = 3.3;
            const double a22             = 4.4;
            const double transformationX = 5.5;
            const double transformationY = 6.6;

            var worldFile = new WorldFile(a11, a21, a12, a22, transformationX, transformationY);

            const int x = 20;
            const int y = 17;

            // When
            Coordinate worldCoordinate  = worldFile.ToWorldCoordinates(x, y);
            Point      screenCoordinate = worldFile.ToScreenCoordinates(worldCoordinate);

            // Assert
            Assert.AreEqual(x, screenCoordinate.X);
            Assert.AreEqual(y, screenCoordinate.Y);
        }
コード例 #4
0
ファイル: WorldFileTest.cs プロジェクト: Deltares/Riskeer
        public void ToWorldCoordinates_InitializedForSimpleRotation_ReturnExpectedLocation(double radian)
        {
            // Setup
            const int x = 1;
            const int y = 2;

            // 2D Rotation matrix:
            double a11 = Math.Cos(radian);
            double a21 = Math.Sin(radian);
            double a12 = -Math.Sin(radian);
            double a22 = Math.Cos(radian);

            var worldFile = new WorldFile(a11, a21, a12, a22, 0.0, 0.0);

            // Call
            Coordinate worldPoint = worldFile.ToWorldCoordinates(x, y);

            // Assert
            double expectedX = a11 * x + a21 * y;
            double expectedY = a12 * x + a22 * y;

            Assert.AreEqual(expectedX, worldPoint.X);
            Assert.AreEqual(expectedY, worldPoint.Y);
        }