@@ -2249,12 +2249,11 @@ d3 = function() {
22492249 listener . sphere ( ) ;
22502250 } ,
22512251 Point : function ( object , listener ) {
2252- var coordinate = object . coordinates ;
2253- listener . point ( coordinate [ 0 ] , coordinate [ 1 ] ) ;
2252+ listener . point . apply ( listener , object . coordinates ) ;
22542253 } ,
22552254 MultiPoint : function ( object , listener ) {
2256- var coordinates = object . coordinates , i = - 1 , n = coordinates . length , coordinate ;
2257- while ( ++ i < n ) coordinate = coordinates [ i ] , listener . point ( coordinate [ 0 ] , coordinate [ 1 ] ) ;
2255+ var coordinates = object . coordinates , i = - 1 , n = coordinates . length ;
2256+ while ( ++ i < n ) listener . point . apply ( listener , coordinates [ i ] ) ;
22582257 } ,
22592258 LineString : function ( object , listener ) {
22602259 d3_geo_streamLine ( object . coordinates , listener , 0 ) ;
@@ -2276,9 +2275,9 @@ d3 = function() {
22762275 }
22772276 } ;
22782277 function d3_geo_streamLine ( coordinates , listener , closed ) {
2279- var i = - 1 , n = coordinates . length - closed , coordinate ;
2278+ var i = - 1 , n = coordinates . length - closed ;
22802279 listener . lineStart ( ) ;
2281- while ( ++ i < n ) coordinate = coordinates [ i ] , listener . point ( coordinate [ 0 ] , coordinate [ 1 ] ) ;
2280+ while ( ++ i < n ) listener . point . apply ( listener , coordinates [ i ] ) ;
22822281 listener . lineEnd ( ) ;
22832282 }
22842283 function d3_geo_streamPolygon ( coordinates , listener ) {
@@ -2287,6 +2286,26 @@ d3 = function() {
22872286 while ( ++ i < n ) d3_geo_streamLine ( coordinates [ i ] , listener , 1 ) ;
22882287 listener . polygonEnd ( ) ;
22892288 }
2289+ function d3_geo_streamTransform ( stream , point ) {
2290+ return {
2291+ point : point ,
2292+ sphere : function ( ) {
2293+ stream . sphere ( ) ;
2294+ } ,
2295+ lineStart : function ( ) {
2296+ stream . lineStart ( ) ;
2297+ } ,
2298+ lineEnd : function ( ) {
2299+ stream . lineEnd ( ) ;
2300+ } ,
2301+ polygonStart : function ( ) {
2302+ stream . polygonStart ( ) ;
2303+ } ,
2304+ polygonEnd : function ( ) {
2305+ stream . polygonEnd ( ) ;
2306+ }
2307+ } ;
2308+ }
22902309 d3 . geo . area = function ( object ) {
22912310 d3_geo_areaSum = 0 ;
22922311 d3 . geo . stream ( object , d3_geo_area ) ;
@@ -3556,31 +3575,13 @@ d3 = function() {
35563575 return path . projection ( d3 . geo . albersUsa ( ) ) . context ( null ) ;
35573576 } ;
35583577 function d3_geo_pathProjectStream ( project ) {
3559- var resample = d3_geo_resample ( function ( λ , φ ) {
3560- return project ( [ λ * d3_degrees , φ * d3_degrees ] ) ;
3578+ var resample = d3_geo_resample ( function ( x , y ) {
3579+ return project ( [ x * d3_degrees , y * d3_degrees ] ) ;
35613580 } ) ;
35623581 return function ( stream ) {
3563- stream = resample ( stream ) ;
3564- return {
3565- point : function ( λ , φ ) {
3566- stream . point ( λ * d3_radians , φ * d3_radians ) ;
3567- } ,
3568- sphere : function ( ) {
3569- stream . sphere ( ) ;
3570- } ,
3571- lineStart : function ( ) {
3572- stream . lineStart ( ) ;
3573- } ,
3574- lineEnd : function ( ) {
3575- stream . lineEnd ( ) ;
3576- } ,
3577- polygonStart : function ( ) {
3578- stream . polygonStart ( ) ;
3579- } ,
3580- polygonEnd : function ( ) {
3581- stream . polygonEnd ( ) ;
3582- }
3583- } ;
3582+ return d3_geo_streamTransform ( stream = resample ( stream ) , function ( x , y ) {
3583+ stream . point ( x * d3_radians , y * d3_radians ) ;
3584+ } ) ;
35843585 } ;
35853586 }
35863587 d3 . geo . projection = d3_geo_projection ;
@@ -3663,27 +3664,10 @@ d3 = function() {
36633664 } ;
36643665 }
36653666 function d3_geo_projectionRadiansRotate ( rotate , stream ) {
3666- return {
3667- point : function ( x , y ) {
3668- y = rotate ( x * d3_radians , y * d3_radians ) , x = y [ 0 ] ;
3669- stream . point ( x > π ? x - 2 * π : x < - π ? x + 2 * π : x , y [ 1 ] ) ;
3670- } ,
3671- sphere : function ( ) {
3672- stream . sphere ( ) ;
3673- } ,
3674- lineStart : function ( ) {
3675- stream . lineStart ( ) ;
3676- } ,
3677- lineEnd : function ( ) {
3678- stream . lineEnd ( ) ;
3679- } ,
3680- polygonStart : function ( ) {
3681- stream . polygonStart ( ) ;
3682- } ,
3683- polygonEnd : function ( ) {
3684- stream . polygonEnd ( ) ;
3685- }
3686- } ;
3667+ return d3_geo_streamTransform ( stream , function ( x , y ) {
3668+ y = rotate ( x * d3_radians , y * d3_radians ) , x = y [ 0 ] ;
3669+ stream . point ( x > π ? x - 2 * π : x < - π ? x + 2 * π : x , y [ 1 ] ) ;
3670+ } ) ;
36873671 }
36883672 function d3_geo_equirectangular ( λ , φ ) {
36893673 return [ λ , φ ] ;
@@ -3953,6 +3937,21 @@ d3 = function() {
39533937 λ0 = λ , sinφ0 = sinφ , cosφ0 = cosφ ;
39543938 }
39553939 }
3940+ d3 . geo . simplify = function ( ) {
3941+ var importance = 1 , simplify = {
3942+ stream : function ( stream ) {
3943+ return d3_geo_streamTransform ( stream , function ( x , y , z ) {
3944+ if ( z >= importance ) stream . point ( x , y ) ;
3945+ } ) ;
3946+ } ,
3947+ importance : function ( _ ) {
3948+ if ( ! arguments . length ) return importance ;
3949+ importance = + _ ;
3950+ return simplify ;
3951+ }
3952+ } ;
3953+ return simplify ;
3954+ } ;
39563955 function d3_geo_azimuthal ( scale , angle ) {
39573956 function azimuthal ( λ , φ ) {
39583957 var cosλ = Math . cos ( λ ) , cosφ = Math . cos ( φ ) , k = scale ( cosλ * cosφ ) ;
0 commit comments