Write all geometry's properties in KML

This commit is contained in:
oterral
2017-05-17 16:08:39 +02:00
parent 132634f10c
commit ca90157e9f
2 changed files with 51 additions and 15 deletions

View File

@@ -2475,10 +2475,16 @@ ol.format.KML.writePrimitiveGeometry_ = function(node, geometry, objectStack) {
var /** @type {ol.XmlNodeStackItem} */ context = {node: node};
context['layout'] = geometry.getLayout();
context['stride'] = geometry.getStride();
ol.xml.pushSerializeAndPop(context,
ol.format.KML.PRIMITIVE_GEOMETRY_SERIALIZERS_,
ol.format.KML.COORDINATES_NODE_FACTORY_,
[flatCoordinates], objectStack);
// serialize properties (properties unknown to KML are not serialized)
var properties = geometry.getProperties();
properties.coordinates = flatCoordinates;
var parentNode = objectStack[objectStack.length - 1].node;
var orderedKeys = ol.format.KML.PRIMITIVE_GEOMETRY_SEQUENCE_[parentNode.namespaceURI];
var values = ol.xml.makeSequence(properties, orderedKeys);
ol.xml.pushSerializeAndPop(context, ol.format.KML.PRIMITIVE_GEOMETRY_SERIALIZERS_,
ol.xml.OBJECT_PROPERTY_NODE_FACTORY, values, objectStack, orderedKeys);
};
@@ -2639,7 +2645,6 @@ ol.format.KML.GEOMETRY_TYPE_TO_NODENAME_ = {
'GeometryCollection': 'MultiGeometry'
};
/**
* @const
* @type {Object.<string, Array.<string>>}
@@ -2815,6 +2820,17 @@ ol.format.KML.PLACEMARK_SERIALIZERS_ = ol.xml.makeStructureNS(
});
/**
* @const
* @type {Object.<string, Array.<string>>}
* @private
*/
ol.format.KML.PRIMITIVE_GEOMETRY_SEQUENCE_ = ol.xml.makeStructureNS(
ol.format.KML.NAMESPACE_URIS_, [
'extrude', 'tessellate', 'altitudeMode', 'coordinates'
]);
/**
* @const
* @type {Object.<string, Object.<string, ol.XmlSerializer>>}
@@ -2822,6 +2838,9 @@ ol.format.KML.PLACEMARK_SERIALIZERS_ = ol.xml.makeStructureNS(
*/
ol.format.KML.PRIMITIVE_GEOMETRY_SERIALIZERS_ = ol.xml.makeStructureNS(
ol.format.KML.NAMESPACE_URIS_, {
'extrude': ol.xml.makeChildAppender(ol.format.XSD.writeBooleanTextNode),
'tessellate': ol.xml.makeChildAppender(ol.format.XSD.writeBooleanTextNode),
'altitudeMode': ol.xml.makeChildAppender(ol.format.XSD.writeStringTextNode),
'coordinates': ol.xml.makeChildAppender(
ol.format.KML.writeCoordinatesTextNode_)
});
@@ -2933,16 +2952,6 @@ ol.format.KML.GEOMETRY_NODE_FACTORY_ = function(value, objectStack,
ol.format.KML.COLOR_NODE_FACTORY_ = ol.xml.makeSimpleNodeFactory('color');
/**
* A factory for creating coordinates nodes.
* @const
* @type {function(*, Array.<*>, string=): (Node|undefined)}
* @private
*/
ol.format.KML.COORDINATES_NODE_FACTORY_ =
ol.xml.makeSimpleNodeFactory('coordinates');
/**
* A factory for creating Data nodes.
* @const