Merge pull request #11811 from mike-000/patch-6

Better getPointResolution default when no transform available
This commit is contained in:
Andreas Hocevar
2020-12-13 22:33:09 +01:00
committed by GitHub
3 changed files with 36 additions and 14 deletions

View File

@@ -212,20 +212,25 @@ export function getPointResolution(projection, resolution, point, opt_units) {
projection,
get('EPSG:4326')
);
let vertices = [
point[0] - resolution / 2,
point[1],
point[0] + resolution / 2,
point[1],
point[0],
point[1] - resolution / 2,
point[0],
point[1] + resolution / 2,
];
vertices = toEPSG4326(vertices, vertices, 2);
const width = getDistance(vertices.slice(0, 2), vertices.slice(2, 4));
const height = getDistance(vertices.slice(4, 6), vertices.slice(6, 8));
pointResolution = (width + height) / 2;
if (toEPSG4326 === identityTransform && units !== Units.DEGREES) {
// no transform is available
pointResolution = resolution * projection.getMetersPerUnit();
} else {
let vertices = [
point[0] - resolution / 2,
point[1],
point[0] + resolution / 2,
point[1],
point[0],
point[1] - resolution / 2,
point[0],
point[1] + resolution / 2,
];
vertices = toEPSG4326(vertices, vertices, 2);
const width = getDistance(vertices.slice(0, 2), vertices.slice(2, 4));
const height = getDistance(vertices.slice(4, 6), vertices.slice(6, 8));
pointResolution = (width + height) / 2;
}
const metersPerUnit = opt_units
? METERS_PER_UNIT[opt_units]
: projection.getMetersPerUnit();