Better default when no transform available

Do not use identityTransform for EPSG:4326 transform unless units are degrees
This commit is contained in:
mike-000
2020-12-07 17:32:08 +00:00
committed by GitHub
parent 62c7853ed7
commit 2bb8aa0f32

View File

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