Merge pull request #13415 from mike-000/graticule
Check for graticule resolution change and fix unrotated size
This commit is contained in:
@@ -20,7 +20,6 @@ import {
|
|||||||
containsExtent,
|
containsExtent,
|
||||||
equals,
|
equals,
|
||||||
getCenter,
|
getCenter,
|
||||||
getHeight,
|
|
||||||
getIntersection,
|
getIntersection,
|
||||||
getWidth,
|
getWidth,
|
||||||
intersects,
|
intersects,
|
||||||
@@ -484,9 +483,16 @@ class Graticule extends VectorLayer {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {?import("../extent.js").Extent}
|
* @type {?import("../extent.js").Extent}
|
||||||
|
* @private
|
||||||
*/
|
*/
|
||||||
this.renderedExtent_ = null;
|
this.renderedExtent_ = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {?number}
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
this.renderedResolution_ = null;
|
||||||
|
|
||||||
this.setRenderOrder(null);
|
this.setRenderOrder(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -536,10 +542,15 @@ class Graticule extends VectorLayer {
|
|||||||
];
|
];
|
||||||
const renderExtent = getIntersection(layerExtent, extent);
|
const renderExtent = getIntersection(layerExtent, extent);
|
||||||
|
|
||||||
if (this.renderedExtent_ && equals(this.renderedExtent_, renderExtent)) {
|
if (
|
||||||
|
this.renderedExtent_ &&
|
||||||
|
equals(this.renderedExtent_, renderExtent) &&
|
||||||
|
this.renderedResolution_ === resolution
|
||||||
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.renderedExtent_ = renderExtent;
|
this.renderedExtent_ = renderExtent;
|
||||||
|
this.renderedResolution_ = resolution;
|
||||||
|
|
||||||
// bail out if nothing to render
|
// bail out if nothing to render
|
||||||
if (isEmpty(renderExtent)) {
|
if (isEmpty(renderExtent)) {
|
||||||
@@ -670,16 +681,14 @@ class Graticule extends VectorLayer {
|
|||||||
*/
|
*/
|
||||||
drawLabels_(event) {
|
drawLabels_(event) {
|
||||||
const rotation = event.frameState.viewState.rotation;
|
const rotation = event.frameState.viewState.rotation;
|
||||||
|
const resolution = event.frameState.viewState.resolution;
|
||||||
|
const size = event.frameState.size;
|
||||||
const extent = event.frameState.extent;
|
const extent = event.frameState.extent;
|
||||||
const rotationCenter = getCenter(extent);
|
const rotationCenter = getCenter(extent);
|
||||||
let rotationExtent = extent;
|
let rotationExtent = extent;
|
||||||
if (rotation) {
|
if (rotation) {
|
||||||
const width = getWidth(extent);
|
const unrotatedWidth = size[0] * resolution;
|
||||||
const height = getHeight(extent);
|
const unrotatedHeight = size[1] * resolution;
|
||||||
const cr = Math.abs(Math.cos(rotation));
|
|
||||||
const sr = Math.abs(Math.sin(rotation));
|
|
||||||
const unrotatedWidth = (sr * height - cr * width) / (sr * sr - cr * cr);
|
|
||||||
const unrotatedHeight = (sr * width - cr * height) / (sr * sr - cr * cr);
|
|
||||||
rotationExtent = [
|
rotationExtent = [
|
||||||
rotationCenter[0] - unrotatedWidth / 2,
|
rotationCenter[0] - unrotatedWidth / 2,
|
||||||
rotationCenter[1] - unrotatedHeight / 2,
|
rotationCenter[1] - unrotatedHeight / 2,
|
||||||
|
|||||||
Reference in New Issue
Block a user