Merge pull request #2840 from tschaub/point-resolution
Fewer point resolution tests.
This commit is contained in:
+5
-5
@@ -252,7 +252,8 @@ ol.proj.Projection.prototype.setWorldExtent = function(worldExtent) {
|
|||||||
* @return {number} Point resolution.
|
* @return {number} Point resolution.
|
||||||
*/
|
*/
|
||||||
ol.proj.Projection.prototype.getPointResolution = function(resolution, point) {
|
ol.proj.Projection.prototype.getPointResolution = function(resolution, point) {
|
||||||
if (this.getUnits() == ol.proj.Units.DEGREES) {
|
var units = this.getUnits();
|
||||||
|
if (units == ol.proj.Units.DEGREES) {
|
||||||
return resolution;
|
return resolution;
|
||||||
} else {
|
} else {
|
||||||
// Estimate point resolution by transforming the center pixel to EPSG:4326,
|
// Estimate point resolution by transforming the center pixel to EPSG:4326,
|
||||||
@@ -272,10 +273,9 @@ ol.proj.Projection.prototype.getPointResolution = function(resolution, point) {
|
|||||||
var height = ol.sphere.NORMAL.haversineDistance(
|
var height = ol.sphere.NORMAL.haversineDistance(
|
||||||
vertices.slice(4, 6), vertices.slice(6, 8));
|
vertices.slice(4, 6), vertices.slice(6, 8));
|
||||||
var pointResolution = (width + height) / 2;
|
var pointResolution = (width + height) / 2;
|
||||||
if (this.getUnits() == ol.proj.Units.FEET) {
|
var metersPerUnit = this.getMetersPerUnit();
|
||||||
// The radius of the normal sphere is defined in meters, so we must
|
if (goog.isDef(metersPerUnit)) {
|
||||||
// convert back to feet.
|
pointResolution /= metersPerUnit;
|
||||||
pointResolution /= 0.3048;
|
|
||||||
}
|
}
|
||||||
return pointResolution;
|
return pointResolution;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -175,8 +175,8 @@ describe('ol.proj', function() {
|
|||||||
var epsg3857Projection = ol.proj.get('EPSG:3857');
|
var epsg3857Projection = ol.proj.get('EPSG:3857');
|
||||||
var googleProjection = ol.proj.get('GOOGLE');
|
var googleProjection = ol.proj.get('GOOGLE');
|
||||||
var point, x, y;
|
var point, x, y;
|
||||||
for (x = -20; x <= 20; ++x) {
|
for (x = -20; x <= 20; x += 2) {
|
||||||
for (y = -20; y <= 20; ++y) {
|
for (y = -20; y <= 20; y += 2) {
|
||||||
point = [1000000 * x, 1000000 * y];
|
point = [1000000 * x, 1000000 * y];
|
||||||
expect(googleProjection.getPointResolution(1, point)).to.roughlyEqual(
|
expect(googleProjection.getPointResolution(1, point)).to.roughlyEqual(
|
||||||
epsg3857Projection.getPointResolution(1, point), 1e-1);
|
epsg3857Projection.getPointResolution(1, point), 1e-1);
|
||||||
|
|||||||
Reference in New Issue
Block a user