mirror of
https://github.com/Myzel394/NumberHub.git
synced 2025-06-18 16:25:27 +02:00
Added luminance (#29)
This commit is contained in:
parent
6ed66e761d
commit
2f87448ab3
@ -1161,6 +1161,45 @@
|
||||
<string name="gallon_per_second_imperial">Gallon/second (Imperial)</string>
|
||||
<string name="gallon_per_second_imperial_short">gal/s</string>
|
||||
|
||||
<!--Luminance-->
|
||||
<string name="candela_per_square_meter">Candela/square meter</string>
|
||||
<string name="candela_per_square_meter_short">cd/m^2</string>
|
||||
<string name="candela_per_square_centimeter">Candela/square centimeter</string>
|
||||
<string name="candela_per_square_centimeter_short">cd/cm^2</string>
|
||||
<string name="candela_per_square_foot">Candela/square foot</string>
|
||||
<string name="candela_per_square_foot_short">cd/ft^2</string>
|
||||
<string name="candela_per_square_inch">Candela/square inch</string>
|
||||
<string name="candela_per_square_inch_short">cd/in^2</string>
|
||||
<string name="kilocandela_per_square_meter">Kilocandela/square meter</string>
|
||||
<string name="kilocandela_per_square_meter_short">kcd</string>
|
||||
<string name="stilb">Stilb</string>
|
||||
<string name="stilb_short">sb</string>
|
||||
<string name="lumen_per_square_meter_per_steradian">Lumen/square meter/steradian</string>
|
||||
<string name="lumen_per_square_meter_per_steradian_short">lm/m^2/sr</string>
|
||||
<string name="lumen_per_square_centimeter_per_steradian">Lumen/square centimeter/steradian</string>
|
||||
<string name="lumen_per_square_centimeter_per_steradian_short">lm/cm^2/sr</string>
|
||||
<string name="lumen_per_square_foot_per_steradian">Lumen/square foot/steradian</string>
|
||||
<string name="lumen_per_square_foot_per_steradian_short">lm/ft^2/sr</string>
|
||||
<string name="watt_per_square_centimeter_per_steradian">Watt/square centimeter/steradian</string>
|
||||
<string name="watt_per_square_centimeter_per_steradian_short">W/cm^2/sr</string>
|
||||
<string name="nit">Nit</string>
|
||||
<string name="nit_short">nt</string>
|
||||
<string name="millinit">Millinit</string>
|
||||
<string name="millinit_short">mnt</string>
|
||||
<string name="lambert">Lambert</string>
|
||||
<string name="lambert_short">L</string>
|
||||
<string name="millilambert">Millilambert</string>
|
||||
<string name="millilambert_short">mL</string>
|
||||
<string name="foot_lambert">Foot-lambert</string>
|
||||
<string name="foot_lambert_short">fL</string>
|
||||
<string name="apostilb">Apostilb</string>
|
||||
<string name="apostilb_short">asb</string>
|
||||
<string name="blondel">Blondel</string>
|
||||
<string name="blondel_short">blondel</string>
|
||||
<string name="bril">Bril</string>
|
||||
<string name="bril_short">bril</string>
|
||||
<string name="skot">Skot</string>
|
||||
<string name="skot_short">sk</string>
|
||||
|
||||
<!--Groups-->
|
||||
<string name="length">Length</string>
|
||||
@ -1185,6 +1224,7 @@
|
||||
<string name="force">Force</string>
|
||||
<string name="torque">Torque</string>
|
||||
<string name="flow_rate">Flow</string>
|
||||
<string name="luminance">Luminance</string>
|
||||
|
||||
<!--Screen names-->
|
||||
<string name="units_screen_from">Convert from</string>
|
||||
|
@ -53,4 +53,5 @@ enum class UnitGroup(
|
||||
FORCE(res = R.string.force),
|
||||
TORQUE(res = R.string.torque),
|
||||
FLOW_RATE(res = R.string.flow_rate),
|
||||
LUMINANCE(res = R.string.luminance),
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ import com.sadellie.unitto.data.units.collections.flowRateCollection
|
||||
import com.sadellie.unitto.data.units.collections.fluxCollection
|
||||
import com.sadellie.unitto.data.units.collections.forceCollection
|
||||
import com.sadellie.unitto.data.units.collections.lengthCollection
|
||||
import com.sadellie.unitto.data.units.collections.luminanceCollection
|
||||
import com.sadellie.unitto.data.units.collections.massCollection
|
||||
import com.sadellie.unitto.data.units.collections.numberBaseCollection
|
||||
import com.sadellie.unitto.data.units.collections.powerCollection
|
||||
|
@ -616,4 +616,25 @@ object MyUnitIDS {
|
||||
const val gallons_per_hour_imperial = "gallons_per_hour_imperial"
|
||||
const val gallons_per_minute_imperial = "gallons_per_minute_imperial"
|
||||
const val gallons_per_second_imperial = "gallons_per_second_imperial"
|
||||
|
||||
// LUMINANCE
|
||||
const val candela_per_square_meter = "candela_per_square_meter"
|
||||
const val candela_per_square_centimeter = "candela_per_square_centimeter"
|
||||
const val candela_per_square_foot = "candela_per_square_foot"
|
||||
const val candela_per_square_inch = "candela_per_square_inch"
|
||||
const val kilocandela_per_square_meter = "kilocandela_per_square_meter"
|
||||
const val stilb = "stilb"
|
||||
const val lumen_per_square_meter_per_steradian = "lumen_per_square_meter_per_steradian"
|
||||
const val lumen_per_square_centimeter_per_steradian = "lumen_per_square_centimeter_per_steradian"
|
||||
const val lumen_per_square_foot_per_steradian = "lumen_per_square_foot_per_steradian"
|
||||
const val watt_per_square_centimeter_per_steradian = "watt_per_square_centimeter_per_steradian"
|
||||
const val nit = "nit"
|
||||
const val millinit = "millinit"
|
||||
const val lambert = "lambert"
|
||||
const val millilambert = "millilambert"
|
||||
const val foot_lambert = "foot_lambert"
|
||||
const val apostilb = "apostilb"
|
||||
const val blondel = "blondel"
|
||||
const val bril = "bril"
|
||||
const val skot = "skot"
|
||||
}
|
||||
|
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Unitto is a unit converter for Android
|
||||
* Copyright (c) 2023 Elshan Agaev
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sadellie.unitto.data.units.collections
|
||||
|
||||
import com.sadellie.unitto.data.model.AbstractUnit
|
||||
import com.sadellie.unitto.data.model.DefaultUnit
|
||||
import com.sadellie.unitto.data.model.UnitGroup
|
||||
import com.sadellie.unitto.data.units.MyUnitIDS
|
||||
import com.sadellie.unitto.data.units.R
|
||||
import java.math.BigDecimal
|
||||
|
||||
val luminanceCollection: List<AbstractUnit> by lazy {
|
||||
listOf(
|
||||
DefaultUnit(MyUnitIDS.candela_per_square_meter, BigDecimal.valueOf(31415926.5359), UnitGroup.LUMINANCE, R.string.candela_per_square_meter, R.string.candela_per_square_meter_short),
|
||||
DefaultUnit(MyUnitIDS.candela_per_square_centimeter, BigDecimal.valueOf(314159265359), UnitGroup.LUMINANCE, R.string.candela_per_square_centimeter, R.string.candela_per_square_centimeter_short),
|
||||
DefaultUnit(MyUnitIDS.candela_per_square_foot, BigDecimal.valueOf(338158218.89), UnitGroup.LUMINANCE, R.string.candela_per_square_foot, R.string.candela_per_square_foot_short),
|
||||
DefaultUnit(MyUnitIDS.candela_per_square_inch, BigDecimal.valueOf(48694783520), UnitGroup.LUMINANCE, R.string.candela_per_square_inch, R.string.candela_per_square_inch_short),
|
||||
DefaultUnit(MyUnitIDS.kilocandela_per_square_meter, BigDecimal.valueOf(31415926535.9), UnitGroup.LUMINANCE, R.string.kilocandela_per_square_meter, R.string.kilocandela_per_square_meter_short),
|
||||
DefaultUnit(MyUnitIDS.stilb, BigDecimal.valueOf(314159265359), UnitGroup.LUMINANCE, R.string.stilb, R.string.stilb_short),
|
||||
DefaultUnit(MyUnitIDS.lumen_per_square_meter_per_steradian, BigDecimal.valueOf(31415926.5359), UnitGroup.LUMINANCE, R.string.lumen_per_square_meter_per_steradian, R.string.lumen_per_square_meter_per_steradian_short),
|
||||
DefaultUnit(MyUnitIDS.lumen_per_square_centimeter_per_steradian, BigDecimal.valueOf(314159265359), UnitGroup.LUMINANCE, R.string.lumen_per_square_centimeter_per_steradian, R.string.lumen_per_square_centimeter_per_steradian_short),
|
||||
DefaultUnit(MyUnitIDS.lumen_per_square_foot_per_steradian, BigDecimal.valueOf(338158218.89), UnitGroup.LUMINANCE, R.string.lumen_per_square_foot_per_steradian, R.string.lumen_per_square_foot_per_steradian_short),
|
||||
DefaultUnit(MyUnitIDS.watt_per_square_centimeter_per_steradian, BigDecimal.valueOf(214570778240185), UnitGroup.LUMINANCE, R.string.watt_per_square_centimeter_per_steradian, R.string.watt_per_square_centimeter_per_steradian_short),
|
||||
DefaultUnit(MyUnitIDS.nit, BigDecimal.valueOf(31415926.5359), UnitGroup.LUMINANCE, R.string.nit, R.string.nit_short),
|
||||
DefaultUnit(MyUnitIDS.millinit, BigDecimal.valueOf(31415.9265359), UnitGroup.LUMINANCE, R.string.millinit, R.string.millinit_short),
|
||||
DefaultUnit(MyUnitIDS.lambert, BigDecimal.valueOf(100000000000), UnitGroup.LUMINANCE, R.string.lambert, R.string.lambert_short),
|
||||
DefaultUnit(MyUnitIDS.millilambert, BigDecimal.valueOf(100000000), UnitGroup.LUMINANCE, R.string.millilambert, R.string.millilambert_short),
|
||||
DefaultUnit(MyUnitIDS.foot_lambert, BigDecimal.valueOf(107639104.167), UnitGroup.LUMINANCE, R.string.foot_lambert, R.string.foot_lambert_short),
|
||||
DefaultUnit(MyUnitIDS.apostilb, BigDecimal.valueOf(10000000), UnitGroup.LUMINANCE, R.string.apostilb, R.string.apostilb_short),
|
||||
DefaultUnit(MyUnitIDS.blondel, BigDecimal.valueOf(10000000), UnitGroup.LUMINANCE, R.string.blondel, R.string.blondel_short),
|
||||
DefaultUnit(MyUnitIDS.skot, BigDecimal.valueOf(10000), UnitGroup.LUMINANCE, R.string.skot, R.string.skot_short),
|
||||
DefaultUnit(MyUnitIDS.bril, BigDecimal.valueOf(1), UnitGroup.LUMINANCE, R.string.bril, R.string.bril_short),
|
||||
)
|
||||
}
|
@ -485,6 +485,29 @@ class AllUnitsTest {
|
||||
gallons_per_second_imperial.checkWith(cubic_meter_per_minute, "312", "85.1028")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testLuminance() = testWithUnits {
|
||||
candela_per_square_meter.checkWith(lumen_per_square_foot_per_steradian, "6723", "624.58714")
|
||||
candela_per_square_centimeter.checkWith(candela_per_square_inch, "6723", "43374.1068")
|
||||
candela_per_square_foot.checkWith(apostilb, "6723", "227343.77056")
|
||||
candela_per_square_inch.checkWith(lumen_per_square_centimeter_per_steradian, "6723", "1042.06708")
|
||||
kilocandela_per_square_meter.checkWith(lambert, "6723", "2112.09274")
|
||||
stilb.checkWith(blondel, "6723", "211209274.10086")
|
||||
lumen_per_square_meter_per_steradian.checkWith(lumen_per_square_centimeter_per_steradian, "6723", "0.6723")
|
||||
lumen_per_square_centimeter_per_steradian.checkWith(millilambert, "6723", "21120927.41009")
|
||||
lumen_per_square_foot_per_steradian.checkWith(skot, "6723", "227343770.55975")
|
||||
watt_per_square_centimeter_per_steradian.checkWith(stilb, "6723", "4591809")
|
||||
nit.checkWith(candela_per_square_foot, "6723", "624.58714")
|
||||
millinit.checkWith(lumen_per_square_foot_per_steradian, "6723", "0.62459")
|
||||
lambert.checkWith(foot_lambert, "6723", "6245871.37921")
|
||||
millilambert.checkWith(apostilb, "6723", "67230")
|
||||
foot_lambert.checkWith(watt_per_square_centimeter_per_steradian, "6723", "0.00337")
|
||||
apostilb.checkWith(kilocandela_per_square_meter, "6723", "2.14")
|
||||
blondel.checkWith(candela_per_square_centimeter, "6723", "0.214")
|
||||
bril.checkWith(skot, "6723", "0.6723")
|
||||
skot.checkWith(lumen_per_square_meter_per_steradian, "6723", "2.14")
|
||||
}
|
||||
|
||||
private fun String.checkWith(checkingId: String, value: String, expected: String) {
|
||||
val unitFrom = allUnitsRepository.getById(this)
|
||||
val unitTo = allUnitsRepository.getById(checkingId)
|
||||
|
Loading…
x
Reference in New Issue
Block a user