コード例 #1
0
        public void TestSTGeogFromWKB()
        {
            using (var db = new PostGisTestDataConnection(TestDatabaseConnectionString))
            {
                // Binary output of select ST_GeogFromText('POINT(127.0092 38.889588)');
                var wkbPoint = new byte[]
                {
                    0x01,
                    0x01, 0x00, 0x00, 0x20,
                    0xE6, 0x10, 0x00, 0x00,
                    0xE3, 0xC7, 0x98, 0xBB, 0x96, 0xC0, 0x5F, 0x40,
                    0x00, 0x75, 0x03, 0x05, 0xDE, 0x71, 0x43, 0x40
                };

                var geographyPoint = db.Select(() => GeometryInput.STGeomFromEWKB(wkbPoint));

                Assert.IsNotNull(geographyPoint);
                Assert.AreEqual(SRID4326, geographyPoint.SRID);
                Assert.AreEqual("Point", geographyPoint.GeometryType);
                Assert.AreEqual(127.0092, geographyPoint.Coordinates[0].X, 1.0E-4);
                Assert.AreEqual(38.889588, geographyPoint.Coordinates[0].Y, 1.0E-6);

                Assert.IsNull(db.Select(() => GeometryInput.STGeogFromWKB(null)));
            }
        }