예제 #1
0
        public void TestGeometryFromWKB()
        {
            using (var db = new PostGisTestDataConnection(TestDatabaseConnectionString))
            {
                const string wkt1 = "POINT(2 5)";
                const string wkt2 = "LINESTRING(2 5,2 6)";
                var          wkb1 = db.Select(() => GeometryInput.STGeomFromText(wkt1).STAsBinary());
                var          wkb2 = db.Select(() => GeometryInput.STGeomFromText(wkt2).STAsBinary());

                Assert.AreEqual(wkt1, db.Select(() => GeometryInput.STWKBToSQL(wkb1).STAsText()));
                Assert.AreEqual(wkt1, db.Select(() => GeometryInput.STGeomFromWKB(wkb1).STAsText()));
                Assert.AreEqual(wkt1, db.Select(() => GeometryInput.STPointFromWKB(wkb1).STAsText()));

                Assert.AreEqual(SRID3857, db.Select(() => GeometryInput.STGeomFromWKB(wkb1, SRID3857).STSrId()));
                Assert.AreEqual(SRID3857, db.Select(() => GeometryInput.STPointFromWKB(wkb1, SRID3857).STSrId()));

                Assert.AreEqual(wkt2, db.Select(() => GeometryInput.STGeomFromWKB(wkb2).STAsText()));
                Assert.AreEqual(wkt2, db.Select(() => GeometryInput.STLineFromWKB(wkb2).STAsText()));
                Assert.AreEqual(wkt2, db.Select(() => GeometryInput.STLinestringFromWKB(wkb2).STAsText()));

                Assert.AreEqual(SRID3857, db.Select(() => GeometryInput.STGeomFromWKB(wkb2, SRID3857).STSrId()));
                Assert.AreEqual(SRID3857, db.Select(() => GeometryInput.STLineFromWKB(wkb2, SRID3857).STSrId()));
                Assert.AreEqual(SRID3857, db.Select(() => GeometryInput.STLinestringFromWKB(wkb2, SRID3857).STSrId()));

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