|
@@ -33,7 +33,7 @@ import RightPanel from './RightPanel';
|
|
import Row from 'react-bootstrap/Row';
|
|
import Row from 'react-bootstrap/Row';
|
|
import Toolbar from './Toolbar';
|
|
import Toolbar from './Toolbar';
|
|
import DataReciever from '../model/DataReciever';
|
|
import DataReciever from '../model/DataReciever';
|
|
-import { LatLng } from 'leaflet';
|
|
|
|
|
|
+// import { LatLng } from 'leaflet';
|
|
|
|
|
|
const LOCATOR_OVERLAY_ID = "mapbox_locator_overlay";
|
|
const LOCATOR_OVERLAY_ID = "mapbox_locator_overlay";
|
|
|
|
|
|
@@ -91,8 +91,8 @@ class Body extends Component {
|
|
};
|
|
};
|
|
|
|
|
|
this._usedImageryNames = new Set();
|
|
this._usedImageryNames = new Set();
|
|
- this._dataReciever = new DataReciever('127.0.0.1', '16820', this._updateData);//'10.126.140.18''localhost'
|
|
|
|
- this._readers = []
|
|
|
|
|
|
+ // this._dataReciever = new DataReciever('127.0.0.1', '16820', this._updateData);//'10.126.140.18''localhost'
|
|
|
|
+ // this._readers = []
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -314,75 +314,75 @@ class Body extends Component {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
- markers = [];
|
|
|
|
- d1 = 10;
|
|
|
|
- d2 = 7.0644;
|
|
|
|
- _updateMarker() {
|
|
|
|
- // this.markers.forEach(marker => {
|
|
|
|
- // marker.lng += 0.000001;
|
|
|
|
- // });
|
|
|
|
- // console.log('got');
|
|
|
|
- this.d1 += 0.1;
|
|
|
|
- this.d2 -= 0.1;
|
|
|
|
- PubSub.publish('body.data.got', this.markers);
|
|
|
|
- this._refreshMarkers([
|
|
|
|
- ['1001', this.d1, this.d2, (new Date(Date.now())).toUTCString(), 1010],
|
|
|
|
- ['1001', this.d1 + 3, this.d2 - 3, (new Date(Date.now())).toUTCString(), 1011],
|
|
|
|
- ]);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- _refreshMarkers(data){
|
|
|
|
- this.markers.length = 0;
|
|
|
|
- // console.log('refresh', data);
|
|
|
|
- this._readers.forEach(reader => {
|
|
|
|
- data.forEach(item => {
|
|
|
|
- if(reader.properties.tags.id === item[0]){
|
|
|
|
- const p1 = new LatLng(reader.properties.tags.lat_1, reader.properties.tags.lng_1);
|
|
|
|
- const p2 = new LatLng(reader.properties.tags.lat_2, reader.properties.tags.lng_2);
|
|
|
|
- const p3 = new LatLng(reader.geometry.coordinates[1], reader.geometry.coordinates[0]);
|
|
|
|
-
|
|
|
|
- const distance = p1.distanceTo(p2)
|
|
|
|
- const d1 = item[1];
|
|
|
|
- const d2 = item[2];
|
|
|
|
- const dlat = reader.properties.tags.lat_2 - reader.properties.tags.lat_1;
|
|
|
|
- const dlng = reader.properties.tags.lng_2 - reader.properties.tags.lng_1;
|
|
|
|
-
|
|
|
|
- const r1 = d1 / distance;
|
|
|
|
- const r2 = d2 / distance;
|
|
|
|
|
|
+ // markers = [];
|
|
|
|
+ // d1 = 10;
|
|
|
|
+ // d2 = 7.0644;
|
|
|
|
+ // _updateMarker() {
|
|
|
|
+ // // this.markers.forEach(marker => {
|
|
|
|
+ // // marker.lng += 0.000001;
|
|
|
|
+ // // });
|
|
|
|
+ // // console.log('got');
|
|
|
|
+ // this.d1 += 0.1;
|
|
|
|
+ // this.d2 -= 0.1;
|
|
|
|
+ // PubSub.publish('body.data.got', this.markers);
|
|
|
|
+ // this._refreshMarkers([
|
|
|
|
+ // ['1001', this.d1, this.d2, (new Date(Date.now())).toUTCString(), 1010],
|
|
|
|
+ // ['1001', this.d1 + 3, this.d2 - 3, (new Date(Date.now())).toUTCString(), 1011],
|
|
|
|
+ // ]);
|
|
|
|
+ // }
|
|
|
|
+
|
|
|
|
+ // _refreshMarkers(data){
|
|
|
|
+ // this.markers.length = 0;
|
|
|
|
+ // // console.log('refresh', data);
|
|
|
|
+ // this._readers.forEach(reader => {
|
|
|
|
+ // data.forEach(item => {
|
|
|
|
+ // if(reader.properties.tags.id === item[0]){
|
|
|
|
+ // const p1 = new LatLng(reader.properties.tags.lat_1, reader.properties.tags.lng_1);
|
|
|
|
+ // const p2 = new LatLng(reader.properties.tags.lat_2, reader.properties.tags.lng_2);
|
|
|
|
+ // const p3 = new LatLng(reader.geometry.coordinates[1], reader.geometry.coordinates[0]);
|
|
|
|
+
|
|
|
|
+ // const distance = p1.distanceTo(p2)
|
|
|
|
+ // const d1 = item[1];
|
|
|
|
+ // const d2 = item[2];
|
|
|
|
+ // const dlat = reader.properties.tags.lat_2 - reader.properties.tags.lat_1;
|
|
|
|
+ // const dlng = reader.properties.tags.lng_2 - reader.properties.tags.lng_1;
|
|
|
|
+
|
|
|
|
+ // const r1 = d1 / distance;
|
|
|
|
+ // const r2 = d2 / distance;
|
|
|
|
|
|
- let lat;
|
|
|
|
- let lng;
|
|
|
|
-
|
|
|
|
- if(d1 + d2 === distance || d1 < d2) {
|
|
|
|
- lat = reader.properties.tags.lat_1 + r1 * dlat;
|
|
|
|
- lng = reader.properties.tags.lng_1 + r1 * dlng;
|
|
|
|
- } else {
|
|
|
|
- lat = reader.properties.tags.lat_2 - r2 * dlat;
|
|
|
|
- lng = reader.properties.tags.lng_2 - r2 * dlng;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- const marker = {
|
|
|
|
- lat: lat,
|
|
|
|
- lng: lng,
|
|
|
|
- reader_id: item[0],
|
|
|
|
- locTime: item[3],
|
|
|
|
- card: item[4],
|
|
|
|
- distance: p3.distanceTo(new LatLng(lat, lng)).toFixed(2),
|
|
|
|
- reader_name: reader.properties.tags.name
|
|
|
|
- };
|
|
|
|
- this.markers.push(marker);
|
|
|
|
- // console.log(marker);
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
|
|
+ // let lat;
|
|
|
|
+ // let lng;
|
|
|
|
+
|
|
|
|
+ // if(d1 + d2 === distance || d1 < d2) {
|
|
|
|
+ // lat = reader.properties.tags.lat_1 + r1 * dlat;
|
|
|
|
+ // lng = reader.properties.tags.lng_1 + r1 * dlng;
|
|
|
|
+ // } else {
|
|
|
|
+ // lat = reader.properties.tags.lat_2 - r2 * dlat;
|
|
|
|
+ // lng = reader.properties.tags.lng_2 - r2 * dlng;
|
|
|
|
+ // }
|
|
|
|
+
|
|
|
|
+ // const marker = {
|
|
|
|
+ // lat: lat,
|
|
|
|
+ // lng: lng,
|
|
|
|
+ // reader_id: item[0],
|
|
|
|
+ // locTime: item[3],
|
|
|
|
+ // card: item[4],
|
|
|
|
+ // distance: p3.distanceTo(new LatLng(lat, lng)).toFixed(2),
|
|
|
|
+ // reader_name: reader.properties.tags.name
|
|
|
|
+ // };
|
|
|
|
+ // this.markers.push(marker);
|
|
|
|
+ // // console.log(marker);
|
|
|
|
+ // }
|
|
|
|
+ // });
|
|
|
|
+ // });
|
|
|
|
+ // }
|
|
|
|
|
|
// {"cmd":"tof_data", "version":"1.0.0.0", "data":[["1002",1.1,2.2,1001,3.1,1.1,1,"2022-06-13 16:50:00.023"]]}
|
|
// {"cmd":"tof_data", "version":"1.0.0.0", "data":[["1002",1.1,2.2,1001,3.1,1.1,1,"2022-06-13 16:50:00.023"]]}
|
|
|
|
|
|
- _updateData(data){
|
|
|
|
- console.log('body', data);
|
|
|
|
- PubSub.publish('body.data.update', data)
|
|
|
|
- }
|
|
|
|
|
|
+ // _updateData(data){
|
|
|
|
+ // console.log('body', data);
|
|
|
|
+ // PubSub.publish('body.data.update', data)
|
|
|
|
+ // }
|
|
|
|
|
|
/**
|
|
/**
|
|
* Append last used preset into stack
|
|
* Append last used preset into stack
|
|
@@ -472,8 +472,8 @@ class Body extends Component {
|
|
|
|
|
|
componentDidMount() {
|
|
componentDidMount() {
|
|
this._timerImagery = setInterval(() => this._updateImagery(), 1000);
|
|
this._timerImagery = setInterval(() => this._updateImagery(), 1000);
|
|
- this._timerMarker = setInterval(() => this._updateMarker(), 1000);
|
|
|
|
- setTimeout(() => {this._readers = window.vectorDataManager.getAllReaders()}, 1000);
|
|
|
|
|
|
+ // this._timerMarker = setInterval(() => this._updateMarker(), 1000);
|
|
|
|
+ // setTimeout(() => {this._readers = window.vectorDataManager.getAllReaders()}, 1000);
|
|
this._checkUserLoggedIn();
|
|
this._checkUserLoggedIn();
|
|
|
|
|
|
PubSub.subscribe("body.data.update", (msg, data) => {
|
|
PubSub.subscribe("body.data.update", (msg, data) => {
|
|
@@ -1086,6 +1086,16 @@ class Body extends Component {
|
|
else {
|
|
else {
|
|
setTimeout(() => PubSub.publish("body.draw.done", data), 100);
|
|
setTimeout(() => PubSub.publish("body.draw.done", data), 100);
|
|
}
|
|
}
|
|
|
|
+ PubSub.publish("body.data.changed");
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ PubSub.subscribe("body.data.changed", () => {
|
|
|
|
+ setTimeout(async () => {
|
|
|
|
+ const diff = await window.vectorDataManager.computeDiff();
|
|
|
|
+ let data = JSON.stringify(diff);
|
|
|
|
+ PubSub.publish('body.data.autosave', data);
|
|
|
|
+ localStorage.setItem("mapData", data);
|
|
|
|
+ }, 100);
|
|
});
|
|
});
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -1209,6 +1219,7 @@ class Body extends Component {
|
|
else {
|
|
else {
|
|
console.log("Missing information for editing this feature", data.feature);
|
|
console.log("Missing information for editing this feature", data.feature);
|
|
}
|
|
}
|
|
|
|
+ PubSub.publish("body.data.changed");
|
|
});
|
|
});
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -1259,6 +1270,7 @@ class Body extends Component {
|
|
else if((this.state.mode === Body.MODE_BUILDING && this.state.building) || (this.state.mode === Body.MODE_LEVELS && this.state.floor)) {
|
|
else if((this.state.mode === Body.MODE_BUILDING && this.state.building) || (this.state.mode === Body.MODE_LEVELS && this.state.floor)) {
|
|
this.setState({ showDialogConfirmDeletion: true });
|
|
this.setState({ showDialogConfirmDeletion: true });
|
|
}
|
|
}
|
|
|
|
+ PubSub.publish("body.data.changed");
|
|
});
|
|
});
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -1575,6 +1587,8 @@ class Body extends Component {
|
|
this.forceUpdate();
|
|
this.forceUpdate();
|
|
}
|
|
}
|
|
);
|
|
);
|
|
|
|
+
|
|
|
|
+ PubSub.publish("body.data.changed");
|
|
});
|
|
});
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -1601,6 +1615,8 @@ class Body extends Component {
|
|
this.forceUpdate();
|
|
this.forceUpdate();
|
|
}
|
|
}
|
|
);
|
|
);
|
|
|
|
+
|
|
|
|
+ PubSub.publish("body.data.changed");
|
|
});
|
|
});
|
|
|
|
|
|
/**
|
|
/**
|