/// <summary>
        /// Writes out the Co-ordinate reference system element in JSON
        /// http://en.wikipedia.org/wiki/Coordinate_reference_system
        /// </summary>
        /// <param name="writer">The Json Writer being used to write out the results.</param>
        /// <param name="epsgId">the EpsgId value to serialize</param>
        private static void WriteCrsElement(JsonWriter writer, int? epsgId)
        {
            //  "crs"
            writer.WriteName(JsonCrsString);

            // { 
            writer.StartObjectScope();

            // "type"
            writer.WriteName(JsonTypeString);

            // :"name"
            writer.WriteValue(JsonNameString);

            // "properties"
            writer.WriteName(PropertiesElementName);

            // :    {
            writer.StartObjectScope();

            // "name":
            writer.WriteName(JsonNameString);

            string epsgidValue = epsgId.HasValue ? epsgId.Value.ToString() : "0";

            // "EPSG:<EpsgIdValue>"
            writer.WriteValue(String.Format(JsonEPSGValueStringFormat, epsgidValue));

            //      }
            writer.EndScope();

            //    }
            writer.EndScope();
        }
        /// <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 GeographyPoint value in geojson format.
        /// {
        ///      "__metadata":{"type":"Edm.GeographyPoint"},
        ///      "type":"Point",
        ///      "coordinates":[Lattitude,Longitude],
        ///      "crs":{"type":"name","properties":{"name":"EPSG:EPSGValue"}}
        /// }
        /// </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 WriteGeographyPoint(GeographyPoint point, JsonWriter writer)
        {
            // see http://geojson.org/geojson-spec.html#id9
            // {
            writer.StartObjectScope();

            //  "__metadata":
            writer.WriteName(JsonMetadataString);

            //      {
            writer.StartObjectScope();

            // "type"
            writer.WriteName(JsonTypeString);

            // "Edm.GeographyPoint"
            writer.WriteValue(Gml_Edm_GeographyPointName);

            //      }
            writer.EndScope();

            //  "type":"Point",
            writer.WriteName(JsonTypeString);
            writer.WriteValue(GmlPoint);

            //  "coordinates":[-122.1202778,47.6741667],
            writer.WriteName(JsonCoOrdinatesString);
            WritePointCoordinates(writer, point);

            // 	"crs": {"type": "name", "properties": {"name": "EPSG:4326"}}
            WriteCrsElement(writer, point.CoordinateSystem.EpsgId);

            // }
            writer.EndScope();
        }