Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var bb = {W:-5.0, N:50.0, E:10.0, S:40.0 }
- svg.append("path")
- .datum({type: "LineString", coordinates:
- [[-5, 40], [-5, 50], [10, 50], [10, 40], [-5, 40]]
- })
- .attr("d", path);
- bounds = [[-50.8,20.0][30,51.5]];
- WNES0 = bounds[0][0], // West "W":-50.8
- WNES1 = bounds[1][1], // North "N": 51.5
- WNES2 = bounds[1][0], // East "E": 30
- WNES3 = bounds[0][1], // South "S": 20.0
- // *********** MATH TOOLKIT ********** //
- function parallel(φ, λ0, λ1) {
- if (λ0 > λ1) λ1 += 360;
- var dλ = λ1 - λ0,
- step = dλ / Math.ceil(dλ);
- return d3.range(λ0, λ1 + .5 * step, step).map(function(λ) { return [normalise(λ), φ]; });
- }
- function normalise(x) {
- return (x + 180) % 360 - 180;
- }
- // *********** APPEND SHAPES ********** //
- svg.append("path")
- .datum({type: "Polygon", coordinates: [
- [[WNES0,WNES3]]
- .concat(parallel(WNES1, WNES0, WNES2))
- .concat(parallel(WNES3, WNES0, WNES2).reverse())
- ]})
- .attr("d", path)
- .style({'fill': '#B10000', 'fill-opacity': 0.3, 'stroke': '#B10000', 'stroke-linejoin': 'round'})
- .style({'stroke-width': 1 });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement