Adicionado tipo de mapa carregado, ajustado referenciamento pela base
This commit is contained in:
parent
2a907f8d5e
commit
cd1257cde5
|
|
@ -1134,6 +1134,7 @@ namespace AgroBase.Models
|
|||
p.Controle = Parametros.Controle;
|
||||
p.QtdBicos = Parametros.QtdBicos;
|
||||
p.QtdCamerasSolo = Parametros.QtdCamerasSolo;
|
||||
p.TipoMapa = Parametros.TipoMapa;
|
||||
p.Mapa = Parametros.Mapa;
|
||||
p.RuasPercorrer = Parametros.RuasPercorrer;
|
||||
p.PontosRetorno = Parametros.PontosRetorno;
|
||||
|
|
@ -1144,6 +1145,7 @@ namespace AgroBase.Models
|
|||
if (Parametros.Mapa != null)
|
||||
{
|
||||
Variaveis.OperacaoEmAndamento.Mapa = new MapasModel() { RuasPercorrer = ruasSelecionadas };
|
||||
Variaveis.OperacaoEmAndamento.Mapa.TipoMapa = p.TipoMapa;
|
||||
Variaveis.OperacaoEmAndamento.Mapa.PopularTrajetoriaMapa(Parametros.Mapa);
|
||||
}
|
||||
|
||||
|
|
@ -1835,7 +1837,7 @@ namespace AgroBase.Models
|
|||
if (controleBase.Dispositivo == T_Code.Dir && controleBase.Tecla == BotoesJoystick.R3)
|
||||
{
|
||||
//GeneralJoystick.EnviaComandoMotor(Keys.R, ForcarComando: true, ID: controleBase._comp_id);
|
||||
GeneralJoystick.ProcessarDadosControle(BotoesJoystick.R3, false);
|
||||
GeneralJoystick.ProcessarDadosControle(BotoesJoystick.R3, false, ID: controleBase._comp_id, ForcarComando: true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -146,6 +146,7 @@ namespace AgroBase.Models.Operacoes
|
|||
public List<OperacaoModulosMandatoriosModel> ModulosMandatorios { get; set; }
|
||||
public List<OperacaoParametrosMandatoriosModel> ParametrosMandatorios { get; set; }
|
||||
|
||||
public TipoMapaOperacao TipoMapa { get; set; }
|
||||
public MapaFeatureCollectionModel Mapa { get; set; }
|
||||
public List<string> RuasPercorrer { get; set; }
|
||||
public List<double[]> PontosRetorno { get; set; }
|
||||
|
|
|
|||
|
|
@ -14,7 +14,8 @@
|
|||
<TextBlock x:Name="OverlayText" Foreground="White" FontSize="12" TextWrapping="Wrap"/>
|
||||
</Border>
|
||||
|
||||
<ComboBox x:Name="CmbBaseMap" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,10,10,0" Width="189" SelectionChanged="OnBaseMapChanged"/>
|
||||
<ComboBox x:Name="CmbBaseMap" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,10,70,0" Width="189" SelectionChanged="OnBaseMapChanged"/>
|
||||
<CheckBox x:Name="chbAcompanhar" Content="Seguir" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,13,10,0"/>
|
||||
|
||||
<Button Content="Carregar Mapa" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,10,10" Padding="8,4" Background="#2ECC71" Foreground="White" FontWeight="Bold" Click="OnLoadMapClicked" Visibility="Collapsed"/>
|
||||
<!--<Button Content="Centralizar" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,10,10" Padding="8,4" Background="#2ECC71" Foreground="White" FontWeight="Bold" Click="OnCenterAreaClicked"/>-->
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ namespace OperationControl.Controls
|
|||
public static readonly DependencyProperty ScaleProperty = DependencyProperty.Register(nameof(Scale), typeof(double), typeof(MapViewControl), new PropertyMetadata(5000.0, OnViewPropertyChanged));
|
||||
public static readonly DependencyProperty MbTilesPathProperty = DependencyProperty.Register(nameof(MbTilesPath), typeof(string), typeof(MapViewControl), new PropertyMetadata(string.Empty, OnMbTilesPathChanged));
|
||||
|
||||
public TipoMapaOperacao TipoMapaSelecionado;
|
||||
public string PathMapaSelecionado;
|
||||
|
||||
public double Latitude
|
||||
|
|
@ -151,12 +152,41 @@ namespace OperationControl.Controls
|
|||
private void HighlightRoad(MIFeature? feature = null, string? id = null)
|
||||
{
|
||||
if (string.IsNullOrEmpty(id))
|
||||
id = GetAttr(feature, "IdCorrigido");
|
||||
var rua = RuasMapaCarregado.FirstOrDefault(x => x.Id == id);
|
||||
if (rua == null) return;
|
||||
id = GetAttr(feature, "Id");
|
||||
|
||||
rua.Selected = !rua.Selected;
|
||||
rua.Status = (rua.Selected) ? StreetMapStyle.Selected : StreetMapStyle.Normal;
|
||||
var rua = RuasMapaCarregado.FirstOrDefault(x => x.Id == id);
|
||||
if (rua == null)
|
||||
return;
|
||||
|
||||
if (!rua.Selected)
|
||||
{
|
||||
// Seleciona no final da fila
|
||||
int proximaOrdem = RuasMapaCarregado
|
||||
.Where(x => x.Selected && x.OrderSelection.HasValue)
|
||||
.Select(x => x.OrderSelection!.Value)
|
||||
.DefaultIfEmpty(0)
|
||||
.Max() + 1;
|
||||
|
||||
rua.Selected = true;
|
||||
rua.Status = StreetMapStyle.Selected;
|
||||
rua.OrderSelection = proximaOrdem;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Guarda a ordem antiga antes de remover
|
||||
int ordemRemovida = rua.OrderSelection ?? 0;
|
||||
|
||||
rua.Selected = false;
|
||||
rua.Status = StreetMapStyle.Normal;
|
||||
rua.OrderSelection = null;
|
||||
|
||||
// Fecha o buraco: todo mundo depois sobe uma posição
|
||||
foreach (var r in RuasMapaCarregado
|
||||
.Where(x => x.Selected && x.OrderSelection.HasValue && x.OrderSelection.Value > ordemRemovida))
|
||||
{
|
||||
r.OrderSelection--;
|
||||
}
|
||||
}
|
||||
|
||||
rua.Feature.Styles.Clear();
|
||||
rua.Feature.Styles.Add(CreateStreetStyle(rua.Status));
|
||||
|
|
@ -192,6 +222,7 @@ namespace OperationControl.Controls
|
|||
public MIFeature Feature { get; set; }
|
||||
public bool Selected { get; set; }
|
||||
public StreetMapStyle Status { get; set; }
|
||||
public int? OrderSelection { get; set; }
|
||||
}
|
||||
|
||||
public class StreetMapClickedEventArgs : EventArgs
|
||||
|
|
@ -766,12 +797,13 @@ namespace OperationControl.Controls
|
|||
/// <summary>
|
||||
/// API pública para ajustar a câmera via código.
|
||||
/// </summary>
|
||||
public void SetView(double latitude, double longitude, double? scale = null)
|
||||
public void SetView(double? latitude, double? longitude, double? scale = null)
|
||||
{
|
||||
Latitude = latitude;
|
||||
Longitude = longitude;
|
||||
if (latitude.HasValue) Latitude = latitude.Value;
|
||||
if (longitude.HasValue) Longitude = longitude.Value;
|
||||
if (scale.HasValue) Scale = scale.Value;
|
||||
NavigateToView();
|
||||
if (latitude.HasValue || longitude.HasValue)
|
||||
NavigateToView();
|
||||
}
|
||||
|
||||
#region CARREGAR ARQUIVO DE MAPA
|
||||
|
|
@ -884,7 +916,7 @@ namespace OperationControl.Controls
|
|||
GetAttr(gf, "ID") ??
|
||||
GetAttr(gf, "id");
|
||||
|
||||
gf["IdCorrigido"] = idFinal;
|
||||
gf["Id"] = idFinal;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(idOriginal))
|
||||
gf["IdOriginal"] = idOriginal;
|
||||
|
|
@ -1001,11 +1033,12 @@ namespace OperationControl.Controls
|
|||
}
|
||||
|
||||
|
||||
public void LoadMapFile(string? path)
|
||||
public void LoadMapFile(string? path, TipoMapaOperacao tipo = TipoMapaOperacao.RuasPlantacao)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(path) || !File.Exists(path) || path == PathMapaSelecionado)
|
||||
return;
|
||||
|
||||
TipoMapaSelecionado = tipo;
|
||||
PathMapaSelecionado = path;
|
||||
|
||||
if (PathMapaSelecionado.EndsWith(".shp", StringComparison.OrdinalIgnoreCase))
|
||||
|
|
@ -1113,6 +1146,7 @@ namespace OperationControl.Controls
|
|||
var dado = Mapa?.features?.FirstOrDefault(x => x.properties.Id == rua.Id);
|
||||
if (dado == null) continue;
|
||||
rua.Selected = RuasSelecionadas.Contains(dado.properties.Id);
|
||||
rua.OrderSelection = RuasMapaCarregado.IndexOf(rua) + 1;
|
||||
}
|
||||
|
||||
AtualizarStylesRuas();
|
||||
|
|
|
|||
|
|
@ -94,6 +94,9 @@
|
|||
<Compile Update="Windows\NetworkConfigWindow.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="Windows\SelecaoTipoMapa.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Update="Controls\AttitudeIndicator.xaml">
|
||||
|
|
@ -186,5 +189,8 @@
|
|||
<Page Update="Windows\NetworkConfigWindow.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="Windows\SelecaoTipoMapa.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
using OperationControl.Helpers;
|
||||
using OperationControl.Models;
|
||||
using OperationControl.Windows;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
|
|
@ -18,7 +20,7 @@ namespace OperationControl.ViewModels
|
|||
{
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
public event Action<string>? CarregarMapaSolicitado;
|
||||
public event Action<string, AgroBase.Models.Enums.TipoMapaOperacao>? CarregarMapaSolicitado;
|
||||
|
||||
// Método, latitude, longitude, altitude, offset frontal cm, offset lateral cm
|
||||
public event Action<MetodoFixacaoBase, double?, double?, double?>? FixarBaseSolicitado;
|
||||
|
|
@ -346,6 +348,16 @@ namespace OperationControl.ViewModels
|
|||
|
||||
private void ExecutarCarregarMapa()
|
||||
{
|
||||
var dlgTipo = new SelecaoTipoMapa
|
||||
{
|
||||
Owner = Variaveis.Dock
|
||||
};
|
||||
|
||||
if (dlgTipo.ShowDialog() != true || dlgTipo.Resultado == null)
|
||||
return;
|
||||
|
||||
var tipoMapa = dlgTipo.Resultado.Value;
|
||||
|
||||
var dlg = new Microsoft.Win32.OpenFileDialog
|
||||
{
|
||||
Filter = "Arquivos de mapa|*.geojson;*.json;*.shp",
|
||||
|
|
@ -354,8 +366,8 @@ namespace OperationControl.ViewModels
|
|||
|
||||
if (dlg.ShowDialog() == true)
|
||||
{
|
||||
StatusTexto = $"Mapa selecionado: {System.IO.Path.GetFileName(dlg.FileName)}";
|
||||
CarregarMapaSolicitado?.Invoke(dlg.FileName);
|
||||
StatusTexto = $"Mapa selecionado: {System.IO.Path.GetFileName(dlg.FileName)} ({tipoMapa})";
|
||||
CarregarMapaSolicitado?.Invoke(dlg.FileName, tipoMapa);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -738,13 +738,14 @@ namespace OperationControl.ViewModels
|
|||
|
||||
public void AtualizarDadosMapa(OperacaoParametrosModel? dados)
|
||||
{
|
||||
_viewOperacaoCenter?.Mapa?.LoadMapFile(_ultimoMapaCarregado);
|
||||
_viewOperacaoCenter?.Mapa?.LoadMapFile(_ultimoMapaCarregado, _ultimoTipoMapaCarregado);
|
||||
_viewOperacaoCenter?.Mapa?.CarregarDadosMapa(dados?.Mapa, dados?.RuasPercorrer, dados?.PontosRetorno);
|
||||
}
|
||||
|
||||
#region TELA 2
|
||||
|
||||
private string? _ultimoMapaCarregado;
|
||||
private TipoMapaOperacao _ultimoTipoMapaCarregado = TipoMapaOperacao.RuasPlantacao;
|
||||
|
||||
private void CriarMarcadorBase(MapViewControl Mapa)
|
||||
{
|
||||
|
|
@ -762,12 +763,12 @@ namespace OperationControl.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
private void OnCarregarMapaSolicitado(string caminhoArquivo)
|
||||
private void OnCarregarMapaSolicitado(string caminhoArquivo, TipoMapaOperacao tipo)
|
||||
{
|
||||
try
|
||||
{
|
||||
_ultimoMapaCarregado = caminhoArquivo;
|
||||
_viewPreparacaoMapa?.MapaPreparacao?.LoadMapFile(caminhoArquivo);
|
||||
_viewPreparacaoMapa?.MapaPreparacao?.LoadMapFile(caminhoArquivo, tipo);
|
||||
MapaCarregado = true;
|
||||
_viewPreparacaoMapaBottom?._vm.AtualizarProgresso(0, $"Mapa carregado: {System.IO.Path.GetFileName(caminhoArquivo)}");
|
||||
}
|
||||
|
|
@ -899,6 +900,7 @@ namespace OperationControl.ViewModels
|
|||
// MAPA
|
||||
var simulacao = obj.Controle?.SimulacaoMPC?.Select(x => new double[] { x.longitude, x.latitude })?.ToList();
|
||||
_viewOperacaoCenter?.Mapa?.markers.UpdateMarkerPosition(rover.RoverId, lat: obj.Gnss?.Latitude, lon: obj.Gnss?.Longitude, heading: obj.Gnss?.OrientacaoReal, predict: simulacao);
|
||||
if (_viewOperacaoCenter?.Mapa?.chbAcompanhar.IsChecked ?? false) _viewOperacaoCenter?.Mapa?.SetView(obj.Gnss?.Latitude, obj.Gnss?.Longitude);
|
||||
_viewOperacaoCenter?.Mapa?.markers.UpdateMarkerInfo(rover.RoverId, status: obj.Operacao?.Status ?? AgroBase.Models.Enums.StatusOperacao.NaoIniciado);
|
||||
|
||||
// ALERTAS
|
||||
|
|
@ -1125,7 +1127,7 @@ namespace OperationControl.ViewModels
|
|||
}
|
||||
|
||||
var dadosMapa = _viewOperacaoCenter?.Mapa?.CriarDadosMapa();
|
||||
var ruasPercorrer = _viewOperacaoCenter?.Mapa?.RuasMapaCarregado?.Where(x => x.Selected)?.Select(x => x.Id)?.ToList() ?? new List<string>();
|
||||
var ruasPercorrer = _viewOperacaoCenter?.Mapa?.RuasMapaCarregado?.Where(x => x.Selected)?.OrderBy(x => x.OrderSelection.Value)?.Select(x => x.Id)?.ToList() ?? new List<string>();
|
||||
|
||||
if (rover?.DadosLeitura?.Operacao?.Modo != parametros.Modo && (rover?.DadosLeitura?.Operacao?.Iniciada ?? false))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,42 @@
|
|||
<Window x:Class="OperationControl.Windows.SelecaoTipoMapa"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Title="Tipo de mapa"
|
||||
Height="180"
|
||||
Width="360"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
ResizeMode="NoResize">
|
||||
<Grid Margin="16">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBlock Text="Selecione o tipo de mapa que será carregado:"
|
||||
FontSize="14"
|
||||
FontWeight="SemiBold"
|
||||
Margin="0,0,0,12"/>
|
||||
|
||||
<ComboBox Grid.Row="1"
|
||||
ItemsSource="{Binding TiposMapa}"
|
||||
SelectedItem="{Binding TipoSelecionado}"
|
||||
DisplayMemberPath="Nome"
|
||||
MinHeight="30"/>
|
||||
|
||||
<StackPanel Grid.Row="3"
|
||||
Orientation="Horizontal"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,16,0,0">
|
||||
<Button Content="Cancelar"
|
||||
Width="90"
|
||||
Margin="0,0,8,0"
|
||||
IsCancel="True"/>
|
||||
<Button Content="OK"
|
||||
Width="90"
|
||||
IsDefault="True"
|
||||
Click="BtnOk_Click"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
using System.Windows;
|
||||
using static AgroBase.Models.Enums;
|
||||
|
||||
namespace OperationControl.Windows
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for SelecaoTipoMapa.xaml
|
||||
/// </summary>
|
||||
public partial class SelecaoTipoMapa : Window
|
||||
{
|
||||
public SelecaoTipoMapa()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
TiposMapa = Enum.GetValues(typeof(TipoMapaOperacao))
|
||||
.Cast<TipoMapaOperacao>()
|
||||
.Where(x => x != TipoMapaOperacao.Indefinido)
|
||||
.Select(x => new TipoMapaItem
|
||||
{
|
||||
Valor = x,
|
||||
Nome = ObterNomeAmigavel(x)
|
||||
})
|
||||
.ToList();
|
||||
|
||||
TipoSelecionado = TiposMapa.FirstOrDefault();
|
||||
|
||||
DataContext = this;
|
||||
}
|
||||
|
||||
public List<TipoMapaItem> TiposMapa { get; set; }
|
||||
public TipoMapaItem? TipoSelecionado { get; set; }
|
||||
|
||||
public TipoMapaOperacao? Resultado { get; private set; }
|
||||
|
||||
private void BtnOk_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (TipoSelecionado == null)
|
||||
{
|
||||
System.Windows.MessageBox.Show("Selecione um tipo de mapa.", "Aviso", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
Resultado = TipoSelecionado.Valor;
|
||||
DialogResult = true;
|
||||
Close();
|
||||
}
|
||||
|
||||
private string ObterNomeAmigavel(TipoMapaOperacao tipo)
|
||||
{
|
||||
return tipo switch
|
||||
{
|
||||
TipoMapaOperacao.GPS => "GPS",
|
||||
TipoMapaOperacao.RuasPlantacao => "Ruas de Plantação",
|
||||
TipoMapaOperacao.Corredores => "Corredores",
|
||||
_ => tipo.ToString()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public class TipoMapaItem
|
||||
{
|
||||
public TipoMapaOperacao Valor { get; set; }
|
||||
public string Nome { get; set; } = "";
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue