Use class method syntax instead of .prototype.method = function
This commit is contained in:
+38
-41
@@ -76,16 +76,13 @@ export class CustomTile extends Tile {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the image element for this tile.
|
* Get the image element for this tile.
|
||||||
* @return {HTMLImageElement} Image.
|
* @return {HTMLImageElement} Image.
|
||||||
*/
|
*/
|
||||||
CustomTile.prototype.getImage = function() {
|
getImage() {
|
||||||
return null;
|
return null;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -93,7 +90,7 @@ CustomTile.prototype.getImage = function() {
|
|||||||
* @param {module:ol/coordinate~Coordinate} coordinate Coordinate.
|
* @param {module:ol/coordinate~Coordinate} coordinate Coordinate.
|
||||||
* @return {*} The data.
|
* @return {*} The data.
|
||||||
*/
|
*/
|
||||||
CustomTile.prototype.getData = function(coordinate) {
|
getData(coordinate) {
|
||||||
if (!this.grid_ || !this.keys_) {
|
if (!this.grid_ || !this.keys_) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -127,7 +124,7 @@ CustomTile.prototype.getData = function(coordinate) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -140,7 +137,7 @@ CustomTile.prototype.getData = function(coordinate) {
|
|||||||
* The tile data is requested if not yet loaded.
|
* The tile data is requested if not yet loaded.
|
||||||
* @template T
|
* @template T
|
||||||
*/
|
*/
|
||||||
CustomTile.prototype.forDataAtCoordinate = function(coordinate, callback, opt_this, opt_request) {
|
forDataAtCoordinate(coordinate, callback, opt_this, opt_request) {
|
||||||
if (this.state == TileState.IDLE && opt_request === true) {
|
if (this.state == TileState.IDLE && opt_request === true) {
|
||||||
listenOnce(this, EventType.CHANGE, function(e) {
|
listenOnce(this, EventType.CHANGE, function(e) {
|
||||||
callback.call(opt_this, this.getData(coordinate));
|
callback.call(opt_this, this.getData(coordinate));
|
||||||
@@ -155,44 +152,44 @@ CustomTile.prototype.forDataAtCoordinate = function(coordinate, callback, opt_th
|
|||||||
callback.call(opt_this, this.getData(coordinate));
|
callback.call(opt_this, this.getData(coordinate));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
CustomTile.prototype.getKey = function() {
|
getKey() {
|
||||||
return this.src_;
|
return this.src_;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
CustomTile.prototype.handleError_ = function() {
|
handleError_() {
|
||||||
this.state = TileState.ERROR;
|
this.state = TileState.ERROR;
|
||||||
this.changed();
|
this.changed();
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {!UTFGridJSON} json UTFGrid data.
|
* @param {!UTFGridJSON} json UTFGrid data.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
CustomTile.prototype.handleLoad_ = function(json) {
|
handleLoad_(json) {
|
||||||
this.grid_ = json.grid;
|
this.grid_ = json.grid;
|
||||||
this.keys_ = json.keys;
|
this.keys_ = json.keys;
|
||||||
this.data_ = json.data;
|
this.data_ = json.data;
|
||||||
|
|
||||||
this.state = TileState.EMPTY;
|
this.state = TileState.EMPTY;
|
||||||
this.changed();
|
this.changed();
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
CustomTile.prototype.loadInternal_ = function() {
|
loadInternal_() {
|
||||||
if (this.state == TileState.IDLE) {
|
if (this.state == TileState.IDLE) {
|
||||||
this.state = TileState.LOADING;
|
this.state = TileState.LOADING;
|
||||||
if (this.jsonp_) {
|
if (this.jsonp_) {
|
||||||
@@ -206,14 +203,14 @@ CustomTile.prototype.loadInternal_ = function() {
|
|||||||
client.send();
|
client.send();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @param {Event} event The load event.
|
* @param {Event} event The load event.
|
||||||
*/
|
*/
|
||||||
CustomTile.prototype.onXHRLoad_ = function(event) {
|
onXHRLoad_(event) {
|
||||||
const client = /** @type {XMLHttpRequest} */ (event.target);
|
const client = /** @type {XMLHttpRequest} */ (event.target);
|
||||||
// status will be 0 for file:// urls
|
// status will be 0 for file:// urls
|
||||||
if (!client.status || client.status >= 200 && client.status < 300) {
|
if (!client.status || client.status >= 200 && client.status < 300) {
|
||||||
@@ -228,26 +225,27 @@ CustomTile.prototype.onXHRLoad_ = function(event) {
|
|||||||
} else {
|
} else {
|
||||||
this.handleError_();
|
this.handleError_();
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @param {Event} event The error event.
|
* @param {Event} event The error event.
|
||||||
*/
|
*/
|
||||||
CustomTile.prototype.onXHRError_ = function(event) {
|
onXHRError_(event) {
|
||||||
this.handleError_();
|
this.handleError_();
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @override
|
* @override
|
||||||
*/
|
*/
|
||||||
CustomTile.prototype.load = function() {
|
load() {
|
||||||
if (this.preemptive_) {
|
if (this.preemptive_) {
|
||||||
this.loadInternal_();
|
this.loadInternal_();
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -326,14 +324,12 @@ class UTFGrid extends TileSource {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @param {Event} event The load event.
|
* @param {Event} event The load event.
|
||||||
*/
|
*/
|
||||||
UTFGrid.prototype.onXHRLoad_ = function(event) {
|
onXHRLoad_(event) {
|
||||||
const client = /** @type {XMLHttpRequest} */ (event.target);
|
const client = /** @type {XMLHttpRequest} */ (event.target);
|
||||||
// status will be 0 for file:// urls
|
// status will be 0 for file:// urls
|
||||||
if (!client.status || client.status >= 200 && client.status < 300) {
|
if (!client.status || client.status >= 200 && client.status < 300) {
|
||||||
@@ -348,16 +344,16 @@ UTFGrid.prototype.onXHRLoad_ = function(event) {
|
|||||||
} else {
|
} else {
|
||||||
this.handleTileJSONError();
|
this.handleTileJSONError();
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @param {Event} event The error event.
|
* @param {Event} event The error event.
|
||||||
*/
|
*/
|
||||||
UTFGrid.prototype.onXHRError_ = function(event) {
|
onXHRError_(event) {
|
||||||
this.handleTileJSONError();
|
this.handleTileJSONError();
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -365,9 +361,9 @@ UTFGrid.prototype.onXHRError_ = function(event) {
|
|||||||
* @return {string|undefined} The template from TileJSON.
|
* @return {string|undefined} The template from TileJSON.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
UTFGrid.prototype.getTemplate = function() {
|
getTemplate() {
|
||||||
return this.template_;
|
return this.template_;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -381,7 +377,7 @@ UTFGrid.prototype.getTemplate = function() {
|
|||||||
* The tile data is requested if not yet loaded.
|
* The tile data is requested if not yet loaded.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
UTFGrid.prototype.forDataAtCoordinateAndResolution = function(
|
forDataAtCoordinateAndResolution(
|
||||||
coordinate, resolution, callback, opt_request) {
|
coordinate, resolution, callback, opt_request) {
|
||||||
if (this.tileGrid) {
|
if (this.tileGrid) {
|
||||||
const tileCoord = this.tileGrid.getTileCoordForCoordAndResolution(
|
const tileCoord = this.tileGrid.getTileCoordForCoordAndResolution(
|
||||||
@@ -398,15 +394,15 @@ UTFGrid.prototype.forDataAtCoordinateAndResolution = function(
|
|||||||
callback(null);
|
callback(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
UTFGrid.prototype.handleTileJSONError = function() {
|
handleTileJSONError() {
|
||||||
this.setState(SourceState.ERROR);
|
this.setState(SourceState.ERROR);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -414,7 +410,7 @@ UTFGrid.prototype.handleTileJSONError = function() {
|
|||||||
* @protected
|
* @protected
|
||||||
* @param {TileJSON} tileJSON Tile JSON.
|
* @param {TileJSON} tileJSON Tile JSON.
|
||||||
*/
|
*/
|
||||||
UTFGrid.prototype.handleTileJSONResponse = function(tileJSON) {
|
handleTileJSONResponse(tileJSON) {
|
||||||
|
|
||||||
const epsg4326Projection = getProjection('EPSG:4326');
|
const epsg4326Projection = getProjection('EPSG:4326');
|
||||||
|
|
||||||
@@ -459,13 +455,13 @@ UTFGrid.prototype.handleTileJSONResponse = function(tileJSON) {
|
|||||||
|
|
||||||
this.setState(SourceState.READY);
|
this.setState(SourceState.READY);
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
UTFGrid.prototype.getTile = function(z, x, y, pixelRatio, projection) {
|
getTile(z, x, y, pixelRatio, projection) {
|
||||||
const tileCoordKey = getKeyZXY(z, x, y);
|
const tileCoordKey = getKeyZXY(z, x, y);
|
||||||
if (this.tileCache.containsKey(tileCoordKey)) {
|
if (this.tileCache.containsKey(tileCoordKey)) {
|
||||||
return (
|
return (
|
||||||
@@ -486,18 +482,19 @@ UTFGrid.prototype.getTile = function(z, x, y, pixelRatio, projection) {
|
|||||||
this.tileCache.set(tileCoordKey, tile);
|
this.tileCache.set(tileCoordKey, tile);
|
||||||
return tile;
|
return tile;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
UTFGrid.prototype.useTile = function(z, x, y) {
|
useTile(z, x, y) {
|
||||||
const tileCoordKey = getKeyZXY(z, x, y);
|
const tileCoordKey = getKeyZXY(z, x, y);
|
||||||
if (this.tileCache.containsKey(tileCoordKey)) {
|
if (this.tileCache.containsKey(tileCoordKey)) {
|
||||||
this.tileCache.get(tileCoordKey);
|
this.tileCache.get(tileCoordKey);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export default UTFGrid;
|
export default UTFGrid;
|
||||||
|
|||||||
+66
-66
@@ -276,9 +276,6 @@ class VectorSource extends Source {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a single feature to the source. If you want to add a batch of features
|
* Add a single feature to the source. If you want to add a batch of features
|
||||||
* at once, call {@link module:ol/source/Vector~VectorSource#addFeatures #addFeatures()}
|
* at once, call {@link module:ol/source/Vector~VectorSource#addFeatures #addFeatures()}
|
||||||
@@ -288,10 +285,10 @@ class VectorSource extends Source {
|
|||||||
* @param {module:ol/Feature} feature Feature to add.
|
* @param {module:ol/Feature} feature Feature to add.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
VectorSource.prototype.addFeature = function(feature) {
|
addFeature(feature) {
|
||||||
this.addFeatureInternal(feature);
|
this.addFeatureInternal(feature);
|
||||||
this.changed();
|
this.changed();
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -299,7 +296,7 @@ VectorSource.prototype.addFeature = function(feature) {
|
|||||||
* @param {module:ol/Feature} feature Feature.
|
* @param {module:ol/Feature} feature Feature.
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
VectorSource.prototype.addFeatureInternal = function(feature) {
|
addFeatureInternal(feature) {
|
||||||
const featureKey = getUid(feature).toString();
|
const featureKey = getUid(feature).toString();
|
||||||
|
|
||||||
if (!this.addToIndex_(featureKey, feature)) {
|
if (!this.addToIndex_(featureKey, feature)) {
|
||||||
@@ -320,7 +317,7 @@ VectorSource.prototype.addFeatureInternal = function(feature) {
|
|||||||
|
|
||||||
this.dispatchEvent(
|
this.dispatchEvent(
|
||||||
new VectorSourceEvent(VectorEventType.ADDFEATURE, feature));
|
new VectorSourceEvent(VectorEventType.ADDFEATURE, feature));
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -328,14 +325,14 @@ VectorSource.prototype.addFeatureInternal = function(feature) {
|
|||||||
* @param {module:ol/Feature} feature The feature.
|
* @param {module:ol/Feature} feature The feature.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
VectorSource.prototype.setupChangeEvents_ = function(featureKey, feature) {
|
setupChangeEvents_(featureKey, feature) {
|
||||||
this.featureChangeKeys_[featureKey] = [
|
this.featureChangeKeys_[featureKey] = [
|
||||||
listen(feature, EventType.CHANGE,
|
listen(feature, EventType.CHANGE,
|
||||||
this.handleFeatureChange_, this),
|
this.handleFeatureChange_, this),
|
||||||
listen(feature, ObjectEventType.PROPERTYCHANGE,
|
listen(feature, ObjectEventType.PROPERTYCHANGE,
|
||||||
this.handleFeatureChange_, this)
|
this.handleFeatureChange_, this)
|
||||||
];
|
];
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -345,7 +342,7 @@ VectorSource.prototype.setupChangeEvents_ = function(featureKey, feature) {
|
|||||||
* candidate for insertion into the Rtree.
|
* candidate for insertion into the Rtree.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
VectorSource.prototype.addToIndex_ = function(featureKey, feature) {
|
addToIndex_(featureKey, feature) {
|
||||||
let valid = true;
|
let valid = true;
|
||||||
const id = feature.getId();
|
const id = feature.getId();
|
||||||
if (id !== undefined) {
|
if (id !== undefined) {
|
||||||
@@ -360,7 +357,7 @@ VectorSource.prototype.addToIndex_ = function(featureKey, feature) {
|
|||||||
this.undefIdIndex_[featureKey] = feature;
|
this.undefIdIndex_[featureKey] = feature;
|
||||||
}
|
}
|
||||||
return valid;
|
return valid;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -368,10 +365,10 @@ VectorSource.prototype.addToIndex_ = function(featureKey, feature) {
|
|||||||
* @param {Array<module:ol/Feature>} features Features to add.
|
* @param {Array<module:ol/Feature>} features Features to add.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
VectorSource.prototype.addFeatures = function(features) {
|
addFeatures(features) {
|
||||||
this.addFeaturesInternal(features);
|
this.addFeaturesInternal(features);
|
||||||
this.changed();
|
this.changed();
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -379,7 +376,7 @@ VectorSource.prototype.addFeatures = function(features) {
|
|||||||
* @param {Array<module:ol/Feature>} features Features.
|
* @param {Array<module:ol/Feature>} features Features.
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
VectorSource.prototype.addFeaturesInternal = function(features) {
|
addFeaturesInternal(features) {
|
||||||
const extents = [];
|
const extents = [];
|
||||||
const newFeatures = [];
|
const newFeatures = [];
|
||||||
const geometryFeatures = [];
|
const geometryFeatures = [];
|
||||||
@@ -413,14 +410,14 @@ VectorSource.prototype.addFeaturesInternal = function(features) {
|
|||||||
for (let i = 0, length = newFeatures.length; i < length; i++) {
|
for (let i = 0, length = newFeatures.length; i < length; i++) {
|
||||||
this.dispatchEvent(new VectorSourceEvent(VectorEventType.ADDFEATURE, newFeatures[i]));
|
this.dispatchEvent(new VectorSourceEvent(VectorEventType.ADDFEATURE, newFeatures[i]));
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {!module:ol/Collection<module:ol/Feature>} collection Collection.
|
* @param {!module:ol/Collection<module:ol/Feature>} collection Collection.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
VectorSource.prototype.bindFeaturesCollection_ = function(collection) {
|
bindFeaturesCollection_(collection) {
|
||||||
let modifyingCollection = false;
|
let modifyingCollection = false;
|
||||||
listen(this, VectorEventType.ADDFEATURE,
|
listen(this, VectorEventType.ADDFEATURE,
|
||||||
function(evt) {
|
function(evt) {
|
||||||
@@ -455,7 +452,7 @@ VectorSource.prototype.bindFeaturesCollection_ = function(collection) {
|
|||||||
}
|
}
|
||||||
}, this);
|
}, this);
|
||||||
this.featuresCollection_ = collection;
|
this.featuresCollection_ = collection;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -463,7 +460,7 @@ VectorSource.prototype.bindFeaturesCollection_ = function(collection) {
|
|||||||
* @param {boolean=} opt_fast Skip dispatching of {@link module:ol/source/Vector~VectorSourceEvent#removefeature} events.
|
* @param {boolean=} opt_fast Skip dispatching of {@link module:ol/source/Vector~VectorSourceEvent#removefeature} events.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
VectorSource.prototype.clear = function(opt_fast) {
|
clear(opt_fast) {
|
||||||
if (opt_fast) {
|
if (opt_fast) {
|
||||||
for (const featureId in this.featureChangeKeys_) {
|
for (const featureId in this.featureChangeKeys_) {
|
||||||
const keys = this.featureChangeKeys_[featureId];
|
const keys = this.featureChangeKeys_[featureId];
|
||||||
@@ -495,7 +492,7 @@ VectorSource.prototype.clear = function(opt_fast) {
|
|||||||
const clearEvent = new VectorSourceEvent(VectorEventType.CLEAR);
|
const clearEvent = new VectorSourceEvent(VectorEventType.CLEAR);
|
||||||
this.dispatchEvent(clearEvent);
|
this.dispatchEvent(clearEvent);
|
||||||
this.changed();
|
this.changed();
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -510,13 +507,13 @@ VectorSource.prototype.clear = function(opt_fast) {
|
|||||||
* @template T
|
* @template T
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
VectorSource.prototype.forEachFeature = function(callback) {
|
forEachFeature(callback) {
|
||||||
if (this.featuresRtree_) {
|
if (this.featuresRtree_) {
|
||||||
return this.featuresRtree_.forEach(callback);
|
return this.featuresRtree_.forEach(callback);
|
||||||
} else if (this.featuresCollection_) {
|
} else if (this.featuresCollection_) {
|
||||||
return this.featuresCollection_.forEach(callback);
|
return this.featuresCollection_.forEach(callback);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -531,7 +528,7 @@ VectorSource.prototype.forEachFeature = function(callback) {
|
|||||||
* @return {T|undefined} The return value from the last call to the callback.
|
* @return {T|undefined} The return value from the last call to the callback.
|
||||||
* @template T
|
* @template T
|
||||||
*/
|
*/
|
||||||
VectorSource.prototype.forEachFeatureAtCoordinateDirect = function(coordinate, callback) {
|
forEachFeatureAtCoordinateDirect(coordinate, callback) {
|
||||||
const extent = [coordinate[0], coordinate[1], coordinate[0], coordinate[1]];
|
const extent = [coordinate[0], coordinate[1], coordinate[0], coordinate[1]];
|
||||||
return this.forEachFeatureInExtent(extent, function(feature) {
|
return this.forEachFeatureInExtent(extent, function(feature) {
|
||||||
const geometry = feature.getGeometry();
|
const geometry = feature.getGeometry();
|
||||||
@@ -541,7 +538,7 @@ VectorSource.prototype.forEachFeatureAtCoordinateDirect = function(coordinate, c
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -563,13 +560,13 @@ VectorSource.prototype.forEachFeatureAtCoordinateDirect = function(coordinate, c
|
|||||||
* @template T
|
* @template T
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
VectorSource.prototype.forEachFeatureInExtent = function(extent, callback) {
|
forEachFeatureInExtent(extent, callback) {
|
||||||
if (this.featuresRtree_) {
|
if (this.featuresRtree_) {
|
||||||
return this.featuresRtree_.forEachInExtent(extent, callback);
|
return this.featuresRtree_.forEachInExtent(extent, callback);
|
||||||
} else if (this.featuresCollection_) {
|
} else if (this.featuresCollection_) {
|
||||||
return this.featuresCollection_.forEach(callback);
|
return this.featuresCollection_.forEach(callback);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -587,7 +584,7 @@ VectorSource.prototype.forEachFeatureInExtent = function(extent, callback) {
|
|||||||
* @template T
|
* @template T
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
VectorSource.prototype.forEachFeatureIntersectingExtent = function(extent, callback) {
|
forEachFeatureIntersectingExtent(extent, callback) {
|
||||||
return this.forEachFeatureInExtent(extent,
|
return this.forEachFeatureInExtent(extent,
|
||||||
/**
|
/**
|
||||||
* @param {module:ol/Feature} feature Feature.
|
* @param {module:ol/Feature} feature Feature.
|
||||||
@@ -603,7 +600,7 @@ VectorSource.prototype.forEachFeatureIntersectingExtent = function(extent, callb
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -613,9 +610,9 @@ VectorSource.prototype.forEachFeatureIntersectingExtent = function(extent, callb
|
|||||||
* @return {module:ol/Collection<module:ol/Feature>} The collection of features.
|
* @return {module:ol/Collection<module:ol/Feature>} The collection of features.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
VectorSource.prototype.getFeaturesCollection = function() {
|
getFeaturesCollection() {
|
||||||
return this.featuresCollection_;
|
return this.featuresCollection_;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -623,7 +620,7 @@ VectorSource.prototype.getFeaturesCollection = function() {
|
|||||||
* @return {Array<module:ol/Feature>} Features.
|
* @return {Array<module:ol/Feature>} Features.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
VectorSource.prototype.getFeatures = function() {
|
getFeatures() {
|
||||||
let features;
|
let features;
|
||||||
if (this.featuresCollection_) {
|
if (this.featuresCollection_) {
|
||||||
features = this.featuresCollection_.getArray();
|
features = this.featuresCollection_.getArray();
|
||||||
@@ -636,7 +633,7 @@ VectorSource.prototype.getFeatures = function() {
|
|||||||
return (
|
return (
|
||||||
/** @type {Array<module:ol/Feature>} */ (features)
|
/** @type {Array<module:ol/Feature>} */ (features)
|
||||||
);
|
);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -645,13 +642,13 @@ VectorSource.prototype.getFeatures = function() {
|
|||||||
* @return {Array<module:ol/Feature>} Features.
|
* @return {Array<module:ol/Feature>} Features.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
VectorSource.prototype.getFeaturesAtCoordinate = function(coordinate) {
|
getFeaturesAtCoordinate(coordinate) {
|
||||||
const features = [];
|
const features = [];
|
||||||
this.forEachFeatureAtCoordinateDirect(coordinate, function(feature) {
|
this.forEachFeatureAtCoordinateDirect(coordinate, function(feature) {
|
||||||
features.push(feature);
|
features.push(feature);
|
||||||
});
|
});
|
||||||
return features;
|
return features;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -665,9 +662,9 @@ VectorSource.prototype.getFeaturesAtCoordinate = function(coordinate) {
|
|||||||
* @return {Array<module:ol/Feature>} Features.
|
* @return {Array<module:ol/Feature>} Features.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
VectorSource.prototype.getFeaturesInExtent = function(extent) {
|
getFeaturesInExtent(extent) {
|
||||||
return this.featuresRtree_.getInExtent(extent);
|
return this.featuresRtree_.getInExtent(extent);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -682,7 +679,7 @@ VectorSource.prototype.getFeaturesInExtent = function(extent) {
|
|||||||
* @return {module:ol/Feature} Closest feature.
|
* @return {module:ol/Feature} Closest feature.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
VectorSource.prototype.getClosestFeatureToCoordinate = function(coordinate, opt_filter) {
|
getClosestFeatureToCoordinate(coordinate, opt_filter) {
|
||||||
// Find the closest feature using branch and bound. We start searching an
|
// Find the closest feature using branch and bound. We start searching an
|
||||||
// infinite extent, and find the distance from the first feature found. This
|
// infinite extent, and find the distance from the first feature found. This
|
||||||
// becomes the closest feature. We then compute a smaller extent which any
|
// becomes the closest feature. We then compute a smaller extent which any
|
||||||
@@ -722,7 +719,7 @@ VectorSource.prototype.getClosestFeatureToCoordinate = function(coordinate, opt_
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
return closestFeature;
|
return closestFeature;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -735,9 +732,9 @@ VectorSource.prototype.getClosestFeatureToCoordinate = function(coordinate, opt_
|
|||||||
* @return {module:ol/extent~Extent} Extent.
|
* @return {module:ol/extent~Extent} Extent.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
VectorSource.prototype.getExtent = function(opt_extent) {
|
getExtent(opt_extent) {
|
||||||
return this.featuresRtree_.getExtent(opt_extent);
|
return this.featuresRtree_.getExtent(opt_extent);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -749,10 +746,10 @@ VectorSource.prototype.getExtent = function(opt_extent) {
|
|||||||
* @return {module:ol/Feature} The feature (or `null` if not found).
|
* @return {module:ol/Feature} The feature (or `null` if not found).
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
VectorSource.prototype.getFeatureById = function(id) {
|
getFeatureById(id) {
|
||||||
const feature = this.idIndex_[id.toString()];
|
const feature = this.idIndex_[id.toString()];
|
||||||
return feature !== undefined ? feature : null;
|
return feature !== undefined ? feature : null;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -761,23 +758,23 @@ VectorSource.prototype.getFeatureById = function(id) {
|
|||||||
* @return {module:ol/format/Feature|undefined} The feature format.
|
* @return {module:ol/format/Feature|undefined} The feature format.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
VectorSource.prototype.getFormat = function() {
|
getFormat() {
|
||||||
return this.format_;
|
return this.format_;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {boolean} The source can have overlapping geometries.
|
* @return {boolean} The source can have overlapping geometries.
|
||||||
*/
|
*/
|
||||||
VectorSource.prototype.getOverlaps = function() {
|
getOverlaps() {
|
||||||
return this.overlaps_;
|
return this.overlaps_;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @override
|
* @override
|
||||||
*/
|
*/
|
||||||
VectorSource.prototype.getResolutions = function() {};
|
getResolutions() {}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -786,16 +783,16 @@ VectorSource.prototype.getResolutions = function() {};
|
|||||||
* @return {string|module:ol/featureloader~FeatureUrlFunction|undefined} The url.
|
* @return {string|module:ol/featureloader~FeatureUrlFunction|undefined} The url.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
VectorSource.prototype.getUrl = function() {
|
getUrl() {
|
||||||
return this.url_;
|
return this.url_;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {module:ol/events/Event} event Event.
|
* @param {module:ol/events/Event} event Event.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
VectorSource.prototype.handleFeatureChange_ = function(event) {
|
handleFeatureChange_(event) {
|
||||||
const feature = /** @type {module:ol/Feature} */ (event.target);
|
const feature = /** @type {module:ol/Feature} */ (event.target);
|
||||||
const featureKey = getUid(feature).toString();
|
const featureKey = getUid(feature).toString();
|
||||||
const geometry = feature.getGeometry();
|
const geometry = feature.getGeometry();
|
||||||
@@ -840,7 +837,7 @@ VectorSource.prototype.handleFeatureChange_ = function(event) {
|
|||||||
this.changed();
|
this.changed();
|
||||||
this.dispatchEvent(new VectorSourceEvent(
|
this.dispatchEvent(new VectorSourceEvent(
|
||||||
VectorEventType.CHANGEFEATURE, feature));
|
VectorEventType.CHANGEFEATURE, feature));
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the feature is contained within the source.
|
* Returns true if the feature is contained within the source.
|
||||||
@@ -848,7 +845,7 @@ VectorSource.prototype.handleFeatureChange_ = function(event) {
|
|||||||
* @return {boolean} Has feature.
|
* @return {boolean} Has feature.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
VectorSource.prototype.hasFeature = function(feature) {
|
hasFeature(feature) {
|
||||||
const id = feature.getId();
|
const id = feature.getId();
|
||||||
if (id !== undefined) {
|
if (id !== undefined) {
|
||||||
return id in this.idIndex_;
|
return id in this.idIndex_;
|
||||||
@@ -856,14 +853,14 @@ VectorSource.prototype.hasFeature = function(feature) {
|
|||||||
const featureKey = getUid(feature).toString();
|
const featureKey = getUid(feature).toString();
|
||||||
return featureKey in this.undefIdIndex_;
|
return featureKey in this.undefIdIndex_;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {boolean} Is empty.
|
* @return {boolean} Is empty.
|
||||||
*/
|
*/
|
||||||
VectorSource.prototype.isEmpty = function() {
|
isEmpty() {
|
||||||
return this.featuresRtree_.isEmpty() && isEmpty(this.nullGeometryFeatures_);
|
return this.featuresRtree_.isEmpty() && isEmpty(this.nullGeometryFeatures_);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -871,7 +868,7 @@ VectorSource.prototype.isEmpty = function() {
|
|||||||
* @param {number} resolution Resolution.
|
* @param {number} resolution Resolution.
|
||||||
* @param {module:ol/proj/Projection} projection Projection.
|
* @param {module:ol/proj/Projection} projection Projection.
|
||||||
*/
|
*/
|
||||||
VectorSource.prototype.loadFeatures = function(extent, resolution, projection) {
|
loadFeatures(extent, resolution, projection) {
|
||||||
const loadedExtentsRtree = this.loadedExtentsRtree_;
|
const loadedExtentsRtree = this.loadedExtentsRtree_;
|
||||||
const extentsToLoad = this.strategy_(extent, resolution);
|
const extentsToLoad = this.strategy_(extent, resolution);
|
||||||
for (let i = 0, ii = extentsToLoad.length; i < ii; ++i) {
|
for (let i = 0, ii = extentsToLoad.length; i < ii; ++i) {
|
||||||
@@ -889,7 +886,7 @@ VectorSource.prototype.loadFeatures = function(extent, resolution, projection) {
|
|||||||
loadedExtentsRtree.insert(extentToLoad, {extent: extentToLoad.slice()});
|
loadedExtentsRtree.insert(extentToLoad, {extent: extentToLoad.slice()});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -897,7 +894,7 @@ VectorSource.prototype.loadFeatures = function(extent, resolution, projection) {
|
|||||||
* @param {module:ol/extent~Extent} extent Extent.
|
* @param {module:ol/extent~Extent} extent Extent.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
VectorSource.prototype.removeLoadedExtent = function(extent) {
|
removeLoadedExtent(extent) {
|
||||||
const loadedExtentsRtree = this.loadedExtentsRtree_;
|
const loadedExtentsRtree = this.loadedExtentsRtree_;
|
||||||
let obj;
|
let obj;
|
||||||
loadedExtentsRtree.forEachInExtent(extent, function(object) {
|
loadedExtentsRtree.forEachInExtent(extent, function(object) {
|
||||||
@@ -909,7 +906,7 @@ VectorSource.prototype.removeLoadedExtent = function(extent) {
|
|||||||
if (obj) {
|
if (obj) {
|
||||||
loadedExtentsRtree.remove(obj);
|
loadedExtentsRtree.remove(obj);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -919,7 +916,7 @@ VectorSource.prototype.removeLoadedExtent = function(extent) {
|
|||||||
* @param {module:ol/Feature} feature Feature to remove.
|
* @param {module:ol/Feature} feature Feature to remove.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
VectorSource.prototype.removeFeature = function(feature) {
|
removeFeature(feature) {
|
||||||
const featureKey = getUid(feature).toString();
|
const featureKey = getUid(feature).toString();
|
||||||
if (featureKey in this.nullGeometryFeatures_) {
|
if (featureKey in this.nullGeometryFeatures_) {
|
||||||
delete this.nullGeometryFeatures_[featureKey];
|
delete this.nullGeometryFeatures_[featureKey];
|
||||||
@@ -930,7 +927,7 @@ VectorSource.prototype.removeFeature = function(feature) {
|
|||||||
}
|
}
|
||||||
this.removeFeatureInternal(feature);
|
this.removeFeatureInternal(feature);
|
||||||
this.changed();
|
this.changed();
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -938,7 +935,7 @@ VectorSource.prototype.removeFeature = function(feature) {
|
|||||||
* @param {module:ol/Feature} feature Feature.
|
* @param {module:ol/Feature} feature Feature.
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
VectorSource.prototype.removeFeatureInternal = function(feature) {
|
removeFeatureInternal(feature) {
|
||||||
const featureKey = getUid(feature).toString();
|
const featureKey = getUid(feature).toString();
|
||||||
this.featureChangeKeys_[featureKey].forEach(unlistenByKey);
|
this.featureChangeKeys_[featureKey].forEach(unlistenByKey);
|
||||||
delete this.featureChangeKeys_[featureKey];
|
delete this.featureChangeKeys_[featureKey];
|
||||||
@@ -950,7 +947,7 @@ VectorSource.prototype.removeFeatureInternal = function(feature) {
|
|||||||
}
|
}
|
||||||
this.dispatchEvent(new VectorSourceEvent(
|
this.dispatchEvent(new VectorSourceEvent(
|
||||||
VectorEventType.REMOVEFEATURE, feature));
|
VectorEventType.REMOVEFEATURE, feature));
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -960,7 +957,7 @@ VectorSource.prototype.removeFeatureInternal = function(feature) {
|
|||||||
* @return {boolean} Removed the feature from the index.
|
* @return {boolean} Removed the feature from the index.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
VectorSource.prototype.removeFromIdIndex_ = function(feature) {
|
removeFromIdIndex_(feature) {
|
||||||
let removed = false;
|
let removed = false;
|
||||||
for (const id in this.idIndex_) {
|
for (const id in this.idIndex_) {
|
||||||
if (this.idIndex_[id] === feature) {
|
if (this.idIndex_[id] === feature) {
|
||||||
@@ -970,7 +967,7 @@ VectorSource.prototype.removeFromIdIndex_ = function(feature) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return removed;
|
return removed;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -979,8 +976,11 @@ VectorSource.prototype.removeFromIdIndex_ = function(feature) {
|
|||||||
* @param {module:ol/featureloader~FeatureLoader} loader The loader to set.
|
* @param {module:ol/featureloader~FeatureLoader} loader The loader to set.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
VectorSource.prototype.setLoader = function(loader) {
|
setLoader(loader) {
|
||||||
this.loader_ = loader;
|
this.loader_ = loader;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export default VectorSource;
|
export default VectorSource;
|
||||||
|
|||||||
+16
-16
@@ -41,7 +41,7 @@ import {createXYZ, extentFromProjection, createForProjection} from '../tilegrid.
|
|||||||
* }));
|
* }));
|
||||||
* // the line below is only required for ol/format/MVT
|
* // the line below is only required for ol/format/MVT
|
||||||
* tile.setExtent(format.getLastExtent());
|
* tile.setExtent(format.getLastExtent());
|
||||||
* };
|
* }
|
||||||
* });
|
* });
|
||||||
* ```
|
* ```
|
||||||
* @property {module:ol/Tile~UrlFunction} [tileUrlFunction] Optional function to get tile URL given a tile coordinate and the projection.
|
* @property {module:ol/Tile~UrlFunction} [tileUrlFunction] Optional function to get tile URL given a tile coordinate and the projection.
|
||||||
@@ -136,29 +136,26 @@ class VectorTile extends UrlTile {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {boolean} The source can have overlapping geometries.
|
* @return {boolean} The source can have overlapping geometries.
|
||||||
*/
|
*/
|
||||||
VectorTile.prototype.getOverlaps = function() {
|
getOverlaps() {
|
||||||
return this.overlaps_;
|
return this.overlaps_;
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* clear {@link module:ol/TileCache~TileCache} and delete all source tiles
|
* clear {@link module:ol/TileCache~TileCache} and delete all source tiles
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
VectorTile.prototype.clear = function() {
|
clear() {
|
||||||
this.tileCache.clear();
|
this.tileCache.clear();
|
||||||
this.sourceTiles_ = {};
|
this.sourceTiles_ = {};
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
VectorTile.prototype.getTile = function(z, x, y, pixelRatio, projection) {
|
getTile(z, x, y, pixelRatio, projection) {
|
||||||
const tileCoordKey = getKeyZXY(z, x, y);
|
const tileCoordKey = getKeyZXY(z, x, y);
|
||||||
if (this.tileCache.containsKey(tileCoordKey)) {
|
if (this.tileCache.containsKey(tileCoordKey)) {
|
||||||
return (
|
return (
|
||||||
@@ -180,13 +177,13 @@ VectorTile.prototype.getTile = function(z, x, y, pixelRatio, projection) {
|
|||||||
this.tileCache.set(tileCoordKey, tile);
|
this.tileCache.set(tileCoordKey, tile);
|
||||||
return tile;
|
return tile;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
VectorTile.prototype.getTileGridForProjection = function(projection) {
|
getTileGridForProjection(projection) {
|
||||||
const code = projection.getCode();
|
const code = projection.getCode();
|
||||||
let tileGrid = this.tileGrids_[code];
|
let tileGrid = this.tileGrids_[code];
|
||||||
if (!tileGrid) {
|
if (!tileGrid) {
|
||||||
@@ -197,23 +194,26 @@ VectorTile.prototype.getTileGridForProjection = function(projection) {
|
|||||||
sourceTileGrid ? sourceTileGrid.getTileSize(sourceTileGrid.getMinZoom()) : undefined);
|
sourceTileGrid ? sourceTileGrid.getTileSize(sourceTileGrid.getMinZoom()) : undefined);
|
||||||
}
|
}
|
||||||
return tileGrid;
|
return tileGrid;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
VectorTile.prototype.getTilePixelRatio = function(pixelRatio) {
|
getTilePixelRatio(pixelRatio) {
|
||||||
return pixelRatio;
|
return pixelRatio;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
VectorTile.prototype.getTilePixelSize = function(z, pixelRatio, projection) {
|
getTilePixelSize(z, pixelRatio, projection) {
|
||||||
const tileGrid = this.getTileGridForProjection(projection);
|
const tileGrid = this.getTileGridForProjection(projection);
|
||||||
const tileSize = toSize(tileGrid.getTileSize(z), this.tmpSize);
|
const tileSize = toSize(tileGrid.getTileSize(z), this.tmpSize);
|
||||||
return [Math.round(tileSize[0] * pixelRatio), Math.round(tileSize[1] * pixelRatio)];
|
return [Math.round(tileSize[0] * pixelRatio), Math.round(tileSize[1] * pixelRatio)];
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export default VectorTile;
|
export default VectorTile;
|
||||||
|
|||||||
+23
-25
@@ -151,20 +151,18 @@ class WMTS extends TileImage {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the URLs to use for requests.
|
* Set the URLs to use for requests.
|
||||||
* URLs may contain OCG conform URL Template Variables: {TileMatrix}, {TileRow}, {TileCol}.
|
* URLs may contain OCG conform URL Template Variables: {TileMatrix}, {TileRow}, {TileCol}.
|
||||||
* @override
|
* @override
|
||||||
*/
|
*/
|
||||||
WMTS.prototype.setUrls = function(urls) {
|
setUrls(urls) {
|
||||||
this.urls = urls;
|
this.urls = urls;
|
||||||
const key = urls.join('\n');
|
const key = urls.join('\n');
|
||||||
this.setTileUrlFunction(this.fixedTileUrlFunction ?
|
this.setTileUrlFunction(this.fixedTileUrlFunction ?
|
||||||
this.fixedTileUrlFunction.bind(this) :
|
this.fixedTileUrlFunction.bind(this) :
|
||||||
createFromTileUrlFunctions(urls.map(createFromWMTSTemplate.bind(this))), key);
|
createFromTileUrlFunctions(urls.map(createFromWMTSTemplate.bind(this))), key);
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the dimensions, i.e. those passed to the constructor through the
|
* Get the dimensions, i.e. those passed to the constructor through the
|
||||||
@@ -173,9 +171,9 @@ WMTS.prototype.setUrls = function(urls) {
|
|||||||
* @return {!Object} Dimensions.
|
* @return {!Object} Dimensions.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
WMTS.prototype.getDimensions = function() {
|
getDimensions() {
|
||||||
return this.dimensions_;
|
return this.dimensions_;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -183,9 +181,9 @@ WMTS.prototype.getDimensions = function() {
|
|||||||
* @return {string} Format.
|
* @return {string} Format.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
WMTS.prototype.getFormat = function() {
|
getFormat() {
|
||||||
return this.format_;
|
return this.format_;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -193,9 +191,9 @@ WMTS.prototype.getFormat = function() {
|
|||||||
* @return {string} Layer.
|
* @return {string} Layer.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
WMTS.prototype.getLayer = function() {
|
getLayer() {
|
||||||
return this.layer_;
|
return this.layer_;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -203,9 +201,9 @@ WMTS.prototype.getLayer = function() {
|
|||||||
* @return {string} MatrixSet.
|
* @return {string} MatrixSet.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
WMTS.prototype.getMatrixSet = function() {
|
getMatrixSet() {
|
||||||
return this.matrixSet_;
|
return this.matrixSet_;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -213,9 +211,9 @@ WMTS.prototype.getMatrixSet = function() {
|
|||||||
* @return {module:ol/source/WMTSRequestEncoding} Request encoding.
|
* @return {module:ol/source/WMTSRequestEncoding} Request encoding.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
WMTS.prototype.getRequestEncoding = function() {
|
getRequestEncoding() {
|
||||||
return this.requestEncoding_;
|
return this.requestEncoding_;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -223,9 +221,9 @@ WMTS.prototype.getRequestEncoding = function() {
|
|||||||
* @return {string} Style.
|
* @return {string} Style.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
WMTS.prototype.getStyle = function() {
|
getStyle() {
|
||||||
return this.style_;
|
return this.style_;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -233,23 +231,23 @@ WMTS.prototype.getStyle = function() {
|
|||||||
* @return {string} Version.
|
* @return {string} Version.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
WMTS.prototype.getVersion = function() {
|
getVersion() {
|
||||||
return this.version_;
|
return this.version_;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @return {string} The key for the current dimensions.
|
* @return {string} The key for the current dimensions.
|
||||||
*/
|
*/
|
||||||
WMTS.prototype.getKeyForDimensions_ = function() {
|
getKeyForDimensions_() {
|
||||||
let i = 0;
|
let i = 0;
|
||||||
const res = [];
|
const res = [];
|
||||||
for (const key in this.dimensions_) {
|
for (const key in this.dimensions_) {
|
||||||
res[i++] = key + '-' + this.dimensions_[key];
|
res[i++] = key + '-' + this.dimensions_[key];
|
||||||
}
|
}
|
||||||
return res.join('/');
|
return res.join('/');
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -257,11 +255,14 @@ WMTS.prototype.getKeyForDimensions_ = function() {
|
|||||||
* @param {Object} dimensions Dimensions.
|
* @param {Object} dimensions Dimensions.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
WMTS.prototype.updateDimensions = function(dimensions) {
|
updateDimensions(dimensions) {
|
||||||
assign(this.dimensions_, dimensions);
|
assign(this.dimensions_, dimensions);
|
||||||
this.setKey(this.getKeyForDimensions_());
|
this.setKey(this.getKeyForDimensions_());
|
||||||
};
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export default WMTS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate source options from a capabilities object.
|
* Generate source options from a capabilities object.
|
||||||
@@ -523,6 +524,3 @@ function createFromWMTSTemplate(template) {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export default WMTS;
|
|
||||||
|
|||||||
@@ -52,17 +52,14 @@ export class CustomTile extends ImageTile {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
CustomTile.prototype.getImage = function() {
|
getImage() {
|
||||||
if (this.zoomifyImage_) {
|
if (this.zoomifyImage_) {
|
||||||
return this.zoomifyImage_;
|
return this.zoomifyImage_;
|
||||||
}
|
}
|
||||||
const image = ImageTile.prototype.getImage.call(this);
|
const image = super.getImage();
|
||||||
if (this.state == TileState.LOADED) {
|
if (this.state == TileState.LOADED) {
|
||||||
const tileSize = this.tileSize_;
|
const tileSize = this.tileSize_;
|
||||||
if (image.width == tileSize[0] && image.height == tileSize[1]) {
|
if (image.width == tileSize[0] && image.height == tileSize[1]) {
|
||||||
@@ -77,7 +74,9 @@ CustomTile.prototype.getImage = function() {
|
|||||||
} else {
|
} else {
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user