Add missing return type to GeoJSON format

This commit is contained in:
Guillaume Beraudo
2016-01-05 09:56:58 +01:00
parent 9fe3d8b2e2
commit a1c72d8890

View File

@@ -520,32 +520,33 @@ ol.format.GeoJSON.prototype.writeFeature;
* *
* @param {ol.Feature} feature Feature. * @param {ol.Feature} feature Feature.
* @param {olx.format.WriteOptions=} opt_options Write options. * @param {olx.format.WriteOptions=} opt_options Write options.
* @return {Object} Object. * @return {GeoJSONObject} Object.
* @api stable * @api stable
*/ */
ol.format.GeoJSON.prototype.writeFeatureObject = function( ol.format.GeoJSON.prototype.writeFeatureObject = function(
feature, opt_options) { feature, opt_options) {
opt_options = this.adaptOptions(opt_options); opt_options = this.adaptOptions(opt_options);
var object = {
var object = /** @type {GeoJSONObject} */ ({
'type': 'Feature' 'type': 'Feature'
}; });
var id = feature.getId(); var id = feature.getId();
if (id !== undefined) { if (id !== undefined) {
object['id'] = id; object.id = id;
} }
var geometry = feature.getGeometry(); var geometry = feature.getGeometry();
if (geometry) { if (geometry) {
object['geometry'] = object.geometry =
ol.format.GeoJSON.writeGeometry_(geometry, opt_options); ol.format.GeoJSON.writeGeometry_(geometry, opt_options);
} else { } else {
object['geometry'] = null; object.geometry = null;
} }
var properties = feature.getProperties(); var properties = feature.getProperties();
delete properties[feature.getGeometryName()]; delete properties[feature.getGeometryName()];
if (!goog.object.isEmpty(properties)) { if (!goog.object.isEmpty(properties)) {
object['properties'] = properties; object.properties = properties;
} else { } else {
object['properties'] = null; object.properties = null;
} }
return object; return object;
}; };
@@ -568,7 +569,7 @@ ol.format.GeoJSON.prototype.writeFeatures;
* *
* @param {Array.<ol.Feature>} features Features. * @param {Array.<ol.Feature>} features Features.
* @param {olx.format.WriteOptions=} opt_options Write options. * @param {olx.format.WriteOptions=} opt_options Write options.
* @return {Object} GeoJSON Object. * @return {GeoJSONFeatureCollection} GeoJSON Object.
* @api stable * @api stable
*/ */
ol.format.GeoJSON.prototype.writeFeaturesObject = ol.format.GeoJSON.prototype.writeFeaturesObject =