2019-06-10 23:19:37 +00:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
import VoronoiOverlay from './VoronoiOverlay.mjs';
|
|
|
|
import VoronoiCell from './VoronoiCell.mjs';
|
|
|
|
|
|
|
|
import Vector2 from '../Helpers/Vector2.mjs';
|
|
|
|
|
|
|
|
class VoronoiManager {
|
|
|
|
constructor(in_device_data, map) {
|
|
|
|
this.device_data = in_device_data;
|
|
|
|
this.overlay = new VoronoiOverlay();
|
|
|
|
this.overlay.addCells(...this.device_data.devices
|
|
|
|
.filter((device) => typeof device.latitude == "number" &&
|
|
|
|
typeof device.longitude == "number")
|
|
|
|
.map((device) =>
|
2019-06-10 23:32:01 +00:00
|
|
|
new VoronoiCell(new Vector2(device.longitude, device.latitude))
|
2019-06-10 23:19:37 +00:00
|
|
|
));
|
|
|
|
this.overlay.add_to(map);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default VoronoiManager;
|