getProjection method on parsers
With this, vector sources/layers do not need to make assumptions on the data projection.
This commit is contained in:
@@ -514,7 +514,7 @@
|
||||
* @property {Object|string|undefined} data Data to parse.
|
||||
* @property {ol.Extent|undefined} extent Extent.
|
||||
* @property {string|undefined} logo Logo.
|
||||
* @property {ol.parser.Parser} parser Parser instance to parse data
|
||||
* @property {ol.parser.FeatureParser} parser Parser instance to parse data
|
||||
* provided as `data` or fetched from `url`.
|
||||
* @property {ol.ProjectionLike|undefined} projection Projection. EPSG:4326
|
||||
* is assumed if not defined. TODO: Get projection from the parser instead
|
||||
|
||||
@@ -418,7 +418,7 @@ ol.layer.Vector.prototype.groupFeaturesBySymbolizerLiteral =
|
||||
|
||||
/**
|
||||
* @param {Object|Element|Document|string} data Feature data.
|
||||
* @param {ol.parser.Parser} parser Feature parser.
|
||||
* @param {ol.parser.FeatureParser} parser Feature parser.
|
||||
* @param {ol.Projection} projection This sucks. The layer should be a view in
|
||||
* one projection.
|
||||
*/
|
||||
@@ -439,6 +439,9 @@ ol.layer.Vector.prototype.parseFeatures = function(data, parser, projection) {
|
||||
|
||||
var addFeatures = function(features) {
|
||||
var sourceProjection = this.getSource().getProjection();
|
||||
if (goog.isNull(sourceProjection)) {
|
||||
sourceProjection = parser.getProjection();
|
||||
}
|
||||
var transform = ol.proj.getTransform(sourceProjection, projection);
|
||||
|
||||
transform(
|
||||
|
||||
@@ -12,6 +12,20 @@ goog.require('ol.Feature');
|
||||
/**
|
||||
* @interface
|
||||
*/
|
||||
ol.parser.FeatureParser = function() {};
|
||||
|
||||
|
||||
/**
|
||||
* @return {ol.Projection} Data projection.
|
||||
*/
|
||||
ol.parser.FeatureParser.prototype.getProjection = goog.abstractMethod;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @interface
|
||||
* @extends {ol.parser.FeatureParser}
|
||||
*/
|
||||
ol.parser.DomFeatureParser = function() {};
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ goog.provide('ol.source.Vector');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.net.XhrIo');
|
||||
goog.require('ol.proj');
|
||||
goog.require('ol.source.Source');
|
||||
|
||||
|
||||
@@ -39,7 +38,7 @@ ol.source.Vector = function(options) {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.parser.Parser}
|
||||
* @type {ol.parser.FeatureParser}
|
||||
*/
|
||||
this.parser_ = goog.isDef(options.parser) ? options.parser : null;
|
||||
|
||||
@@ -53,8 +52,7 @@ ol.source.Vector = function(options) {
|
||||
attributions: options.attributions,
|
||||
extent: options.extent,
|
||||
logo: options.logo,
|
||||
projection: goog.isDef(options.projection) ?
|
||||
options.projection : ol.proj.get('EPSG:4326')
|
||||
projection: options.projection
|
||||
});
|
||||
};
|
||||
goog.inherits(ol.source.Vector, ol.source.Source);
|
||||
|
||||
Reference in New Issue
Block a user