* Returns a localized representation of the given area measurement. * * @param {Number} meters2 area in square meters * @param {Boolean} isImperial true for U.S. customary units; false for metric * @return {string} Text to display
(meters2, isImperial)
| 743 | * @return {string} Text to display |
| 744 | */ |
| 745 | displayArea(meters2, isImperial) { |
| 746 | const locale = this._currLocaleCode; |
| 747 | let n = meters2 * (isImperial ? 10.7639111056 : 1); |
| 748 | let n1, n2, unit1, unit2; |
| 749 | |
| 750 | if (isImperial) { |
| 751 | if (n >= 6969600) { // > 0.25mi² show mi² |
| 752 | n1 = n / 27878400; |
| 753 | unit1 = 'square_miles'; |
| 754 | } else { |
| 755 | n1 = n; |
| 756 | unit1 = 'square_feet'; |
| 757 | } |
| 758 | |
| 759 | if (n > 4356 && n < 43560000) { // 0.1 - 1000 acres |
| 760 | n2 = n / 43560; |
| 761 | unit2 = 'acres'; |
| 762 | } |
| 763 | |
| 764 | } else { |
| 765 | if (n >= 250000) { // > 0.25km² show km² |
| 766 | n1 = n / 1000000; |
| 767 | unit1 = 'square_kilometers'; |
| 768 | } else { |
| 769 | n1 = n; |
| 770 | unit1 = 'square_meters'; |
| 771 | } |
| 772 | |
| 773 | if (n > 1000 && n < 10000000) { // 0.1 - 1000 hectares |
| 774 | n2 = n / 10000; |
| 775 | unit2 = 'hectares'; |
| 776 | } |
| 777 | } |
| 778 | |
| 779 | const area = this.t(`units.${unit1}`, { |
| 780 | quantity: n1.toLocaleString(locale, { maximumSignificantDigits: 4 }) |
| 781 | }); |
| 782 | |
| 783 | if (unit2) { |
| 784 | const area2 = this.t(`units.${unit2}`, { |
| 785 | quantity: n2.toLocaleString(locale, { maximumSignificantDigits: 2 }) |
| 786 | }); |
| 787 | |
| 788 | return this.t('units.area_pair', { area1: area, area2: area2 }); |
| 789 | } else { |
| 790 | return area; |
| 791 | } |
| 792 | } |
| 793 | |
| 794 | |
| 795 | /** |