Пример #1
0
        public void GeoJSONToGeometryTest()
        {
            string json = "{\"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\":{}}]}";

            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 expected = SqlGeometry.STGeomFromText(wkbGeometry, 4326);
            SqlGeometry actual;

            actual = GeoJSON.JSONToGeometry(json);
            Assert.AreEqual(expected.ToString(), actual.ToString());
        }