Replies: 2 comments
-
2022/12/19の検討内容
検討2つの変換パターンがある
import { ElevationLevel as el} from 'ElevationLevel';
const option = {
TP: '0.0',
FL: '2.0',
// GL: '3.0'
}
const foo = new el({option})
console.log(foo.get('FL'))
// foo.get('GL')
// Error GL is not defined
import { toFL } from 'ElevationLevel';
const foo = toFl({ GL: { TP: 2.0}}, {GL: 3.0}) 標高基準(TPとかGL)の変換加算ELと数字の足し算(ELが戻る)const foo : el = new el({ "TP" : 1.0 });
const bar : el = foo.add(12.5);
console.log(bar.get("TP")); //13.5 EL同士の足し算(数字が戻る)const foo : el = new el({ "TP" : 1.0 });
const bar : el = new el({ "TP" : 12.5 });
const hoge : Decimal = foo.add(bar);
console.log(hoge.toNumber()); // 13.5 減算ELから数字を引く(ELが戻る)const foo : el = new el({ "TP" : 1.0 });
const bar : el = foo.sub(12.5);
console.log(bar.get("TP")); //-11.5 (絶対値がいい) EL同士の足し算const foo : el = new el({ "TP" : 1.0 });
const bar : el = new el({ "TP" : 12.5 });
const hoge : Decimal = foo.add(bar);
console.log(hoge.toNumber()); // 13.5 |
Beta Was this translation helpful? Give feedback.
0 replies
-
2022/12/20の検討 // 標高
interface ElevationLevel {
level: Decimal; // 1.0
standard: string; // "TP"
}
// 変換オプション
// 例: GL=TP+10.0 GL=TP+12.0 Option { TP: 0.0, GL: -10.0, FL: -12.0 }
interface ElcOption{
[id: string]: number;
}
// 変換用クラス
class ElConverter{ ... } 仕様イメージ // 使用イメージ(宣言)
el: ElevationLevel = {
ev: Decimal(1.0)
lv: "TP"
}
option: ElcOption = {
TP: 0.0,
GL: -10.0,
} // GL=TP+10.0
// 値を変換して取得
elc = ElConverter(option)
elc.get(el, "TP") //→TPに変換して返す→Decimal(1.0)
elc.get(el, "GL") //→GLに変換して返す→Decimal(11.0)
elc.get(el) //→el.lvがTPなので、TPで返す→Decimal(1.0)
// 足し算
el1 = ElevationLevel(Decimal(1.0), "TP")
el2 = ElevationLevel(Decimal(5.0), "GL") // = TP+10
elc.add(el1, el2, "TP") //→Decimalで返す→Decimal(16.0)
elc.add(el1, 10.0, "TP") //→ElevationLevelで返す→{ev: 11.0, lv: "TP"}
// 引き算
elc.sub(el1, el2, "TP") //→Decimalで返す→Decimal(-14.0)
els.sub(el1, 10.0, "TP") //→ElevationLevelで返す→{ev: .0, lv: "TP"} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
使用の検討
Beta Was this translation helpful? Give feedback.
All reactions