public void MultiPolygon() { var reader = new GeoJsonReader(); var geo = new MultiPolygon( new Polygon(new LinearRing(new Coordinate(0, 0), new Coordinate(1, 1), new Coordinate(2, 0), new Coordinate(0, 0)))); Assert.AreEqual(@"{""type"":""MultiPolygon"",""coordinates"":[[[[0,0],[1,1],[0,2],[0,0]]]]}", geo.ToGeoJson()); Assert.AreEqual(geo, reader.Read(geo.ToGeoJson())); }
public void TestMultiPolygonSerialization() { var geometry1 = new Polygon(new LineairRing( new GeoCoordinate[] { new GeoCoordinate(0, 0), new GeoCoordinate(0, 1), new GeoCoordinate(1, 1), new GeoCoordinate(1, 0), new GeoCoordinate(0, 0) })); var geometry2 = new Polygon(new LineairRing( new GeoCoordinate[] { new GeoCoordinate(0, 0), new GeoCoordinate(0, 2), new GeoCoordinate(2, 2), new GeoCoordinate(2, 0), new GeoCoordinate(0, 0) })); var geometry3 = new Polygon(new LineairRing( new GeoCoordinate[] { new GeoCoordinate(0, 0), new GeoCoordinate(0, 3), new GeoCoordinate(3, 3), new GeoCoordinate(3, 0), new GeoCoordinate(0, 0) })); var geometryCollection = new MultiPolygon(new Polygon[] { geometry1, geometry2, geometry3 }); var serialized = geometryCollection.ToGeoJson(); serialized = serialized.RemoveWhitespace(); Assert.AreEqual("{\"type\":\"MultiPolygon\",\"coordinates\":[[[[0.0,0.0],[1.0,0.0],[1.0,1.0],[0.0,1.0],[0.0,0.0]]],[[[0.0,0.0],[2.0,0.0],[2.0,2.0],[0.0,2.0],[0.0,0.0]]],[[[0.0,0.0],[3.0,0.0],[3.0,3.0],[0.0,3.0],[0.0,0.0]]]]}", serialized); }