/// <summary> /// Writes out a GeographyLineString value in geojson format. /// { /// "__metadata": {"type": "Edm.GeographyLineString"}, /// { "type" :"LineString", /// "coordinates": { [-122.1202778,47.6741667] } , /// "crs":{"type":"name","properties":{"name":"EPSG:4326"}} /// } /// } /// </summary> /// <param name="geographyLineStringValue">The geography value to serialize into Json</param> /// <param name="writer">The Json writer being used to write out a Json payload</param> private static void WriteGeographyLineString(GeographyLineString lineString, JsonWriter writer) { // { writer.StartObjectScope(); // "__metadata": writer.WriteName(JsonMetadataString); // { writer.StartObjectScope(); // "type" writer.WriteName(JsonTypeString); // "Edm.GeographyLineString" writer.WriteValue(Gml_Edm_GeographyLineStringName); // } writer.EndScope(); // "type":"LineString", writer.WriteName(JsonTypeString); writer.WriteValue(GmlLineString); // "coordinates": writer.WriteName(JsonCoOrdinatesString); // [ writer.StartArrayScope(); foreach (var point in lineString.Points) { WritePointCoordinates(writer, point); } // ] writer.EndScope(); // "crs": {"type": "name", "properties": {"name": "EPSG:4326"}} WriteCrsElement(writer, lineString.CoordinateSystem.EpsgId); // } writer.EndScope(); }
/// <summary> /// Writes out a geography point's Co-ordinates in JSON /// </summary> /// <param name="writer">The Json Writer being used to write out the results.</param> /// <param name="point">The Point to serialize into JSON</param> private static void WritePointCoordinates(JsonWriter writer, GeographyPoint point) { writer.StartArrayScope(); writer.WriteValue(point.Longitude); writer.WriteValue(point.Latitude); writer.EndScope(); }