File tree Expand file tree Collapse file tree
src/GeoJSON.Net.Tests/Geometry Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11using System . Collections . Generic ;
2+ using GeoJSON . Net . Converters ;
23using GeoJSON . Net . Geometry ;
34using Newtonsoft . Json ;
45using NUnit . Framework ;
@@ -28,6 +29,31 @@ public void Can_Serialize()
2829 JsonAssert . AreEqual ( expectedJson , actualJson ) ;
2930 }
3031
32+ [ Test ]
33+ public void Can_RoundTrip_IGeometryObject ( )
34+ {
35+ IGeometryObject polygon = new Polygon ( new List < LineString >
36+ {
37+ new LineString ( new List < IPosition >
38+ {
39+ new Position ( 52.379790828551016 , 5.3173828125 ) ,
40+ new Position ( 52.36721467920585 , 5.456085205078125 ) ,
41+ new Position ( 52.303440474272755 , 5.386047363281249 , 4.23 ) ,
42+ new Position ( 52.379790828551016 , 5.3173828125 ) ,
43+ } )
44+ } ) ;
45+
46+ var serializerSettings = new JsonSerializerSettings ( )
47+ {
48+ Converters = new List < JsonConverter > ( ) { new GeometryConverter ( ) }
49+ } ;
50+
51+ var json = JsonConvert . SerializeObject ( polygon , serializerSettings ) ;
52+ var result = JsonConvert . DeserializeObject < IGeometryObject > ( json , serializerSettings ) ;
53+
54+ Assert . AreEqual ( result , polygon ) ;
55+ }
56+
3157 [ Test ]
3258 public void Can_Deserialize_With_Exterior_And_Inner_Rings ( )
3359 {
You can’t perform that action at this time.
0 commit comments