in JSLib/src/odata-gml.js [493:551]
var gmlNewODataSpatialValue = function (dom, value, type, isGeography) {
/// <summary>Creates a new GML DOM element for the value of an OData spatial property or GeoJSON object.</summary>
/// <param name="dom">DOM document used for creating the new DOM Element.</param>
/// <param name="value" type="Object">Spatial property value in GeoJSON format.</param>
/// <param name="type" type="String">String indicating the GeoJSON type of the value to serialize.</param>
/// <param name="isGeography" type="Boolean" Optional="True">Flag indicating if the value uses a geographic reference system or not.<param>
/// <remarks>
/// When using a geographic reference system, the first component of all the coordinates in the GeoJSON value is the Longitude and
/// will be serialized as the second component of each <pos> element in the GML DOM tree.
/// </remarks>
/// <returns>New DOM element in the GML namespace for the spatial value. </returns>
var gmlWriter;
switch (type) {
case GEOJSON_POINT:
gmlWriter = gmlNewODataPoint;
break;
case GEOJSON_LINESTRING:
gmlWriter = gmlNewODataLineString;
break;
case GEOJSON_POLYGON:
gmlWriter = gmlNewODataPolygon;
break;
case GEOJSON_MULTIPOINT:
gmlWriter = gmlNewODataMultiPoint;
break;
case GEOJSON_MULTILINESTRING:
gmlWriter = gmlNewODataMultiLineString;
break;
case GEOJSON_MULTIPOLYGON:
gmlWriter = gmlNewODataMultiPolygon;
break;
case GEOJSON_GEOMETRYCOLLECTION:
gmlWriter = gmlNewODataGeometryCollection;
break;
default:
djsassert(false, "gmlNewODataSpatialValue - Unknown GeoJSON type <" + type + ">!!");
return null;
}
var gml = gmlWriter(dom, value, isGeography);
// Set the srsName attribute if applicable.
var crs = value.crs;
if (crs) {
if (crs.type === "name") {
var properties = crs.properties;
var name = properties && properties.name;
if (name && name.indexOf("ESPG:") === 0 && name.length > 5) {
var crsId = name.substring(5);
var srsName = xmlNewAttribute(dom, null, "srsName", gmlPrefix + crsId);
xmlAppendChild(gml, srsName);
}
}
}
return gml;
};