@@ -3,10 +3,18 @@ d3.geo.centroid = function(object) {
33} ;
44
55var d3_geo_centroidType = d3_geo_type ( {
6+
67 FeatureCollection : d3_noop ,
78 GeometryCollection : d3_noop ,
8- Feature : function ( feature ) { return this . geometry ( feature . geometry ) ; } ,
9- Point : function ( point ) { return point . coordinates ; } ,
9+
10+ Feature : function ( feature ) {
11+ return this . geometry ( feature . geometry ) ;
12+ } ,
13+
14+ Point : function ( point ) {
15+ return point . coordinates ;
16+ } ,
17+
1018 MultiPoint : function ( multiPoint ) {
1119 var coordinates = multiPoint . coordinates ,
1220 n = coordinates . length ,
@@ -31,6 +39,7 @@ var d3_geo_centroidType = d3_geo_type({
3139 Math . asin ( Math . max ( - 1 , Math . min ( 1 , z ) ) ) * d3_degrees
3240 ] : null ;
3341 } ,
42+
3443 LineString : function ( line ) {
3544 var centroid = d3_geo_centroidLine ( line . coordinates ) ,
3645 cx ,
@@ -41,6 +50,7 @@ var d3_geo_centroidType = d3_geo_type({
4150 Math . asin ( Math . max ( - 1 , Math . min ( 1 , ( cz = centroid [ 2 ] ) / Math . sqrt ( cx * cx + cy * cy + cz * cz ) ) ) ) * d3_degrees
4251 ] : null ;
4352 } ,
53+
4454 MultiLineString : function ( multiLine ) {
4555 var coordinates = multiLine . coordinates ,
4656 n = coordinates . length ,
@@ -62,12 +72,14 @@ var d3_geo_centroidType = d3_geo_type({
6272 Math . asin ( Math . max ( - 1 , Math . min ( 1 , cz / Math . sqrt ( cx * cx + cy * cy + cz * cz ) ) ) ) * d3_degrees
6373 ] : null ;
6474 } ,
75+
76+ // TODO use area weighting
6577 Polygon : function ( polygon ) {
66- // TODO use area weighting
6778 return this . MultiLineString ( polygon ) ;
6879 } ,
80+
81+ // TODO use area weighting
6982 MultiPolygon : function ( multiPolygon ) {
70- // TODO use area weighting
7183 var coordinates = multiPolygon . coordinates ,
7284 n = coordinates . length ,
7385 i = - 1 ,
0 commit comments