ajustado carregamento do mapa json
This commit is contained in:
parent
4c0eb3de81
commit
0e852e69e2
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
|
|
@ -669,36 +669,6 @@
|
|||
<Content Include="Python\Models\yolov7\utils\google_app_engine\Dockerfile">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Python\Models\yolov7\models\__pycache__\common.cpython-310.pyc">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Python\Models\yolov7\models\__pycache__\experimental.cpython-310.pyc">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Python\Models\yolov7\models\__pycache__\__init__.cpython-310.pyc">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Python\Models\yolov7\utils\__pycache__\datasets.cpython-310.pyc">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Python\Models\yolov7\utils\__pycache__\general.cpython-310.pyc">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Python\Models\yolov7\utils\__pycache__\google_utils.cpython-310.pyc">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Python\Models\yolov7\utils\__pycache__\metrics.cpython-310.pyc">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Python\Models\yolov7\utils\__pycache__\plots.cpython-310.pyc">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Python\Models\yolov7\utils\__pycache__\torch_utils.cpython-310.pyc">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Python\Models\yolov7\utils\__pycache__\__init__.cpython-310.pyc">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<None Include="Python\Output\fonts\glyphicons-halflings-regular.ttf">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
|
|
|
|||
|
|
@ -32,13 +32,16 @@
|
|||
this.pnlMapa = new System.Windows.Forms.Panel();
|
||||
this.picLoading = new System.Windows.Forms.PictureBox();
|
||||
this.pnlInformacoes = new System.Windows.Forms.Panel();
|
||||
this.lblLatitude = new System.Windows.Forms.Label();
|
||||
this.lblLongitude = new System.Windows.Forms.Label();
|
||||
this.lblPrecisao = new System.Windows.Forms.Label();
|
||||
this.lblSatelites = new System.Windows.Forms.Label();
|
||||
this.lblDatahora = new System.Windows.Forms.Label();
|
||||
this.lblAltitude = new System.Windows.Forms.Label();
|
||||
this.lblOrientacao = new System.Windows.Forms.Label();
|
||||
this.chbSalvar = new System.Windows.Forms.CheckBox();
|
||||
this.lblVelocidade = new System.Windows.Forms.Label();
|
||||
this.lblAltitude = new System.Windows.Forms.Label();
|
||||
this.lblDatahora = new System.Windows.Forms.Label();
|
||||
this.lblSatelites = new System.Windows.Forms.Label();
|
||||
this.lblPrecisao = new System.Windows.Forms.Label();
|
||||
this.lblLongitude = new System.Windows.Forms.Label();
|
||||
this.lblLatitude = new System.Windows.Forms.Label();
|
||||
this.btnGerarMapa = new System.Windows.Forms.Button();
|
||||
this.pnlMapa.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.picLoading)).BeginInit();
|
||||
this.pnlInformacoes.SuspendLayout();
|
||||
|
|
@ -53,7 +56,7 @@
|
|||
this.pnlMapa.Location = new System.Drawing.Point(9, 10);
|
||||
this.pnlMapa.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.pnlMapa.Name = "pnlMapa";
|
||||
this.pnlMapa.Size = new System.Drawing.Size(772, 464);
|
||||
this.pnlMapa.Size = new System.Drawing.Size(1177, 464);
|
||||
this.pnlMapa.TabIndex = 2;
|
||||
//
|
||||
// picLoading
|
||||
|
|
@ -66,7 +69,7 @@
|
|||
this.picLoading.Location = new System.Drawing.Point(194, 24);
|
||||
this.picLoading.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.picLoading.Name = "picLoading";
|
||||
this.picLoading.Size = new System.Drawing.Size(384, 416);
|
||||
this.picLoading.Size = new System.Drawing.Size(789, 416);
|
||||
this.picLoading.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
|
||||
this.picLoading.TabIndex = 2;
|
||||
this.picLoading.TabStop = false;
|
||||
|
|
@ -74,6 +77,9 @@
|
|||
//
|
||||
// pnlInformacoes
|
||||
//
|
||||
this.pnlInformacoes.Controls.Add(this.btnGerarMapa);
|
||||
this.pnlInformacoes.Controls.Add(this.lblOrientacao);
|
||||
this.pnlInformacoes.Controls.Add(this.chbSalvar);
|
||||
this.pnlInformacoes.Controls.Add(this.lblVelocidade);
|
||||
this.pnlInformacoes.Controls.Add(this.lblAltitude);
|
||||
this.pnlInformacoes.Controls.Add(this.lblDatahora);
|
||||
|
|
@ -85,68 +91,28 @@
|
|||
this.pnlInformacoes.Location = new System.Drawing.Point(0, 479);
|
||||
this.pnlInformacoes.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.pnlInformacoes.Name = "pnlInformacoes";
|
||||
this.pnlInformacoes.Size = new System.Drawing.Size(790, 46);
|
||||
this.pnlInformacoes.Size = new System.Drawing.Size(1195, 46);
|
||||
this.pnlInformacoes.TabIndex = 3;
|
||||
//
|
||||
// lblLatitude
|
||||
// lblOrientacao
|
||||
//
|
||||
this.lblLatitude.AutoSize = true;
|
||||
this.lblLatitude.Location = new System.Drawing.Point(9, 17);
|
||||
this.lblLatitude.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||
this.lblLatitude.Name = "lblLatitude";
|
||||
this.lblLatitude.Size = new System.Drawing.Size(57, 13);
|
||||
this.lblLatitude.TabIndex = 1;
|
||||
this.lblLatitude.Text = "Latitude: 0";
|
||||
this.lblOrientacao.AutoSize = true;
|
||||
this.lblOrientacao.Location = new System.Drawing.Point(800, 17);
|
||||
this.lblOrientacao.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||
this.lblOrientacao.Name = "lblOrientacao";
|
||||
this.lblOrientacao.Size = new System.Drawing.Size(65, 13);
|
||||
this.lblOrientacao.TabIndex = 9;
|
||||
this.lblOrientacao.Text = "Orientação: ";
|
||||
//
|
||||
// lblLongitude
|
||||
// chbSalvar
|
||||
//
|
||||
this.lblLongitude.AutoSize = true;
|
||||
this.lblLongitude.Location = new System.Drawing.Point(131, 17);
|
||||
this.lblLongitude.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||
this.lblLongitude.Name = "lblLongitude";
|
||||
this.lblLongitude.Size = new System.Drawing.Size(66, 13);
|
||||
this.lblLongitude.TabIndex = 2;
|
||||
this.lblLongitude.Text = "Longitude: 0";
|
||||
//
|
||||
// lblPrecisao
|
||||
//
|
||||
this.lblPrecisao.AutoSize = true;
|
||||
this.lblPrecisao.Location = new System.Drawing.Point(497, 17);
|
||||
this.lblPrecisao.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||
this.lblPrecisao.Name = "lblPrecisao";
|
||||
this.lblPrecisao.Size = new System.Drawing.Size(60, 13);
|
||||
this.lblPrecisao.TabIndex = 3;
|
||||
this.lblPrecisao.Text = "Precisão: 0";
|
||||
//
|
||||
// lblSatelites
|
||||
//
|
||||
this.lblSatelites.AutoSize = true;
|
||||
this.lblSatelites.Location = new System.Drawing.Point(584, 17);
|
||||
this.lblSatelites.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||
this.lblSatelites.Name = "lblSatelites";
|
||||
this.lblSatelites.Size = new System.Drawing.Size(59, 13);
|
||||
this.lblSatelites.TabIndex = 4;
|
||||
this.lblSatelites.Text = "Satélites: 0";
|
||||
//
|
||||
// lblDatahora
|
||||
//
|
||||
this.lblDatahora.AutoSize = true;
|
||||
this.lblDatahora.Location = new System.Drawing.Point(669, 17);
|
||||
this.lblDatahora.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||
this.lblDatahora.Name = "lblDatahora";
|
||||
this.lblDatahora.Size = new System.Drawing.Size(77, 13);
|
||||
this.lblDatahora.TabIndex = 5;
|
||||
this.lblDatahora.Text = "Ultima Leitura: ";
|
||||
//
|
||||
// lblAltitude
|
||||
//
|
||||
this.lblAltitude.AutoSize = true;
|
||||
this.lblAltitude.Location = new System.Drawing.Point(283, 17);
|
||||
this.lblAltitude.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||
this.lblAltitude.Name = "lblAltitude";
|
||||
this.lblAltitude.Size = new System.Drawing.Size(54, 13);
|
||||
this.lblAltitude.TabIndex = 6;
|
||||
this.lblAltitude.Text = "Altitude: 0";
|
||||
this.chbSalvar.AutoSize = true;
|
||||
this.chbSalvar.Location = new System.Drawing.Point(914, 16);
|
||||
this.chbSalvar.Name = "chbSalvar";
|
||||
this.chbSalvar.Size = new System.Drawing.Size(103, 17);
|
||||
this.chbSalvar.TabIndex = 8;
|
||||
this.chbSalvar.Text = "Salvar Trajetória";
|
||||
this.chbSalvar.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// lblVelocidade
|
||||
//
|
||||
|
|
@ -158,11 +124,81 @@
|
|||
this.lblVelocidade.TabIndex = 7;
|
||||
this.lblVelocidade.Text = "Velocidade: 0";
|
||||
//
|
||||
// lblAltitude
|
||||
//
|
||||
this.lblAltitude.AutoSize = true;
|
||||
this.lblAltitude.Location = new System.Drawing.Point(283, 17);
|
||||
this.lblAltitude.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||
this.lblAltitude.Name = "lblAltitude";
|
||||
this.lblAltitude.Size = new System.Drawing.Size(54, 13);
|
||||
this.lblAltitude.TabIndex = 6;
|
||||
this.lblAltitude.Text = "Altitude: 0";
|
||||
//
|
||||
// lblDatahora
|
||||
//
|
||||
this.lblDatahora.AutoSize = true;
|
||||
this.lblDatahora.Location = new System.Drawing.Point(669, 17);
|
||||
this.lblDatahora.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||
this.lblDatahora.Name = "lblDatahora";
|
||||
this.lblDatahora.Size = new System.Drawing.Size(77, 13);
|
||||
this.lblDatahora.TabIndex = 5;
|
||||
this.lblDatahora.Text = "Ultima Leitura: ";
|
||||
//
|
||||
// lblSatelites
|
||||
//
|
||||
this.lblSatelites.AutoSize = true;
|
||||
this.lblSatelites.Location = new System.Drawing.Point(584, 17);
|
||||
this.lblSatelites.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||
this.lblSatelites.Name = "lblSatelites";
|
||||
this.lblSatelites.Size = new System.Drawing.Size(59, 13);
|
||||
this.lblSatelites.TabIndex = 4;
|
||||
this.lblSatelites.Text = "Satélites: 0";
|
||||
//
|
||||
// lblPrecisao
|
||||
//
|
||||
this.lblPrecisao.AutoSize = true;
|
||||
this.lblPrecisao.Location = new System.Drawing.Point(497, 17);
|
||||
this.lblPrecisao.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||
this.lblPrecisao.Name = "lblPrecisao";
|
||||
this.lblPrecisao.Size = new System.Drawing.Size(60, 13);
|
||||
this.lblPrecisao.TabIndex = 3;
|
||||
this.lblPrecisao.Text = "Precisão: 0";
|
||||
//
|
||||
// lblLongitude
|
||||
//
|
||||
this.lblLongitude.AutoSize = true;
|
||||
this.lblLongitude.Location = new System.Drawing.Point(131, 17);
|
||||
this.lblLongitude.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||
this.lblLongitude.Name = "lblLongitude";
|
||||
this.lblLongitude.Size = new System.Drawing.Size(66, 13);
|
||||
this.lblLongitude.TabIndex = 2;
|
||||
this.lblLongitude.Text = "Longitude: 0";
|
||||
//
|
||||
// lblLatitude
|
||||
//
|
||||
this.lblLatitude.AutoSize = true;
|
||||
this.lblLatitude.Location = new System.Drawing.Point(9, 17);
|
||||
this.lblLatitude.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||
this.lblLatitude.Name = "lblLatitude";
|
||||
this.lblLatitude.Size = new System.Drawing.Size(57, 13);
|
||||
this.lblLatitude.TabIndex = 1;
|
||||
this.lblLatitude.Text = "Latitude: 0";
|
||||
//
|
||||
// btnGerarMapa
|
||||
//
|
||||
this.btnGerarMapa.Location = new System.Drawing.Point(1033, 12);
|
||||
this.btnGerarMapa.Name = "btnGerarMapa";
|
||||
this.btnGerarMapa.Size = new System.Drawing.Size(75, 23);
|
||||
this.btnGerarMapa.TabIndex = 10;
|
||||
this.btnGerarMapa.Text = "Gerar Mapa";
|
||||
this.btnGerarMapa.UseVisualStyleBackColor = true;
|
||||
this.btnGerarMapa.Click += new System.EventHandler(this.btnGerarMapa_Click);
|
||||
//
|
||||
// frmGPS
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(790, 525);
|
||||
this.ClientSize = new System.Drawing.Size(1195, 525);
|
||||
this.Controls.Add(this.pnlInformacoes);
|
||||
this.Controls.Add(this.pnlMapa);
|
||||
this.Name = "frmGPS";
|
||||
|
|
@ -190,5 +226,8 @@
|
|||
private System.Windows.Forms.Label lblLongitude;
|
||||
private System.Windows.Forms.Label lblVelocidade;
|
||||
private System.Windows.Forms.Label lblAltitude;
|
||||
private System.Windows.Forms.CheckBox chbSalvar;
|
||||
private System.Windows.Forms.Label lblOrientacao;
|
||||
private System.Windows.Forms.Button btnGerarMapa;
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,11 @@
|
|||
using AgroBase.Services;
|
||||
using CefSharp;
|
||||
using CefSharp.WinForms;
|
||||
using Newtonsoft.Json;
|
||||
using SharpDX.Text;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace AgroBase.Forms
|
||||
|
|
@ -11,6 +15,8 @@ namespace AgroBase.Forms
|
|||
{
|
||||
private MapasModel Mapa;
|
||||
private Timer tmrLeitura;
|
||||
private List<GPSModel> Trajetoria = new List<GPSModel>();
|
||||
private string LogID = DateTime.Now.ToString("dd_MM_yyyy_HH_mm_ss");
|
||||
|
||||
public frmGPS()
|
||||
{
|
||||
|
|
@ -39,6 +45,25 @@ namespace AgroBase.Forms
|
|||
lblPrecisao.Text = "Precisão: " + GPSService.UltimaLeitura.PrecisaoHorizontal.ToString();
|
||||
lblSatelites.Text = "Satélites: " + GPSService.UltimaLeitura.NumeroSatelites.ToString();
|
||||
lblVelocidade.Text = "Velocidade: " + GPSService.UltimaLeitura.Velocidade.ToString("0.00") + " km/h";
|
||||
lblOrientacao.Text = "Orientação: " + GPSService.UltimaLeitura.Orientacao.ToString("0.00") + "º";
|
||||
|
||||
if (chbSalvar.Checked)
|
||||
{
|
||||
GPSModel leitura = new GPSModel()
|
||||
{
|
||||
Altitude = GPSService.UltimaLeitura.Altitude,
|
||||
DataHora = GPSService.UltimaLeitura.DataHora,
|
||||
Latitude = GPSService.UltimaLeitura.Latitude,
|
||||
Longitude = GPSService.UltimaLeitura.Longitude,
|
||||
NumeroSatelites = GPSService.UltimaLeitura.NumeroSatelites,
|
||||
PrecisaoHorizontal = GPSService.UltimaLeitura.PrecisaoHorizontal,
|
||||
Velocidade = GPSService.UltimaLeitura.Velocidade,
|
||||
Orientacao = GPSService.UltimaLeitura.Orientacao
|
||||
};
|
||||
Trajetoria.Add(leitura);
|
||||
|
||||
File.WriteAllText(Variaveis.CaminhoLogsDispositivos + "GPS/" + LogID + ".json", JsonConvert.SerializeObject(Trajetoria, Formatting.None), Encoding.UTF8);
|
||||
}
|
||||
}
|
||||
|
||||
private void frmGPS_FormClosing(object sender, FormClosingEventArgs e)
|
||||
|
|
@ -51,6 +76,10 @@ namespace AgroBase.Forms
|
|||
Mapa.CarregarMapaGPS();
|
||||
}
|
||||
|
||||
|
||||
private void btnGerarMapa_Click(object sender, EventArgs e)
|
||||
{
|
||||
MapasService.CriarArquivoMapa(new List<List<GPSModel>> { Trajetoria });
|
||||
MessageBox.Show("Mapa gerado com sucesso!", "Sucesso", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ namespace AgroBase.Models
|
|||
public double Velocidade { get; set; }
|
||||
public int NumeroSatelites { get; set; }
|
||||
public double PrecisaoHorizontal { get; set; }
|
||||
public double Orientacao { get; set; }
|
||||
public int idxRua { get; set; } = -1;
|
||||
public DirecaoCarroRua DirecaoTrecho { get; set; } = DirecaoCarroRua.Parado;
|
||||
public bool Passado { get; set; } = false;
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ namespace AgroBase.Models
|
|||
public static string CaminhoSistema { get; set; } = AppDomain.CurrentDomain.BaseDirectory;
|
||||
public static string CaminhoLogsDispositivos { get; } = "Logs/";
|
||||
public static string CaminhoOperacoes { get; } = "Operacoes/";
|
||||
public static string CaminhoMapasConvertidos { get; } = "Mapas/";
|
||||
public static List<IDispositivosService> DispositivosConectados { get; set; } = new List<IDispositivosService>();
|
||||
public static OperacaoModel OperacaoEmAndamento { get; set; } = new OperacaoModel(ModoOperacao.Manual);
|
||||
public static MqttService MqttService { get; set; } = new MqttService("localhost", 1883);
|
||||
|
|
|
|||
|
|
@ -117,13 +117,22 @@ with open(caminho_completo_html, 'r+') as arquivo_html:
|
|||
# Script JavaScript para adicionar ao HTML, com o ID do mapa substituído
|
||||
script_atualizacao_marcador = f"""
|
||||
<script src="folium/mqtt.min.js"></script>
|
||||
<script src="folium/leaflet.rotatedMarker.js"></script>
|
||||
<script>
|
||||
let posicaoAtual = {{
|
||||
lat: 0,
|
||||
long: 0
|
||||
}};
|
||||
|
||||
var customIcon = L.icon({{
|
||||
iconUrl: 'folium/images/position_marker.png',
|
||||
iconSize: [32, 32],
|
||||
iconAnchor: [16, 16],
|
||||
popupAnchor: [0, -16]
|
||||
}});
|
||||
|
||||
var marcadorDinamico = L.marker([0, 0], {{
|
||||
icon: L.AwesomeMarkers.icon({{
|
||||
icon: 'info-sign',
|
||||
markerColor: 'red',
|
||||
prefix: 'glyphicon'
|
||||
}})
|
||||
icon: customIcon
|
||||
}}).addTo({id_mapa});
|
||||
|
||||
// Conectar ao broker MQTT
|
||||
|
|
@ -152,9 +161,44 @@ with open(caminho_completo_html, 'r+') as arquivo_html:
|
|||
var novaLongitude = dados.longitude;
|
||||
var novaPosicao = [novaLatitude, novaLongitude];
|
||||
marcadorDinamico.setLatLng(novaPosicao);
|
||||
|
||||
// Calcular angulo de rotacao
|
||||
var angulo = calcularOrientacao(novaPosicao[0], novaPosicao[1], posicaoAtual.lat, posicaoAtual.long);
|
||||
|
||||
posicaoAtual.lat = novaPosicao[0];
|
||||
posicaoAtual.long = novaPosicao[1];
|
||||
|
||||
// Rotacionar o marcador para o angulo calculado
|
||||
marcadorDinamico.setRotationAngle(angulo);
|
||||
|
||||
adicionarCoordenada("Tj", [novaLongitude, novaLatitude]);
|
||||
{id_mapa}.setView(novaPosicao, {id_mapa}.getZoom());
|
||||
}});
|
||||
|
||||
function calcularOrientacao(P1latitude, P1longitude, P2latitude, P2longitude) {{
|
||||
// Converter latitudes e longitudes de graus para radianos
|
||||
const latA = P1latitude * (Math.PI / 180.0);
|
||||
const lonA = P1longitude * (Math.PI / 180.0);
|
||||
const latB = P2latitude * (Math.PI / 180.0);
|
||||
const lonB = P2longitude * (Math.PI / 180.0);
|
||||
|
||||
// Calcular a diferença de longitude
|
||||
const deltaLon = lonB - lonA;
|
||||
|
||||
// Calcular a direção
|
||||
const y = Math.sin(deltaLon) * Math.cos(latB);
|
||||
const x = Math.cos(latA) * Math.sin(latB) - Math.sin(latA) * Math.cos(latB) * Math.cos(deltaLon);
|
||||
const direcaoRadianos = Math.atan2(y, x);
|
||||
|
||||
// Converter a direção de radianos para graus
|
||||
let direcaoGraus = direcaoRadianos * (180.0 / Math.PI);
|
||||
|
||||
// Normalizar a direção para que esteja no intervalo de 0 a 360 graus
|
||||
direcaoGraus = (direcaoGraus + 360) % 360;
|
||||
|
||||
return direcaoGraus;
|
||||
}}
|
||||
|
||||
</script>
|
||||
"""
|
||||
|
||||
|
|
|
|||
|
|
@ -23,15 +23,30 @@ outputMapName = sys.argv[4]
|
|||
topico_gps = sys.argv[5]
|
||||
topico_ruas = sys.argv[6]
|
||||
topico_trajeto_dinamico = sys.argv[7]
|
||||
mapa_dados_json = sys.argv[8]
|
||||
pastaSaida = 'Python/Output/'
|
||||
|
||||
# Carregar o arquivo shapefile contendo a geometria
|
||||
input_shapefile = pathFiles + fileName + '.shp'
|
||||
data_geometry = gpd.read_file(input_shapefile)
|
||||
|
||||
# Calcular os limites (bounds) da geometria
|
||||
minx, miny, maxx, maxy = data_geometry.total_bounds
|
||||
center = [(miny + maxy) / 2, (minx + maxx) / 2]
|
||||
if mapa_dados_json == "0":
|
||||
# Carregar o arquivo shapefile contendo a geometria
|
||||
input_shapefile = pathFiles + fileName + '.shp'
|
||||
data_geometry = gpd.read_file(input_shapefile)
|
||||
|
||||
# Converter o GeoDataFrame para GeoJSON e adicionar ao mapa
|
||||
geojson_data = data_geometry.to_json()
|
||||
# Calcular os limites (bounds) da geometria
|
||||
minx, miny, maxx, maxy = data_geometry.total_bounds
|
||||
center = [(miny + maxy) / 2, (minx + maxx) / 2]
|
||||
|
||||
# Salvar GEOJson
|
||||
data_geometry.to_file(pastaSaida + outputName, driver='GeoJSON')
|
||||
else:
|
||||
# Lendo os dados JSON
|
||||
with open(pathFiles + fileName + '.json', 'r', encoding='utf-8-sig') as f:
|
||||
geojson_data = json.load(f)
|
||||
# Obter os limites (bounds) dos dados GeoJSON
|
||||
bounds = folium.GeoJson(geojson_data).get_bounds()
|
||||
center = [(bounds[0][0] + bounds[1][0]) / 2, (bounds[0][1] + bounds[1][1]) / 2]
|
||||
|
||||
# Verificar se há conexão com a internet
|
||||
if internet_disponivel():
|
||||
|
|
@ -39,12 +54,8 @@ if internet_disponivel():
|
|||
else:
|
||||
m = folium.Map(location=center, zoom_start=12, tiles=None)
|
||||
|
||||
# Converter o GeoDataFrame para GeoJSON e adicionar ao mapa
|
||||
geojson_data = data_geometry.to_json()
|
||||
folium.GeoJson(geojson_data).add_to(m)
|
||||
|
||||
# Salvar GEOJson
|
||||
data_geometry.to_file(pastaSaida + outputName, driver='GeoJSON')
|
||||
folium.GeoJson(geojson_data).add_to(m)
|
||||
|
||||
# Salvar o mapa interativo em um arquivo HTML
|
||||
m.save(pastaSaida + outputMapName)
|
||||
|
|
|
|||
|
|
@ -99,6 +99,7 @@ namespace AgroBase.Services
|
|||
PenultimaLeitura.DataHora = UltimaLeitura.DataHora;
|
||||
PenultimaLeitura.NumeroSatelites = UltimaLeitura.NumeroSatelites;
|
||||
PenultimaLeitura.Velocidade = UltimaLeitura.Velocidade;
|
||||
PenultimaLeitura.Orientacao = UltimaLeitura.Orientacao;
|
||||
|
||||
if (parts[2] != "" && parts[3] != "")
|
||||
{
|
||||
|
|
@ -111,6 +112,7 @@ namespace AgroBase.Services
|
|||
UltimaLeitura.NumeroSatelites = int.TryParse(parts[7], out int numSat) ? numSat : 0;
|
||||
UltimaLeitura.PrecisaoHorizontal = double.TryParse(parts[8], NumberStyles.Float, CultureInfo.InvariantCulture, out double hdop) ? hdop : 0;
|
||||
UltimaLeitura.Altitude = ConvertToDouble(parts[9]);
|
||||
UltimaLeitura.Orientacao = CalcularOrientacao(PenultimaLeitura, UltimaLeitura);
|
||||
|
||||
//APIService.AtualizarCoordenadasGPS(UltimaLeitura, APIService.GPS_IDcoordenadasRobo);
|
||||
AtualizarCoordenadasGPS();
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
using AgroBase.Models;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace AgroBase.Services
|
||||
|
|
@ -42,23 +44,26 @@ namespace AgroBase.Services
|
|||
opfMapa = new OpenFileDialog
|
||||
{
|
||||
DefaultExt = ".shp",
|
||||
Filter = "Shapefile (*.shp)|*.shp",
|
||||
Filter = "Shapefile (*.shp)|*.shp|JSON Files (*.json)|*.json",
|
||||
Title = "Selecionar arquivo de mapa"
|
||||
};
|
||||
|
||||
if (opfMapa.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
NomeArquivos = opfMapa.FileName.Split('\\')[opfMapa.FileName.Split('\\').Length - 1].Split('.')[0];
|
||||
CaminhoMapa = opfMapa.FileName.Substring(0, opfMapa.FileName.Length - NomeArquivos.Length - 4).Replace("\\", "/");
|
||||
string extensao = "." + opfMapa.FileName.Split('.')[opfMapa.FileName.Split('.').Length - 1];
|
||||
NomeArquivos = opfMapa.FileName.Split('\\')[opfMapa.FileName.Split('\\').Length - 1].Replace(extensao, "");
|
||||
CaminhoMapa = opfMapa.FileName.Replace(NomeArquivos, "").Replace(extensao, "").Replace("\\", "/");
|
||||
|
||||
pythonProcess = PythonService.RunScript(PythonService.ScriptMapConverter, new string[] {
|
||||
pythonProcess = PythonService.RunScript(PythonService.ScriptMapConverter, new string[]
|
||||
{
|
||||
CaminhoMapa,
|
||||
NomeArquivos,
|
||||
ArquivoSaida,
|
||||
NomeArquivoMapa,
|
||||
MapasVariaveisModel.TopicoCoordenadasGPS,
|
||||
MapasVariaveisModel.TopicoSelecaoRuasMapa,
|
||||
MapasVariaveisModel.TopicoTrajetoriaDinamica,
|
||||
MapasVariaveisModel.TopicoTrajetoriaDinamica,
|
||||
opfMapa.FileName.Split('.')[1] == "json" ? "1" : "0"
|
||||
});
|
||||
|
||||
MapaUrl = new Uri(CaminhoSaida + NomeArquivoMapa).AbsoluteUri;
|
||||
|
|
@ -70,7 +75,8 @@ namespace AgroBase.Services
|
|||
{
|
||||
NomeArquivoMapa = nomeArquivoMapa;
|
||||
|
||||
pythonProcess = PythonService.RunScript(PythonService.ScriptMapGPS, new string[] {
|
||||
pythonProcess = PythonService.RunScript(PythonService.ScriptMapGPS, new string[]
|
||||
{
|
||||
CaminhoMapa,
|
||||
NomeArquivos,
|
||||
ArquivoSaida,
|
||||
|
|
@ -94,6 +100,49 @@ namespace AgroBase.Services
|
|||
});
|
||||
}
|
||||
|
||||
public static void CriarArquivoMapa(List<List<GPSModel>> Trajetoria, int id = 1517, string name = "Projeto", double dist1 = 0.0, double dist2 = 0.0)
|
||||
{
|
||||
var featureCollection = new MapaFeatureCollectionModel
|
||||
{
|
||||
type = "FeatureCollection",
|
||||
features = new List<MapaFeatureModel>()
|
||||
};
|
||||
|
||||
foreach (var rua in Trajetoria)
|
||||
{
|
||||
double length = GPSService.DistanciaDoTrecho(rua);
|
||||
featureCollection.features.Add(new MapaFeatureModel()
|
||||
{
|
||||
type = "Feature",
|
||||
properties = new MapaFeaturePropertiesModel()
|
||||
{
|
||||
Id = id.ToString(),
|
||||
Name = name,
|
||||
Length = length,
|
||||
Dist1 = dist1,
|
||||
Dist2 = dist2
|
||||
},
|
||||
geometry = new MapaFeatureGeometryModel()
|
||||
{
|
||||
type = "LineString",
|
||||
coordinates = new List<List<double>>()
|
||||
}
|
||||
});
|
||||
|
||||
// Adicionando coordenadas aos recursos
|
||||
var coordinates = featureCollection.features[0].geometry.coordinates;
|
||||
foreach (var gpsModel in rua)
|
||||
{
|
||||
var coordinate = new List<double> { gpsModel.Longitude, gpsModel.Latitude };
|
||||
coordinates.Add(coordinate);
|
||||
}
|
||||
}
|
||||
|
||||
// Serializando o objeto para JSON
|
||||
string jsonString = JsonConvert.SerializeObject(featureCollection);
|
||||
|
||||
File.WriteAllText(Variaveis.CaminhoMapasConvertidos + name + ".json", jsonString, Encoding.UTF8);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1 @@
|
|||
[{"Latitude":-22.213156666666666,"Longitude":-47.38163183333333,"DataHora":"2024-05-06T12:54:28","Altitude":608.5,"Velocidade":0.331508,"NumeroSatelites":7,"PrecisaoHorizontal":1.61,"Orientacao":307.09351168994016,"idxRua":-1,"DirecaoTrecho":0,"Passado":false},{"Latitude":-22.213156,"Longitude":-47.381633,"DataHora":"2024-05-06T12:54:29","Altitude":608.2,"Velocidade":0.39262400000000003,"NumeroSatelites":7,"PrecisaoHorizontal":1.61,"Orientacao":301.68444431165642,"idxRua":-1,"DirecaoTrecho":0,"Passado":false},{"Latitude":-22.213156666666666,"Longitude":-47.381632833333335,"DataHora":"2024-05-06T12:54:30","Altitude":608.5,"Velocidade":0.275948,"NumeroSatelites":8,"PrecisaoHorizontal":1.61,"Orientacao":166.96857574357796,"idxRua":-1,"DirecaoTrecho":0,"Passado":false},{"Latitude":-22.213156833333333,"Longitude":-47.3816325,"DataHora":"2024-05-06T12:54:31","Altitude":608.8,"Velocidade":0.31669200000000003,"NumeroSatelites":8,"PrecisaoHorizontal":1.61,"Orientacao":118.37272374365136,"idxRua":-1,"DirecaoTrecho":0,"Passado":false},{"Latitude":-22.213156,"Longitude":-47.381634166666664,"DataHora":"2024-05-06T12:54:32","Altitude":608.2,"Velocidade":0.283356,"NumeroSatelites":7,"PrecisaoHorizontal":1.61,"Orientacao":298.37272332706175,"idxRua":-1,"DirecaoTrecho":0,"Passado":false},{"Latitude":-22.213154166666666,"Longitude":-47.381636666666665,"DataHora":"2024-05-06T12:54:33","Altitude":607.3,"Velocidade":0.67968400000000007,"NumeroSatelites":7,"PrecisaoHorizontal":1.61,"Orientacao":308.38350401265575,"idxRua":-1,"DirecaoTrecho":0,"Passado":false},{"Latitude":-22.213157333333335,"Longitude":-47.3816335,"DataHora":"2024-05-06T12:54:34","Altitude":608.6,"Velocidade":0.30558,"NumeroSatelites":7,"PrecisaoHorizontal":1.61,"Orientacao":137.20698333442311,"idxRua":-1,"DirecaoTrecho":0,"Passado":false},{"Latitude":-22.2131615,"Longitude":-47.381628333333332,"DataHora":"2024-05-06T12:54:35","Altitude":610.9,"Velocidade":0.98341200000000006,"NumeroSatelites":7,"PrecisaoHorizontal":1.61,"Orientacao":131.05917143890986,"idxRua":-1,"DirecaoTrecho":0,"Passado":false},{"Latitude":-22.213162666666666,"Longitude":-47.381627833333333,"DataHora":"2024-05-06T12:54:36","Altitude":611.0,"Velocidade":0.86303200000000013,"NumeroSatelites":6,"PrecisaoHorizontal":1.61,"Orientacao":158.35858113762151,"idxRua":-1,"DirecaoTrecho":0,"Passado":false},{"Latitude":-22.213163166666668,"Longitude":-47.381627166666668,"DataHora":"2024-05-06T12:54:37","Altitude":611.3,"Velocidade":0.577824,"NumeroSatelites":6,"PrecisaoHorizontal":1.61,"Orientacao":129.01177615176914,"idxRua":-1,"DirecaoTrecho":0,"Passado":false}]
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1 @@
|
|||
{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"Id":1517,"Name":"Projeto","Length":2.1950901896934623,"Dist1":0.0,"Dist2":0.0},"geometry":{"id":null,"type":"LineString","coordinates":[[-47.38163183333333,-22.213156666666666],[-47.381633,-22.213156],[-47.381632833333335,-22.213156666666666],[-47.3816325,-22.213156833333333],[-47.381634166666664,-22.213156],[-47.381636666666665,-22.213154166666666],[-47.3816335,-22.213157333333335],[-47.381628333333332,-22.2131615],[-47.381627833333333,-22.213162666666666],[-47.381627166666668,-22.213163166666668]]}}]}
|
||||
|
|
@ -0,0 +1 @@
|
|||
[{"Momento":"2024-05-06T10:49:39.4832413-03:00","VelocidadeMedia":0.0,"PorcentagemBateria":-226.83333333333334,"BateriaConsumida":0.0,"DistanciaPercorrida":[],"DistanciaEsquerda":0.0,"DistanciaDireita":0.0,"AnguloCarroGPS":0.0,"AnguloCarroBussola":360.0,"AnguloCarro":360.0,"SonarFrontal":null},{"Momento":"2024-05-06T10:49:44.4983744-03:00","VelocidadeMedia":0.0,"PorcentagemBateria":-227.0,"BateriaConsumida":0.0,"DistanciaPercorrida":[0.0],"DistanciaEsquerda":0.0,"DistanciaDireita":0.0,"AnguloCarroGPS":0.0,"AnguloCarroBussola":0.0,"AnguloCarro":0.0,"SonarFrontal":null},{"Momento":"2024-05-06T10:49:49.4983432-03:00","VelocidadeMedia":0.0,"PorcentagemBateria":-227.0,"BateriaConsumida":0.0,"DistanciaPercorrida":[0.0],"DistanciaEsquerda":0.0,"DistanciaDireita":0.0,"AnguloCarroGPS":0.0,"AnguloCarroBussola":0.0,"AnguloCarro":0.0,"SonarFrontal":null},{"Momento":"2024-05-06T10:49:54.1155221-03:00","VelocidadeMedia":0.0,"PorcentagemBateria":-227.0,"BateriaConsumida":0.0,"DistanciaPercorrida":[0.0],"DistanciaEsquerda":0.0,"DistanciaDireita":0.0,"AnguloCarroGPS":0.0,"AnguloCarroBussola":0.0,"AnguloCarro":0.0,"SonarFrontal":null}]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[{"Latitude":-22.213107666666666,"Longitude":-47.381568333333334,"DataHora":"2024-05-06T10:49:30","Altitude":0.0,"Velocidade":0.0,"NumeroSatelites":0,"PrecisaoHorizontal":99.99,"idxRua":-1,"DirecaoTrecho":0,"Passado":false},{"Latitude":-22.213107666666666,"Longitude":-47.381568333333334,"DataHora":"2024-05-06T10:49:31","Altitude":0.0,"Velocidade":0.0,"NumeroSatelites":0,"PrecisaoHorizontal":99.99,"idxRua":-1,"DirecaoTrecho":0,"Passado":false},{"Latitude":-22.213107666666666,"Longitude":-47.381568333333334,"DataHora":"2024-05-06T10:49:32","Altitude":0.0,"Velocidade":0.0,"NumeroSatelites":0,"PrecisaoHorizontal":99.99,"idxRua":-1,"DirecaoTrecho":0,"Passado":false},{"Latitude":-22.213107666666666,"Longitude":-47.381568333333334,"DataHora":"2024-05-06T10:49:33","Altitude":0.0,"Velocidade":0.0,"NumeroSatelites":0,"PrecisaoHorizontal":99.99,"idxRua":-1,"DirecaoTrecho":0,"Passado":false},{"Latitude":-22.213107666666666,"Longitude":-47.381568333333334,"DataHora":"2024-05-06T10:49:34","Altitude":0.0,"Velocidade":0.0,"NumeroSatelites":0,"PrecisaoHorizontal":99.99,"idxRua":-1,"DirecaoTrecho":0,"Passado":false},{"Latitude":-22.213107666666666,"Longitude":-47.381568333333334,"DataHora":"2024-05-06T10:49:35","Altitude":0.0,"Velocidade":0.0,"NumeroSatelites":0,"PrecisaoHorizontal":99.99,"idxRua":-1,"DirecaoTrecho":0,"Passado":false},{"Latitude":-22.213107666666666,"Longitude":-47.381568333333334,"DataHora":"2024-05-06T10:49:36","Altitude":0.0,"Velocidade":0.0,"NumeroSatelites":0,"PrecisaoHorizontal":99.99,"idxRua":-1,"DirecaoTrecho":0,"Passado":false},{"Latitude":-22.213107666666666,"Longitude":-47.381568333333334,"DataHora":"2024-05-06T10:49:37","Altitude":0.0,"Velocidade":0.0,"NumeroSatelites":0,"PrecisaoHorizontal":99.99,"idxRua":-1,"DirecaoTrecho":0,"Passado":false},{"Latitude":-22.213107666666666,"Longitude":-47.381568333333334,"DataHora":"2024-05-06T10:49:38","Altitude":0.0,"Velocidade":0.0,"NumeroSatelites":0,"PrecisaoHorizontal":99.99,"idxRua":-1,"DirecaoTrecho":0,"Passado":false},{"Latitude":-22.213107666666666,"Longitude":-47.381568333333334,"DataHora":"2024-05-06T10:49:39","Altitude":0.0,"Velocidade":0.0,"NumeroSatelites":0,"PrecisaoHorizontal":99.99,"idxRua":-1,"DirecaoTrecho":0,"Passado":false}]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[{"Momento":"2024-05-06T10:50:24.9175688-03:00","VelocidadeMedia":0.0,"PorcentagemBateria":-227.0,"BateriaConsumida":0.0,"DistanciaPercorrida":[],"DistanciaEsquerda":0.0,"DistanciaDireita":0.0,"AnguloCarroGPS":0.0,"AnguloCarroBussola":360.0,"AnguloCarro":360.0,"SonarFrontal":null}
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[{"Momento":"2024-05-06T10:50:31.0242704-03:00","VelocidadeMedia":0.0,"PorcentagemBateria":-227.16666666666666,"BateriaConsumida":0.0,"DistanciaPercorrida":[],"DistanciaEsquerda":0.0,"DistanciaDireita":0.0,"AnguloCarroGPS":0.0,"AnguloCarroBussola":0.0,"AnguloCarro":0.0,"SonarFrontal":null},{"Momento":"2024-05-06T10:50:34.8649539-03:00","VelocidadeMedia":0.0,"PorcentagemBateria":-227.66666666666666,"BateriaConsumida":0.0,"DistanciaPercorrida":[],"DistanciaEsquerda":0.0,"DistanciaDireita":0.0,"AnguloCarroGPS":0.0,"AnguloCarroBussola":360.0,"AnguloCarro":360.0,"SonarFrontal":null}]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -25,7 +25,7 @@
|
|||
<meta name="viewport" content="width=device-width,
|
||||
initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
|
||||
<style>
|
||||
#map_cd190092d4e8a0a7ac66c9a62953f137 {
|
||||
#map_cc542e997f50a5c3413836621529b149 {
|
||||
position: relative;
|
||||
width: 100.0%;
|
||||
height: 100.0%;
|
||||
|
|
@ -39,14 +39,14 @@
|
|||
<body>
|
||||
|
||||
|
||||
<div class="folium-map" id="map_cd190092d4e8a0a7ac66c9a62953f137" ></div>
|
||||
<div class="folium-map" id="map_cc542e997f50a5c3413836621529b149" ></div>
|
||||
|
||||
</body>
|
||||
<script>
|
||||
|
||||
|
||||
var map_cd190092d4e8a0a7ac66c9a62953f137 = L.map(
|
||||
"map_cd190092d4e8a0a7ac66c9a62953f137",
|
||||
var map_cc542e997f50a5c3413836621529b149 = L.map(
|
||||
"map_cc542e997f50a5c3413836621529b149",
|
||||
{
|
||||
center: [0.0, 0.0],
|
||||
crs: L.CRS.EPSG3857,
|
||||
|
|
@ -60,13 +60,13 @@
|
|||
|
||||
|
||||
|
||||
var tile_layer_d95d5dcfac5811d5b167ee7965f28aff = L.tileLayer(
|
||||
var tile_layer_d17ce14d549a3fb1bcc02c6ad6d0ca1f = L.tileLayer(
|
||||
"https://tile.openstreetmap.org/{z}/{x}/{y}.png",
|
||||
{"attribution": "\u0026copy; \u003ca href=\"https://www.openstreetmap.org/copyright\"\u003eOpenStreetMap\u003c/a\u003e contributors", "detectRetina": false, "maxNativeZoom": 19, "maxZoom": 19, "minZoom": 0, "noWrap": false, "opacity": 1, "subdomains": "abc", "tms": false}
|
||||
);
|
||||
|
||||
|
||||
tile_layer_d95d5dcfac5811d5b167ee7965f28aff.addTo(map_cd190092d4e8a0a7ac66c9a62953f137);
|
||||
tile_layer_d17ce14d549a3fb1bcc02c6ad6d0ca1f.addTo(map_cc542e997f50a5c3413836621529b149);
|
||||
|
||||
</script>
|
||||
|
||||
|
|
@ -87,7 +87,7 @@
|
|||
}
|
||||
trajeto_json_add({"features": []});
|
||||
|
||||
trajeto_json.addTo(map_cd190092d4e8a0a7ac66c9a62953f137);
|
||||
trajeto_json.addTo(map_cc542e997f50a5c3413836621529b149);
|
||||
|
||||
function adicionarGeometria(novaGeometria) {
|
||||
trajeto_json.addData(novaGeometria);
|
||||
|
|
@ -129,14 +129,23 @@
|
|||
</script>
|
||||
|
||||
<script src="folium/mqtt.min.js"></script>
|
||||
<script src="folium/leaflet.rotatedMarker.js"></script>
|
||||
<script>
|
||||
let posicaoAtual = {
|
||||
lat: 0,
|
||||
long: 0
|
||||
};
|
||||
|
||||
var customIcon = L.icon({
|
||||
iconUrl: 'folium/images/position_marker.png',
|
||||
iconSize: [32, 32],
|
||||
iconAnchor: [16, 16],
|
||||
popupAnchor: [0, -16]
|
||||
});
|
||||
|
||||
var marcadorDinamico = L.marker([0, 0], {
|
||||
icon: L.AwesomeMarkers.icon({
|
||||
icon: 'info-sign',
|
||||
markerColor: 'red',
|
||||
prefix: 'glyphicon'
|
||||
})
|
||||
}).addTo(map_cd190092d4e8a0a7ac66c9a62953f137);
|
||||
icon: customIcon
|
||||
}).addTo(map_cc542e997f50a5c3413836621529b149);
|
||||
|
||||
// Conectar ao broker MQTT
|
||||
const client = mqtt.connect('ws://localhost:9001'); // Use wss para conexão segura
|
||||
|
|
@ -164,8 +173,43 @@
|
|||
var novaLongitude = dados.longitude;
|
||||
var novaPosicao = [novaLatitude, novaLongitude];
|
||||
marcadorDinamico.setLatLng(novaPosicao);
|
||||
|
||||
// Calcular angulo de rotacao
|
||||
var angulo = calcularOrientacao(novaPosicao[0], novaPosicao[1], posicaoAtual.lat, posicaoAtual.long);
|
||||
|
||||
posicaoAtual.lat = novaPosicao[0];
|
||||
posicaoAtual.long = novaPosicao[1];
|
||||
|
||||
// Rotacionar o marcador para o angulo calculado
|
||||
marcadorDinamico.setRotationAngle(angulo);
|
||||
|
||||
adicionarCoordenada("Tj", [novaLongitude, novaLatitude]);
|
||||
map_cd190092d4e8a0a7ac66c9a62953f137.setView(novaPosicao, map_cd190092d4e8a0a7ac66c9a62953f137.getZoom());
|
||||
map_cc542e997f50a5c3413836621529b149.setView(novaPosicao, map_cc542e997f50a5c3413836621529b149.getZoom());
|
||||
});
|
||||
|
||||
function calcularOrientacao(P1latitude, P1longitude, P2latitude, P2longitude) {
|
||||
// Converter latitudes e longitudes de graus para radianos
|
||||
const latA = P1latitude * (Math.PI / 180.0);
|
||||
const lonA = P1longitude * (Math.PI / 180.0);
|
||||
const latB = P2latitude * (Math.PI / 180.0);
|
||||
const lonB = P2longitude * (Math.PI / 180.0);
|
||||
|
||||
// Calcular a diferença de longitude
|
||||
const deltaLon = lonB - lonA;
|
||||
|
||||
// Calcular a direção
|
||||
const y = Math.sin(deltaLon) * Math.cos(latB);
|
||||
const x = Math.cos(latA) * Math.sin(latB) - Math.sin(latA) * Math.cos(latB) * Math.cos(deltaLon);
|
||||
const direcaoRadianos = Math.atan2(y, x);
|
||||
|
||||
// Converter a direção de radianos para graus
|
||||
let direcaoGraus = direcaoRadianos * (180.0 / Math.PI);
|
||||
|
||||
// Normalizar a direção para que esteja no intervalo de 0 a 360 graus
|
||||
direcaoGraus = (direcaoGraus + 360) % 360;
|
||||
|
||||
return direcaoGraus;
|
||||
}
|
||||
|
||||
</script>
|
||||
</html>
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -117,13 +117,22 @@ with open(caminho_completo_html, 'r+') as arquivo_html:
|
|||
# Script JavaScript para adicionar ao HTML, com o ID do mapa substituído
|
||||
script_atualizacao_marcador = f"""
|
||||
<script src="folium/mqtt.min.js"></script>
|
||||
<script src="folium/leaflet.rotatedMarker.js"></script>
|
||||
<script>
|
||||
let posicaoAtual = {{
|
||||
lat: 0,
|
||||
long: 0
|
||||
}};
|
||||
|
||||
var customIcon = L.icon({{
|
||||
iconUrl: 'folium/images/position_marker.png',
|
||||
iconSize: [32, 32],
|
||||
iconAnchor: [16, 16],
|
||||
popupAnchor: [0, -16]
|
||||
}});
|
||||
|
||||
var marcadorDinamico = L.marker([0, 0], {{
|
||||
icon: L.AwesomeMarkers.icon({{
|
||||
icon: 'info-sign',
|
||||
markerColor: 'red',
|
||||
prefix: 'glyphicon'
|
||||
}})
|
||||
icon: customIcon
|
||||
}}).addTo({id_mapa});
|
||||
|
||||
// Conectar ao broker MQTT
|
||||
|
|
@ -152,9 +161,44 @@ with open(caminho_completo_html, 'r+') as arquivo_html:
|
|||
var novaLongitude = dados.longitude;
|
||||
var novaPosicao = [novaLatitude, novaLongitude];
|
||||
marcadorDinamico.setLatLng(novaPosicao);
|
||||
|
||||
// Calcular angulo de rotacao
|
||||
var angulo = calcularOrientacao(novaPosicao[0], novaPosicao[1], posicaoAtual.lat, posicaoAtual.long);
|
||||
|
||||
posicaoAtual.lat = novaPosicao[0];
|
||||
posicaoAtual.long = novaPosicao[1];
|
||||
|
||||
// Rotacionar o marcador para o angulo calculado
|
||||
marcadorDinamico.setRotationAngle(angulo);
|
||||
|
||||
adicionarCoordenada("Tj", [novaLongitude, novaLatitude]);
|
||||
{id_mapa}.setView(novaPosicao, {id_mapa}.getZoom());
|
||||
}});
|
||||
|
||||
function calcularOrientacao(P1latitude, P1longitude, P2latitude, P2longitude) {{
|
||||
// Converter latitudes e longitudes de graus para radianos
|
||||
const latA = P1latitude * (Math.PI / 180.0);
|
||||
const lonA = P1longitude * (Math.PI / 180.0);
|
||||
const latB = P2latitude * (Math.PI / 180.0);
|
||||
const lonB = P2longitude * (Math.PI / 180.0);
|
||||
|
||||
// Calcular a diferença de longitude
|
||||
const deltaLon = lonB - lonA;
|
||||
|
||||
// Calcular a direção
|
||||
const y = Math.sin(deltaLon) * Math.cos(latB);
|
||||
const x = Math.cos(latA) * Math.sin(latB) - Math.sin(latA) * Math.cos(latB) * Math.cos(deltaLon);
|
||||
const direcaoRadianos = Math.atan2(y, x);
|
||||
|
||||
// Converter a direção de radianos para graus
|
||||
let direcaoGraus = direcaoRadianos * (180.0 / Math.PI);
|
||||
|
||||
// Normalizar a direção para que esteja no intervalo de 0 a 360 graus
|
||||
direcaoGraus = (direcaoGraus + 360) % 360;
|
||||
|
||||
return direcaoGraus;
|
||||
}}
|
||||
|
||||
</script>
|
||||
"""
|
||||
|
||||
|
|
|
|||
|
|
@ -23,15 +23,30 @@ outputMapName = sys.argv[4]
|
|||
topico_gps = sys.argv[5]
|
||||
topico_ruas = sys.argv[6]
|
||||
topico_trajeto_dinamico = sys.argv[7]
|
||||
mapa_dados_json = sys.argv[8]
|
||||
pastaSaida = 'Python/Output/'
|
||||
|
||||
# Carregar o arquivo shapefile contendo a geometria
|
||||
input_shapefile = pathFiles + fileName + '.shp'
|
||||
data_geometry = gpd.read_file(input_shapefile)
|
||||
|
||||
# Calcular os limites (bounds) da geometria
|
||||
minx, miny, maxx, maxy = data_geometry.total_bounds
|
||||
center = [(miny + maxy) / 2, (minx + maxx) / 2]
|
||||
if mapa_dados_json == "0":
|
||||
# Carregar o arquivo shapefile contendo a geometria
|
||||
input_shapefile = pathFiles + fileName + '.shp'
|
||||
data_geometry = gpd.read_file(input_shapefile)
|
||||
|
||||
# Converter o GeoDataFrame para GeoJSON e adicionar ao mapa
|
||||
geojson_data = data_geometry.to_json()
|
||||
# Calcular os limites (bounds) da geometria
|
||||
minx, miny, maxx, maxy = data_geometry.total_bounds
|
||||
center = [(miny + maxy) / 2, (minx + maxx) / 2]
|
||||
|
||||
# Salvar GEOJson
|
||||
data_geometry.to_file(pastaSaida + outputName, driver='GeoJSON')
|
||||
else:
|
||||
# Lendo os dados JSON
|
||||
with open(pathFiles + fileName + '.json', 'r', encoding='utf-8-sig') as f:
|
||||
geojson_data = json.load(f)
|
||||
# Obter os limites (bounds) dos dados GeoJSON
|
||||
bounds = folium.GeoJson(geojson_data).get_bounds()
|
||||
center = [(bounds[0][0] + bounds[1][0]) / 2, (bounds[0][1] + bounds[1][1]) / 2]
|
||||
|
||||
# Verificar se há conexão com a internet
|
||||
if internet_disponivel():
|
||||
|
|
@ -39,12 +54,8 @@ if internet_disponivel():
|
|||
else:
|
||||
m = folium.Map(location=center, zoom_start=12, tiles=None)
|
||||
|
||||
# Converter o GeoDataFrame para GeoJSON e adicionar ao mapa
|
||||
geojson_data = data_geometry.to_json()
|
||||
folium.GeoJson(geojson_data).add_to(m)
|
||||
|
||||
# Salvar GEOJson
|
||||
data_geometry.to_file(pastaSaida + outputName, driver='GeoJSON')
|
||||
folium.GeoJson(geojson_data).add_to(m)
|
||||
|
||||
# Salvar o mapa interativo em um arquivo HTML
|
||||
m.save(pastaSaida + outputMapName)
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
|
|
@ -403,19 +403,8 @@ C:\ZendionINC\agrobot_base\AgroBase\AgroBase\obj\Debug\AgroBase.Forms.Sensoriame
|
|||
C:\ZendionINC\agrobot_base\AgroBase\AgroBase\obj\Debug\AgroBase.Properties.Resources.resources
|
||||
C:\ZendionINC\agrobot_base\AgroBase\AgroBase\obj\Debug\AgroBase.csproj.GenerateResource.cache
|
||||
C:\ZendionINC\agrobot_base\AgroBase\AgroBase\obj\Debug\AgroBase.csproj.CoreCompileInputs.cache
|
||||
C:\ZendionINC\agrobot_base\AgroBase\AgroBase\obj\Debug\AgroBase.csproj.Up2Date
|
||||
C:\ZendionINC\agrobot_base\AgroBase\AgroBase\obj\Debug\AgroBase.exe
|
||||
C:\ZendionINC\agrobot_base\AgroBase\AgroBase\obj\Debug\AgroBase.pdb
|
||||
C:\ZendionINC\agrobot_base\AgroBase\AgroBase\bin\Debug\Python\Models\yolov7\models\__pycache__\common.cpython-310.pyc
|
||||
C:\ZendionINC\agrobot_base\AgroBase\AgroBase\bin\Debug\Python\Models\yolov7\models\__pycache__\experimental.cpython-310.pyc
|
||||
C:\ZendionINC\agrobot_base\AgroBase\AgroBase\bin\Debug\Python\Models\yolov7\models\__pycache__\__init__.cpython-310.pyc
|
||||
C:\ZendionINC\agrobot_base\AgroBase\AgroBase\bin\Debug\Python\Models\yolov7\utils\__pycache__\datasets.cpython-310.pyc
|
||||
C:\ZendionINC\agrobot_base\AgroBase\AgroBase\bin\Debug\Python\Models\yolov7\utils\__pycache__\general.cpython-310.pyc
|
||||
C:\ZendionINC\agrobot_base\AgroBase\AgroBase\bin\Debug\Python\Models\yolov7\utils\__pycache__\google_utils.cpython-310.pyc
|
||||
C:\ZendionINC\agrobot_base\AgroBase\AgroBase\bin\Debug\Python\Models\yolov7\utils\__pycache__\metrics.cpython-310.pyc
|
||||
C:\ZendionINC\agrobot_base\AgroBase\AgroBase\bin\Debug\Python\Models\yolov7\utils\__pycache__\plots.cpython-310.pyc
|
||||
C:\ZendionINC\agrobot_base\AgroBase\AgroBase\bin\Debug\Python\Models\yolov7\utils\__pycache__\torch_utils.cpython-310.pyc
|
||||
C:\ZendionINC\agrobot_base\AgroBase\AgroBase\bin\Debug\Python\Models\yolov7\utils\__pycache__\__init__.cpython-310.pyc
|
||||
C:\ZendionINC\agrobot_base\AgroBase\AgroBase\bin\Debug\Python\Models\deeplabv3plus\backbone\hrnetv2.py
|
||||
C:\ZendionINC\agrobot_base\AgroBase\AgroBase\bin\Debug\Python\Models\deeplabv3plus\backbone\mobilenetv2.py
|
||||
C:\ZendionINC\agrobot_base\AgroBase\AgroBase\bin\Debug\Python\Models\deeplabv3plus\backbone\resnet.py
|
||||
|
|
@ -452,3 +441,4 @@ C:\ZendionINC\agrobot_base\AgroBase\AgroBase\bin\Debug\Python\Models\deeplabv3pl
|
|||
C:\ZendionINC\agrobot_base\AgroBase\AgroBase\bin\Debug\AgroBase.exe.config
|
||||
C:\ZendionINC\agrobot_base\AgroBase\AgroBase\bin\Debug\AgroBase.exe
|
||||
C:\ZendionINC\agrobot_base\AgroBase\AgroBase\bin\Debug\AgroBase.pdb
|
||||
C:\ZendionInc\agrobot_base\AgroBase\AgroBase\obj\Debug\AgroBase.csproj.CopyComplete
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue