Merge pull request #4677 from ahocevar/pixel-proj

Make pixel projection handling work in compiled mode
This commit is contained in:
Andreas Hocevar
2016-01-15 22:06:42 +01:00
2 changed files with 15 additions and 13 deletions
+14 -13
View File
@@ -104,18 +104,9 @@ ol.featureloader.loadFeaturesXhr = function(url, format, success, failure) {
goog.asserts.fail('unexpected format type'); goog.asserts.fail('unexpected format type');
} }
if (source) { if (source) {
if (ol.ENABLE_VECTOR_TILE && this instanceof ol.VectorTile) {
var dataUnits = format.readProjection(source).getUnits();
if (dataUnits === ol.proj.Units.TILE_PIXELS) {
projection = new ol.proj.Projection({
code: this.getProjection().getCode(),
units: dataUnits
});
this.setProjection(projection);
}
}
success.call(this, format.readFeatures(source, success.call(this, format.readFeatures(source,
{featureProjection: projection})); {featureProjection: projection}),
format.readProjection(source));
} else { } else {
goog.asserts.fail('undefined or null source'); goog.asserts.fail('undefined or null source');
} }
@@ -147,9 +138,18 @@ ol.featureloader.tile = function(url, format) {
return ol.featureloader.loadFeaturesXhr(url, format, return ol.featureloader.loadFeaturesXhr(url, format,
/** /**
* @param {Array.<ol.Feature>} features The loaded features. * @param {Array.<ol.Feature>} features The loaded features.
* @param {ol.proj.Projection} dataProjection Data projection.
* @this {ol.VectorTile} * @this {ol.VectorTile}
*/ */
function(features) { function(features, dataProjection) {
var dataUnits = dataProjection.getUnits();
if (dataUnits === ol.proj.Units.TILE_PIXELS) {
var projection = new ol.proj.Projection({
code: this.getProjection().getCode(),
units: dataUnits
});
this.setProjection(projection);
}
this.setFeatures(features); this.setFeatures(features);
}, },
/** /**
@@ -174,9 +174,10 @@ ol.featureloader.xhr = function(url, format) {
return ol.featureloader.loadFeaturesXhr(url, format, return ol.featureloader.loadFeaturesXhr(url, format,
/** /**
* @param {Array.<ol.Feature>} features The loaded features. * @param {Array.<ol.Feature>} features The loaded features.
* @param {ol.proj.Projection} dataProjection Data projection.
* @this {ol.source.Vector} * @this {ol.source.Vector}
*/ */
function(features) { function(features, dataProjection) {
this.addFeatures(features); this.addFeatures(features);
}, /* FIXME handle error */ ol.nullFunction); }, /* FIXME handle error */ ol.nullFunction);
}; };
+1
View File
@@ -161,6 +161,7 @@ ol.VectorTile.prototype.load = function() {
/** /**
* @param {Array.<ol.Feature>} features Features. * @param {Array.<ol.Feature>} features Features.
* @api
*/ */
ol.VectorTile.prototype.setFeatures = function(features) { ol.VectorTile.prototype.setFeatures = function(features) {
this.features_ = features; this.features_ = features;