{"url":"https://api.github.com/gists/4260668","forks_url":"https://api.github.com/gists/4260668/forks","commits_url":"https://api.github.com/gists/4260668/commits","id":"4260668","node_id":"MDQ6R2lzdDQyNjA2Njg=","git_pull_url":"https://gist.github.com/4260668.git","git_push_url":"https://gist.github.com/4260668.git","html_url":"https://gist.github.com/mbostock/4260668","files":{"type.js":{"filename":"type.js","type":"text/javascript","language":"JavaScript","raw_url":"https://gist.githubusercontent.com/mbostock/4260668/raw/f7e26422f08fcb333128e552cbcc4308361ab8f3/type.js","size":2987,"truncated":false,"content":"function d3_geo_type(types) {\n  for (var type in d3_geo_typeDefaults) {\n    if (!(type in types)) {\n      types[type] = d3_geo_typeDefaults[type];\n    }\n  }\n  return types;\n}\n\nvar d3_geo_typeDefaults = {\n\n  Feature: function(o) {\n    var g = this.geometry(o.geometry);\n    return g && (o = Object.create(o), o.geometry = g);\n  },\n\n  FeatureCollection: function(o) {\n    var a = [], f, features = o.features, i = -1, n = features.length;\n    while (++i < n) if (f = this.Feature(features[i])) a.push(f);\n    return a.length ? (o = Object.create(o), o.features = a) : null;\n  },\n\n  GeometryCollection: function(o) {\n    var a = [], g, geometries = o.geometries, i = -1, n = geometries.length;\n    while (++i < n) if (g = this.geometry(geometries[i])) a.push(g);\n    return a.length ? (o = Object.create(o), o.geometries = a) : null;\n  },\n\n  LineString: function(o) {\n    var c = this.line(o.coordinates);\n    return c && (o = Object.create(o), o.coordinates = c);\n  },\n\n  MultiLineString: function(o) {\n    var a = [], c, coordinates = o.coordinates, i = -1, n = coordinates.length;\n    while (++i < n) if(c = this.line(coordinates[i])) a.push(c);\n    return a.length ? (o = Object.create(o), o.coordinates = a) : null;\n  },\n\n  MultiPoint: function(o) {\n    var a = [], c, coordinates = o.coordinates, i = -1, n = coordinates.length;\n    while (++i < n) if(c = this.point(coordinates[i])) a.push(c);\n    return a.length ? (o = Object.create(o), o.coordinates = a) : null;\n  },\n\n  MultiPolygon: function(multiPolygon) {\n    var a = [], c, coordinates = o.coordinates, i = -1, n = coordinates.length;\n    while (++i < n) if(c = this.polygon(coordinates[i])) a.push(c);\n    return a.length ? (o = Object.create(o), o.coordinates = a) : null;\n  },\n\n  Point: function(point) {\n    var c = this.point(o.coordinates);\n    return c && (o = Object.create(o), o.coordinates = c);\n  },\n\n  Polygon: function(polygon) {\n    var c = this.polygon(o.coordinates);\n    return c && (o = Object.create(o), o.coordinates = c);\n  },\n\n  Sphere: d3_noop,\n\n  object: function(object) {\n    return d3_geo_typeObjects.hasOwnProperty(object.type)\n        ? this[object.type](object)\n        : this.geometry(object);\n  },\n\n  geometry: function(geometry) {\n    return d3_geo_typeGeometries.hasOwnProperty(geometry.type)\n        ? this[geometry.type](geometry)\n        : null;\n  },\n\n  point: d3_noop,\n\n  line: function(coordinates) {\n    var a = [], c, i = -1, n = coordinates.length;\n    while (++i < n) if(c = this.point(coordinates[i])) a.push(c);\n    return a.length ? a : null;\n  },\n\n  polygon: function(coordinates) {\n    var a = [], c, i = -1, n = coordinates.length;\n    while (++i < n) if(c = this.line(coordinates[i])) a.push(c);\n    return a.length ? a : null;\n  }\n};\n\nvar d3_geo_typeGeometries = {\n  LineString: 1,\n  MultiLineString: 1,\n  MultiPoint: 1,\n  MultiPolygon: 1,\n  Point: 1,\n  Polygon: 1,\n  Sphere: 1\n};\n\nvar d3_geo_typeObjects = {\n  Feature: 1,\n  FeatureCollection: 1,\n  GeometryCollection: 1\n};\n","encoding":"utf-8"}},"public":true,"created_at":"2012-12-11T17:59:51Z","updated_at":"2015-10-13T21:48:17Z","description":"GeoJSON Transforms","comments":0,"user":null,"comments_enabled":true,"comments_url":"https://api.github.com/gists/4260668/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":"0b36c33f5636dd87b8ae496ac09f10d56a4f6548","committed_at":"2012-12-11T18:06:23Z","change_status":{"total":148,"additions":105,"deletions":43},"url":"https://api.github.com/gists/4260668/0b36c33f5636dd87b8ae496ac09f10d56a4f6548"},{"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":"c095de542f0a864ed481c50e7ae99b2b17980b93","committed_at":"2012-12-11T17:59:51Z","change_status":{"total":43,"additions":43,"deletions":0},"url":"https://api.github.com/gists/4260668/c095de542f0a864ed481c50e7ae99b2b17980b93"}],"truncated":false}