Exemple #1
0
        public void TestSTGeomFromGeoJSON()
        {
            using (var db = new PostGisTestDataConnection(TestDatabaseConnectionString))
            {
                var wkt1 = db.Select(() => GeometryInput.STGeomFromGeoJSON("{\"type\":\"Point\",\"coordinates\":[-48.23456,20.12345]}").STAsText());
                Assert.AreEqual("POINT(-48.23456 20.12345)", wkt1);

                var wkt2 = db.Select(() => GeometryInput.STGeomFromGeoJSON("{\"type\":\"LineString\",\"coordinates\":[[1,2,3],[4,5,6],[7,8,9]]}").STAsText());
                Assert.AreEqual("LINESTRING Z (1 2 3,4 5 6,7 8 9)", wkt2);

                var wkt3 = db.Select(() => GeometryInput.STGeomFromGeoJSON(null).STAsText());
                Assert.IsNull(wkt3);
            }
        }