Skip to content

Commit 8479315

Browse files
committed
Fix d3#1437 - add identity projection.
The identity projection is equivalent to setting path.projection(null), except that you can apply post-projection features such as viewport clipping.
1 parent 23ee2c0 commit 8479315

4 files changed

Lines changed: 38 additions & 2 deletions

File tree

d3.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3932,6 +3932,21 @@ d3 = function() {
39323932
(d3.geo.gnomonic = function() {
39333933
return d3_geo_projection(d3_geo_gnomonic);
39343934
}).raw = d3_geo_gnomonic;
3935+
d3.geo.identity = function() {
3936+
var clipExtent = null;
3937+
function identity(x) {
3938+
return x;
3939+
}
3940+
identity.invert = identity;
3941+
identity.stream = identity;
3942+
identity.clipExtent = function(_) {
3943+
if (!arguments.length) return clipExtent;
3944+
clipExtent = _;
3945+
identity.stream = _ == null ? identity : d3_geo_clipView(_[0][0], _[0][1], _[1][0], _[1][1]);
3946+
return identity;
3947+
};
3948+
return identity;
3949+
};
39353950
function d3_geo_mercator(λ, φ) {
39363951
return [ λ, Math.log(Math.tan(π / 4 + φ / 2)) ];
39373952
}

d3.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/geo/identity.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
d3.geo.identity = function() {
2+
var clipExtent = null;
3+
4+
function identity(x) {
5+
return x;
6+
}
7+
8+
identity.invert = identity;
9+
10+
identity.stream = identity;
11+
12+
identity.clipExtent = function(_) {
13+
if (!arguments.length) return clipExtent;
14+
clipExtent = _;
15+
identity.stream = _ == null ? identity : d3_geo_clipView(_[0][0], _[0][1], _[1][0], _[1][1]);
16+
return identity;
17+
};
18+
19+
return identity;
20+
};

src/geo/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import "conic-equal-area";
2626
import "conic-equidistant";
2727
import "equirectangular";
2828
import "gnomonic";
29+
import "identity";
2930
import "mercator";
3031
import "orthographic";
3132
import "stereographic";

0 commit comments

Comments
 (0)