Skip to content

Commit 7eac7db

Browse files
committed
Checkpoint new graphics pipeline.
1 parent a10b226 commit 7eac7db

17 files changed

Lines changed: 697 additions & 1981 deletions

d3.js

Lines changed: 379 additions & 1662 deletions
Large diffs are not rendered by default.

d3.min.js

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

src/geo/area.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import "../core/noop";
22
import "../math/adder";
33
import "../math/trigonometry";
44
import "geo";
5-
import "stream";
65

7-
d3.geo.area = function(object) {
8-
d3_geo_areaSum = 0;
9-
d3.geo.stream(object, d3_geo_area);
10-
return d3_geo_areaSum;
11-
};
6+
// TODO sink API
7+
// d3.geo.area = function(object) {
8+
// d3_geo_areaSum = 0;
9+
// d3.geo.stream(object, d3_geo_area);
10+
// return d3_geo_areaSum;
11+
// };
1212

1313
var d3_geo_areaSum,
1414
d3_geo_areaRingSum = new d3_adder;

src/geo/clip-antimeridian.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import "../math/trigonometry";
44
import "clip";
55
import "point-in-polygon";
66

7-
var d3_geo_clipAntimeridian = d3_geo_clip(
7+
d3.geo.clipAntimeridian = d3_geo_clip(
88
d3_true,
99
d3_geo_clipAntimeridianLine,
1010
d3_geo_clipAntimeridianInterpolate,

src/geo/clip.js

Lines changed: 29 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ import "../math/trigonometry";
44
import "clip-polygon";
55

66
function d3_geo_clip(pointVisible, clipLine, interpolate, clipStart) {
7-
return function(rotate, listener) {
8-
var line = clipLine(listener),
9-
rotatedClipStart = rotate.invert(clipStart[0], clipStart[1]);
7+
return function(sink) {
8+
var line = clipLine(sink);
109

1110
var clip = {
1211
point: point,
@@ -25,63 +24,56 @@ function d3_geo_clip(pointVisible, clipLine, interpolate, clipStart) {
2524
clip.lineEnd = lineEnd;
2625

2726
segments = d3.merge(segments);
28-
var clipStartInside = d3_geo_pointInPolygon(rotatedClipStart, polygon);
27+
var clipStartInside = d3_geo_pointInPolygon(clipStart, polygon);
2928
if (segments.length) {
30-
if (!polygonStarted) listener.polygonStart(), polygonStarted = true;
31-
d3_geo_clipPolygon(segments, d3_geo_clipSort, clipStartInside, interpolate, listener);
29+
if (!polygonStarted) sink.polygonStart(), polygonStarted = true;
30+
d3_geo_clipPolygon(segments, d3_geo_clipSort, clipStartInside, interpolate, sink);
3231
} else if (clipStartInside) {
33-
if (!polygonStarted) listener.polygonStart(), polygonStarted = true;
34-
listener.lineStart();
35-
interpolate(null, null, 1, listener);
36-
listener.lineEnd();
32+
if (!polygonStarted) sink.polygonStart(), polygonStarted = true;
33+
sink.lineStart();
34+
interpolate(null, null, 1, sink);
35+
sink.lineEnd();
3736
}
38-
if (polygonStarted) listener.polygonEnd(), polygonStarted = false;
37+
if (polygonStarted) sink.polygonEnd(), polygonStarted = false;
3938
segments = polygon = null;
4039
},
4140
sphere: function() {
42-
listener.polygonStart();
43-
listener.lineStart();
44-
interpolate(null, null, 1, listener);
45-
listener.lineEnd();
46-
listener.polygonEnd();
41+
sink.polygonStart();
42+
sink.lineStart();
43+
interpolate(null, null, 1, sink);
44+
sink.lineEnd();
45+
sink.polygonEnd();
4746
}
4847
};
4948

50-
function point(λ, φ) {
51-
var point = rotate(λ, φ);
52-
if (pointVisible(λ = point[0], φ = point[1])) listener.point(λ, φ);
53-
}
54-
function pointLine(λ, φ) {
55-
var point = rotate(λ, φ);
56-
line.point(point[0], point[1]);
57-
}
49+
function point(λ, φ) { if (pointVisible(λ, φ)) sink.point(λ, φ); }
50+
function pointLine(λ, φ) { line.point(λ, φ); }
5851
function lineStart() { clip.point = pointLine; line.lineStart(); }
5952
function lineEnd() { clip.point = point; line.lineEnd(); }
6053

6154
var segments;
6255

63-
var buffer = d3_geo_clipBufferListener(),
64-
ringListener = clipLine(buffer),
56+
var buffer = d3_geo_clipBufferSink(),
57+
ringSink = clipLine(buffer),
6558
polygonStarted = false,
6659
polygon,
6760
ring;
6861

6962
function pointRing(λ, φ) {
7063
ring.push([λ, φ]);
71-
var point = rotate(λ, φ);
72-
ringListener.point(point[0], point[1]);
64+
ringSink.point(λ, φ);
7365
}
7466

7567
function ringStart() {
76-
ringListener.lineStart();
68+
ringSink.lineStart();
7769
ring = [];
7870
}
7971

8072
function ringEnd() {
8173
pointRing(ring[0][0], ring[0][1]);
82-
ringListener.lineEnd();
74+
ringSink.lineEnd();
8375

84-
var clean = ringListener.clean(),
76+
var clean = ringSink.clean(),
8577
ringSegments = buffer.buffer(),
8678
segment,
8779
n = ringSegments.length;
@@ -99,16 +91,16 @@ function d3_geo_clip(pointVisible, clipLine, interpolate, clipStart) {
9991
i = -1,
10092
point;
10193
if (n > 0) {
102-
if (!polygonStarted) listener.polygonStart(), polygonStarted = true;
103-
listener.lineStart();
104-
while (++i < n) listener.point((point = segment[i])[0], point[1]);
105-
listener.lineEnd();
94+
if (!polygonStarted) sink.polygonStart(), polygonStarted = true;
95+
sink.lineStart();
96+
while (++i < n) sink.point((point = segment[i])[0], point[1]);
97+
sink.lineEnd();
10698
}
10799
return;
108100
}
109101

110102
// Rejoin connected segments.
111-
// TODO reuse bufferListener.rejoin()?
103+
// TODO reuse bufferSink.rejoin()?
112104
if (n > 1 && clean & 2) ringSegments.push(ringSegments.pop().concat(ringSegments.shift()));
113105

114106
segments.push(ringSegments.filter(d3_geo_clipSegmentLength1));
@@ -122,7 +114,7 @@ function d3_geo_clipSegmentLength1(segment) {
122114
return segment.length > 1;
123115
}
124116

125-
function d3_geo_clipBufferListener() {
117+
function d3_geo_clipBufferSink() {
126118
var lines = [],
127119
line;
128120
return {

src/geo/equirectangular.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import "geo";
2-
import "projection";
2+
// import "projection";
33

4-
function d3_geo_equirectangular(λ, φ) {
4+
d3.geo.equirectangular = function(λ, φ) {
55
return [λ, φ];
6-
}
6+
};
77

8-
(d3.geo.equirectangular = function() {
9-
return d3_geo_projection(d3_geo_equirectangular);
10-
}).raw = d3_geo_equirectangular.invert = d3_geo_equirectangular;
8+
// (d3.geo.equirectangular = function() {
9+
// return d3_geo_projection(d3_geo_equirectangular);
10+
// }).raw = d3_geo_equirectangular.invert = d3_geo_equirectangular;

src/geo/index.js

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,8 @@
11
import "geo";
2-
import "area";
3-
import "bounds";
4-
import "centroid";
5-
import "circle";
6-
import "distance";
7-
import "graticule";
8-
import "greatArc";
9-
import "interpolate";
10-
import "length";
11-
import "path";
12-
import "path-area";
13-
import "path-buffer";
14-
import "path-centroid";
15-
import "path-context";
16-
import "projection";
17-
import "rotation";
18-
import "stream";
19-
import "transform";
20-
import "albers";
21-
import "albers-usa";
22-
import "azimuthal";
23-
import "azimuthal-equal-area";
24-
import "azimuthal-equidistant";
25-
import "conic-conformal";
26-
import "conic-equal-area";
27-
import "conic-equidistant";
2+
3+
import "json-source";
4+
import "rotate";
5+
import "project";
6+
import "clip-antimeridian";
287
import "equirectangular";
29-
import "gnomonic";
30-
import "mercator";
318
import "orthographic";
32-
import "stereographic";
33-
import "transverse-mercator";

src/geo/json-source.js

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import "geo";
2+
3+
d3.geo.jsonSource = function(sink) {
4+
return function(object) {
5+
(object && d3_geo_jsonSourceObjectType.hasOwnProperty(object.type)
6+
? d3_geo_jsonSourceObjectType[object.type]
7+
: d3_geo_jsonSourceGeometry)(object, sink);
8+
};
9+
};
10+
11+
function d3_geo_jsonSourceGeometry(geometry, sink) {
12+
if (geometry && d3_geo_jsonSourceGeometryType.hasOwnProperty(geometry.type)) {
13+
d3_geo_jsonSourceGeometryType[geometry.type](geometry, sink);
14+
}
15+
}
16+
17+
var d3_geo_jsonSourceObjectType = {
18+
Feature: function(feature, sink) {
19+
d3_geo_jsonSourceGeometry(feature.geometry, sink);
20+
},
21+
FeatureCollection: function(object, sink) {
22+
var features = object.features, i = -1, n = features.length;
23+
while (++i < n) d3_geo_jsonSourceGeometry(features[i].geometry, sink);
24+
}
25+
};
26+
27+
var d3_geo_jsonSourceGeometryType = {
28+
Sphere: function(object, sink) {
29+
sink.sphere();
30+
},
31+
Point: function(object, sink) {
32+
object = object.coordinates;
33+
sink.point(object[0] * d3_radians, object[1] * d3_radians);
34+
},
35+
MultiPoint: function(object, sink) {
36+
var coordinates = object.coordinates, i = -1, n = coordinates.length;
37+
while (++i < n) object = coordinates[i], sink.point(object[0] * d3_radians, object[1] * d3_radians);
38+
},
39+
LineString: function(object, sink) {
40+
d3_geo_jsonSourceLine(object.coordinates, sink, 0);
41+
},
42+
MultiLineString: function(object, sink) {
43+
var coordinates = object.coordinates, i = -1, n = coordinates.length;
44+
while (++i < n) d3_geo_jsonSourceLine(coordinates[i], sink, 0);
45+
},
46+
Polygon: function(object, sink) {
47+
d3_geo_jsonSourcePolygon(object.coordinates, sink);
48+
},
49+
MultiPolygon: function(object, sink) {
50+
var coordinates = object.coordinates, i = -1, n = coordinates.length;
51+
while (++i < n) d3_geo_jsonSourcePolygon(coordinates[i], sink);
52+
},
53+
GeometryCollection: function(object, sink) {
54+
var geometries = object.geometries, i = -1, n = geometries.length;
55+
while (++i < n) d3_geo_jsonSourceGeometry(geometries[i], sink);
56+
}
57+
};
58+
59+
function d3_geo_jsonSourceLine(coordinates, sink, closed) {
60+
var i = -1, n = coordinates.length - closed, coordinate;
61+
sink.lineStart();
62+
while (++i < n) coordinate = coordinates[i], sink.point(coordinate[0] * d3_radians, coordinate[1] * d3_radians);
63+
sink.lineEnd();
64+
}
65+
66+
function d3_geo_jsonSourcePolygon(coordinates, sink) {
67+
var i = -1, n = coordinates.length;
68+
sink.polygonStart();
69+
while (++i < n) d3_geo_jsonSourceLine(coordinates[i], sink, 1);
70+
sink.polygonEnd();
71+
}

src/geo/orthographic.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import "azimuthal";
22
import "geo";
3-
import "projection";
3+
// import "projection";
44

5-
var d3_geo_orthographic = d3_geo_azimuthal(
5+
d3.geo.orthographic = d3_geo_azimuthal(
66
function() { return 1; },
77
Math.asin
88
);
99

10-
(d3.geo.orthographic = function() {
11-
return d3_geo_projection(d3_geo_orthographic);
12-
}).raw = d3_geo_orthographic;
10+
// (d3.geo.orthographic = function() {
11+
// return d3_geo_projection(d3_geo_orthographic);
12+
// }).raw = d3_geo_orthographic;

src/geo/path-context.js

Lines changed: 0 additions & 49 deletions
This file was deleted.

0 commit comments

Comments
 (0)