Coordinate
… 座標を格納するクラス
CoordinateList
… 座標リストを格納するクラス
const c1 = new Coordinate([['x', 1], ['y', 2]]);
console.log(JSON.stringify(c1)); // {"dimensionName":"x y","x":1,"y":2}
console.log(c1.keys()); // ["x", "y"]
console.log(c1.values()); // [1, 2]
console.log(c1.entries()); // [["x", 1],["y", 2]]
c1.set([' y ', 3]);
console.log(c1.entries()); // [["x", 1],["y", 3]]
c1.set(['z', 4]);
console.log(c1.entries()); // [["x", 1],["y", 3],["y", 4]]
new Coordinate([['x', 'foo']]); // TypeError: foo is not a number
new Coordinate([['x y', 1]]); // Error: Do not include white-spaces in the "key": x y
const list = new CoordinateList([[['x', 1], ['y', 2]], [['x', 2], ['y', 3]], [['x', 3], ['y', 4]]]);
console.log(JSON.stringify(list)); // {"dimensionName":"x y","item":[{"dimensionName":"x y","x":1,"y":2},{"dimensionName":"x y","x":2,"y":3},{"dimensionName":"x y","x":3,"y":4}]}
console.log(list.entries()); // [[["x",1],["y",2]],[["x",2],["y",3]],[["x",3],["y",4]]]
console.log(list.getCenter()); // Coordinate {dimensionName: "x y", x: 2, y: 3,...} (中心座標を返す)
new CoordinateList([[['x', 1], ['y', 2]], [['z', 1], ['t', 2]]]); // Error: All coordinate.dimensionName must be identical