Avances en ventana de Limpieza, preparar para exportación, etc
parent
55d87b0edf
commit
5e766d9fab
|
|
@ -27,7 +27,8 @@ namespace OliviaAddInPro
|
|||
{
|
||||
if (OliviaGlob.TipoEjec == TiposEjecucion.Ninguno)
|
||||
{
|
||||
OliviaGlob.TipoEjec = TiposEjecucion.LimpiezaConfig;
|
||||
OliviaGlob.TipoEjec = TiposEjecucion.Limp;
|
||||
OliviaGlob.Limp = new Limpieza();
|
||||
DockpaneLimpiezaViewModel.Show();
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -27,7 +27,8 @@ namespace OliviaAddInPro
|
|||
{
|
||||
if(OliviaGlob.TipoEjec==TiposEjecucion.Ninguno)
|
||||
{
|
||||
OliviaGlob.TipoEjec = TiposEjecucion.RecoConfig;
|
||||
OliviaGlob.TipoEjec = TiposEjecucion.Reco;
|
||||
//OliviaGlob.Reco=new
|
||||
DockpaneRecogidaViewModel.Show();
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -19,8 +19,7 @@
|
|||
</tab>
|
||||
</tabs>
|
||||
<groups>
|
||||
<group id="OliviaAddInPro_Group1" caption="Olivia" appearsOnAddInTab="false">
|
||||
<button refID="OliviaAddInPro_Button1" size="large" />
|
||||
<group id="OliviaAddInPro_Group1" caption="Olivia" appearsOnAddInTab="false">
|
||||
<button refID="OliviaAddInPro_ButtonLimp" size="large" />
|
||||
<button refID="OliviaAddInPro_ButtonRec" size="large" />
|
||||
<button refID="OliviaAddInPro_ButtonMaq" size="large" />
|
||||
|
|
@ -44,10 +43,7 @@
|
|||
<button id="OliviaAddInPro_ButtonConfig" caption="Configuración" className="ButtonConfig" loadOnClick="true" largeImage="Images/config.png">
|
||||
<tooltip heading="OLIVIA - Configuración">
|
||||
Add-In de ArcGIS Pro para la herramienta de optimización de la limpieza viaria, OLIVIA<disabledText /></tooltip>
|
||||
</button>
|
||||
<button id="OliviaAddInPro_ButtonArcGisPro" caption="ButtonArcGisPro" className="ButtonArcGisPro" loadOnClick="true" smallImage="pack://application:,,,/ArcGIS.Desktop.Resources;component/Images/GenericButtonBlue16.png" largeImage="pack://application:,,,/ArcGIS.Desktop.Resources;component/Images/GenericButtonBlue32.png">
|
||||
<tooltip heading="Tooltip Heading">Tooltip text<disabledText /></tooltip>
|
||||
</button>
|
||||
</button>
|
||||
</controls>
|
||||
<dockPanes>
|
||||
<dockPane id="OliviaAddInPro_DockpaneLimpieza" caption="OLIVIA | Limpieza" className="DockpaneLimpiezaViewModel" dock="group" dockWith="esri_core_contentsDockPane">
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ namespace OliviaAddInPro.Helper
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
HelperGdb.out_str = "Error al abrir Geodatabase " + path + ": " + ex.Message;
|
||||
HelperGdb.OutStr = "Error al abrir Geodatabase " + path + ": " + ex.Message;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -205,7 +205,7 @@ namespace OliviaAddInPro.Helper
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
HelperGdb.out_str = "Error al abrir Feature Class " + nameFtclss + ": " + ex.Message;
|
||||
HelperGdb.OutStr = "Error al abrir Feature Class " + nameFtclss + ": " + ex.Message;
|
||||
return null;
|
||||
}
|
||||
return ftclss;
|
||||
|
|
@ -230,7 +230,7 @@ namespace OliviaAddInPro.Helper
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
HelperGdb.out_str = "Error al abrir Shapefile " + pathShp + ": " + ex.Message;
|
||||
HelperGdb.OutStr = "Error al abrir Shapefile " + pathShp + ": " + ex.Message;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -252,7 +252,7 @@ namespace OliviaAddInPro.Helper
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
HelperGdb.out_str = "No se encuentra el campo " + fieldName + ": " + ex.Message;
|
||||
HelperGdb.OutStr = "No se encuentra el campo " + fieldName + ": " + ex.Message;
|
||||
return null;
|
||||
}
|
||||
return field;
|
||||
|
|
@ -282,13 +282,35 @@ namespace OliviaAddInPro.Helper
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
HelperGdb.out_str = "Error al leer los campos " + fc.GetName() + ": " + ex.Message;
|
||||
HelperGdb.OutStr = "Error al leer los campos " + fc.GetName() + ": " + ex.Message;
|
||||
return fields_st;
|
||||
}
|
||||
return fields_st;
|
||||
}));
|
||||
}
|
||||
|
||||
/*
|
||||
* Comprueba que en la capa dada exista un campo con nombre 'field'
|
||||
*/
|
||||
public static bool CheckField(string pathCapa, string field)
|
||||
{
|
||||
FeatureClass fc = GetFtClass(pathCapa);
|
||||
if (fc == null)
|
||||
{
|
||||
HelperGdb.OutStr = "No se puede abrir la capa";
|
||||
return false;
|
||||
}
|
||||
|
||||
ObservableCollection<string> fields = GetFields(fc).Result;
|
||||
if (!fields.Contains(field))
|
||||
{
|
||||
HelperGdb.OutStr = "No se encuentra el campo " + field;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//Devuelve comilla simple si el campo es de texto, o nada si es númerico
|
||||
//var whereClause = $"{SelectedField} = {Quote(f)}{FieldValue}{Quote(f)}";
|
||||
public static string Quote(ArcGIS.Core.Data.Field f)
|
||||
|
|
@ -329,7 +351,7 @@ namespace OliviaAddInPro.Helper
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
HelperGdb.out_str = "Error al leer los campos " + fc.GetName() + ": " + ex.Message;
|
||||
HelperGdb.OutStr = "Error al leer los campos " + fc.GetName() + ": " + ex.Message;
|
||||
return attribs_st;
|
||||
|
||||
}
|
||||
|
|
@ -448,7 +470,7 @@ namespace OliviaAddInPro.Helper
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
out_str = "Error al leer generar geometría única " + out_str + ex.Message;
|
||||
OutStr = "Error al leer generar geometría única " + OutStr + ex.Message;
|
||||
return geomsal;
|
||||
}
|
||||
|
||||
|
|
@ -467,7 +489,7 @@ namespace OliviaAddInPro.Helper
|
|||
ArcGIS.Core.Data.QueryFilter filtro;
|
||||
bool ok = true;
|
||||
ReiniciaOutStr();
|
||||
TextoSal = string.Empty;
|
||||
string txtsal = string.Empty;
|
||||
|
||||
return ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run((Func<ArcGIS.Core.Geometry.Geometry>)(() =>
|
||||
{
|
||||
|
|
@ -488,18 +510,19 @@ namespace OliviaAddInPro.Helper
|
|||
continue;
|
||||
}
|
||||
geomsal = UneGeom(geomsal, geomAux);
|
||||
TextoSal = TextoSal + HelperGlobal.RevisaText(selFieldVals[i]);
|
||||
txtsal = txtsal + HelperGlobal.RevisaText(selFieldVals[i]);
|
||||
}
|
||||
TextoSal = txtsal;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
HelperGdb.out_str = "Error al generar geometría en " + fclss.GetName() + " Con filtro " + where +": " + ex.Message;
|
||||
HelperGdb.OutStr = "Error al generar geometría en " + fclss.GetName() + " Con filtro " + where +": " + ex.Message;
|
||||
return geomsal;
|
||||
|
||||
}
|
||||
if (!ok)
|
||||
HelperGdb.out_str = "Error al generar geometría en " + fclss.GetName() + " Con filtro " + where + HelperGdb.out_str;
|
||||
HelperGdb.OutStr = "Error al generar geometría en " + fclss.GetName() + " Con filtro " + where + HelperGdb.OutStr;
|
||||
return geomsal;
|
||||
}));
|
||||
}
|
||||
|
|
@ -548,7 +571,7 @@ namespace OliviaAddInPro.Helper
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
HelperGdb.out_str = "Error al contar filas en " + fc.GetName() + ": " + ex.Message;
|
||||
HelperGdb.OutStr = "Error al contar filas en " + fc.GetName() + ": " + ex.Message;
|
||||
return n;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,13 +13,18 @@ namespace OliviaAddInPro.Helper
|
|||
public static class HelperGlobal
|
||||
{
|
||||
|
||||
public static void ponMsg(String mensaje, System.Windows.MessageBoxImage icon = MessageBoxImage.Information,
|
||||
public static bool ponMsg(String mensaje, System.Windows.MessageBoxImage icon = MessageBoxImage.Information,
|
||||
String titulo = "OLIVIA",
|
||||
MessageBoxButton button= MessageBoxButton.OK)
|
||||
{
|
||||
{
|
||||
//MessageBoxResult Show(string messageText, string caption, MessageBoxButton button, MessageBoxImage icon);
|
||||
ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(mensaje, titulo, button, icon);
|
||||
MessageBoxResult res = ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(mensaje, titulo, button, icon);
|
||||
if (res == MessageBoxResult.Yes || res == MessageBoxResult.OK)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public static string RevisaText(string text)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
|
@ -32,5 +37,18 @@ namespace OliviaAddInPro.Helper
|
|||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
public static bool Str2Int(string entr, out int sal)
|
||||
{
|
||||
sal = 0;
|
||||
try
|
||||
{
|
||||
sal=int.Parse(entr);
|
||||
return true;
|
||||
}
|
||||
catch(Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,31 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OliviaAddInPro.Model
|
||||
{
|
||||
public interface ILimpieza
|
||||
{
|
||||
//**********************************************
|
||||
//Se recogen en PaneLimpiezaSub1
|
||||
/**
|
||||
* Tipo de tratamiento elegidos
|
||||
*/
|
||||
int TipoTto { get; }
|
||||
/**
|
||||
* Ámbitos de trabajo elegidos
|
||||
*/
|
||||
bool[] AmbitosSel { get; }
|
||||
/**
|
||||
* Indica si respeta el sentido de circulación o no
|
||||
*/
|
||||
bool RespCirc { get; }
|
||||
/**
|
||||
* Tipo de unidades del tiempo de tto
|
||||
*/
|
||||
int UdsTTto { get; }
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -12,38 +12,54 @@ using OliviaAddInPro.Services;
|
|||
|
||||
namespace OliviaAddInPro.Model
|
||||
{
|
||||
public class Limpieza : Comun
|
||||
public class Limpieza : TratamientoComun
|
||||
{
|
||||
//**********************************************
|
||||
//Se recogen en PaneLimpiezaSub1
|
||||
/**
|
||||
* Tipo de tratamiento elegidos
|
||||
*/
|
||||
public int TipoTto = -1;
|
||||
public int TipoTto { get; set; } = -1;
|
||||
/**
|
||||
* Ámbitos de trabajo elegidos
|
||||
*/
|
||||
public bool[] AmbitosSel = new bool[(int)LimpiezaDef.AmbitsTra.AmbN];
|
||||
public bool[] AmbitosSel { get; set; } = new bool[(int)LimpiezaDef.AmbitsTra.AmbN];
|
||||
/**
|
||||
* Indica si respeta el sentido de circulación o no
|
||||
*/
|
||||
public bool RespCirc = false;
|
||||
public bool RespCirc { get; set; } = false;
|
||||
/**
|
||||
* Tipo de unidades del tiempo de tto
|
||||
*/
|
||||
public int UdsTTto = (int)GeneralDef.OlvTiposTto.OlvTipTtoNoDef;
|
||||
public int UdsTTto { get; set; } = (int)GeneralDef.OlvTiposTto.OlvTipTtoNoDef;
|
||||
/**
|
||||
* Path a una capa auxiliar que almacena las columnas de sectorización y planif
|
||||
*/
|
||||
public string CapaAuxPlanif = string.Empty;
|
||||
/**
|
||||
* Instancia para las funciones de exportación y demás
|
||||
*/
|
||||
public LimpiezaServ Serv = null;
|
||||
/**
|
||||
* Almacena la consulta para exportar los ámbitos
|
||||
*/
|
||||
public string ConsultaAmbs = "";
|
||||
public LimpiezaServ Serv { get; set; } = null;
|
||||
public Limpieza()
|
||||
{
|
||||
Serv = new LimpiezaServ(this);
|
||||
}
|
||||
|
||||
public void Ejecuta(ModosEjec modo)
|
||||
{
|
||||
bool bien = true;
|
||||
if (modo == ModosEjec.Sectoriza)
|
||||
bien = Serv.Sectoriza();
|
||||
else if (modo == ModosEjec.Planifica)
|
||||
bien=Serv.Planifica();
|
||||
if(!bien)
|
||||
{
|
||||
string msg;
|
||||
if (Serv.ErrStr.Length > 0)
|
||||
msg = Serv.ErrStr;
|
||||
else
|
||||
msg="Han ocurrido errores al comenzar la ejeción."
|
||||
HelperGlobal.ponMsg(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,6 +37,8 @@ namespace OliviaAddInPro.Model
|
|||
public static string consulta_observ; //<Campo a consultar de la capa de limpieza, observaciones
|
||||
public static string consulta_anch_tip; //<Campo a consultar de la capa de limpieza, ancho tipo
|
||||
public static string consulta_tipolo; //<Campo a consultar de la capa de limpieza, tipología
|
||||
public static string consulta_sector; //<Campo a consultar de la capa planificada, sector
|
||||
public static string consulta_secuen; //<Campo a consultar de la capa planificada, planificacion
|
||||
};
|
||||
/**
|
||||
* Nombre de los atributos (de las capas) sobre los que se realizarán consultas para la limpieza
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
/**
|
||||
|
||||
|
||||
using ArcGIS.Core.Geometry;
|
||||
/**
|
||||
* @file GeneralDef.cs
|
||||
* Clase con definiciones globales comunes al proyecto Olivia y a OliviaTasks.
|
||||
*/
|
||||
/**
|
||||
*//**
|
||||
* Clase con definiciones globales comunes al proyecto Olivia y a OliviaTasks.
|
||||
*/
|
||||
namespace OliviaAddInPro.Model
|
||||
|
|
@ -36,6 +38,7 @@ namespace OliviaAddInPro.Model
|
|||
OlvTipTtoM2h_eje,
|
||||
};
|
||||
public static string[] UdsTto = new string[] {"min","m/h","m/h","m2/h","m2/h"};
|
||||
public static int SpatRefDef { get; set; } = (int)esriSRProjCS4Type.esriSRProjCS_ETRS1989_UTM_Zone_30N;
|
||||
//*************************************************************************************
|
||||
//Variables generales
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -1,20 +1,31 @@
|
|||
using System;
|
||||
using ArcGIS.Desktop.Internal.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using OliviaAddInPro.Services;
|
||||
using ArcGIS.Core.Geometry;
|
||||
|
||||
namespace OliviaAddInPro.Model
|
||||
{
|
||||
enum TiposEjecucion
|
||||
[Flags]
|
||||
/**
|
||||
* 2 primeros bit indican si es nada (0), limp (1), reco(2), u otros (3)
|
||||
* 3er bit indica si es config
|
||||
* 4º bit indica ejec
|
||||
*/
|
||||
public enum TiposEjecucion
|
||||
{
|
||||
Ninguno,
|
||||
LimpiezaConfig,
|
||||
LimpiezaEjec,
|
||||
RecoConfig,
|
||||
RecoEjec,
|
||||
Maqueta,
|
||||
Config
|
||||
Ninguno = 0,
|
||||
Limp=1,
|
||||
Reco=2,
|
||||
Config = 4, //está configurando por primera vez
|
||||
Ejec=8,//está ejecutando por primera vez
|
||||
Config2=16,//está configurando después de haber planificado ya al menos una primera vez
|
||||
Ejec2=32,//está ejecutando después de haber planificado ya al menos una primera vez
|
||||
Maqueta =64,
|
||||
Conifg=128,
|
||||
}
|
||||
static class OliviaGlob
|
||||
{
|
||||
|
|
@ -50,8 +61,11 @@ namespace OliviaAddInPro.Model
|
|||
public static Limpieza Limp
|
||||
{
|
||||
get { return limp; }
|
||||
//set { limp = value; }
|
||||
set { limp = value; }
|
||||
}
|
||||
public static EjecServ Serv { get; } = new EjecServ();
|
||||
public static SpatialReference SpatRef { get; set; } = null;
|
||||
|
||||
#endregion Properties
|
||||
|
||||
public static void Inicia()
|
||||
|
|
@ -59,6 +73,50 @@ namespace OliviaAddInPro.Model
|
|||
IniDefault();
|
||||
LimpiezaDef.iniciaLimpDef();
|
||||
limp = new Limpieza();
|
||||
SpatRef = ArcGIS.Core.Geometry.SpatialReferenceBuilder.CreateSpatialReference(GeneralDef.SpatRefDef);
|
||||
}
|
||||
|
||||
public static bool IsLimp()
|
||||
{
|
||||
return (OliviaGlob.TipoEjec & TiposEjecucion.Limp) == TiposEjecucion.Limp;
|
||||
}
|
||||
public static bool IsReco()
|
||||
{
|
||||
return (OliviaGlob.TipoEjec & TiposEjecucion.Reco) == TiposEjecucion.Reco;
|
||||
}
|
||||
public static bool IsConfig2()
|
||||
{
|
||||
return (OliviaGlob.TipoEjec & TiposEjecucion.Config2) == TiposEjecucion.Config2;
|
||||
}
|
||||
/**
|
||||
* Habilita Sh=true
|
||||
* o Deshabilita sh=false
|
||||
* el pane correspondiente
|
||||
*/
|
||||
public static void ShowHidePane(bool sh)
|
||||
{
|
||||
if (OliviaGlob.IsLimp())
|
||||
{
|
||||
if (sh)
|
||||
{
|
||||
DockpaneLimpiezaViewModel.Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
DockpaneLimpiezaViewModel.Hide_();
|
||||
}
|
||||
}
|
||||
else if (OliviaGlob.IsReco())
|
||||
{
|
||||
if (sh)
|
||||
{
|
||||
DockpaneRecogidaViewModel.Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
DockpaneRecogidaViewModel.Hide_();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -99,6 +157,8 @@ namespace OliviaAddInPro.Model
|
|||
LimpiezaDef.Campos.consulta_observ = "OBSERVACIONES";
|
||||
LimpiezaDef.Campos.consulta_anch_tip = "ANCHO_TIPO";
|
||||
LimpiezaDef.Campos.consulta_tipolo = "TIPOLOGIA";
|
||||
LimpiezaDef.Campos.consulta_sector = "SECTOR";
|
||||
LimpiezaDef.Campos.consulta_secuen = "SECUENCIA";
|
||||
|
||||
LimpiezaDef.Atributos.atr_esca = "Escaleras";
|
||||
LimpiezaDef.Atributos.atr_fuent = "Fuentes";
|
||||
|
|
|
|||
|
|
@ -8,72 +8,83 @@ using ArcGIS.Desktop.Internal.Layouts.Utilities;
|
|||
|
||||
namespace OliviaAddInPro.Model
|
||||
{
|
||||
public abstract class Comun
|
||||
public class TratamientoComun
|
||||
{
|
||||
/**
|
||||
* Capa de ámbitos
|
||||
*/
|
||||
public string CapaElems = string.Empty;
|
||||
public string CapaElems { get; set; } = string.Empty;
|
||||
/**
|
||||
* Velocidad de desplazamiento, en km/h. Si es 0, es determinada por la vía
|
||||
*/
|
||||
public double VDespl = 0;
|
||||
public int VDespl { get; set; } = 0;
|
||||
/**
|
||||
* Tiempo de tratamiento, en minutos
|
||||
*/
|
||||
public double Ttto = 5;
|
||||
public int Ttto { get; set; } = 5;
|
||||
/**
|
||||
* Geometría para el filtro de ámbitos, incluye zonas, se añaden los ámbitos que pertenecen a esa geom
|
||||
*/
|
||||
public Geometry GeomZon = null;
|
||||
public Geometry GeomZon { get; set; } = null;
|
||||
public string TextGeomZon { get; set; } = string.Empty;
|
||||
/**
|
||||
* Geometría para el filtro de ámbitos, incluye zonas, se añaden los ámbitos que pertenecen a esa geom
|
||||
*/
|
||||
public Geometry GeomNiv = null;
|
||||
public Geometry GeomNiv { get; set; } = null;
|
||||
public string TextGeomNiv { get; set; } = string.Empty;
|
||||
/**
|
||||
* Geometría para el filtro de ámbitos, incluye restricciones, se quitan los ámbitos que pertenecen a esa geom
|
||||
*/
|
||||
public Geometry GeomRestr = null;
|
||||
public Geometry GeomRestr { get; set; } = null;
|
||||
public string TextGeomRestr { get; set; } = string.Empty;
|
||||
/**
|
||||
* Coordenadas de la instalación
|
||||
*/
|
||||
public Coordinate2D CoordsInstal = new Coordinate2D(0, 0);
|
||||
public Coordinate2D CoordsInstal { get; set; } = new Coordinate2D(0, 0);
|
||||
/**
|
||||
* Buffer para la exportación, en metros
|
||||
*/
|
||||
public int BuffExport = 1000;
|
||||
public int BuffExport { get; set; } = 1000;
|
||||
/**
|
||||
* Tiempo de trabajo al día por convenio, en minutos
|
||||
*/
|
||||
public double TConv = LimpiezaDef.Parametros.t_conv;
|
||||
public double TConv { get; set; } = LimpiezaDef.Parametros.t_conv;
|
||||
/**
|
||||
* Tiempo de descanso del personal, en minutos
|
||||
*/
|
||||
public double TDescan = LimpiezaDef.Parametros.t_descanso;
|
||||
public double TDescan { get; set; } = LimpiezaDef.Parametros.t_descanso;
|
||||
/**
|
||||
* Tiempo de carga y descarga, en minutos
|
||||
*/
|
||||
public double TDescarg = LimpiezaDef.Parametros.t_cardesc;
|
||||
public double TDescarg { get; set; } = LimpiezaDef.Parametros.t_cardesc;
|
||||
/**
|
||||
* Tiempo de desplazamiento inicio/fin a las instalaciones, en minutos
|
||||
*/
|
||||
public double TDesplIniFin = LimpiezaDef.Parametros.t_desp;
|
||||
public double TDesplIniFin { get; set; } = LimpiezaDef.Parametros.t_desp;
|
||||
/**
|
||||
* hora de inicio de la jornada de trabajo, en minutos
|
||||
*/
|
||||
public double HIni = LimpiezaDef.Parametros.h_inicio;
|
||||
public double HIni { get; set; } = LimpiezaDef.Parametros.h_inicio;
|
||||
/**
|
||||
* Porcentaje de tráfico que se estima, ya que si no los vehículos irían siempre a la velocida máxima permitida por la vía
|
||||
*/
|
||||
public int Trafico = 80;
|
||||
public int Trafico { get; set; } = 80;
|
||||
/**
|
||||
* Número de puntos de control
|
||||
*/
|
||||
public int NPtosCtrl = 3;
|
||||
public int NPtosCtrl { get; set; } = 3;
|
||||
/**
|
||||
* Número de sectores, si es 0, se calcula automáticamente, si es negativo, se ajusta a jornada
|
||||
*/
|
||||
public int NSect = 3;
|
||||
public int NSect { get; set; } = 3;
|
||||
/**
|
||||
* Ignorar o noelementos aislados
|
||||
*/
|
||||
public bool IgnoAis { get; set; } = true;
|
||||
/**
|
||||
* Almacena la consulta para exportar los ámbitos
|
||||
*/
|
||||
public string ConsultaAmbs { get; set; } = "";
|
||||
/**
|
||||
* String para errores o mensajes
|
||||
*/
|
||||
|
|
@ -133,11 +133,12 @@
|
|||
<Compile Include="Helper\CheckedListItem.cs" />
|
||||
<Compile Include="Helper\HelperGdb.cs" />
|
||||
<Compile Include="Helper\HelperGlobal.cs" />
|
||||
<Compile Include="Model\Comun.cs" />
|
||||
<Compile Include="Model\ILimpieza.cs" />
|
||||
<Compile Include="Model\ESRI.ArcGIS.Geometry.esriSRProjCS4Type.cs" />
|
||||
<Compile Include="Model\TratamientoComun.cs" />
|
||||
<Compile Include="Model\Limpieza.cs" />
|
||||
<Compile Include="Model\LimpiezaDef.cs" />
|
||||
<Compile Include="Model\OliviaDef.cs" />
|
||||
<Compile Include="Services\EjecServ.cs" />
|
||||
<Compile Include="Services\LimpiezaServ.cs" />
|
||||
<Compile Include="ViewModel\OptionsMenuItem.cs" />
|
||||
<Compile Include="ViewModel\PaneEjecutarViewModel.cs" />
|
||||
|
|
|
|||
|
|
@ -0,0 +1,213 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using OliviaAddInPro.Model;
|
||||
using ArcGIS.Core.Data;
|
||||
using ArcGIS.Core.Geometry;
|
||||
using OliviaAddInPro.Helper;
|
||||
using ArcGIS.Core.Internal.Data;
|
||||
|
||||
namespace OliviaAddInPro.Services
|
||||
{
|
||||
public enum ModosEjec
|
||||
{
|
||||
Sectoriza,
|
||||
Planifica
|
||||
}
|
||||
//Clase que realiza las funciones de la ejecución
|
||||
public class EjecServ
|
||||
{
|
||||
//Cadenas de nombres internos para la exportación/importación de los archivos
|
||||
public string prefNameExport = "data_";
|
||||
public string extShp = ".shp";
|
||||
public string name_export_nw = "nw_";
|
||||
|
||||
public string ErrStr = "";
|
||||
public TratamientoComun com;
|
||||
/**
|
||||
* Acciones para comenzar ejecución
|
||||
* Modo 0, sectorizar
|
||||
* Modo 1, planificar
|
||||
*/
|
||||
public bool ComienzaEjec(ModosEjec modo)
|
||||
{
|
||||
bool fue_mal = false;
|
||||
|
||||
//esconde el pane
|
||||
OliviaGlob.ShowHidePane(false);
|
||||
|
||||
//Cuenta las filas que cumplen la consulta
|
||||
int nelems = HelperGdb.GetNumElems(com.CapaElems, com.ConsultaAmbs);
|
||||
if(nelems<=0)
|
||||
{
|
||||
ErrStr = "No existen ámbitos que cumplan las condiciones introducidas para la exportación " + com.ConsultaAmbs;
|
||||
fue_mal = true;
|
||||
}
|
||||
|
||||
//Obtiene la geometría que envuelve a los ámbitos
|
||||
Geometry geom_export = null;
|
||||
if (!fue_mal)
|
||||
{
|
||||
geom_export = GetGeomAmbitsExport();
|
||||
if (geom_export == null || geom_export.IsEmpty)
|
||||
{
|
||||
fue_mal = true;
|
||||
}
|
||||
}
|
||||
|
||||
//mira spatialreference de los datos de entrada
|
||||
GetSpatialRef(geom_export);
|
||||
|
||||
//crea el filtro de exportación
|
||||
SpatialQueryFilter filtroEspacial = null;
|
||||
if (!fue_mal)
|
||||
{
|
||||
filtroEspacial = CreaFiltro(com.ConsultaAmbs, geom_export);
|
||||
if (filtroEspacial == null)
|
||||
{
|
||||
fue_mal = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!fue_mal)
|
||||
{
|
||||
Ejecuta(modo);
|
||||
return true;
|
||||
}
|
||||
|
||||
//fue mal
|
||||
//muestra pane
|
||||
OliviaGlob.ShowHidePane(true);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepara la geometría para exportar los ámbitos
|
||||
*/
|
||||
public Geometry GetGeomAmbitsExport()
|
||||
{
|
||||
Geometry geomAux = null;
|
||||
FeatureClass fc = HelperGdb.GetFtClass(com.CapaElems);
|
||||
QueryFilter filtro = new QueryFilter { WhereClause = com.ConsultaAmbs };
|
||||
if (fc == null)
|
||||
{
|
||||
ErrStr = "No se ha podido abrir la clase " + com.CapaElems;
|
||||
return null;
|
||||
}
|
||||
//comprueba que haya elementos que cumplen la consulta
|
||||
int nElem = HelperGdb.GetNumElems(fc, com.ConsultaAmbs).Result;
|
||||
if (nElem <= 0)
|
||||
{
|
||||
ErrStr = "No existen ámbitos que cumplan las condiciones dadas " + com.ConsultaAmbs;
|
||||
return null;
|
||||
}
|
||||
//Primero hace la geometría de los ámbitos que cumplen la consulta
|
||||
geomAux = HelperGdb.GetGeomConvexHull(fc, filtro);
|
||||
if (geomAux == null || geomAux.IsEmpty)
|
||||
{
|
||||
ErrStr = "No se ha podido generar geometría de los ámbitos" + com.ConsultaAmbs;
|
||||
return null;
|
||||
}
|
||||
//Hace la intersección de dicha geometría con las zonas
|
||||
if (com.GeomZon != null)
|
||||
{
|
||||
geomAux = HelperGdb.IntersectGeom(geomAux, com.GeomZon);
|
||||
if (geomAux == null)
|
||||
{
|
||||
ErrStr = "Error al intersecar con las zonas.";
|
||||
return null;
|
||||
}
|
||||
if(geomAux.IsEmpty)
|
||||
{
|
||||
ErrStr = "No existen ámbitos en la intersección con las zonas.";
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
//Hace la intersección de la geometría con los niveles
|
||||
if (com.GeomNiv != null)
|
||||
{
|
||||
geomAux = HelperGdb.IntersectGeom(geomAux, com.GeomNiv);
|
||||
if (geomAux == null)
|
||||
{
|
||||
ErrStr = "Error al intersecar con los niveles.";
|
||||
return null;
|
||||
}
|
||||
if (geomAux.IsEmpty)
|
||||
{
|
||||
ErrStr = "No existen ámbitos en la intersección con los niveles.";
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
//le quita las restricciones
|
||||
if (com.GeomRestr != null)
|
||||
{
|
||||
geomAux = HelperGdb.QuitaGeom(geomAux, com.GeomRestr);
|
||||
if (geomAux == null)
|
||||
{
|
||||
ErrStr = "Error al intersecar con las restricciones.";
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return geomAux;
|
||||
}
|
||||
|
||||
public SpatialQueryFilter CreaFiltro(string consulta, Geometry geom)
|
||||
{
|
||||
SpatialQueryFilter filtSpac = new SpatialQueryFilter
|
||||
{
|
||||
WhereClause = consulta,
|
||||
FilterGeometry = geom,
|
||||
SpatialRelationship = SpatialRelationship.Contains,
|
||||
};
|
||||
return filtSpac;
|
||||
}
|
||||
|
||||
/**
|
||||
* Devuelve el string a concatenar en el nombre del path dependiendo de los polígonos seleccionados (zonas, turnos... etc)
|
||||
*/
|
||||
public string DameStrPoligs()
|
||||
{
|
||||
string str = "";
|
||||
|
||||
if (com.TextGeomNiv != "" && com.GeomNiv != null)
|
||||
str += "_N" + com.TextGeomNiv;
|
||||
if (com.TextGeomZon != "" && com.GeomZon != null)
|
||||
str += "_Z" + com.TextGeomZon;
|
||||
if (com.TextGeomRestr != "" && com.GeomRestr != null)
|
||||
str += "_R" + com.TextGeomRestr;
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Coge spatial reference de los datos a exportar
|
||||
*/
|
||||
public void GetSpatialRef(Geometry geom)
|
||||
{
|
||||
OliviaGlob.SpatRef = geom.SpatialReference;
|
||||
}
|
||||
|
||||
/**
|
||||
* Exporta y lanza proceso y ventana de proceso
|
||||
*/
|
||||
public void Ejecuta(ModosEjec modo)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Exporta los datos de entrada y el nw
|
||||
*/
|
||||
public void Exporta(ModosEjec modo)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
using ArcGIS.Core.Data;
|
||||
using ArcGIS.Core.Geometry;
|
||||
using ArcGIS.Core.Internal.CIM;
|
||||
using OliviaAddInPro.Helper;
|
||||
using OliviaAddInPro.Model;
|
||||
using System;
|
||||
|
|
@ -7,82 +8,249 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace OliviaAddInPro.Services
|
||||
{
|
||||
public class LimpiezaServ
|
||||
public class LimpiezaServ : EjecServ
|
||||
{
|
||||
private Limpieza limp;
|
||||
public string ErrStr="";
|
||||
|
||||
public LimpiezaServ(Limpieza _limp)
|
||||
{
|
||||
limp = _limp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepara la geometría para exportar
|
||||
* Acciones para comenzar ejecución
|
||||
* Modo 0, sectorizar
|
||||
* Modo 1, planificar
|
||||
*/
|
||||
public Geometry GetGeomAmbitsExport()
|
||||
public bool Sectoriza()
|
||||
{
|
||||
Geometry geomAux = null;
|
||||
FeatureClass fc = HelperGdb.GetFtClass(limp.CapaElems);
|
||||
QueryFilter filtro = new QueryFilter { WhereClause = limp.ConsultaAmbs };
|
||||
if(fc==null)
|
||||
string nombFileAmbs = string.Empty;
|
||||
//Prepara consulta
|
||||
if (!PreparaConsulta(out nombFileAmbs))
|
||||
{
|
||||
ErrStr = "No se ha podido abrir la clase " + limp.CapaElems;
|
||||
return null;
|
||||
}
|
||||
//comprueba que haya elementos que cumplen la consulta
|
||||
int nElem = HelperGdb.GetNumElems(fc, limp.ConsultaAmbs).Result;
|
||||
if(nElem<=0)
|
||||
{
|
||||
ErrStr = "No existen ámbitos que cumplan las condiciones dadas " + limp.ConsultaAmbs;
|
||||
return null;
|
||||
}
|
||||
//Primero hace la geometría de los ámbitos que cumplen la consulta
|
||||
geomAux = HelperGdb.GetGeomUnica(fc, filtro);
|
||||
if(geomAux==null || geomAux.IsEmpty)
|
||||
{
|
||||
ErrStr = "No se ha podido generar geometría de los ámbitos" + limp.ConsultaAmbs;
|
||||
return null;
|
||||
}
|
||||
//Hace la intersección de dicha geometría con las zonas
|
||||
if (limp.GeomZon != null)
|
||||
{
|
||||
geomAux = HelperGdb.IntersectGeom(geomAux, limp.GeomZon);
|
||||
if(geomAux==null)
|
||||
{
|
||||
ErrStr = "Error al intersecar con las zonas.";
|
||||
return null;
|
||||
}
|
||||
ErrStr = "No se ha seleccionado una consulta válida" + limp.ConsultaAmbs;
|
||||
return false;
|
||||
}
|
||||
|
||||
//Hace la intersección de la geometría con los niveles
|
||||
if (limp.GeomNiv != null)
|
||||
//Prepara nombre
|
||||
string fechaHora = string.Empty;
|
||||
string nombreDatExport = string.Empty;
|
||||
//se consigue el tiempo en este instante para añadirlo a los nombres de los archivos de salida (shapefiles)
|
||||
fechaHora = DateTime.Now.ToString("yyyyMMdd_Hmmss");
|
||||
//Pone nombre al shape en función de los ámbitos, el tratamiento, y los polígonos + timestamp
|
||||
nombreDatExport = prefNameExport + "T" + limp.TipoTto.ToString("00") + nombFileAmbs + DameStrPoligs() + "_" + fechaHora + extShp;
|
||||
|
||||
//comienza ejecucion
|
||||
com = (TratamientoComun)limp;
|
||||
if(!ComienzaEjec(ModosEjec.Sectoriza))
|
||||
{
|
||||
geomAux = HelperGdb.IntersectGeom(geomAux, limp.GeomNiv);
|
||||
if (geomAux == null)
|
||||
{
|
||||
ErrStr = "Error al intersecar con los niveles.";
|
||||
return null;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//le quita las restricciones
|
||||
if (limp.GeomRestr != null)
|
||||
{
|
||||
geomAux = HelperGdb.QuitaGeom(geomAux, limp.GeomRestr);
|
||||
if (geomAux == null)
|
||||
{
|
||||
ErrStr = "Error al intersecar con las restricciones.";
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
return geomAux;
|
||||
}
|
||||
|
||||
public bool PreparaConsulta(out string nombFileAmbs)
|
||||
{
|
||||
nombFileAmbs = string.Empty;
|
||||
limp.ConsultaAmbs = DameAmbsConsulta(out nombFileAmbs);
|
||||
if (string.IsNullOrEmpty(limp.ConsultaAmbs))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Planifica()
|
||||
{
|
||||
//se asegura que tiene todo para planif
|
||||
if(!CompruebaPlanif())
|
||||
{
|
||||
ErrStr = "En la capa de ámbitos seleccionada no se encuentran columnas de SECTOR y/o SECUENCIA, necesarias para planificar";
|
||||
return false;
|
||||
}
|
||||
//Prepara consulta
|
||||
string nombFileAmbs = string.Empty;
|
||||
//Prepara consulta
|
||||
if (!PreparaConsulta(out nombFileAmbs))
|
||||
{
|
||||
ErrStr = "No se ha seleccionado una consulta válida" + limp.ConsultaAmbs;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public string DameAmbsConsulta(out string ambs_file)
|
||||
{
|
||||
string consulta, orstr;
|
||||
|
||||
consulta = string.Empty;
|
||||
ambs_file = "";
|
||||
orstr = null;
|
||||
for (int i = 0; i < limp.AmbitosSel.Length; i++)
|
||||
{
|
||||
if (limp.AmbitosSel[i])
|
||||
{
|
||||
consulta = consulta + orstr + "(" + LimpiezaDef.filtro_str[i] + ")";
|
||||
ambs_file = ambs_file + i.ToString("00");
|
||||
if (orstr == null)
|
||||
orstr = " OR ";
|
||||
}
|
||||
}
|
||||
ambs_file = "_A" + ambs_file;
|
||||
if (consulta == "()")
|
||||
consulta = "";
|
||||
|
||||
return consulta;
|
||||
}
|
||||
|
||||
/**
|
||||
* Comprueba lo necesario para ver si hay campos para la planificación
|
||||
*/
|
||||
public bool CompruebaPlanif()
|
||||
{
|
||||
string path = null;
|
||||
|
||||
//si ha importado no hace falta que compruebe, seguro que las tiene
|
||||
if (OliviaGlob.IsConfig2())
|
||||
return true;
|
||||
if (ComprCamposPlanif(limp.CapaElems))
|
||||
return true;
|
||||
|
||||
if (!HelperGlobal.ponMsg("En la capa de ámbitos seleccionada no se encuentran columnas de SECTOR y/o SECUENCIA, " +
|
||||
"necesarias para planificar. ¿Desea utilizar la sectorización de otra capa?",MessageBoxImage.Question,"OLIVIA",
|
||||
MessageBoxButton.YesNo))
|
||||
return false;
|
||||
|
||||
//saca diálogo para elegir capa
|
||||
path = HelperGdb.OpenFileDialog(HelperGdb.TiposOpenFileDlg.OpenFtrClassLine | HelperGdb.TiposOpenFileDlg.OpenFtrClassPoint);
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//comprueba que en la nueva capa haya columnas de planif
|
||||
if (!ComprCamposPlanif(path))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//almacena la info de secto auxiliar
|
||||
limp.CapaAuxPlanif = path;
|
||||
return true;
|
||||
|
||||
}
|
||||
public bool ComprCamposPlanif(string pathCapa)
|
||||
{
|
||||
int NCAMPS = 2;
|
||||
string[] camps;
|
||||
int i;
|
||||
camps = new string[NCAMPS];
|
||||
camps[0] = LimpiezaDef.Campos.consulta_sector;
|
||||
camps[1] = LimpiezaDef.Campos.consulta_secuen;
|
||||
if (string.IsNullOrEmpty(pathCapa))
|
||||
return false;
|
||||
for (i = 0; i < NCAMPS; i++)
|
||||
{
|
||||
if (!HelperGdb.CheckField(pathCapa, camps[i]))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i < NCAMPS)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Lee la capa que se ha seleccionzdo de limpieza y se comprueba que los campos que se han editado corresponden con la capa
|
||||
* (es decir, se puede leer la capa con los campos configurados)
|
||||
*/
|
||||
public bool CompruebaCamposLimp(string pathCapa)
|
||||
{
|
||||
int NCAMPS = 5;
|
||||
string[] camps;
|
||||
int i;
|
||||
camps = new string[NCAMPS];
|
||||
camps[0] = LimpiezaDef.Campos.consulta_entidad;
|
||||
camps[1] = LimpiezaDef.Campos.consulta_mecan;
|
||||
camps[2] = LimpiezaDef.Campos.consulta_observ;
|
||||
camps[3] = LimpiezaDef.Campos.consulta_anch_tip;
|
||||
camps[4] = LimpiezaDef.Campos.consulta_tipolo;
|
||||
if (string.IsNullOrEmpty(pathCapa))
|
||||
return false;
|
||||
for (i = 0; i < NCAMPS; i++)
|
||||
{
|
||||
if (!HelperGdb.CheckField(pathCapa, camps[i]))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i < NCAMPS)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Lee la gdb y devuelve el array de ámbitos en función de si hay en la gdb o no
|
||||
*/
|
||||
public bool[] BuscAmbGdb(string pathCapa)
|
||||
{
|
||||
string consulta;
|
||||
int numero_lin;
|
||||
bool[] amb_gdb = new bool[(int)LimpiezaDef.AmbitsTra.AmbN];//se inician a false
|
||||
string ftclass;
|
||||
|
||||
//mira a ver si hay ejes de calle
|
||||
ftclass = LimpiezaDef.ftclass[(int)LimpiezaDef.AmbitsTra.AmbEjeCalle];
|
||||
consulta = LimpiezaDef.filtro_str[(int)LimpiezaDef.AmbitsTra.AmbEjeCalle];
|
||||
numero_lin = HelperGdb.GetNumElems(OliviaGlob.Paths.PathGdbNw, ftclass, consulta);
|
||||
if (numero_lin > 0)
|
||||
{
|
||||
amb_gdb[(int)LimpiezaDef.AmbitsTra.AmbEjeCalle] = true;
|
||||
}
|
||||
//mira a ver si hay el resto de capas y tienen entidades
|
||||
for (int i = (int)LimpiezaDef.AmbitsTra.AmbBordLibreMec; i < (int)LimpiezaDef.AmbitsTra.AmbN; i++)
|
||||
{
|
||||
consulta = LimpiezaDef.filtro_str[i];
|
||||
numero_lin = HelperGdb.GetNumElems(pathCapa, consulta);
|
||||
|
||||
if (numero_lin > 0)
|
||||
{
|
||||
amb_gdb[i] = true;
|
||||
}
|
||||
}
|
||||
|
||||
return amb_gdb;
|
||||
}
|
||||
/**Devuelve el array de los ámbitos comunes y no comunes de las opciones de un tratamiento tto
|
||||
* Es un array de longitud el número de ámbitos totales, con true en las posiciones en los que el ámbito sea común o
|
||||
* no común en las opciones
|
||||
*/
|
||||
public bool[] DameAmbTto(int tto)
|
||||
{
|
||||
int i;
|
||||
bool sig;
|
||||
bool[] amb_com = new bool[(int)LimpiezaDef.AmbitsTra.AmbN];
|
||||
|
||||
for (int j = 0; j < (int)LimpiezaDef.AmbitsTra.AmbN; j++)
|
||||
{
|
||||
sig = false;
|
||||
for (i = 0; i < LimpiezaDef.ambs_val[tto].n_ops && !sig; i++)
|
||||
{
|
||||
if (LimpiezaDef.ambs_val[tto].ambs_ops[i].ambs[j]) //con que encuentre uno true lo pone y pasa al siguiente
|
||||
{
|
||||
amb_com[j] = sig = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return amb_com;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
xmlns:ui="clr-namespace:OliviaAddInPro"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="40" d:DesignWidth="300"
|
||||
d:DataContext="{Binding Path=ui.PaneLimpiezaSub3ViewModel}">
|
||||
d:DataContext="{Binding Path=ui.PaneEjecutarViewModel}">
|
||||
<UserControl.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
|
|
@ -23,8 +23,8 @@
|
|||
<ColumnDefinition Width="100"/>
|
||||
<ColumnDefinition Width="100"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button x:Name="button_secto" Grid.Column="1" Style="{DynamicResource Esri_Button}" Content="Sectorizar" Margin="10,0,10,0"/>
|
||||
<Button x:Name="button_planif" Grid.Column="2" Style="{DynamicResource Esri_Button}" Content="Planificar" Margin="10,0,10,0"/>
|
||||
<Button x:Name="button_secto" Grid.Column="1" Style="{DynamicResource Esri_Button}" Content="Sectorizar" Margin="10,0,10,0" Click="button_secto_Click"/>
|
||||
<Button x:Name="button_planif" Grid.Column="2" Style="{DynamicResource Esri_Button}" Content="Planificar" Margin="10,0,10,0" Click="button_planif_Click"/>
|
||||
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
|
|
|
|||
|
|
@ -26,5 +26,14 @@ namespace OliviaAddInPro
|
|||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void button_secto_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void button_planif_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@
|
|||
</ResourceDictionary>
|
||||
</UserControl.Resources>
|
||||
|
||||
<Grid MinHeight="200" MinWidth="300">
|
||||
<Grid MinHeight="200" MinWidth="300" x:Name="GridLimp">
|
||||
<!--TextBlock Text="Add your custom content here" VerticalAlignment="Center" HorizontalAlignment="Center"></-->
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
|
|
@ -65,7 +65,21 @@
|
|||
<ContentPresenter Content="{Binding CurrentSubPanelPage}"/>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="2" Margin="0,20,0,0">
|
||||
<ContentPresenter Content="{Binding SubPanelEjec}"/>
|
||||
<ContentPresenter Name="PaneEjecutar">
|
||||
<ContentPresenter.Content>
|
||||
<StackPanel Orientation="Vertical">
|
||||
<Grid Margin="0,10,0,0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="100"/>
|
||||
<ColumnDefinition Width="100"/>
|
||||
<ColumnDefinition Width="100"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button x:Name="button_secto" Grid.Column="1" Style="{DynamicResource Esri_Button}" Content="Sectorizar" Margin="10,0,10,0" Click="button_secto_Click"/>
|
||||
<Button x:Name="button_planif" Grid.Column="2" Style="{DynamicResource Esri_Button}" Content="Planificar" Margin="10,0,10,0" Click="button_planif_Click"/>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</ContentPresenter.Content>
|
||||
</ContentPresenter>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
|
|
|||
|
|
@ -25,5 +25,22 @@ namespace OliviaAddInPro
|
|||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void button_secto_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (DataContext is PaneLimpiezaViewModel mod)
|
||||
{
|
||||
mod.Ejecuta(OliviaAddInPro.Services.ModosEjec.Sectoriza);
|
||||
}
|
||||
}
|
||||
|
||||
private void button_planif_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (DataContext is PaneLimpiezaViewModel mod)
|
||||
{
|
||||
mod.Ejecuta(OliviaAddInPro.Services.ModosEjec.Planifica);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ namespace OliviaAddInPro
|
|||
{
|
||||
label_capalimp.Content = Resource1.String_selec_capa;
|
||||
if (DataContext is PaneLimpiezaSub1ViewModel mod)
|
||||
mod.CapaAbierta = false;
|
||||
mod.AbiertaCapa(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,10 @@ namespace OliviaAddInPro
|
|||
e.Handled = !PanelGlobal.IsValid(((TextBox)sender).Text + e.Text,0,9999);
|
||||
}
|
||||
|
||||
private ArcGIS.Core.Geometry.Geometry selecGeom(FeatureClass fc, out string _texto, bool multisel)
|
||||
/*
|
||||
* Saca ventana para seleccionar el campo del que leer para elegir la geometría
|
||||
*/
|
||||
private ArcGIS.Core.Geometry.Geometry SelecLeeGeom(FeatureClass fc, out string _texto, bool multisel)
|
||||
{
|
||||
ArcGIS.Core.Geometry.Geometry geomsal = null;
|
||||
string texto = "";
|
||||
|
|
@ -53,63 +56,75 @@ namespace OliviaAddInPro
|
|||
texto = HelperGdb.TextoSal;
|
||||
}
|
||||
}
|
||||
if (geomsal==null)
|
||||
{
|
||||
texto = Resource1.String_selec_capa;
|
||||
if (HelperGdb.OutStr.Length > 0)
|
||||
HelperGlobal.ponMsg(HelperGdb.OutStr, System.Windows.MessageBoxImage.Error);
|
||||
}
|
||||
|
||||
_texto = texto;
|
||||
return geomsal;
|
||||
}
|
||||
|
||||
private ArcGIS.Core.Geometry.Geometry AbreGeom(out string texto)
|
||||
{
|
||||
//inicialmente
|
||||
ArcGIS.Core.Geometry.Geometry geom = null;
|
||||
texto = Resource1.String_selec_capa;
|
||||
|
||||
//abre
|
||||
FeatureClass fc = HelperGdb.OpenFtClassDialog(HelperGdb.TiposOpenFileDlg.OpenFtrClassPolygon);
|
||||
if (fc != null)
|
||||
{
|
||||
//hace geom
|
||||
geom = SelecLeeGeom(fc, out texto, true);
|
||||
if (geom == null && (HelperGdb.OutStr.Length > 0))
|
||||
HelperGlobal.ponMsg(HelperGdb.OutStr, System.Windows.MessageBoxImage.Error);
|
||||
|
||||
HelperGdb.Free(fc);
|
||||
}
|
||||
return geom;
|
||||
}
|
||||
|
||||
private void button_caparestr_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
FeatureClass fc = HelperGdb.OpenFtClassDialog(HelperGdb.TiposOpenFileDlg.OpenFtrClassPolygon);
|
||||
string texto="";
|
||||
|
||||
OliviaGlob.Limp.GeomRestr = selecGeom(fc, out texto, true);
|
||||
|
||||
string texto = "";
|
||||
ArcGIS.Core.Geometry.Geometry geom = AbreGeom(out texto);
|
||||
if (DataContext is PaneLimpiezaSub2ViewModel mod)
|
||||
{
|
||||
mod.GeomRestr = geom;
|
||||
}
|
||||
label_caparestr.Content = texto;
|
||||
HelperGdb.Free(fc);
|
||||
}
|
||||
|
||||
private void button_capaniv_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
FeatureClass fc = HelperGdb.OpenFtClassDialog(HelperGdb.TiposOpenFileDlg.OpenFtrClassPolygon);
|
||||
string texto = "";
|
||||
|
||||
OliviaGlob.Limp.GeomNiv = selecGeom(fc, out texto, true);
|
||||
|
||||
label_capaniv.Content = texto;
|
||||
HelperGdb.Free(fc);
|
||||
|
||||
ArcGIS.Core.Geometry.Geometry geom = AbreGeom(out texto);
|
||||
if (DataContext is PaneLimpiezaSub2ViewModel mod)
|
||||
{
|
||||
mod.GeomNiv = geom;
|
||||
}
|
||||
label_capaniv.Content = texto;
|
||||
}
|
||||
|
||||
private void button_capazon_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
FeatureClass fc = HelperGdb.OpenFtClassDialog(HelperGdb.TiposOpenFileDlg.OpenFtrClassPolygon);
|
||||
string texto = "";
|
||||
|
||||
OliviaGlob.Limp.GeomZon = selecGeom(fc, out texto, true);
|
||||
|
||||
label_capazon.Content = texto;
|
||||
HelperGdb.Free(fc);
|
||||
|
||||
ArcGIS.Core.Geometry.Geometry geom = AbreGeom(out texto);
|
||||
if (DataContext is PaneLimpiezaSub2ViewModel mod)
|
||||
{
|
||||
mod.GeomZon = geom;
|
||||
}
|
||||
label_capazon.Content = texto;
|
||||
}
|
||||
|
||||
private void button_capainst_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
FeatureClass fc = HelperGdb.OpenFtClassDialog(HelperGdb.TiposOpenFileDlg.OpenFtrClassPoint);
|
||||
string texto = "";
|
||||
ArcGIS.Core.Geometry.Geometry geomsal = selecGeom(fc, out texto, false);
|
||||
if (geomsal != null && geomsal is MapPoint mp)
|
||||
|
||||
ArcGIS.Core.Geometry.Geometry geomsal = AbreGeom(out texto);
|
||||
|
||||
if ((DataContext is PaneLimpiezaSub2ViewModel mod) && geomsal != null && geomsal is MapPoint mp)
|
||||
{
|
||||
OliviaGlob.Limp.CoordsInstal = mp.Coordinate2D;
|
||||
}
|
||||
label_capainst.Content = texto;
|
||||
HelperGdb.Free(fc);
|
||||
mod.CoordsInstal = mp.Coordinate2D;
|
||||
}
|
||||
label_capainst.Content = texto;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,8 +35,8 @@
|
|||
<ColumnDefinition Width="Auto" MinWidth="100"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label Content="Nº de sectores" HorizontalAlignment="Left" Margin="15,0,0,0" VerticalAlignment="Top" Width="90" Height="30"/>
|
||||
<xctk:IntegerUpDown x:Name="spinner_nsect" Value="{Binding Path=NumSect, Mode = TwoWay}" Grid.Column="1" Height="20" Width="70" FormatString="N0" Increment="1" Maximum="20" Minimum="1" Margin="17,4,2,6" AllowTextInput ="False"/>
|
||||
<CheckBox x:Name="checkBox_sectauto" Grid.Column="2" Margin="9,6,9,-1" Content="Automático" IsChecked="{Binding Path=CheckSectAuto, Mode = TwoWay}" Checked="checkBox_sectauto_Checked"/>
|
||||
<xctk:IntegerUpDown x:Name="spinner_nsect" Value="{Binding Path=NumSect, Mode = TwoWay}" Grid.Column="1" Height="20" Width="70" FormatString="N0" Increment="1" Maximum="30" Minimum="1" Margin="17,4,2,6" AllowTextInput ="False" IsEnabled="{Binding Path=EnableNSect, Mode = TwoWay}"/>
|
||||
<CheckBox x:Name="checkBox_sectauto" Grid.Column="2" Margin="9,6,9,-1" Content="Automático" IsChecked="{Binding Path=CheckSectAuto, Mode = TwoWay}"/>
|
||||
</Grid>
|
||||
<CheckBox x:Name="checkBox_ajustsect" Margin="18,10,0,0" Content="Ajustar sectores a jornada" IsChecked="{Binding Path=CheckAjustSect, Mode = TwoWay}"/>
|
||||
<CheckBox x:Name="checkBox_ignorais" Margin="18,10,0,0" Content="Ignorar elementos aislados" IsChecked="{Binding Path=CheckIgnoAis, Mode = TwoWay}"/>
|
||||
|
|
|
|||
|
|
@ -28,14 +28,14 @@ namespace OliviaAddInPro
|
|||
|
||||
private void checkBox_sectauto_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if(checkBox_sectauto.IsChecked ?? true)
|
||||
/*if(checkBox_sectauto.IsChecked ?? true)
|
||||
{
|
||||
spinner_nsect.IsEnabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
spinner_nsect.IsEnabled = true;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,6 +44,15 @@ namespace OliviaAddInPro
|
|||
pane.Activate();
|
||||
}
|
||||
|
||||
internal static void Hide_()
|
||||
{
|
||||
DockPane pane = FrameworkApplication.DockPaneManager.Find(_dockPaneID);
|
||||
if (pane == null)
|
||||
return;
|
||||
|
||||
pane.Hide();
|
||||
}
|
||||
|
||||
//The parameter passed to this method will be true if the Dockpane is being opened and it is false when you close the dockpane
|
||||
protected override void OnShow(bool isVisible)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -39,6 +39,15 @@ namespace OliviaAddInPro
|
|||
pane.Activate();
|
||||
}
|
||||
|
||||
internal static void Hide_()
|
||||
{
|
||||
DockPane pane = FrameworkApplication.DockPaneManager.Find(_dockPaneID);
|
||||
if (pane == null)
|
||||
return;
|
||||
|
||||
pane.Hide();
|
||||
}
|
||||
|
||||
//The parameter passed to this method will be true if the Dockpane is being opened and it is false when you close the dockpane
|
||||
//also false the first time
|
||||
protected override void OnShow(bool isVisible)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ using ArcGIS.Desktop.Mapping;
|
|||
|
||||
namespace OliviaAddInPro
|
||||
{
|
||||
internal class PaneEjecutarViewModel : PanelViewModelBase
|
||||
public class PaneEjecutarViewModel : PanelViewModelBase
|
||||
{
|
||||
public PaneEjecutarViewModel()
|
||||
{
|
||||
|
|
@ -30,14 +30,7 @@ namespace OliviaAddInPro
|
|||
public override string DisplayName
|
||||
{
|
||||
get { return "Ejecutar"; }
|
||||
}
|
||||
|
||||
private int numPtosCtrl;
|
||||
public int NumPtosCtrl
|
||||
{
|
||||
get { return numPtosCtrl; }
|
||||
set { base.SetProperty(ref numPtosCtrl, value, () => NumPtosCtrl); }
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Properties
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,10 +19,11 @@ using System.Collections.ObjectModel;
|
|||
using OliviaAddInPro.Model;
|
||||
using OliviaAddInPro.Helper;
|
||||
using ArcGIS.Desktop.Internal.Layouts.Utilities;
|
||||
using OliviaAddInPro.Services;
|
||||
|
||||
namespace OliviaAddInPro
|
||||
{
|
||||
internal class PaneLimpiezaSub1ViewModel : PanelViewModelBase, ILimpieza
|
||||
internal class PaneLimpiezaSub1ViewModel : PanelViewModelBase
|
||||
{
|
||||
|
||||
private ObservableCollection<string> tiposTto = new ObservableCollection<string>(LimpiezaDef.tipos_tto_str);
|
||||
|
|
@ -51,6 +52,7 @@ namespace OliviaAddInPro
|
|||
* Matriz que da true aquellos ámbitos de trabajo que están contemplados en .gdb una vez leida
|
||||
*/
|
||||
bool[] amb_tra_gdb = null;
|
||||
private LimpiezaServ limpServ;
|
||||
|
||||
//implementan la interfaz Limpieza
|
||||
private int selTto = -1;
|
||||
|
|
@ -196,6 +198,7 @@ namespace OliviaAddInPro
|
|||
textVeloDespl = "10";
|
||||
lblUdsTimeTto = "min";
|
||||
lblUdsVeloDespl = "km/h";
|
||||
limpServ = new LimpiezaServ(null); //no hace falta instancia limp
|
||||
|
||||
}
|
||||
/**
|
||||
|
|
@ -203,17 +206,21 @@ namespace OliviaAddInPro
|
|||
*/
|
||||
public void AbiertaCapa(string capa)
|
||||
{
|
||||
capaElems = capa;
|
||||
CapaAbierta = false;
|
||||
CapaElems = string.Empty;
|
||||
OpsAmbs.Clear();
|
||||
Ambitos.Clear();
|
||||
OliviaGlob.TipoEjec = OliviaGlob.TipoEjec | TiposEjecucion.Config; //lo reinicia, por si estaba después de planificar
|
||||
if (string.IsNullOrEmpty(capa))
|
||||
return;
|
||||
//comprueba los campos de limpieza
|
||||
string ss = "";
|
||||
if (!CompruebaCamposLimp(capa, out ss))
|
||||
if (!limpServ.CompruebaCamposLimp(capa))
|
||||
{
|
||||
HelperGlobal.ponMsg(ss, System.Windows.MessageBoxImage.Warning);
|
||||
HelperGlobal.ponMsg(HelperGdb.OutStr, System.Windows.MessageBoxImage.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
amb_tra_gdb = BuscAmbGdb(capa);
|
||||
amb_tra_gdb = limpServ.BuscAmbGdb(capa);
|
||||
bool hay_alguno = false;
|
||||
foreach (bool b in amb_tra_gdb)
|
||||
{
|
||||
|
|
@ -229,11 +236,9 @@ namespace OliviaAddInPro
|
|||
System.Windows.MessageBoxImage.Warning);
|
||||
return;
|
||||
}
|
||||
//hay elementos en la gdb
|
||||
OpsAmbs.Clear();
|
||||
Ambitos.Clear();
|
||||
//hay elementos en la gdb
|
||||
CapaElems = capa;
|
||||
CapaAbierta = true;
|
||||
|
||||
}
|
||||
/**
|
||||
* Realiza los cambios en los ámbitos cuando se ha seleccionado un tratamiento
|
||||
|
|
@ -251,11 +256,15 @@ namespace OliviaAddInPro
|
|||
if (TipoTto != (int)LimpiezaDef.TiposTto.TtoNoDef)
|
||||
{
|
||||
RespCirc = LimpiezaDef.rest_circ[TipoTto];
|
||||
|
||||
|
||||
if (LimpiezaDef.v_desplazamiento[TipoTto] > 0)
|
||||
{
|
||||
TextVeloDespl = Convert.ToString(LimpiezaDef.v_desplazamiento[TipoTto]);
|
||||
}
|
||||
else
|
||||
{
|
||||
TextVeloDespl = Resource1.String_velo_nodef;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
|
@ -374,6 +383,7 @@ namespace OliviaAddInPro
|
|||
&& amb_tra_gdb[(int)((AmbitsList)lista[i]).amb_i];
|
||||
}
|
||||
Ambitos.ElementAt(i).IsChecked = check;
|
||||
Ambitos.ElementAt(i).IsEnabled = amb_tra_gdb[(int)((AmbitsList)lista[i]).amb_i];
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
|
@ -389,7 +399,7 @@ namespace OliviaAddInPro
|
|||
if (TipoTto < (int)LimpiezaDef.TiposTto.TtoCustom)
|
||||
{
|
||||
//pide un array de booleanos donde es true en las posiciones de los ámbitos comunes
|
||||
amb_val = DameAmbTto(selTto);
|
||||
amb_val = limpServ.DameAmbTto(selTto);
|
||||
//crea un array con el número de elementos del array anterior que sean true
|
||||
ambs_list = new ObservableCollection<AmbitsList>();//cuenta los trues
|
||||
//rellena el array apuntando los índices y los textos correspondientes a los trues
|
||||
|
|
@ -477,7 +487,6 @@ namespace OliviaAddInPro
|
|||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//MessageBox.Show("Error al poner los ámbitos", "Olivia", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
@ -535,124 +544,7 @@ namespace OliviaAddInPro
|
|||
udsTTto = (int)GeneralDef.OlvTiposTto.OlvTipTtoM2h_eje;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/*
|
||||
* Lee la capa que se ha seleccionzdo de limpieza y se comprueba que los campos que se han editado corresponden con la capa
|
||||
* (es decir, se puede leer la capa con los campos configurados)
|
||||
*/
|
||||
public bool CompruebaCamposLimp(string pathCapa, out string err_str)
|
||||
{
|
||||
int NCAMPS = 2;
|
||||
string[] camps;
|
||||
int i;
|
||||
camps = new string[NCAMPS];
|
||||
camps[0] = LimpiezaDef.Campos.consulta_entidad;
|
||||
camps[1] = LimpiezaDef.Campos.consulta_mecan;
|
||||
FeatureClass fc = HelperGdb.GetFtClass(pathCapa);
|
||||
err_str = "";
|
||||
if (fc == null)
|
||||
{
|
||||
err_str = "No se puede abrir la capa";
|
||||
return false;
|
||||
}
|
||||
|
||||
ObservableCollection<string> fields = HelperGdb.GetFields(fc).Result;
|
||||
for (i = 0; i < NCAMPS; i++)
|
||||
{
|
||||
if (!fields.Contains(camps[i]))
|
||||
{
|
||||
err_str = "No se encuentra el campo " + camps[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i < NCAMPS)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Lee la gdb y devuelve el array de ámbitos en función de si hay en la gdb o no
|
||||
*/
|
||||
public bool[] BuscAmbGdb(string pathCapa)
|
||||
{
|
||||
string consulta;
|
||||
int numero_lin;
|
||||
bool[] amb_gdb = new bool[(int)LimpiezaDef.AmbitsTra.AmbN];//se inician a false
|
||||
string ftclass;
|
||||
|
||||
//mira a ver si hay ejes de calle
|
||||
ftclass = LimpiezaDef.ftclass[(int)LimpiezaDef.AmbitsTra.AmbEjeCalle];
|
||||
consulta = LimpiezaDef.filtro_str[(int)LimpiezaDef.AmbitsTra.AmbEjeCalle];
|
||||
numero_lin = HelperGdb.GetNumElems(OliviaGlob.Paths.PathGdbNw, ftclass, consulta);
|
||||
if (numero_lin > 0)
|
||||
{
|
||||
amb_gdb[(int)LimpiezaDef.AmbitsTra.AmbEjeCalle] = true;
|
||||
}
|
||||
//mira a ver si hay el resto de capas y tienen entidades
|
||||
for (int i = (int)LimpiezaDef.AmbitsTra.AmbBordLibreMec; i < (int)LimpiezaDef.AmbitsTra.AmbN; i++)
|
||||
{
|
||||
consulta = LimpiezaDef.filtro_str[i];
|
||||
numero_lin = HelperGdb.GetNumElems(pathCapa, consulta);
|
||||
|
||||
if (numero_lin > 0)
|
||||
{
|
||||
amb_gdb[i] = true;
|
||||
}
|
||||
}
|
||||
|
||||
return amb_gdb;
|
||||
}
|
||||
/**Devuelve el array de los ámbitos comunes y no comunes de las opciones de un tratamiento tto
|
||||
* Es un array de longitud el número de ámbitos totales, con true en las posiciones en los que el ámbito sea común o
|
||||
* no común en las opciones
|
||||
*/
|
||||
public bool[] DameAmbTto(int tto)
|
||||
{
|
||||
int i;
|
||||
bool sig;
|
||||
bool[] amb_com = new bool[(int)LimpiezaDef.AmbitsTra.AmbN];
|
||||
|
||||
for (int j = 0; j < (int)LimpiezaDef.AmbitsTra.AmbN; j++)
|
||||
{
|
||||
sig = false;
|
||||
for (i = 0; i < LimpiezaDef.ambs_val[tto].n_ops && !sig; i++)
|
||||
{
|
||||
if (LimpiezaDef.ambs_val[tto].ambs_ops[i].ambs[j]) //con que encuentre uno true lo pone y pasa al siguiente
|
||||
{
|
||||
amb_com[j] = sig = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return amb_com;
|
||||
}
|
||||
/**
|
||||
* Devuelve qué consulta hay que hacer, el filtro de los ámbitos y el nombre de la clase donde están
|
||||
*/
|
||||
public string dame_consul_amb_clas(out string ambitos, out string nom_class)
|
||||
{
|
||||
string consulta, orstr;
|
||||
|
||||
consulta = null;
|
||||
ambitos = "";
|
||||
orstr = null;
|
||||
nom_class = null;
|
||||
for (int i = 0; i < AmbitosSel.Length; i++)
|
||||
{
|
||||
if (AmbitosSel[i])
|
||||
{
|
||||
if (nom_class == null)
|
||||
nom_class = LimpiezaDef.ftclass[i];
|
||||
consulta = consulta + orstr + "(" + LimpiezaDef.filtro_str[i] + ")";
|
||||
ambitos = ambitos + i.ToString("00");
|
||||
if (orstr == null)
|
||||
orstr = " OR ";
|
||||
}
|
||||
}
|
||||
ambitos = "_A" + ambitos;
|
||||
if (consulta == "()")
|
||||
consulta = "";
|
||||
|
||||
return consulta;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ using ArcGIS.Desktop.Mapping;
|
|||
|
||||
namespace OliviaAddInPro
|
||||
{
|
||||
internal class PaneLimpiezaSub2ViewModel : PanelViewModelBase
|
||||
public class PaneLimpiezaSub2ViewModel : PanelViewModelBase
|
||||
{
|
||||
public PaneLimpiezaSub2ViewModel()
|
||||
{
|
||||
|
|
@ -63,6 +63,22 @@ namespace OliviaAddInPro
|
|||
get { return txtBuffExport; }
|
||||
set { base.SetProperty(ref txtBuffExport, value, () => TxtBuffExport); }
|
||||
}
|
||||
/**
|
||||
* Geometría para el filtro de ámbitos, incluye zonas, se añaden los ámbitos que pertenecen a esa geom
|
||||
*/
|
||||
public Geometry GeomZon { get; set; } = null;
|
||||
/**
|
||||
* Geometría para el filtro de ámbitos, incluye zonas, se añaden los ámbitos que pertenecen a esa geom
|
||||
*/
|
||||
public Geometry GeomNiv { get; set; } = null;
|
||||
/**
|
||||
* Geometría para el filtro de ámbitos, incluye restricciones, se quitan los ámbitos que pertenecen a esa geom
|
||||
*/
|
||||
public Geometry GeomRestr { get; set; } = null;
|
||||
/**
|
||||
* Coordenadas de la instalación
|
||||
*/
|
||||
public Coordinate2D CoordsInstal { get; set; } = new Coordinate2D(0, 0);
|
||||
#endregion Properties
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,12 +17,14 @@ using ArcGIS.Desktop.Mapping;
|
|||
|
||||
namespace OliviaAddInPro
|
||||
{
|
||||
internal class PaneLimpiezaSub3ViewModel : PanelViewModelBase
|
||||
public class PaneLimpiezaSub3ViewModel : PanelViewModelBase
|
||||
{
|
||||
public PaneLimpiezaSub3ViewModel()
|
||||
{
|
||||
numPtosCtrl = numSect = 3;
|
||||
checkAjustSect = checkSectAuto = false;
|
||||
checkIgnoAis = true;
|
||||
enableNSect = true;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -51,7 +53,18 @@ namespace OliviaAddInPro
|
|||
public bool CheckSectAuto
|
||||
{
|
||||
get { return checkSectAuto; }
|
||||
set { base.SetProperty(ref checkSectAuto, value, () => CheckSectAuto); }
|
||||
set {
|
||||
if (checkSectAuto)
|
||||
EnableNSect = false;
|
||||
else
|
||||
EnableNSect = true;
|
||||
base.SetProperty(ref checkSectAuto, value, () => CheckSectAuto); }
|
||||
}
|
||||
private bool enableNSect;
|
||||
public bool EnableNSect
|
||||
{
|
||||
get { return enableNSect; }
|
||||
set { base.SetProperty(ref enableNSect, value, () => EnableNSect); }
|
||||
}
|
||||
|
||||
private bool checkAjustSect;
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ using ArcGIS.Desktop.Mapping;
|
|||
|
||||
namespace OliviaAddInPro
|
||||
{
|
||||
internal class PaneLimpiezaSub4ViewModel : PanelViewModelBase
|
||||
public class PaneLimpiezaSub4ViewModel : PanelViewModelBase
|
||||
{
|
||||
public PaneLimpiezaSub4ViewModel()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -6,27 +6,21 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Media.Imaging;
|
||||
using OliviaAddInPro.Helper;
|
||||
|
||||
namespace OliviaAddInPro
|
||||
{
|
||||
class PaneLimpiezaViewModel : PanelViewModelBase
|
||||
{
|
||||
private PaneLimpiezaSub1ViewModel _subPanel1ViewModel;
|
||||
private PaneLimpiezaSub2ViewModel _subPanel2ViewModel;
|
||||
private PaneLimpiezaSub3ViewModel _subPanel3ViewModel;
|
||||
private PaneLimpiezaSub4ViewModel _subPanel4ViewModel;
|
||||
private PaneEjecutarViewModel _subPanelEjec;
|
||||
private PanelViewModelBase _subPanelEjecBase;
|
||||
Limpieza limp;
|
||||
|
||||
public PaneLimpiezaViewModel()
|
||||
{
|
||||
limp = OliviaGlob.Limp;
|
||||
{
|
||||
_subPanel1ViewModel = new PaneLimpiezaSub1ViewModel();
|
||||
_subPanel2ViewModel = new PaneLimpiezaSub2ViewModel();
|
||||
_subPanel3ViewModel = new PaneLimpiezaSub3ViewModel();
|
||||
_subPanel4ViewModel = new PaneLimpiezaSub4ViewModel();
|
||||
_subPanelEjec = new PaneEjecutarViewModel();
|
||||
_subPanel4ViewModel = new PaneLimpiezaSub4ViewModel();
|
||||
|
||||
OptionsMenu = new ObservableCollection<OptionsMenuItem>
|
||||
{
|
||||
|
|
@ -35,8 +29,8 @@ namespace OliviaAddInPro
|
|||
new OptionsMenuItem(new BitmapImage(new Uri("pack://application:,,,/OliviaAddInPro;component/Resources/Cat32.png")), Resource1.String_ctrol, _subPanel3ViewModel),
|
||||
new OptionsMenuItem(new BitmapImage(new Uri("pack://application:,,,/OliviaAddInPro;component/Resources/Panda32.png")), Resource1.String_tiempos, _subPanel4ViewModel)
|
||||
};
|
||||
SelectedOption = OptionsMenu[0];
|
||||
SubPanelEjec = _subPanelEjecBase=_subPanelEjec;
|
||||
SelectedOption = OptionsMenu[0];
|
||||
limp = OliviaGlob.Limp;
|
||||
}
|
||||
public override string DisplayName
|
||||
{
|
||||
|
|
@ -56,12 +50,6 @@ namespace OliviaAddInPro
|
|||
set { SetProperty(ref _currentSubPanelPage, value, () => CurrentSubPanelPage); }
|
||||
}
|
||||
|
||||
public PanelViewModelBase SubPanelEjec
|
||||
{
|
||||
get { return _subPanelEjecBase; }
|
||||
set { SetProperty(ref _subPanelEjecBase, value, () => SubPanelEjec); }
|
||||
}
|
||||
|
||||
private OptionsMenuItem _selectionOption;
|
||||
public OptionsMenuItem SelectedOption
|
||||
{
|
||||
|
|
@ -77,22 +65,72 @@ namespace OliviaAddInPro
|
|||
err_str = "";
|
||||
try
|
||||
{
|
||||
///Lee el primer panel
|
||||
/*limp.CapaElems = _subPanel1ViewModel.CapaElems;
|
||||
limp.Ttto = _subPanel1ViewModel.SelTto;
|
||||
if (limp.Ttto == (int)LimpiezaDef.TiposTto.TtoNoDef)
|
||||
////////////////////////////////////////////////////////////
|
||||
///Lee el panel 1
|
||||
if(!_subPanel1ViewModel.CapaAbierta || string.IsNullOrEmpty(_subPanel1ViewModel.CapaElems))
|
||||
{
|
||||
err_str = "No se ha seleccionado ninguna Capa de Limpieza";
|
||||
return false;
|
||||
}
|
||||
limp.CapaElems = _subPanel1ViewModel.CapaElems;
|
||||
|
||||
//lee el tipo tto
|
||||
if (_subPanel1ViewModel.TipoTto == (int)LimpiezaDef.TiposTto.TtoNoDef)
|
||||
{
|
||||
err_str = "No se ha seleccionado ningún Tipo de Tratamiento";
|
||||
return false;
|
||||
}
|
||||
//lee el ámbito seleccionado
|
||||
limp.TipoTto = _subPanel1ViewModel.TipoTto;
|
||||
|
||||
//lee el/los ámbito seleccionado
|
||||
if (!_subPanel1ViewModel.lee_ambitos())
|
||||
{
|
||||
err_str = "No se ha seleccionado ningún Ámbito de trabajo";
|
||||
return false;
|
||||
}
|
||||
limp.AmbitosSel = _subPanel1ViewModel.AmbitosSel;
|
||||
*/
|
||||
int i = 0;
|
||||
for (i = 0; i < limp.AmbitosSel.Length; i++)
|
||||
if (limp.AmbitosSel[i])
|
||||
break;
|
||||
if(i>= limp.AmbitosSel.Length)
|
||||
{
|
||||
err_str = "No se ha seleccionado ningún Ámbito de trabajo";
|
||||
return false;
|
||||
}
|
||||
//lee si respeta circulacion
|
||||
limp.RespCirc = _subPanel1ViewModel.RespCirc;
|
||||
|
||||
//lee velo de desplazamiento
|
||||
int vv = -1;
|
||||
if((!HelperGlobal.Str2Int(_subPanel1ViewModel.TextVeloDespl, out vv)) && (_subPanel1ViewModel.TextVeloDespl!=Resource1.String_velo_nodef))
|
||||
{
|
||||
err_str = "Error al leer la velocidad de desplazamiento";
|
||||
return false;
|
||||
}
|
||||
if ((vv == 0) || (vv > LimpiezaDef.Parametros.v_despM) || (vv < LimpiezaDef.Parametros.v_despm))
|
||||
{
|
||||
err_str = "La velocidad de desplazamiento no está dentro de los límites configurados";
|
||||
return false;
|
||||
}
|
||||
limp.VDespl = vv;
|
||||
|
||||
//lee tiempo de tto
|
||||
if ((_subPanel1ViewModel.TimeTto == 0) ||
|
||||
(_subPanel1ViewModel.TimeTto > LimpiezaDef.Parametros.t_ttoM) || (_subPanel1ViewModel.TimeTto < LimpiezaDef.Parametros.t_ttom))
|
||||
{
|
||||
err_str = "El tiempo de tratamiento no está dentro de los límites configurados";
|
||||
return false;
|
||||
}
|
||||
limp.Ttto = _subPanel1ViewModel.TimeTto;
|
||||
limp.UdsTTto = _subPanel1ViewModel.UdsTTto;
|
||||
|
||||
//lee las propiedades comunes a recogida
|
||||
if (!LeeComun(limp,out err_str))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
|
|
@ -100,5 +138,21 @@ namespace OliviaAddInPro
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Acciones para comenzar ejecución
|
||||
*/
|
||||
public void Ejecuta(OliviaAddInPro.Services.ModosEjec modo)
|
||||
{
|
||||
string err = "";
|
||||
if(!Lee(out err))
|
||||
{
|
||||
HelperGlobal.ponMsg(err);
|
||||
return;
|
||||
}
|
||||
|
||||
OliviaGlob.Limp.Ejecuta(modo);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using OliviaAddInPro.Model;
|
||||
|
||||
namespace OliviaAddInPro
|
||||
{
|
||||
|
|
@ -14,9 +16,87 @@ namespace OliviaAddInPro
|
|||
#region Properties
|
||||
|
||||
public abstract string DisplayName { get; }
|
||||
|
||||
public PaneLimpiezaSub2ViewModel _subPanel2ViewModel;
|
||||
public PaneLimpiezaSub3ViewModel _subPanel3ViewModel;
|
||||
public PaneLimpiezaSub4ViewModel _subPanel4ViewModel;
|
||||
|
||||
#endregion Properties
|
||||
|
||||
public bool LeeComun(TratamientoComun com, out string err_str)
|
||||
{
|
||||
err_str = string.Empty;
|
||||
////////////////////////////////////////////////////////////
|
||||
///Lee el panel 2
|
||||
///Lee las capas
|
||||
com.GeomRestr = _subPanel2ViewModel.GeomRestr;
|
||||
if (com.GeomRestr!=null)
|
||||
com.TextGeomRestr = _subPanel2ViewModel.LblCapaRestr;
|
||||
com.GeomNiv = _subPanel2ViewModel.GeomNiv;
|
||||
if (com.GeomNiv != null)
|
||||
com.TextGeomNiv = _subPanel2ViewModel.LblCapaNiv;
|
||||
com.GeomZon = _subPanel2ViewModel.GeomZon;
|
||||
if (com.GeomZon != null)
|
||||
com.TextGeomZon = _subPanel2ViewModel.LblCapaZon;
|
||||
com.CoordsInstal = _subPanel2ViewModel.CoordsInstal;
|
||||
|
||||
//lee el buffer de export
|
||||
if ((_subPanel2ViewModel.TxtBuffExport <= 0) || (_subPanel2ViewModel.TxtBuffExport > 100000))
|
||||
{
|
||||
err_str = "El buffer de exportación no está dentro de los límites configurados";
|
||||
return false;
|
||||
}
|
||||
com.BuffExport = _subPanel2ViewModel.TxtBuffExport;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
///Lee el panel 3
|
||||
if (_subPanel3ViewModel.CheckSectAuto)
|
||||
com.NSect = 0; //envía 0 si es sector automat
|
||||
else
|
||||
{
|
||||
com.NSect = _subPanel3ViewModel.NumSect; //limitado entre 1 y 30 por código del spinner
|
||||
if (_subPanel3ViewModel.CheckAjustSect)
|
||||
com.NSect = com.NSect * (-1);//lo envía negativo si es ajustar a sectores
|
||||
}
|
||||
com.NPtosCtrl = _subPanel3ViewModel.NumPtosCtrl; //limitado entre 3 y 10 por código del spinner
|
||||
com.IgnoAis = _subPanel3ViewModel.CheckIgnoAis;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
///Lee el panel 4
|
||||
//lee los tiempos
|
||||
com.TDescarg = PanelGlobal.Hm_DateTime2int(_subPanel4ViewModel.TimeCargDesc);
|
||||
if ((com.TDescarg == 0) || (com.TDescarg > LimpiezaDef.Parametros.t_cardescM) || (com.TDescarg < LimpiezaDef.Parametros.t_cardescm))
|
||||
{
|
||||
err_str = "El valor introducido para el tiempo de carga y descarga no es válido.";
|
||||
return false;
|
||||
}
|
||||
com.TDesplIniFin = PanelGlobal.Hm_DateTime2int(_subPanel4ViewModel.TimeDespIniFin);
|
||||
if ((com.TDesplIniFin == 0) || (com.TDesplIniFin > LimpiezaDef.Parametros.t_despM) || (com.TDesplIniFin < LimpiezaDef.Parametros.t_despm))
|
||||
{
|
||||
err_str = "El valor introducido para el tiempo de desplazamiento no es válido.";
|
||||
return false;
|
||||
}
|
||||
com.TDescan = PanelGlobal.Hm_DateTime2int(_subPanel4ViewModel.TimeDescPers);
|
||||
if ((com.TDescan == 0) || (com.TDescan > LimpiezaDef.Parametros.t_descansoM) || (com.TDescan < LimpiezaDef.Parametros.t_descansom))
|
||||
{
|
||||
err_str = "El valor introducido para el tiempo de descanso no es válido.";
|
||||
return false;
|
||||
}
|
||||
com.TConv = PanelGlobal.Hm_DateTime2int(_subPanel4ViewModel.TimeJornadaConv);
|
||||
if ((com.TConv == 0) || (com.TConv > LimpiezaDef.Parametros.t_convM) || (com.TConv < LimpiezaDef.Parametros.t_convm))
|
||||
{
|
||||
err_str = "El valor introducido para el tiempo de trabajo por convenio no es válido.";
|
||||
return false;
|
||||
}
|
||||
com.HIni = PanelGlobal.Hm_DateTime2int(_subPanel4ViewModel.TimeIniJornada);
|
||||
//porcent reducc traf
|
||||
com.Trafico = _subPanel4ViewModel.TextPercentTrafico;
|
||||
if ((com.Trafico <= 0) || (com.Trafico > 100))
|
||||
{
|
||||
err_str = "El porcentaje de tráfico en las vías no está dentro de los límites configurados";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//******************************************************
|
||||
|
|
@ -31,31 +111,7 @@ namespace OliviaAddInPro
|
|||
/**
|
||||
* Dado un tiempo en minutos devuelve las horas modulo 60 y los minutos restantes
|
||||
*/
|
||||
/*public static string Hm_int2str(double t)
|
||||
{
|
||||
int[] hm = { 0, 0 };
|
||||
|
||||
hm[0] = (int)(t / 60);
|
||||
hm[1] = (int)(t - hm[0] * 60);
|
||||
|
||||
return String.Format("%dd h %dd m", hm[0], hm[1]);
|
||||
}
|
||||
public static int Hm_str2int(string hm)
|
||||
{
|
||||
int h = 0;
|
||||
int m = 0;
|
||||
int t = 0;
|
||||
Match match = Regex.Match(hm, "^([0-9]+).([0-9]+).([0-9]+) ([0-9]+):([0-9]+):([0-9]+)");
|
||||
|
||||
|
||||
if (match.Success)
|
||||
{
|
||||
h = int.Parse(match.Groups[4].Value);
|
||||
m = int.Parse(match.Groups[5].Value);
|
||||
t = h * 60 + m;
|
||||
}
|
||||
return t;
|
||||
}*/
|
||||
|
||||
public static DateTime Hm_int2DateTime(double t)
|
||||
{
|
||||
int[] hm = { 0, 0 };
|
||||
|
|
@ -76,6 +132,7 @@ namespace OliviaAddInPro
|
|||
t = h * 60 + m;
|
||||
return t;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue