Bugfix: Fix a bunch of crashes in the client-side map, but it's still not working :-/
This commit is contained in:
parent
bd42fa29a6
commit
c6e6150d3e
1 changed files with 15 additions and 10 deletions
|
@ -3,7 +3,10 @@
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
import L from 'leaflet';
|
import L from 'leaflet';
|
||||||
import * as tf from '@tensorflow/tfjs';
|
import {
|
||||||
|
loadLayersModel as tf_loadLayersModel,
|
||||||
|
tensor as tf_tensor
|
||||||
|
} from '@tensorflow/tfjs';
|
||||||
import chroma from 'chroma-js';
|
import chroma from 'chroma-js';
|
||||||
|
|
||||||
import GetFromUrl from './Helpers/GetFromUrl.mjs';
|
import GetFromUrl from './Helpers/GetFromUrl.mjs';
|
||||||
|
@ -18,7 +21,7 @@ class LayerAI {
|
||||||
north: Infinity,
|
north: Infinity,
|
||||||
south: -Infinity
|
south: -Infinity
|
||||||
};
|
};
|
||||||
for(let gateway of this.index) {
|
for(let gateway of this.index.index) {
|
||||||
result.east = Math.min(gateway.longitude, result.east);
|
result.east = Math.min(gateway.longitude, result.east);
|
||||||
result.west = Math.max(gateway.longitude, result.west);
|
result.west = Math.max(gateway.longitude, result.west);
|
||||||
|
|
||||||
|
@ -42,7 +45,7 @@ class LayerAI {
|
||||||
for(let gateway of this.index.index) {
|
for(let gateway of this.index.index) {
|
||||||
this.gateways.set(
|
this.gateways.set(
|
||||||
gateway.id,
|
gateway.id,
|
||||||
await tf.loadModel(`${window.location.href}/${path.dirname(Config.ai_index_file)}/${gateway.id}`)
|
await tf_loadLayersModel(`${window.location.href}/${path.dirname(Config.ai_index_file)}/${gateway.id}/model.json`)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +54,8 @@ class LayerAI {
|
||||||
}
|
}
|
||||||
|
|
||||||
generate_layer() {
|
generate_layer() {
|
||||||
return L.geoJSON(this.render_map(), {
|
let map = this.render_map();
|
||||||
|
return L.geoJSON(map, {
|
||||||
style: (feature) => { return {
|
style: (feature) => { return {
|
||||||
fillColor: feature.properties.colour,
|
fillColor: feature.properties.colour,
|
||||||
fillOpacity: 0.4
|
fillOpacity: 0.4
|
||||||
|
@ -69,10 +73,10 @@ class LayerAI {
|
||||||
map_bounds.west -= Config.border;
|
map_bounds.west -= Config.border;
|
||||||
|
|
||||||
let coverage = [],
|
let coverage = [],
|
||||||
colour_scale = chroma.scale(
|
colour_scale = chroma.scale([
|
||||||
Config.colour_scale.min,
|
Config.colour_scale.min,
|
||||||
Config.colour_scale.max
|
Config.colour_scale.max
|
||||||
).domain(
|
]).domain(
|
||||||
this.index.properties.rssi_min,
|
this.index.properties.rssi_min,
|
||||||
this.index.properties.rssi_max
|
this.index.properties.rssi_max
|
||||||
);
|
);
|
||||||
|
@ -82,11 +86,12 @@ class LayerAI {
|
||||||
let max_predicted_rssi = -Infinity;
|
let max_predicted_rssi = -Infinity;
|
||||||
|
|
||||||
for(let [, ai] of this.gateways) {
|
for(let [, ai] of this.gateways) {
|
||||||
|
let next_prediction = ai.predict(
|
||||||
|
tf_tensor([ lat, lng ], [1, 2])
|
||||||
|
);
|
||||||
max_predicted_rssi = Math.max(
|
max_predicted_rssi = Math.max(
|
||||||
max_predicted_rssi,
|
max_predicted_rssi,
|
||||||
ai.predict(
|
next_prediction.arraySync()[0][0]
|
||||||
tf.tensor1d([ lat, lng ])
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,7 +115,7 @@ class LayerAI {
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
properties: {
|
properties: {
|
||||||
colour: colour_scale(max_predicted_rssi)
|
colour: colour_scale(max_predicted_rssi).toString()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue