private void TestRoundTrip <TCoordinates>(string expected, GeoJsonFeature <TCoordinates> feature) where TCoordinates : GeoJsonCoordinates { var json = feature.ToJson(); Assert.AreEqual(expected, json); var rehydrated = BsonSerializer.Deserialize <GeoJsonFeature <TCoordinates> >(json); Assert.AreEqual(expected, rehydrated.ToJson()); }
public void ToJson1() { // Initialize a new feature GeoJsonFeature feature = new GeoJsonFeature( new GeoJsonPoint(9.536067, 55.708116) ); // Convert the feature to a JSON string string json = feature.ToJson(Formatting.None); Assert.AreEqual("{\"type\":\"Feature\",\"geometry\":{\"type\":\"Point\",\"coordinates\":[9.536067,55.708116]}}", json); }
public void ToJson2() { GeoJsonFeature feature = new GeoJsonFeature( new GeoJsonPoint(9.536067, 55.708116), new GeoJsonProperties { Name = "My feature" } ); // Convert the point to a JSON string string json = feature.ToJson(Formatting.None); Assert.AreEqual("{\"type\":\"Feature\",\"properties\":{\"name\":\"My feature\"},\"geometry\":{\"type\":\"Point\",\"coordinates\":[9.536067,55.708116]}}", json); }