Additional changes to work with user projection

This commit is contained in:
Tim Schaub
2019-09-24 19:58:53 +02:00
parent 7be4835144
commit b1f0b6997b
11 changed files with 81 additions and 21 deletions

View File

@@ -488,7 +488,7 @@ class Overlay extends BaseObject {
return;
}
const pixel = map.getPixelFromCoordinateInternal(position);
const pixel = map.getPixelFromCoordinate(position);
const mapSize = map.getSize();
this.updateRenderedPosition(pixel, mapSize);
}

View File

@@ -546,7 +546,7 @@ class PluggableMap extends BaseObject {
if (!this.frameState_) {
return;
}
const coordinate = this.getCoordinateFromPixel(pixel);
const coordinate = this.getCoordinateFromPixelInternal(pixel);
opt_options = opt_options !== undefined ? opt_options :
/** @type {AtPixelOptions} */ ({});
const hitTolerance = opt_options.hitTolerance !== undefined ?
@@ -618,7 +618,7 @@ class PluggableMap extends BaseObject {
if (!this.frameState_) {
return false;
}
const coordinate = this.getCoordinateFromPixel(pixel);
const coordinate = this.getCoordinateFromPixelInternal(pixel);
opt_options = opt_options !== undefined ? opt_options :
/** @type {AtPixelOptions} */ ({});
const layerFilter = opt_options.layerFilter !== undefined ? opt_options.layerFilter : TRUE;

View File

@@ -206,7 +206,7 @@ class CanvasBuilder extends VectorContext {
* @inheritDoc.
*/
drawCustom(geometry, feature, renderer) {
this.beginGeometry(feature);
this.beginGeometry(geometry, feature);
const type = geometry.getType();
const stride = geometry.getStride();
const builderBegin = this.coordinates.length;
@@ -253,12 +253,14 @@ class CanvasBuilder extends VectorContext {
/**
* @protected
* @param {import("../../geom/Geometry").default|import("../Feature.js").default} geometry The geometry.
* @param {import("../../Feature.js").FeatureLike} feature Feature.
*/
beginGeometry(feature) {
this.beginGeometryInstruction1_ = [CanvasInstruction.BEGIN_GEOMETRY, feature, 0];
beginGeometry(geometry, feature) {
const extent = geometry.getExtent();
this.beginGeometryInstruction1_ = [CanvasInstruction.BEGIN_GEOMETRY, feature, 0, extent];
this.instructions.push(this.beginGeometryInstruction1_);
this.beginGeometryInstruction2_ = [CanvasInstruction.BEGIN_GEOMETRY, feature, 0];
this.beginGeometryInstruction2_ = [CanvasInstruction.BEGIN_GEOMETRY, feature, 0, extent];
this.hitDetectionInstructions.push(this.beginGeometryInstruction2_);
}

View File

@@ -556,8 +556,7 @@ class Executor extends Disposable {
switch (type) {
case CanvasInstruction.BEGIN_GEOMETRY:
feature = /** @type {import("../../Feature.js").FeatureLike} */ (instruction[1]);
if (opt_hitExtent !== undefined && !intersects(
opt_hitExtent, feature.getGeometry().getExtent())) {
if (opt_hitExtent !== undefined && !intersects(opt_hitExtent, instruction[3])) {
i = /** @type {number} */ (instruction[2]) + 1;
} else {
++i;

View File

@@ -113,7 +113,7 @@ class CanvasImageBuilder extends CanvasBuilder {
if (!this.image_) {
return;
}
this.beginGeometry(feature);
this.beginGeometry(pointGeometry, feature);
const flatCoordinates = pointGeometry.getFlatCoordinates();
const stride = pointGeometry.getStride();
const myBegin = this.coordinates.length;
@@ -142,7 +142,7 @@ class CanvasImageBuilder extends CanvasBuilder {
if (!this.image_) {
return;
}
this.beginGeometry(feature);
this.beginGeometry(multiPointGeometry, feature);
const flatCoordinates = multiPointGeometry.getFlatCoordinates();
const stride = multiPointGeometry.getStride();
const myBegin = this.coordinates.length;

View File

@@ -44,7 +44,7 @@ class CanvasLineStringBuilder extends CanvasBuilder {
return;
}
this.updateStrokeStyle(state, this.applyStroke);
this.beginGeometry(feature);
this.beginGeometry(lineStringGeometry, feature);
this.hitDetectionInstructions.push([
CanvasInstruction.SET_STROKE_STYLE,
state.strokeStyle, state.lineWidth, state.lineCap, state.lineJoin,
@@ -68,7 +68,7 @@ class CanvasLineStringBuilder extends CanvasBuilder {
return;
}
this.updateStrokeStyle(state, this.applyStroke);
this.beginGeometry(feature);
this.beginGeometry(multiLineStringGeometry, feature);
this.hitDetectionInstructions.push([
CanvasInstruction.SET_STROKE_STYLE,
state.strokeStyle, state.lineWidth, state.lineCap, state.lineJoin,

View File

@@ -72,7 +72,7 @@ class CanvasPolygonBuilder extends CanvasBuilder {
return;
}
this.setFillStrokeStyles_();
this.beginGeometry(feature);
this.beginGeometry(circleGeometry, feature);
if (state.fillStyle !== undefined) {
this.hitDetectionInstructions.push([
CanvasInstruction.SET_FILL_STYLE,
@@ -116,7 +116,7 @@ class CanvasPolygonBuilder extends CanvasBuilder {
return;
}
this.setFillStrokeStyles_();
this.beginGeometry(feature);
this.beginGeometry(polygonGeometry, feature);
if (state.fillStyle !== undefined) {
this.hitDetectionInstructions.push([
CanvasInstruction.SET_FILL_STYLE,
@@ -148,7 +148,7 @@ class CanvasPolygonBuilder extends CanvasBuilder {
return;
}
this.setFillStrokeStyles_();
this.beginGeometry(feature);
this.beginGeometry(multiPolygonGeometry, feature);
if (state.fillStyle !== undefined) {
this.hitDetectionInstructions.push([
CanvasInstruction.SET_FILL_STYLE,

View File

@@ -184,7 +184,7 @@ class CanvasTextBuilder extends CanvasBuilder {
ends.push(endss[i][0]);
}
}
this.beginGeometry(feature);
this.beginGeometry(geometry, feature);
const textAlign = textState.textAlign;
let flatOffset = 0;
let flatEnd;
@@ -270,7 +270,7 @@ class CanvasTextBuilder extends CanvasBuilder {
}
}
this.beginGeometry(feature);
this.beginGeometry(geometry, feature);
// The image is unknown at this stage so we pass null; it will be computed at render time.
// For clarity, we pass NaN for offsetX, offsetY, width and height, which will be computed at