Accept feature projection in GeoJSON constructor

This commit is contained in:
Tim Schaub
2016-09-26 22:56:07 -06:00
parent f8bcd725ad
commit 4b6e907f69
4 changed files with 59 additions and 14 deletions

View File

@@ -1,6 +1,7 @@
goog.provide('ol.format.Feature');
goog.require('ol.geom.Geometry');
goog.require('ol.obj');
goog.require('ol.proj');
@@ -24,6 +25,12 @@ ol.format.Feature = function() {
*/
this.defaultDataProjection = null;
/**
* @protected
* @type {ol.proj.Projection}
*/
this.defaultFeatureProjection = null;
};
@@ -64,19 +71,10 @@ ol.format.Feature.prototype.getReadOptions = function(source, opt_options) {
* Updated options.
*/
ol.format.Feature.prototype.adaptOptions = function(options) {
var updatedOptions;
if (options) {
updatedOptions = {
featureProjection: options.featureProjection,
dataProjection: options.dataProjection ?
options.dataProjection : this.defaultDataProjection,
rightHanded: options.rightHanded
};
if (options.decimals) {
updatedOptions.decimals = options.decimals;
}
}
return updatedOptions;
return ol.obj.assign({
dataProjection: this.defaultDataProjection,
featureProjection: this.defaultFeatureProjection
}, options);
};

View File

@@ -42,6 +42,10 @@ ol.format.GeoJSON = function(opt_options) {
options.defaultDataProjection : 'EPSG:4326');
if (options.featureProjection) {
this.defaultFeatureProjection = ol.proj.get(options.featureProjection);
}
/**
* Name of the geometry attribute for features.
* @type {string|undefined}