Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 61 additions & 12 deletions Site/src/js/bus.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,30 @@ var locAtual;
var locAnt;
var bus;
var busList = []
var a;
var c;

class Bus {
constructor(name, signalQuality, temp, timer, lat, lng, speed, direction) {
this.name = name;
this.signalQuality = signalQuality;
this.temp = temp;
this.timer = timer;
this.timer = Date.now(); //timer;
this.lat = lat;
this.lng = lng;
this.speed = speed;
this.direction = direction;
this.oldLoc = null;
this.marker = null;
this.crono = null; //ls
this.j = null; //ls
}
}

var busIcon = L.icon({
iconUrl: './img/bus/iconCircular.png',
iconAnchor: [0, 32, 0, 0]
iconAnchor: [0, 32, 0, 0], //32 no segundo
popupAnchor: [0, -15, 0, 0]
});

function set_bus(name, signalQuality, temp, timer, lat, lng, speed, direction, map){
Expand All @@ -33,20 +38,49 @@ function set_bus(name, signalQuality, temp, timer, lat, lng, speed, direction, m
}
}

function update_bus(name, signalQuality, temp, timer, lat, lng, speed, direction, busList){
function update_bus(name, signalQuality, temp, timer, lat, lng, speed, direction, busList, crono, j){
for (b of busList){
if (b.name == name){
a = b.timer;
if((b.lng == lng) && (b.lat == lat)){ //ls //mudar para igual dps
console.log('test1');
b.j = Date.now(); //ls
console.log(b.timer);
console.log(b.j);
b.crono = b.crono + b.j - b.timer; //ls
console.log(b.crono);
if(b.crono > 60000) { //ls
console.log('test');
b.marker.remove(); //ls
}else {
console.log('test4');
b.signalQuality = signalQuality;
b.temp = temp;
b.timer = Date.now(); //timer;
b.lat = lat;
b.lng = lng;
b.speed = speed;
b.direction = direction;
c = b.timer;
}
} else { //ls
console.log('test2');
console.log(b.name);
b.signalQuality = signalQuality;
b.temp = temp;
b.timer = timer;
b.oldLoc = [b.lat, b.lng];
b.lat = lat;
b.lng = lng;
b.speed = speed;
b.direction = direction;
b.crono = 0;
c = b.timer;

// move_bus(b);
b.marker.remove();
create_bus(b);
move_bus(b);
//b.marker.remove();
//create_bus(b);
}
}
}
}
Expand All @@ -63,11 +97,26 @@ function find_bus(name, busList){
function create_bus(b){
b.marker = L.marker([b.lat, b.lng], {icon: busIcon}).addTo(map);
b.locAnt = [b.lat, b.lng];
b.marker.bindPopup(b.name); //nome do circular no mapa
}

function conection(a, c, name, busList) {
for (let b of busList){
if (b.name == name){
if(a == c){
b.marker.remove();
}
}
}
}

// function move_bus(b){
// b.marker = L.Marker.movingMarker([b.oldLoc, [b.lat, b.lng]], [1000], {icon: busIcon},).addTo(map);
// map.addLayer(b.marker);
// b.marker.start();
// b.oldLoc = [b.lat, b.lng];
// }
function move_bus(b){
b.marker.remove();
b.marker = L.Marker.movingMarker([b.oldLoc, [b.lat, b.lng]], [1000], {icon: busIcon},);//.addTo(map); //marker1
map.addLayer(b.marker); //marker1
b.marker.start(); //marker1
//b.marker.remove(); //ls
//b.marker = b.marker1//ls
b.marker.bindPopup(b.name); //nome do circular no mapa
b.oldLoc = [b.lat, b.lng];
}
6 changes: 3 additions & 3 deletions Site/src/js/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ function initialize_map() {
}).addTo(map);

var popup = L.popup();
function onMapClick(e) {
/*function onMapClick(e) { //here
popup
.setLatLng(e.latlng)
.setContent("You clicked the map at " + e.latlng.toString())
.openOn(map);
}

map.on('click', onMapClick);
map.on('click', onMapClick);*/ // here tira as coordenadas ao clicar
set_stops(map);

var track = new L.KML("data/rota.kml", {async: true});
var track = new L.KML("data/rota.kml", {async: true});
track.on("loaded", function(e) {
map.fitBounds(e.target.getBounds());
});
Expand Down
8 changes: 5 additions & 3 deletions Site/src/js/mqtt/clientMqtt.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// <Qualidade do sinal>,<Temperatura>,<UTC date & Time>,<Latitude>,<Longitude>,<Velocidade>,<Curso>

var client = mqtt.connect('wss://iot.eclipse.org:443/ws')
var client = mqtt.connect('ws://iot.eclipse.org:80/ws') //'wss://iot.eclipse.org:443/ws'
client.on('connect', function () {
console.log('client connected')
client.subscribe('/ufpa/circular/loc/+');
client.subscribe('/dev/circular/loc/+');
client.on('message', function (topic, payload) {
var circular = topic.split('/')
var message = (payload.toString()).split(',')

busText = "Circular" + circular[4]; // Nome do circular + circular[4] que é o numero do circular
busText = "Circular " + circular[4]; // Nome do circular + circular[4] que é o numero do circular
busSignalQuality = message[0] // Qualidade de Sinal
busTemperature = message[1] // Temperatura
busTimer = message[2] // Hora e Data
Expand All @@ -20,3 +20,5 @@ client.on('connect', function () {
set_bus(busText, busSignalQuality, busTemperature, busTimer, busLat, busLng, busSpeed, busDirection, map);
});
});

conection(a, c, circular[4], busList);
21 changes: 11 additions & 10 deletions Site/src/js/stop.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,25 @@ function set_stops(map){
{lat: -1.473141, lng: -48.455911, fullname: "Ginasio"},
{lat: -1.475790, lng: -48.455654, fullname: "Reitoria e Biblioteca"},
{lat: -1.476433, lng: -48.454813, fullname: "Reitoria"},
{lat: -1.475053, lng: -48.458483, fullname: "RU e Instituto de Geociência"},
{lat: -1.473459, lng: -48.458701, fullname: ""},
{lat: -1.472336, lng: -48.457703, fullname: ""},
{lat: -1.475053, lng: -48.458483, fullname: "Instituto de Geociência"},
{lat: -1.473459, lng: -48.458701, fullname: "Garagem"}, //ls
{lat: -1.472336, lng: -48.457703, fullname: "CAPACIT"},
{lat: -1.474918, lng: -48.454406, fullname: "PGITEC"},
{lat: -1.474969, lng: -48.454264, fullname: "PGITEC"},
{lat: -1.477671, lng: -48.456557, fullname: ""},
{lat: -1.477092, lng: -48.458086, fullname: ""},
{lat: -1.473297, lng: -48.453620, fullname: "Dona Gina"},
{lat: -1.472667, lng: -48.448853, fullname: ""},
{lat: -1.477671, lng: -48.456557, fullname: "Mirante"},
{lat: -1.477092, lng: -48.458086, fullname: "RU"}, //ls
{lat: -1.473297, lng: -48.453620, fullname: "FAESA"},
{lat: -1.471597, lng: -48.450195, fullname: "ICJ"}, //ls
{lat: -1.472667, lng: -48.448853, fullname: "ICSA"},
{lat: -1.471116, lng: -48.448037, fullname: "Odontologia e Laboratorio de Analises Clinicas"},
{lat: -1.470950, lng: -48.447908, fullname: "Odontologia e Laboratorio de Analises Clinicas"},
{lat: -1.470126, lng: -48.446759, fullname: "Nutricao e Betina"},
{lat: -1.467505, lng: -48.447569, fullname: "Portão 04"},
{lat: -1.467192, lng: -48.446933, fullname: "Portão 04"},
{lat: -1.467192, lng: -48.446933, fullname: "Ceamazon"},
{lat: -1.468420, lng: -48.448159, fullname: "Biomedicina"},
{lat: -1.468937, lng: -48.448218, fullname: ""},
{lat: -1.463631, lng: -48.444562, fullname: "PCT"},
{lat: -1.463215, lng: -48.444622, fullname: "PCT"},
{lat: -1.465925, lng: -48.444579, fullname: "PCT"}, //ls //nao existe
{lat: -1.463215, lng: -48.444622, fullname: "Portão 5"},
{lat: -1.461523, lng: -48.442213, fullname: "Instituto de Pesquisas Espaciais"}
];

Expand Down