Fix missing corners of the world
This commit is contained in:
+30
-1
@@ -2,7 +2,7 @@
|
|||||||
* @module ol/reproj
|
* @module ol/reproj
|
||||||
*/
|
*/
|
||||||
import {createCanvasContext2D} from './dom.js';
|
import {createCanvasContext2D} from './dom.js';
|
||||||
import {containsCoordinate, createEmpty, extend, getHeight, getTopLeft, getWidth} from './extent.js';
|
import {containsCoordinate, createEmpty, extend, forEachCorner, getCenter, getHeight, getTopLeft, getWidth} from './extent.js';
|
||||||
import {solveLinearSystem} from './math.js';
|
import {solveLinearSystem} from './math.js';
|
||||||
import {getPointResolution, transform} from './proj.js';
|
import {getPointResolution, transform} from './proj.js';
|
||||||
|
|
||||||
@@ -53,6 +53,35 @@ export function calculateSourceResolution(sourceProj, targetProj,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculates ideal resolution to use from the source in order to achieve
|
||||||
|
* pixel mapping as close as possible to 1:1 during reprojection.
|
||||||
|
* The resolution is calculated regardless of what resolutions
|
||||||
|
* are actually available in the dataset (TileGrid, Image, ...).
|
||||||
|
*
|
||||||
|
* @param {import("./proj/Projection.js").default} sourceProj Source projection.
|
||||||
|
* @param {import("./proj/Projection.js").default} targetProj Target projection.
|
||||||
|
* @param {import("./extent.js").Extent} targetExtent Target extent
|
||||||
|
* @param {number} targetResolution Target resolution.
|
||||||
|
* @return {number} The best resolution to use. Can be +-Infinity, NaN or 0.
|
||||||
|
*/
|
||||||
|
export function calculateSourceExtentResolution(sourceProj, targetProj,
|
||||||
|
targetExtent, targetResolution) {
|
||||||
|
|
||||||
|
const targetCenter = getCenter(targetExtent);
|
||||||
|
let sourceResolution = calculateSourceResolution(sourceProj, targetProj, targetCenter, targetResolution);
|
||||||
|
|
||||||
|
if (!isFinite(sourceResolution) || sourceResolution <= 0) {
|
||||||
|
forEachCorner(targetExtent, function(corner) {
|
||||||
|
sourceResolution = calculateSourceResolution(sourceProj, targetProj, corner, targetResolution);
|
||||||
|
return isFinite(sourceResolution) && sourceResolution > 0;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return sourceResolution;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders the source data into new canvas based on the triangulation.
|
* Renders the source data into new canvas based on the triangulation.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -7,9 +7,9 @@ import Tile from '../Tile.js';
|
|||||||
import TileState from '../TileState.js';
|
import TileState from '../TileState.js';
|
||||||
import {listen, unlistenByKey} from '../events.js';
|
import {listen, unlistenByKey} from '../events.js';
|
||||||
import EventType from '../events/EventType.js';
|
import EventType from '../events/EventType.js';
|
||||||
import {getArea, getCenter, getIntersection} from '../extent.js';
|
import {getArea, getIntersection} from '../extent.js';
|
||||||
import {clamp} from '../math.js';
|
import {clamp} from '../math.js';
|
||||||
import {calculateSourceResolution, render as renderReprojected} from '../reproj.js';
|
import {calculateSourceExtentResolution, render as renderReprojected} from '../reproj.js';
|
||||||
import Triangulation from './Triangulation.js';
|
import Triangulation from './Triangulation.js';
|
||||||
|
|
||||||
|
|
||||||
@@ -140,9 +140,8 @@ class ReprojTile extends Tile {
|
|||||||
const targetResolution = targetTileGrid.getResolution(
|
const targetResolution = targetTileGrid.getResolution(
|
||||||
this.wrappedTileCoord_[0]);
|
this.wrappedTileCoord_[0]);
|
||||||
|
|
||||||
const targetCenter = getCenter(limitedTargetExtent);
|
const sourceResolution = calculateSourceExtentResolution(
|
||||||
const sourceResolution = calculateSourceResolution(
|
sourceProj, targetProj, limitedTargetExtent, targetResolution);
|
||||||
sourceProj, targetProj, targetCenter, targetResolution);
|
|
||||||
|
|
||||||
if (!isFinite(sourceResolution) || sourceResolution <= 0) {
|
if (!isFinite(sourceResolution) || sourceResolution <= 0) {
|
||||||
// invalid sourceResolution -> EMPTY
|
// invalid sourceResolution -> EMPTY
|
||||||
|
|||||||
Reference in New Issue
Block a user