{"id":4408,"date":"2015-07-29T19:26:57","date_gmt":"2015-07-29T10:26:57","guid":{"rendered":"https:\/\/gunmagisgeek.com\/wordpress\/?p=4408"},"modified":"2018-03-07T15:43:17","modified_gmt":"2018-03-07T06:43:17","slug":"post-4408","status":"publish","type":"post","link":"https:\/\/gunmagisgeek.com\/blog\/d3v4\/4408","title":{"rendered":"D3.js\u3068TopoJson\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u4f7f\u3063\u3066\u5730\u7406\u60c5\u5831\u3092\u52d5\u7684\u306b\u7c21\u7d20\u5316\u3059\u308b\u3002"},"content":{"rendered":"<p>\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u30b5\u30a4\u30c9\u306etopojson\u306b\u306f\u8aad\u307f\u8fbc\u3093\u3060\u5730\u7406\u30c7\u30fc\u30bf\u3092\u7c21\u7d20\u5316\u3059\u308bpresimplify\u3068\u3044\u3046\u6a5f\u80fd\u304c\u3042\u308a\u307e\u3059\u3002<br \/>\n\u4eca\u56de\u306f\u3053\u306e\u6a5f\u80fd\u3092\u4f7f\u3063\u305f\u5730\u5f62\u30c7\u30fc\u30bf\u306e\u52d5\u7684\u306a\u7c21\u7d20\u5316\u306e\u30b5\u30f3\u30d7\u30eb\u3092\u3064\u304f\u308a\u307e\u3057\u305f\u3002<\/p>\n<p><a href=\"http:\/\/bl.ocks.org\/shimizu\/44bfe038e1ba6942b4ba\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2015\/07\/presimplify-example.jpg\" alt=\"presimplify example\" width=\"590\" height=\"184\" class=\"aligncenter size-full wp-image-4409 border\" srcset=\"https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2015\/07\/presimplify-example.jpg 590w, https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2015\/07\/presimplify-example-300x94.jpg 300w\" sizes=\"auto, (max-width: 590px) 100vw, 590px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/bl.ocks.org\/shimizu\/44bfe038e1ba6942b4ba\">example<\/a><\/p>\n<p>\u30b9\u30e9\u30a4\u30c0\u30fc\u3092\u53f3\u306b\u52d5\u304b\u3059\u3068\u5730\u5f62\u304c\u7c21\u7d20\u5316\u3055\u308c\u307e\u3059\u3002<\/p>\n<h2>\u89e3\u8aac<\/h2>\n<p>\u5168\u304f\u6301\u3063\u3066\u4e0a\u624b\u304f\u8aac\u660e\u3067\u304d\u308b\u81ea\u4fe1\u304c\u306a\u3044\u306e\u3067\u3059\u304c\u3001\u305f\u3060\u30b3\u30fc\u30c9\u3092\u7f6e\u3044\u3066\u304a\u304f\u306e\u3082\u306a\u3093\u306a\u306e\u3067\u4e00\u5fdc\u89e3\u8aac\u3063\u307d\u3044\u3082\u306e\u3092\u304b\u3044\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<h3>\u30b8\u30aa\u30b9\u30c8\u30ea\u30fc\u30e0<\/h3>\n<p>D3\u3092\u7528\u3044\u3066\u5730\u7406\u60c5\u5831\u3092\u63cf\u753b\u3059\u308b\u969b\u3001projection\u95a2\u6570\u3068path\u95a2\u6570\u3092\u4f5c\u6210\u3057\u3066\u63cf\u753b\u51e6\u7406\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"lang:js decode:true \" >\/\/\u7def\u5ea6\u7d4c\u5ea6\u3092pixcel\u5ea7\u6a19\u306b\u5909\u63db\u3059\u308b\u30ea\u30b9\u30ca\u30fc\nvar projection = d3.geoMercator()       \n\nprojection([139.0032936, 36.3219088]);\n-&gt; [480, 320]\n    \n\/\/pixcel\u5ea7\u6a19\u306e\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u3092path\u8981\u7d20\u306ed\u5c5e\u6027\u306b\u6e21\u3059\u30d1\u30b9\u30c7\u30fc\u30bf\u5f62\u5f0f\u306b\u5909\u63db\u3059\u308b\u95a2\u6570   \nvar path = d3.geoPath().projection(projection);\n\n\npath(geojson);\n-&gt; \"M318.33499585167647,350.924745060654,L318.5161692703732,350.51.199698 \u2026\u2026\u3000Z\"\n<\/pre>\n<p>D3\u3067\u306f\u5730\u7406\u60c5\u5831\u304c\u3082\u3064\u7def\u5ea6\u7d4c\u5ea6\u3092pixcel\u306e\u5ea7\u6a19\u3078\u3068\u5909\u63db\u3059\u308b\u30c7\u30fc\u30bf\u306e\u6d41\u308c\u3092\u300c<a href=\"https:\/\/github.com\/mbostock\/d3\/wiki\/Geo-Streams\">\u30b8\u30aa\u30b9\u30c8\u30ea\u30fc\u30e0<\/a>\u300d\u3068\u547c\u3073\u307e\u3059\u3002<br \/>\n\u305d\u3057\u3066\u305d\u306e\u30b8\u30aa\u30b9\u30c8\u30ea\u30fc\u30e0\u306b\u5bfe\u3057\u3066\u5909\u63db\u51e6\u7406\u3092\u884c\u3046\u95a2\u6570\u3092\u30b9\u30c8\u30ea\u30fc\u30e0\u30ea\u30b9\u30ca\u30fc\u3068\u547c\u3073\u307e\u3059\u3002<br \/>\nd3.geoMercator\u306f\u3001\u30e1\u30eb\u30ab\u30c8\u30eb\u56f3\u6cd5\u3092\u57fa\u6e96\u306b\u3057\u3066\u7def\u5ea6\u7d4c\u5ea6\u3092pixcel\u5ea7\u6a19\u3078\u3068\u5909\u63db\u3059\u308b\u30b9\u30c8\u30ea\u30fc\u30e0\u30ea\u30b9\u30ca\u30fc\u3092\u751f\u6210\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\n\u4eca\u56de\u306f\u3053\u306e\u30e1\u30eb\u30ab\u30c8\u30eb\u56f3\u6cd5\u306e\u30b9\u30c8\u30ea\u30fc\u30e0\u30ea\u30b9\u30ca\u30fc\u3092\u30e9\u30c3\u30d7\u3057\u3066geometory\u3092\u7c21\u7d20\u5316\u3059\u308b\u30b9\u30c8\u30ea\u30fc\u30e0\u30ea\u30b9\u30ca\u30fc\u3092\u4f5c\u308a\u307e\u3057\u305f\u3002<\/p>\n<h3>topojson.presimplify<\/h3>\n<p>topojson.presimplify\u30e1\u30bd\u30c3\u30c9\u306f\u3001\u5f15\u6570\u3067\u6e21\u3055\u308c\u305ftopojson\u306b\u7c21\u7d20\u5316\u306b\u57f7\u62d7\u306a\u30b8\u30aa\u30e1\u30c8\u30ea\u60c5\u5831\u3092\u8ffd\u52a0\u3057\u305f\u30b3\u30d4\u30fc\u3092\u8fd4\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:js decode:true \" >const presimplify = topojson.presimplify(topojson);<\/pre>\n<p>presimplify\u30e1\u30bd\u30c3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3068geometory\u306e\u5404\u70b9\u3054\u3068\u306b\u96a3\u63a5\u3057\u305f\u4e09\u70b9\u3092\u7d50\u3093\u3060\u4e09\u89d2\u5f62\u306e\u9762\u7a4d\u304c\u4ed8\u52a0\u3055\u308c\u307e\u3059\u3002\u3053\u306e\u9762\u7a4d\u306e\u5024\u306b\u95be\u5024\u3092\u8a2d\u5b9a\u3057\u3066\u305d\u304e\u843d\u3068\u3059\u3053\u3068\u3067geometory\u306e\u7c21\u7d20\u5316\u3092\u884c\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<br \/>\n\u8a73\u3057\u3044\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u306b\u3064\u3044\u3066\u306f\u4ee5\u4e0b\u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><a href=\"http:\/\/bost.ocks.org\/mike\/simplify\/\">Line Simplification<\/a><\/p>\n<p>\u7c21\u5358\u306b\u8aac\u660e\u3059\u308b\u3068\u300c\u96a3\u63a5\u3059\u308b\u4e09\u70b9\u3092\u7d50\u3093\u3067\u4f5c\u6210\u3057\u305f\u4e09\u89d2\u5f62\u306e\u9762\u7a4d\u304c\u5c0f\u3055\u3044\u5ea7\u6a19\u70b9\u306f\u3001\u96a3\u63a5\u3059\u308b\u5ea7\u6a19\u70b9\u3068\u306e\u5909\u5316\u304c\u5c11\u306a\u3044\u70b9\u306a\u306e\u3067\u3001\u7121\u304f\u3057\u3061\u3083\u3063\u3066\u3082\u554f\u984c\u306a\u3044\u3088\u306d\uff01\u300d\u307f\u305f\u3044\u306a\u611f\u3058\u3067\u3059\u3002<\/p>\n<h3>\u30ab\u30b9\u30bf\u30e0\u30b9\u30c8\u30ea\u30fc\u30e0\u30ea\u30b9\u30ca\u30fc<\/h3>\n<p>d3.geo.transform\u3092\u5229\u7528\u3059\u308b\u3068\u30b8\u30aa\u30b9\u30c8\u30ea\u30fc\u30e0(\u7def\u5ea6\u7d4c\u5ea6\u3092pixcel\u5ea7\u6a19\u306b\u5909\u63db\u3059\u308b\u30d7\u30ed\u30bb\u30b9)\u3092\u9014\u4e2d\u3067\u30d5\u30c3\u30af\u3057\u3001\u72ec\u81ea\u306e\u30b9\u30c8\u30ea\u30fc\u30e0\u30ea\u30b9\u30ca\u30fc\u3092\u751f\u6210\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<br \/>\ntopojson.presimplify\u30e1\u30bd\u30c3\u30c9\u3067\u4ed8\u52a0\u3057\u305f\u9762\u7a4d\u306e\u5024\u306f\u30b9\u30c8\u30ea\u30fc\u30e0\u30ea\u30b9\u30ca\u30fc\u306b\u5f15\u6570\u3068\u3057\u3066\u6e21\u3055\u308c\u308b\u306e\u3067\u3001\u95be\u5024\u3092\u8a2d\u5b9a\u3057geometory\u3092\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"lang:js decode:true \" >\/\/\u7def\u5ea6\u7d4c\u5ea6\u3092pixcel\u5ea7\u6a19\u306b\u5909\u63db\u3059\u308b\u95a2\u6570(\u30b8\u30aa\u30b9\u30c8\u30ea\u30fc\u30e0\u30ea\u30b9\u30ca\u30fc\uff09\nvar projection = d3.geoMercator()       \n    \n\/\/\u30ab\u30b9\u30bf\u30e0\u30b9\u30c8\u30ea\u30fc\u30e0\u30ea\u30b9\u30ca\u30fc\nvar simplify= d3.geoTransform({\n    point: function(x, y, z) {\n        \/\/\u96a3\u63a5\u3057\u305f\uff13\u70b9\u3092\u7d50\u3093\u3060\u9762\u7a4d\u304c1\u3092\u8d85\u3048\u308b\u3082\u306e\u3060\u3051\u3092\u6b8b\u3059\n        if (z &gt;= 1)  this.stream.point(projection([x, y]));\n    } \n});\n\n\/\/\u30d1\u30b9\u30b8\u30a7\u30cd\u30ec\u30fc\u30bf\u30fc\u3092\u751f\u6210  \nvar path = d3.geoPath().projection(simplify);\u3000<\/pre>\n<p>\u30ab\u30b9\u30bf\u30e0\u30b9\u30c8\u30ea\u30fc\u30e0\u30ea\u30b9\u30ca\u30fc\u306e\u4e2d\u3067\u3001\u96a3\u63a5\u3059\u308b\u4e09\u70b9\u3092\u7d50\u3093\u3060\u4e09\u89d2\u5f62\u306e\u9762\u7a4d\u304c\u95be\u5024\u3092\u8d85\u3048\u308b\u5ea7\u6a19\u70b9\u306e\u307f\u3092\u5909\u63db\u5bfe\u8c61\u3068\u3057\u3001\u305d\u308c\u4ee5\u5916\u306e\u5ea7\u6a19\u306f\u5207\u308a\u6368\u3066\u3066\u3057\u307e\u3046\u3053\u3068\u3067\u3001\u5ea7\u6a19\u70b9\u3092\u6e1b\u3089\u3057\u7c21\u7d20\u5316\u3057\u305f\u56f3\u5f62\u3092\u63cf\u753b\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u30b5\u30a4\u30c9\u306etopojson\u306b\u306f\u8aad\u307f\u8fbc\u3093\u3060&hellip;<\/p>\n","protected":false},"author":1,"featured_media":4409,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[69],"tags":[],"class_list":["post-4408","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-d3v4","has-post-thumbnail-archive"],"_links":{"self":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts\/4408","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/comments?post=4408"}],"version-history":[{"count":1,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts\/4408\/revisions"}],"predecessor-version":[{"id":5647,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts\/4408\/revisions\/5647"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/media\/4409"}],"wp:attachment":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/media?parent=4408"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/categories?post=4408"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/tags?post=4408"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}