{"action":"opened","issue":{"url":"https://api.github.com/repos/d3/d3-geo-projection/issues/75","repository_url":"https://api.github.com/repos/d3/d3-geo-projection","labels_url":"https://api.github.com/repos/d3/d3-geo-projection/issues/75/labels{/name}","comments_url":"https://api.github.com/repos/d3/d3-geo-projection/issues/75/comments","events_url":"https://api.github.com/repos/d3/d3-geo-projection/issues/75/events","html_url":"https://github.com/d3/d3-geo-projection/issues/75","id":186401632,"number":75,"title":"geostitch --segment?","user":{"login":"mbostock","id":230541,"avatar_url":"https://avatars.githubusercontent.com/u/230541?v=3","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","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-10-31T21:25:01Z","updated_at":"2016-10-31T21:25:01Z","closed_at":null,"body":"Some GIS (GISes?) assume linear interpolation, even in spherical coordinate systems such as WGS84 / EPSG:4326. This is bad because it is rotation-variant. In contrast, D3 / TopoJSON assume great arcs (spherical interpolation) between points on lines and rings in spherical coordinates.\r\n\r\nIt would be useful if TopoJSON had a built-in way to fix this assumption as part of the conversion process, introducing interstitial points. Ideally this would be adaptive and measure the deviation between the great arc and the Cartesian line, but here is a simple approach that could then be simplified to achieve the same result:\r\n\r\n``` js\r\n// Takes a sparse line string that assumes Cartesian interpolation in spherical\r\n// coordinates and inserts interstitial points for greater accuracy when\r\n// rendering with D3, which assumes spherical interpolation.\r\nfunction resample(coordinates) {\r\n  var i = 0,\r\n      j = -1,\r\n      n = coordinates.length,\r\n      source = coordinates.slice(),\r\n      p0, x0, y0,\r\n      p1 = coordinates[0], x1 = p1[0], y1 = p1[1],\r\n      dx, dy, d2,\r\n      m2 = 10; // squared minimum angular distance\r\n  while (++i < n) {\r\n    p0 = p1, x0 = x1, y0 = y1;\r\n    p1 = source[i], x1 = p1[0], y1 = p1[1];\r\n    dx = x1 - x0, dy = y1 - y0, d2 = dx * dx + dy * dy;\r\n    coordinates[++j] = p0;\r\n    if (d2 > m2) for (var k = 1, m = Math.ceil(Math.sqrt(d2 / m2)); k < m; ++k) {\r\n      coordinates[++j] = [x0 + dx * k / m, y0 + dy * k / m];\r\n    }\r\n  }\r\n  coordinates[++j] = p1;\r\n  coordinates.length = j + 1;\r\n}\r\n```\r\n\r\nI’m not sure whether we want to assume that GeoJSON / Shapefile input assumes linear interpolation in spherical coordinates, or if we only want to enable this selectively using a command-line argument. Probably the latter is the safer course of action, although I suspect many users are not aware of this issue.\r\n\r\nMoved from topojson/topojson#110."}}
{"actor":{"display_login":"mbostock"}}