Соответственно смысл в том чтобы конвертировать координаты GoogleMaps в 2GIS - тоесть сейчас цифры разные
Это 43.256449960663694 конвертировать в это 43.106491921792255
{
"south": 43.106491921792255,
"west": 76.71745650634767,
"north": 43.4065384633472,
"east": 77.13974349365236
}
{
"northEast": [
43.25695003829279,
76.92894332280319,
],
"southWest": [
43.256449960663694,
76.92825667730312,
]
}
class CompatibleBounds {
northEast = [0, 0];
southWest = [0, 0];
constructor(bounds) {
Object.assign(this, bounds);
}
static new(bounds) {
return new this(bounds);
}
get south(){ return this.southWest[1] }
get west(){ return this.southWest[0] }
get north(){ return this.northEast[1] }
get east(){ return this.northEast[0] }
set south(value){ this.southWest[1] = value }
set west(value){ this.southWest[0] = value }
set north(value){ this.northEast[1] = value }
set east(value){ this.northEast[0] = value }
}
const compatibleBounds = CompatibleBounds.new({
"south": 43.106491921792255,
"west": 76.71745650634767,
"north": 43.4065384633472,
"east": 77.13974349365236
});
// или
const compatibleBounds = CompatibleBounds.new({
"northEast": [
76.92894332280319,
43.25695003829279
],
"southWest": [
76.92825667730312,
43.256449960663694
]
});
// на выходе универсальный динамический объект:
compatibleBounds.southWest = [1, 2];
console.log(compatibleBounds.south); // 2
compatibleBounds.south = 3
console.log(compatibleBounds.southWest); // [1, 3]
const gmExample = {
"south": 43.106491921792255,
"west": 76.71745650634767,
"north": 43.4065384633472,
"east": 77.13974349365236
};
const dgExample= {
"northEast": [
76.92894332280319,
43.25695003829279
],
"southWest": [
76.92825667730312,
43.256449960663694
]
};
const gm = {
"south": dgExample.southWest[1],
"west": dgExample.southWest[0],
"north": dgExample.northEast[1],
"east": dgExample.northEast[0]
};
const dg = {
"northEast": [
gmExample.east,
gmExample.north
],
"southWest": [
gmExample.west,
gmExample.south
]
};