コード例 #1
0
        public void SqlGeometryToJSONTest()
        {
            string expected = "{\"type\":\"FeatureCollection\", \"features\":[{\"type\":\"Feature\", \"geometry\":{\"type\":\"Polygon\", \"coordinates\":[[[-41.2281722793271, 174.70763047448], [-41.1553878554989, 174.777668316277], [-41.1560745010067, 174.840839702996], [-41.2171859512021, 174.878605205926], [-41.2549514541317, 174.807880718621], [-41.2803573379208, 174.802387554559], [-41.2824172744442, 174.834659893426], [-41.3270492324521, 174.841526348504], [-41.3531417617489, 174.774921734246], [-41.3043899306942, 174.715870220574], [-41.2281722793271, 174.70763047448]]]}, \"properties\":null, \"crs\":{\"type\":\"name\", \"properties\":{\"name\":\"epsg:4326\"}}}]}";

            System.Data.SqlTypes.SqlChars wkbGeometry = new System.Data.SqlTypes.SqlChars("POLYGON ((-41.2281722793271 174.70763047448, -41.1553878554989 174.777668316277, -41.1560745010067 174.840839702996, -41.2171859512021 174.878605205926, -41.2549514541317 174.807880718621, -41.2803573379208 174.802387554559, -41.2824172744442 174.834659893426, -41.3270492324521 174.841526348504, -41.3531417617489 174.774921734246, -41.3043899306942 174.715870220574, -41.2281722793271 174.70763047448))");
            SqlGeometry sqlGeometry = SqlGeometry.STGeomFromText(wkbGeometry, 4326);
            string      actual;

            actual = GeoJSON.SqlGeometryToJSON(sqlGeometry);
            Assert.AreEqual(expected, actual);
        }