1717 * under the License. */
1818
1919import { wrapToTau } from '../geometry' ;
20- import { Coordinate , Distance , Pixels , Radian , Radius , RingSector } from '../types/geometry_types' ;
20+ import { Coordinate , Distance , Pixels , Radian , Radius , Ratio , RingSector } from '../types/geometry_types' ;
2121import { Config } from '../types/config_types' ;
2222import { logarithm , TAU , trueBearingToStandardPositionAngle } from '../utils/math' ;
2323import {
@@ -172,6 +172,26 @@ export function getSectorRowGeometry(
172172 return { rowCentroidX, rowCentroidY, maximumRowLength } ;
173173}
174174
175+ function getVerticalAlignment (
176+ container : RectangleConstruction ,
177+ verticalAlignment : VerticalAlignment ,
178+ linePitch : Pixels ,
179+ totalRowCount : number ,
180+ rowIndex : number ,
181+ padding : Pixels ,
182+ fontSize : Pixels ,
183+ overhang : Ratio ,
184+ ) {
185+ switch ( verticalAlignment ) {
186+ case VerticalAlignments . top :
187+ return - ( container . y0 + linePitch * rowIndex + padding + fontSize * overhang ) ;
188+ case VerticalAlignments . bottom :
189+ return - ( container . y1 - linePitch * ( totalRowCount - 1 - rowIndex ) - fontSize * overhang ) ;
190+ default :
191+ return - ( ( container . y0 + container . y1 ) / 2 + ( linePitch * ( rowIndex - totalRowCount ) ) / 2 ) ;
192+ }
193+ }
194+
175195/** @internal */
176196export function getRectangleRowGeometry (
177197 container : RectangleConstruction ,
@@ -193,12 +213,16 @@ export function getRectangleRowGeometry(
193213 maximumRowLength : 0 ,
194214 } ;
195215 }
196- const rowCentroidY =
197- verticalAlignment === VerticalAlignments . top
198- ? - ( container . y0 + linePitch * rowIndex + padding + fontSize * overhang )
199- : verticalAlignment === VerticalAlignments . bottom
200- ? - ( container . y1 - linePitch * ( totalRowCount - 1 - rowIndex ) - fontSize * overhang )
201- : - ( ( container . y0 + container . y1 ) / 2 + ( linePitch * ( rowIndex - totalRowCount ) ) / 2 ) ;
216+ const rowCentroidY = getVerticalAlignment (
217+ container ,
218+ verticalAlignment ,
219+ linePitch ,
220+ totalRowCount ,
221+ rowIndex ,
222+ padding ,
223+ fontSize ,
224+ overhang ,
225+ ) ;
202226 return {
203227 rowCentroidX : cx ,
204228 rowCentroidY,
0 commit comments