Advertisement
Guest User

Untitled

a guest
Aug 20th, 2014
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. var bb = {W:-5.0, N:50.0, E:10.0, S:40.0 }
  2.  
  3. svg.append("path")
  4. .datum({type: "LineString", coordinates:
  5. [[-5, 40], [-5, 50], [10, 50], [10, 40], [-5, 40]]
  6. })
  7. .attr("d", path);
  8.  
  9. bounds = [[-50.8,20.0][30,51.5]];
  10. WNES0 = bounds[0][0], // West "W":-50.8
  11. WNES1 = bounds[1][1], // North "N": 51.5
  12. WNES2 = bounds[1][0], // East "E": 30
  13. WNES3 = bounds[0][1], // South "S": 20.0
  14.  
  15. // *********** MATH TOOLKIT ********** //
  16. function parallel(φ, λ0, λ1) {
  17. if (λ0 > λ1) λ1 += 360;
  18. var dλ = λ1 - λ0,
  19. step = dλ / Math.ceil(dλ);
  20. return d3.range(λ0, λ1 + .5 * step, step).map(function(λ) { return [normalise(λ), φ]; });
  21. }
  22. function normalise(x) {
  23. return (x + 180) % 360 - 180;
  24. }
  25.  
  26. // *********** APPEND SHAPES ********** //
  27. svg.append("path")
  28. .datum({type: "Polygon", coordinates: [
  29. [[WNES0,WNES3]]
  30. .concat(parallel(WNES1, WNES0, WNES2))
  31. .concat(parallel(WNES3, WNES0, WNES2).reverse())
  32. ]})
  33. .attr("d", path)
  34. .style({'fill': '#B10000', 'fill-opacity': 0.3, 'stroke': '#B10000', 'stroke-linejoin': 'round'})
  35. .style({'stroke-width': 1 });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement