-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathgeolines.js
86 lines (75 loc) · 2.79 KB
/
geolines.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import { geolines as getlines } from "../helpers/geolines.js";
import { geoPath } from "d3-geo";
const d3 = Object.assign({}, { geoPath });
export function geolines(selection, projection, planar, options = {}, clipid) {
if (!planar) {
let stroke = options.stroke != undefined ? options.stroke : "#020e21";
if (!Array.isArray(stroke)) {
stroke = Array(3).fill(stroke);
}
let strokeWidth =
options.strokeWidth != undefined ? options.strokeWidth : [1.5, 1.2, 0.7];
if (!Array.isArray(strokeWidth)) {
strokeWidth = Array(3).fill(strokeWidth);
}
let strokeOpacity =
options.strokeOpacity != undefined ? options.strokeOpacity : 1;
if (!Array.isArray(strokeOpacity)) {
strokeOpacity = Array(3).fill(strokeOpacity);
}
let strokeDasharray =
options.strokeDasharray != undefined
? options.strokeDasharray
: ["none", 5, 3];
if (!Array.isArray(strokeDasharray)) {
strokeDasharray = Array(3).fill(strokeDasharray);
}
let strokeLinecap =
options.strokeLinecap != undefined ? options.strokeLinecap : "butt";
if (!Array.isArray(strokeLinecap)) {
strokeLinecap = Array(3).fill(strokeLinecap);
}
let lines = getlines().features;
let l = selection
.append("g")
.attr("class", options.id)
.attr("data-layer", JSON.stringify({ _type: "geolines" }));
l.attr("clip-path", clipid == null ? `none` : `url(#clip_${clipid})`);
l.append("g")
.selectAll("path")
.data(lines.filter((d) => d.properties.name == "Equator"))
.join("path")
.attr("d", d3.geoPath(projection))
.attr("class", "onglobe")
.attr("fill", "none")
.attr("stroke", stroke[0])
.attr("stroke-width", strokeWidth[0])
.attr("stroke-opacity", strokeOpacity[0])
.attr("stroke-dasharray", strokeDasharray[0])
.attr("stroke-linecap", strokeLinecap[0]);
l.append("g")
.selectAll("path")
.data(lines.filter((d) => d.properties.name.includes("Tropic")))
.join("path")
.attr("d", d3.geoPath(projection))
.attr("class", "onglobe")
.attr("fill", "none")
.attr("stroke", stroke[1])
.attr("stroke-width", strokeWidth[1])
.attr("stroke-opacity", strokeOpacity[1])
.attr("stroke-dasharray", strokeDasharray[1])
.attr("stroke-linecap", strokeLinecap[1]);
l.append("g")
.selectAll("path")
.data(lines.filter((d) => d.properties.name.includes("Circle")))
.join("path")
.attr("d", d3.geoPath(projection))
.attr("class", "onglobe")
.attr("fill", "none")
.attr("stroke", stroke[2])
.attr("stroke-width", strokeWidth[2])
.attr("stroke-opacity", strokeOpacity[2])
.attr("stroke-dasharray", strokeDasharray[2])
.attr("stroke-linecap", strokeLinecap[2]);
}
}