@@ -110,52 +110,40 @@ export function Projection(
110110 return { stream : ( s ) => projection . stream ( transform . stream ( clip ( s ) ) ) , ratio} ;
111111}
112112
113- // When a projection is specified, try to determine a good value for the
114- // projection’s height, if it is a named projection. When we don’t have a way to
115- // know, the golden ratio is our best guess.
116- export function projectionAspectRatio ( { projection} = { } , geometry ) {
117- projection = Projection (
118- { projection} ,
119- { width : 100 , height : 300 , marginLeft : 0 , marginRight : 0 , marginTop : 0 , marginBottom : 0 }
120- ) ;
121- if ( projection == null ) return geometry ? golden - 1 : 0 ;
122- return projection . ratio ?? golden - 1 ;
123- }
124-
125113function namedProjection ( projection ) {
126114 switch ( `${ projection } ` . toLowerCase ( ) ) {
127115 case "albers-usa" :
128- return scaleProjection ( geoAlbersUsa , 0.7463 , 0.4673 ) ;
116+ return scaleProjection ( geoAlbersUsa , 0.7463 , 0.4673 , 610 / 975 ) ;
129117 case "albers" :
130- return conicProjection ( geoAlbers , 0.7463 , 0.4673 ) ;
118+ return conicProjection ( geoAlbers , 0.7463 , 0.4673 , 610 / 975 ) ;
131119 case "azimuthal-equal-area" :
132- return scaleProjection ( geoAzimuthalEqualArea , 4 , 4 ) ;
120+ return scaleProjection ( geoAzimuthalEqualArea , 4 , 4 , 1 ) ;
133121 case "azimuthal-equidistant" :
134- return scaleProjection ( geoAzimuthalEquidistant , tau , tau ) ;
122+ return scaleProjection ( geoAzimuthalEquidistant , tau , tau , 1 ) ;
135123 case "conic-conformal" :
136124 return conicProjection ( geoConicConformal , tau , tau ) ;
137125 case "conic-equal-area" :
138126 return conicProjection ( geoConicEqualArea , 6.1702 , 2.9781 ) ;
139127 case "conic-equidistant" :
140128 return conicProjection ( geoConicEquidistant , 7.312 , 3.6282 ) ;
141129 case "equal-earth" :
142- return scaleProjection ( geoEqualEarth , 5.4133 , 2.6347 ) ;
130+ return scaleProjection ( geoEqualEarth , 5.4133 , 2.6347 , 0.4867 ) ;
143131 case "equirectangular" :
144- return scaleProjection ( geoEquirectangular , tau , pi ) ;
132+ return scaleProjection ( geoEquirectangular , tau , pi , 0.5 ) ;
145133 case "gnomonic" :
146- return scaleProjection ( geoGnomonic , 3.4641 , 3.4641 ) ;
134+ return scaleProjection ( geoGnomonic , 3.4641 , 3.4641 , 1 ) ;
147135 case "identity" :
148136 return identity ;
149137 case "reflect-y" :
150138 return reflectY ;
151139 case "mercator" :
152140 return scaleProjection ( geoMercator , tau , tau , 1 ) ;
153141 case "orthographic" :
154- return scaleProjection ( geoOrthographic , 2 , 2 ) ;
142+ return scaleProjection ( geoOrthographic , 2 , 2 , 1 ) ;
155143 case "stereographic" :
156- return scaleProjection ( geoStereographic , 2 , 2 ) ;
144+ return scaleProjection ( geoStereographic , 2 , 2 , 1 ) ;
157145 case "transverse-mercator" :
158- return scaleProjection ( geoTransverseMercator , tau , tau ) ;
146+ return scaleProjection ( geoTransverseMercator , tau , tau , 1 ) ;
159147 default :
160148 throw new Error ( `unknown projection type: ${ projection } ` ) ;
161149 }
@@ -226,3 +214,15 @@ export function applyProjection(values, projection) {
226214 stream . point ( x [ i ] , y [ i ] ) ;
227215 }
228216}
217+
218+ // When a projection is specified, try to determine a good value for the
219+ // projection’s height, if it is a named projection. When we don’t have a way to
220+ // know, the golden ratio is our best guess.
221+ export function projectionAspectRatio ( { projection} = { } , geometry ) {
222+ projection = Projection (
223+ { projection} ,
224+ { width : 100 , height : 300 , marginLeft : 0 , marginRight : 0 , marginTop : 0 , marginBottom : 0 }
225+ ) ;
226+ if ( projection == null ) return geometry ? golden - 1 : 0 ;
227+ return projection . ratio ?? golden - 1 ;
228+ }
0 commit comments