Simplify vector tile projection handling

This commit is contained in:
ahocevar
2019-03-10 09:34:40 +01:00
parent 7002053678
commit b2722542fe
10 changed files with 148 additions and 181 deletions

View File

@@ -24,10 +24,10 @@ class VectorTile extends Tile {
this.consumers = 0;
/**
* @private
* Extent of this tile; set by the source.
* @type {import("./extent.js").Extent}
*/
this.extent_ = null;
this.extent = null;
/**
* @private
@@ -48,11 +48,16 @@ class VectorTile extends Tile {
this.loader_;
/**
* Data projection
* @private
* Feature projection of this tile; set by the source.
* @type {import("./proj/Projection.js").default}
*/
this.projection_ = null;
this.projection = null;
/**
* Resolution of this tile; set by the source.
* @type {number}
*/
this.resolution;
/**
* @private
@@ -76,15 +81,6 @@ class VectorTile extends Tile {
super.disposeInternal();
}
/**
* Gets the extent of the vector tile.
* @return {import("./extent.js").Extent} The extent.
* @api
*/
getExtent() {
return this.extent_;
}
/**
* Get the feature format assigned for reading this tile's features.
* @return {import("./format/Feature.js").default} Feature format.
@@ -95,8 +91,7 @@ class VectorTile extends Tile {
}
/**
* Get the features for this tile. Geometries will be in the projection returned
* by {@link module:ol/VectorTile~VectorTile#getProjection}.
* Get the features for this tile. Geometries will be in the view projection.
* @return {Array<import("./Feature.js").FeatureLike>} Features.
* @api
*/
@@ -111,16 +106,6 @@ class VectorTile extends Tile {
return this.url_;
}
/**
* Get the feature projection of features returned by
* {@link module:ol/VectorTile~VectorTile#getFeatures}.
* @return {import("./proj/Projection.js").default} Feature projection.
* @api
*/
getProjection() {
return this.projection_;
}
/**
* @inheritDoc
*/
@@ -128,7 +113,7 @@ class VectorTile extends Tile {
if (this.state == TileState.IDLE) {
this.setState(TileState.LOADING);
this.tileLoadFunction_(this, this.url_);
this.loader_(null, NaN, null);
this.loader_(this.extent, this.resolution, this.projection);
}
}
@@ -136,11 +121,8 @@ class VectorTile extends Tile {
* Handler for successful tile load.
* @param {Array<import("./Feature.js").default>} features The loaded features.
* @param {import("./proj/Projection.js").default} dataProjection Data projection.
* @param {import("./extent.js").Extent} extent Extent.
*/
onLoad(features, dataProjection, extent) {
this.setProjection(dataProjection);
this.setExtent(extent);
onLoad(features, dataProjection) {
this.setFeatures(features);
}
@@ -151,22 +133,6 @@ class VectorTile extends Tile {
this.setState(TileState.ERROR);
}
/**
* Function for use in an {@link module:ol/source/VectorTile~VectorTile}'s
* `tileLoadFunction`. Sets the extent of the vector tile. This is only required
* for tiles in projections with `tile-pixels` as units. The extent should be
* set to `[0, 0, tilePixelSize, tilePixelSize]`, where `tilePixelSize` is
* calculated by multiplying the tile size with the tile pixel ratio. For
* sources using {@link module:ol/format/MVT~MVT} as feature format, the
* {@link module:ol/format/MVT~MVT#getLastExtent} method will return the correct
* extent.
* @param {import("./extent.js").Extent} extent The extent.
* @api
*/
setExtent(extent) {
this.extent_ = extent;
}
/**
* Function for use in an {@link module:ol/source/VectorTile~VectorTile}'s `tileLoadFunction`.
* Sets the features for the tile.
@@ -178,17 +144,6 @@ class VectorTile extends Tile {
this.setState(TileState.LOADED);
}
/**
* Function for use in an {@link module:ol/source/VectorTile~VectorTile}'s `tileLoadFunction`.
* Sets the projection of the features that were added with
* {@link module:ol/VectorTile~VectorTile#setFeatures}.
* @param {import("./proj/Projection.js").default} projection Feature projection.
* @api
*/
setProjection(projection) {
this.projection_ = projection;
}
/**
* Set the feature loader for reading this tile's features.
* @param {import("./featureloader.js").FeatureLoader} loader Feature loader.