Fixes #1134.
This commit is contained in:
Jason Davies 2013-03-11 21:49:54 +00:00
Родитель 09f6c76329
Коммит 759947a2ad
4 изменённых файлов: 23 добавлений и 7 удалений

7
d3.js поставляемый
Просмотреть файл

@ -6774,10 +6774,15 @@ d3 = function() {
}
d3.geo.rotation = function(rotate) {
rotate = d3_geo_rotation(rotate[0] % 360 * d3_radians, rotate[1] * d3_radians, rotate.length > 2 ? rotate[2] * d3_radians : 0);
return function(coordinates) {
function forward(coordinates) {
coordinates = rotate(coordinates[0] * d3_radians, coordinates[1] * d3_radians);
return coordinates[0] *= d3_degrees, coordinates[1] *= d3_degrees, coordinates;
}
forward.invert = function(coordinates) {
coordinates = rotate.invert(coordinates[0] * d3_radians, coordinates[1] * d3_radians);
return coordinates[0] *= d3_degrees, coordinates[1] *= d3_degrees, coordinates;
};
return forward;
};
function d3_geo_rotation(δλ, δφ, δγ) {
return δλ ? δφ || δγ ? d3_geo_compose(d3_geo_rotationλ(δλ), d3_geo_rotationφγ(δφ, δγ)) : d3_geo_rotationλ(δλ) : δφ || δγ ? d3_geo_rotationφγ(δφ, δγ) : d3_geo_equirectangular;

10
d3.min.js поставляемый

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

@ -1,9 +1,17 @@
d3.geo.rotation = function(rotate) {
rotate = d3_geo_rotation(rotate[0] % 360 * d3_radians, rotate[1] * d3_radians, rotate.length > 2 ? rotate[2] * d3_radians : 0);
return function(coordinates) {
function forward(coordinates) {
coordinates = rotate(coordinates[0] * d3_radians, coordinates[1] * d3_radians);
return coordinates[0] *= d3_degrees, coordinates[1] *= d3_degrees, coordinates;
}
forward.invert = function(coordinates) {
coordinates = rotate.invert(coordinates[0] * d3_radians, coordinates[1] * d3_radians);
return coordinates[0] *= d3_degrees, coordinates[1] *= d3_degrees, coordinates;
};
return forward;
};
// Note: |δλ| must be < 2π

Просмотреть файл

@ -23,6 +23,9 @@ suite.addBatch({
},
"rotates longitude and latitude": function(rotation) {
assert.inDelta(rotation([0, 0]), [-54.73561, 30], 1e-6);
},
"inverse rotation of longitude and latitude": function(rotation) {
assert.inDelta(rotation.invert([-54.73561, 30]), [0, 0], 1e-6);
}
}
});