{"url":"https://api.github.com/gists/3804779","forks_url":"https://api.github.com/gists/3804779/forks","commits_url":"https://api.github.com/gists/3804779/commits","id":"3804779","node_id":"MDQ6R2lzdDM4MDQ3Nzk=","git_pull_url":"https://gist.github.com/3804779.git","git_push_url":"https://gist.github.com/3804779.git","html_url":"https://gist.github.com/mbostock/3804779","files":{"projection.js":{"filename":"projection.js","type":"text/javascript","language":"JavaScript","raw_url":"https://gist.githubusercontent.com/mbostock/3804779/raw/f20e2aafce6499f4f811b2bcb7aba2ee9d188959/projection.js","size":1662,"truncated":false,"content":"projection.line = function(coordinates, context) {\n  if (!(n = coordinates.length)) return;\n  context = radiansAndRotateContext(projectAndTransformContext(context));\n  var i = 0,\n      n = coordinates.length,\n      p = coordinates[0];\n  context.moveTo(p[0], p[1]);\n  while (++i < n) context.lineTo((p = coordinates[i])[0], p[1]);\n};\n\nfunction radiansAndRotateContext(context) {\n  return {\n    moveTo: function() {\n      var p = arguments;\n      radians(p);\n      rotate(p);\n      context.moveTo(p[0], p[1]);\n    },\n    lineTo: function() {\n      var p = arguments;\n      radians(p);\n      rotate(p);\n      context.lineTo(p[0], p[1]);\n    },\n    closePath: function() {\n      context.closePath();\n    }\n  };\n}\n\nfunction intersectAntemeridian(context) {\n  var λ0, φ0, sλ0;\n  return {\n    moveTo: function(λ, φ) {\n      sλ0 = λ > 0 ? π : -π;\n      context.moveTo(λ0 = λ, φ0 = φ);\n    },\n    lineTo: function(λ, φ) {\n      var sλ = λ > 0 ? π : -π;\n      if (sλ0 !== sλ && Math.abs(λ - λ0) >= π) {\n        context.lineTo(sλ0, φ0 = d3_geo_projectionIntersectAntemeridian(λ0, φ0, λ, φ));\n        context.moveTo(sλ0 = sλ, φ0);\n      }\n      context.lineTo(λ0 = λ, φ0 = φ);\n    },\n    closePath: function() {\n      context.closePath();\n    }\n  };\n}\n\nfunction projectAndTransformContext(context) {\n  return {\n    moveTo: function() {\n      var p = arguments;\n      project(p);\n      transform(p);\n      context.moveTo(p[0], p[1]);\n    },\n    lineTo: function() {\n      var p = arguments;\n      project(p);\n      transform(p);\n      context.lineTo(p[0], p[1]);\n    },\n    closePath: function() {\n      context.closePath();\n    }\n  };\n}\n","encoding":"utf-8"}},"public":true,"created_at":"2012-09-29T18:16:53Z","updated_at":"2015-10-11T04:47:51Z","description":"Projection Contexts","comments":0,"user":null,"comments_enabled":true,"comments_url":"https://api.github.com/gists/3804779/comments","owner":{"login":"mbostock","id":230541,"node_id":"MDQ6VXNlcjIzMDU0MQ==","avatar_url":"https://avatars.githubusercontent.com/u/230541?v=4","gravatar_id":"","url":"https://api.github.com/users/mbostock","html_url":"https://github.com/mbostock","followers_url":"https://api.github.com/users/mbostock/followers","following_url":"https://api.github.com/users/mbostock/following{/other_user}","gists_url":"https://api.github.com/users/mbostock/gists{/gist_id}","starred_url":"https://api.github.com/users/mbostock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbostock/subscriptions","organizations_url":"https://api.github.com/users/mbostock/orgs","repos_url":"https://api.github.com/users/mbostock/repos","events_url":"https://api.github.com/users/mbostock/events{/privacy}","received_events_url":"https://api.github.com/users/mbostock/received_events","type":"User","user_view_type":"public","site_admin":false},"forks":[],"history":[{"user":{"login":"mbostock","id":230541,"node_id":"MDQ6VXNlcjIzMDU0MQ==","avatar_url":"https://avatars.githubusercontent.com/u/230541?v=4","gravatar_id":"","url":"https://api.github.com/users/mbostock","html_url":"https://github.com/mbostock","followers_url":"https://api.github.com/users/mbostock/followers","following_url":"https://api.github.com/users/mbostock/following{/other_user}","gists_url":"https://api.github.com/users/mbostock/gists{/gist_id}","starred_url":"https://api.github.com/users/mbostock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbostock/subscriptions","organizations_url":"https://api.github.com/users/mbostock/orgs","repos_url":"https://api.github.com/users/mbostock/repos","events_url":"https://api.github.com/users/mbostock/events{/privacy}","received_events_url":"https://api.github.com/users/mbostock/received_events","type":"User","user_view_type":"public","site_admin":false},"version":"7cc325dc58ffb933c07f833117501b3a8627aa53","committed_at":"2012-09-29T18:34:02Z","change_status":{"total":2,"additions":1,"deletions":1},"url":"https://api.github.com/gists/3804779/7cc325dc58ffb933c07f833117501b3a8627aa53"},{"user":{"login":"mbostock","id":230541,"node_id":"MDQ6VXNlcjIzMDU0MQ==","avatar_url":"https://avatars.githubusercontent.com/u/230541?v=4","gravatar_id":"","url":"https://api.github.com/users/mbostock","html_url":"https://github.com/mbostock","followers_url":"https://api.github.com/users/mbostock/followers","following_url":"https://api.github.com/users/mbostock/following{/other_user}","gists_url":"https://api.github.com/users/mbostock/gists{/gist_id}","starred_url":"https://api.github.com/users/mbostock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbostock/subscriptions","organizations_url":"https://api.github.com/users/mbostock/orgs","repos_url":"https://api.github.com/users/mbostock/repos","events_url":"https://api.github.com/users/mbostock/events{/privacy}","received_events_url":"https://api.github.com/users/mbostock/received_events","type":"User","user_view_type":"public","site_admin":false},"version":"72fce9253e1a7d18741644aa49100c886f56f4de","committed_at":"2012-09-29T18:33:02Z","change_status":{"total":4,"additions":2,"deletions":2},"url":"https://api.github.com/gists/3804779/72fce9253e1a7d18741644aa49100c886f56f4de"},{"user":{"login":"mbostock","id":230541,"node_id":"MDQ6VXNlcjIzMDU0MQ==","avatar_url":"https://avatars.githubusercontent.com/u/230541?v=4","gravatar_id":"","url":"https://api.github.com/users/mbostock","html_url":"https://github.com/mbostock","followers_url":"https://api.github.com/users/mbostock/followers","following_url":"https://api.github.com/users/mbostock/following{/other_user}","gists_url":"https://api.github.com/users/mbostock/gists{/gist_id}","starred_url":"https://api.github.com/users/mbostock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbostock/subscriptions","organizations_url":"https://api.github.com/users/mbostock/orgs","repos_url":"https://api.github.com/users/mbostock/repos","events_url":"https://api.github.com/users/mbostock/events{/privacy}","received_events_url":"https://api.github.com/users/mbostock/received_events","type":"User","user_view_type":"public","site_admin":false},"version":"8bca8cb72ccb82b21151d43925c53394856bf434","committed_at":"2012-09-29T18:16:53Z","change_status":{"total":70,"additions":70,"deletions":0},"url":"https://api.github.com/gists/3804779/8bca8cb72ccb82b21151d43925c53394856bf434"}],"truncated":false}