@@ -55,6 +55,8 @@ export interface LocationMeasurementProps extends MeasurementProps {
55
55
56
56
/** Formatting properties for location measurement. */
57
57
export interface LocationMeasurementFormattingProps {
58
+ /** Defaults to "AecUnits.LENGTH_COORDINATE" and "Units.M" */
59
+ coordinate ?: MeasurementFormattingProps ;
58
60
/** Defaults to "AecUnits.LENGTH" and "Units.M" */
59
61
length ?: MeasurementFormattingProps ;
60
62
/** Defaults to "RoadRailUnits.STATION" and "Units.M" */
@@ -105,6 +107,8 @@ export class LocationMeasurement extends Measurement {
105
107
106
108
private _textMarker ?: TextMarker ; // No serialize
107
109
private _isDynamic : boolean ; // No serialize
110
+ private _coordinateKoQ : string ;
111
+ private _coordinatePersistenceUnitName : string ;
108
112
private _lengthKoQ : string ;
109
113
private _lengthPersistenceUnitName : string ;
110
114
private _stationKoQ : string ;
@@ -158,6 +162,21 @@ export class LocationMeasurement extends Measurement {
158
162
if ( this . _textMarker ) this . _textMarker . pickable = ! v ;
159
163
}
160
164
165
+ public get coordinateKoQ ( ) : string {
166
+ return this . _coordinateKoQ ;
167
+ }
168
+ public set coordinateKoQ ( value : string ) {
169
+ this . _coordinateKoQ = value ;
170
+ this . createTextMarker ( ) . catch ( ) ; // eslint-disable-line @typescript-eslint/no-floating-promises
171
+ }
172
+ public get coordinatePersistenceUnitName ( ) : string {
173
+ return this . _coordinatePersistenceUnitName ;
174
+ }
175
+ public set coordinatePersistenceUnitName ( value : string ) {
176
+ this . _coordinatePersistenceUnitName = value ;
177
+ this . createTextMarker ( ) . catch ( ) ; // eslint-disable-line @typescript-eslint/no-floating-promises
178
+ }
179
+
161
180
public get lengthKoQ ( ) : string {
162
181
return this . _lengthKoQ ;
163
182
}
@@ -204,6 +223,8 @@ export class LocationMeasurement extends Measurement {
204
223
205
224
this . _location = Point3d . createZero ( ) ;
206
225
this . _isDynamic = false ;
226
+ this . _coordinateKoQ = "AecUnits.LENGTH_COORDINATE" ;
227
+ this . _coordinatePersistenceUnitName = "Units.M" ;
207
228
this . _lengthKoQ = "AecUnits.LENGTH" ;
208
229
this . _lengthPersistenceUnitName = "Units.M" ;
209
230
this . _stationKoQ = "RoadRailUnits.STATION" ;
@@ -272,6 +293,13 @@ export class LocationMeasurement extends Measurement {
272
293
}
273
294
274
295
public override async populateFormattingSpecsRegistry ( _force ?: boolean ) : Promise < void > {
296
+ const coordinateEntry = IModelApp . quantityFormatter . getSpecsByName ( this . _coordinateKoQ ) ;
297
+ if ( _force || ! coordinateEntry || coordinateEntry . formatterSpec . persistenceUnit ?. name !== this . _coordinatePersistenceUnitName ) {
298
+ const coordinateFormatProps = await IModelApp . formatsProvider . getFormat ( this . _coordinateKoQ ) ;
299
+ if ( coordinateFormatProps ) {
300
+ await IModelApp . quantityFormatter . addFormattingSpecsToRegistry ( this . _coordinateKoQ , this . _coordinatePersistenceUnitName , coordinateFormatProps ) ;
301
+ }
302
+ }
275
303
const lengthEntry = IModelApp . quantityFormatter . getSpecsByName ( this . _lengthKoQ ) ;
276
304
if ( _force || ! lengthEntry || lengthEntry . formatterSpec . persistenceUnit ?. name !== this . _lengthPersistenceUnitName ) {
277
305
const lengthFormatProps = await IModelApp . formatsProvider . getFormat ( this . _lengthKoQ ) ;
@@ -320,26 +348,26 @@ export class LocationMeasurement extends Measurement {
320
348
321
349
private async createTextMarker ( ) : Promise < void > {
322
350
const adjustedLocation = this . adjustPointWithSheetToWorldTransform ( this . adjustPointForGlobalOrigin ( this . _location ) ) ;
323
- const lengthSpec = IModelApp . quantityFormatter . getSpecsByName ( this . _lengthKoQ ) ?. formatterSpec ;
351
+ const coordinateSpec = IModelApp . quantityFormatter . getSpecsByName ( this . _coordinateKoQ ) ?. formatterSpec ;
324
352
325
353
const entries = [
326
354
{
327
355
label : MeasureTools . localization . getLocalizedString (
328
356
"MeasureTools:tools.MeasureLocation.coordinate_x"
329
357
) ,
330
- value : await FormatterUtils . formatLength ( adjustedLocation . x , lengthSpec ) ,
358
+ value : await FormatterUtils . formatLength ( adjustedLocation . x , coordinateSpec ) ,
331
359
} ,
332
360
{
333
361
label : MeasureTools . localization . getLocalizedString (
334
362
"MeasureTools:tools.MeasureLocation.coordinate_y"
335
363
) ,
336
- value : await FormatterUtils . formatLength ( adjustedLocation . y , lengthSpec ) ,
364
+ value : await FormatterUtils . formatLength ( adjustedLocation . y , coordinateSpec ) ,
337
365
} ,
338
366
{
339
367
label : MeasureTools . localization . getLocalizedString (
340
368
"MeasureTools:tools.MeasureLocation.coordinate_z"
341
369
) ,
342
- value : await FormatterUtils . formatLength ( adjustedLocation . z , lengthSpec ) ,
370
+ value : await FormatterUtils . formatLength ( adjustedLocation . z , coordinateSpec ) ,
343
371
} ,
344
372
] ;
345
373
@@ -376,12 +404,13 @@ export class LocationMeasurement extends Measurement {
376
404
protected override async getDataForMeasurementWidgetInternal ( ) : Promise <
377
405
MeasurementWidgetData | undefined
378
406
> {
407
+ const coordinateSpec = IModelApp . quantityFormatter . getSpecsByName ( this . _coordinateKoQ ) ?. formatterSpec ;
379
408
const lengthSpec = IModelApp . quantityFormatter . getSpecsByName ( this . _lengthKoQ ) ?. formatterSpec ;
380
409
const angleSpec = IModelApp . quantityFormatter . getSpecsByName ( this . _angleKoQ ) ?. formatterSpec ;
381
410
const stationSpec = IModelApp . quantityFormatter . getSpecsByName ( this . _stationKoQ ) ?. formatterSpec ;
382
411
383
412
const adjustedLocation = this . adjustPointWithSheetToWorldTransform ( this . adjustPointForGlobalOrigin ( this . _location ) ) ;
384
- const fCoordinates = FormatterUtils . formatCoordinatesImmediate ( adjustedLocation , lengthSpec ) ;
413
+ const fCoordinates = FormatterUtils . formatCoordinatesImmediate ( adjustedLocation , coordinateSpec ) ;
385
414
386
415
let title = MeasureTools . localization . getLocalizedString (
387
416
"MeasureTools:Measurements.locationMeasurement"
@@ -416,7 +445,7 @@ export class LocationMeasurement extends Measurement {
416
445
"MeasureTools:tools.MeasureLocation.altitude"
417
446
) ,
418
447
name : "LocationMeasurement_Altitude" ,
419
- value : await FormatterUtils . formatLength ( adjustedLocation . z , lengthSpec ) ,
448
+ value : await FormatterUtils . formatLength ( adjustedLocation . z , coordinateSpec ) ,
420
449
} ) ;
421
450
}
422
451
if ( this . drawingMetadata ?. sheetToWorldTransform === undefined ) {
@@ -566,6 +595,10 @@ export class LocationMeasurement extends Measurement {
566
595
this . _geoLocation = Cartographic . fromRadians ( jsonLoc . geoLocation ) ;
567
596
else this . _geoLocation = undefined ;
568
597
598
+ if ( jsonLoc . formatting ?. coordinate ?. koqName ) this . _coordinateKoQ = jsonLoc . formatting . coordinate . koqName ;
599
+ if ( jsonLoc . formatting ?. coordinate ?. persistenceUnitName )
600
+ this . _coordinatePersistenceUnitName = jsonLoc . formatting . coordinate . persistenceUnitName ;
601
+
569
602
if ( jsonLoc . formatting ?. length ?. koqName ) this . _lengthKoQ = jsonLoc . formatting . length . koqName ;
570
603
if ( jsonLoc . formatting ?. length ?. persistenceUnitName )
571
604
this . _lengthPersistenceUnitName = jsonLoc . formatting . length . persistenceUnitName ;
@@ -609,6 +642,10 @@ export class LocationMeasurement extends Measurement {
609
642
jsonLoc . station = this . _station ;
610
643
jsonLoc . offset = this . _offset ;
611
644
jsonLoc . formatting = {
645
+ coordinate : {
646
+ koqName : this . _coordinateKoQ ,
647
+ persistenceUnitName : this . _coordinatePersistenceUnitName ,
648
+ } ,
612
649
length : {
613
650
koqName : this . _lengthKoQ ,
614
651
persistenceUnitName : this . _lengthPersistenceUnitName ,
0 commit comments