Move WriteOptions to ol/format/Feature

This commit is contained in:
Tim Schaub
2018-03-11 15:55:48 -06:00
parent 4eb6603af7
commit 8eaee5618e
15 changed files with 89 additions and 151 deletions

View File

@@ -21,6 +21,32 @@ import {get as getProjection, equivalent as equivalentProjection, transformExten
*/
/**
* @typedef {Object} WriteOptions
* @property {ol.ProjectionLike} dataProjection Projection of the data we are writing.
* If not provided, the `defaultDataProjection` of the format is assigned (where set).
* If no `defaultDataProjection` is set for a format, the features will be returned
* in the `featureProjection`.
* @property {ol.ProjectionLike} featureProjection Projection of the feature geometries
* that will be serialized by the format writer. If not provided, geometries are assumed
* to be in the `dataProjection` if that is set; in other words, they are not transformed.
* @property {boolean|undefined} rightHanded When writing geometries, follow the right-hand
* rule for linear ring orientation. This means that polygons will have counter-clockwise
* exterior rings and clockwise interior rings. By default, coordinates are serialized
* as they are provided at construction. If `true`, the right-hand rule will
* be applied. If `false`, the left-hand rule will be applied (clockwise for
* exterior and counter-clockwise for interior rings). Note that not all
* formats support this. The GeoJSON format does use this property when writing
* geometries.
* @property {number|undefined} decimals Maximum number of decimal places for coordinates.
* Coordinates are stored internally as floats, but floating-point arithmetic can create
* coordinates with a large number of decimal places, not generally wanted on output.
* Set a number here to round coordinates. Can also be used to ensure that
* coordinates read in can be written back out with the same number of decimals.
* Default is no rounding.
*/
/**
* @classdesc
* Abstract base class; normally only used for creating subclasses and not
@@ -74,10 +100,10 @@ FeatureFormat.prototype.getReadOptions = function(source, opt_options) {
/**
* Sets the `defaultDataProjection` on the options, if no `dataProjection`
* is set.
* @param {olx.format.WriteOptions|module:ol/format/Feature~ReadOptions|undefined} options
* @param {module:ol/format/Feature~WriteOptions|module:ol/format/Feature~ReadOptions|undefined} options
* Options.
* @protected
* @return {olx.format.WriteOptions|module:ol/format/Feature~ReadOptions|undefined}
* @return {module:ol/format/Feature~WriteOptions|module:ol/format/Feature~ReadOptions|undefined}
* Updated options.
*/
FeatureFormat.prototype.adaptOptions = function(options) {
@@ -152,7 +178,7 @@ FeatureFormat.prototype.readProjection = function(source) {};
*
* @abstract
* @param {ol.Feature} feature Feature.
* @param {olx.format.WriteOptions=} opt_options Write options.
* @param {module:ol/format/Feature~WriteOptions=} opt_options Write options.
* @return {string} Result.
*/
FeatureFormat.prototype.writeFeature = function(feature, opt_options) {};
@@ -163,7 +189,7 @@ FeatureFormat.prototype.writeFeature = function(feature, opt_options) {};
*
* @abstract
* @param {Array.<ol.Feature>} features Features.
* @param {olx.format.WriteOptions=} opt_options Write options.
* @param {module:ol/format/Feature~WriteOptions=} opt_options Write options.
* @return {string} Result.
*/
FeatureFormat.prototype.writeFeatures = function(features, opt_options) {};
@@ -174,7 +200,7 @@ FeatureFormat.prototype.writeFeatures = function(features, opt_options) {};
*
* @abstract
* @param {ol.geom.Geometry} geometry Geometry.
* @param {olx.format.WriteOptions=} opt_options Write options.
* @param {module:ol/format/Feature~WriteOptions=} opt_options Write options.
* @return {string} Result.
*/
FeatureFormat.prototype.writeGeometry = function(geometry, opt_options) {};
@@ -184,7 +210,7 @@ export default FeatureFormat;
/**
* @param {ol.geom.Geometry|module:ol/extent~Extent} geometry Geometry.
* @param {boolean} write Set to true for writing, false for reading.
* @param {(olx.format.WriteOptions|module:ol/format/Feature~ReadOptions)=} opt_options
* @param {(module:ol/format/Feature~WriteOptions|module:ol/format/Feature~ReadOptions)=} opt_options
* Options.
* @return {ol.geom.Geometry|module:ol/extent~Extent} Transformed geometry.
*/