Skip to content

Commit

Permalink
Add projection argument when loading features
Browse files Browse the repository at this point in the history
  • Loading branch information
twpayne committed Mar 12, 2014
1 parent eec1727 commit 52523fc
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/objectliterals.jsdoc
Expand Up @@ -892,7 +892,7 @@
* @typedef {Object} olx.source.RemoteVectorOptions
* @property {Array.<ol.Attribution>|undefined} attributions Attributions.
* @property {ol.Extent|undefined} extent Extent.
* @property {function(ol.Extent, number): string} extentUrlFunction Extent URL function.
* @property {function(ol.Extent, number, ol.proj.Projection): string} extentUrlFunction Extent URL function.
* @property {Object.<string, string>|undefined} headers Headers.
* @property {ol.format.Feature} format Format.
* @property {function(ol.Extent, number): Array.<ol.Extent>} loadingFunction Loading function.
Expand Down
17 changes: 9 additions & 8 deletions src/ol/renderer/canvas/canvasvectorlayerrenderer.js
Expand Up @@ -213,12 +213,14 @@ ol.renderer.canvas.VectorLayer.prototype.prepareFrame =
}

var frameStateExtent = frameState.extent;
var frameStateResolution = frameState.view2DState.resolution;
var view2DState = frameState.view2DState;
var projection = view2DState.projection;
var resolution = view2DState.resolution;
var pixelRatio = frameState.pixelRatio;
var vectorLayerRevision = vectorLayer.getRevision();

if (!this.dirty_ &&
this.renderedResolution_ == frameStateResolution &&
this.renderedResolution_ == resolution &&
this.renderedRevision_ == vectorLayerRevision &&
ol.extent.containsExtent(this.renderedExtent_, frameStateExtent)) {
return;
Expand All @@ -242,22 +244,21 @@ ol.renderer.canvas.VectorLayer.prototype.prepareFrame =
if (!goog.isDef(styleFunction)) {
styleFunction = ol.feature.defaultStyleFunction;
}
var tolerance = frameStateResolution / (2 * pixelRatio);
var tolerance = resolution / (2 * pixelRatio);
var replayGroup = new ol.render.canvas.ReplayGroup(tolerance, extent);
vectorSource.loadFeatures(extent, frameStateResolution);
vectorSource.loadFeatures(extent, resolution, projection);
vectorSource.forEachFeatureInExtent(extent,
/**
* @param {ol.Feature} feature Feature.
*/
function(feature) {
var dirty =
this.renderFeature(feature, frameStateResolution, pixelRatio,
styleFunction, replayGroup);
var dirty = this.renderFeature(
feature, resolution, pixelRatio, styleFunction, replayGroup);
this.dirty_ = this.dirty_ || dirty;
}, this);
replayGroup.finish();

this.renderedResolution_ = frameStateResolution;
this.renderedResolution_ = resolution;
this.renderedRevision_ = vectorLayerRevision;
this.replayGroup_ = replayGroup;

Expand Down
7 changes: 4 additions & 3 deletions src/ol/source/remotevectorsource.js
Expand Up @@ -38,7 +38,7 @@ ol.source.RemoteVector = function(options) {

/**
* @private
* @type {function(ol.Extent, number): string}
* @type {function(ol.Extent, number, ol.proj.Projection): string}
*/
this.extentUrlFunction_ = options.extentUrlFunction;

Expand Down Expand Up @@ -74,7 +74,8 @@ ol.source.RemoteVector.prototype.addFeaturesInternal = function(features) {
/**
* @inheritDoc
*/
ol.source.RemoteVector.prototype.loadFeatures = function(extent, resolution) {
ol.source.RemoteVector.prototype.loadFeatures =
function(extent, resolution, projection) {
var loadedExtents = this.loadedExtents_;
var extentsToLoad = this.loadingFunction_(extent, resolution);
var i, ii;
Expand All @@ -89,7 +90,7 @@ ol.source.RemoteVector.prototype.loadFeatures = function(extent, resolution) {
return ol.extent.containsExtent(object.extent, extentToLoad);
});
if (!alreadyLoaded) {
var url = this.extentUrlFunction_(extentToLoad, resolution);
var url = this.extentUrlFunction_(extentToLoad, resolution, projection);
this.loadFeaturesFromURL(url);
loadedExtents.insert(extentToLoad, {extent: extentToLoad.slice()});
}
Expand Down
2 changes: 2 additions & 0 deletions src/ol/source/vectorsource.js
Expand Up @@ -13,6 +13,7 @@ goog.require('goog.events.Event');
goog.require('goog.events.EventType');
goog.require('goog.object');
goog.require('ol.ObjectEventType');
goog.require('ol.proj');
goog.require('ol.source.Source');
goog.require('ol.structs.RBush');

Expand Down Expand Up @@ -329,6 +330,7 @@ ol.source.Vector.prototype.isEmpty = function() {
/**
* @param {ol.Extent} extent Extent.
* @param {number} resolution Resolution.
* @param {ol.proj.Projection} projection Projection.
*/
ol.source.Vector.prototype.loadFeatures = goog.nullFunction;

Expand Down

0 comments on commit 52523fc

Please sign in to comment.