Añadido configuracion tipo de red.

Gerardo/StreetMapPremium
Gerardo 2023-11-03 23:56:06 +01:00
parent 6e7c7f787c
commit f94b4e3a2e
9 changed files with 244 additions and 25 deletions

View File

@ -1444,7 +1444,7 @@ namespace OliviaAddInPro.Helper
if (!System.IO.Directory.Exists(outpath)) if (!System.IO.Directory.Exists(outpath))
System.IO.Directory.CreateDirectory(outpath); System.IO.Directory.CreateDirectory(outpath);
FeatureClass fc = null; FeatureClass fc = null;
bool debug = true; bool debug = false;
///////////////////////////////////////////////////////// /////////////////////////////////////////////////////////
//Prepara una where_clause con las entidades que cumplen el filtro //Prepara una where_clause con las entidades que cumplen el filtro
//Abre la featureclass //Abre la featureclass
@ -2807,6 +2807,44 @@ namespace OliviaAddInPro.Helper
{ {
} }
return res;
}
/*
* Añadir columna calculada
*/
public static bool CalculateFieldsSync(string fcname, string field, string sqlquery)
{
bool res = false;
var args = Geoprocessing.MakeValueArray(fcname, field, sqlquery, "ARCADE");
// run the tool
try
{
var gpres = Geoprocessing.ExecuteToolAsync("management.CalculateField", args);
while (!gpres.IsCompleted && !gpres.IsCanceled && !gpres.IsFaulted)
Thread.Sleep(10);
if (gpres.IsFaulted)
{
var gpResult = gpres.Result;
string msg;
if (gpResult.ErrorMessages != null)
msg = gpResult.ErrorMessages.First().Text;
else
msg = "Errores al calcular campo "+ field;
}
else
{
res = true; //ha ido bien
}
gpres.Dispose();
return res;
}
catch
{
}
return res; return res;
} }
} }

View File

@ -17,11 +17,16 @@ namespace OliviaAddInPro.Model
*/ */
public struct CamposNW public struct CamposNW
{ {
public static string cons_onew; //<Campo que indica el sentido public static string cons_onewFT="_sen_ft"; //<Campo que indica el sentido
public static string cons_kph; //<Campo que indica la velocidad en kph public static string cons_onewTF="_sen_tf"; //<Campo que indica el sentido
public static string cons_name; //<Campo que indica el nombre de la calle
public static string cons_fow; //Campo que indica el tipo de vial, si es peatonal o no public static string cons_kph="_vel"; //<Campo que indica la velocidad en kph
public static string cons_name="_dir"; //<Campo que indica el nombre de la calle
public static string cons_fow="_pea"; //Campo que indica el tipo de vial, si es peatonal o no
public static string cons_evit = "_evita"; //Campo que indica si el vial es evitable
public static OliviaConfNW config; //configuracion para sacar capmos por defecto
}; };
/** /**
* Nombre de los Atributos de la cartografía de la red navegable que se consultan para la exportación * Nombre de los Atributos de la cartografía de la red navegable que se consultan para la exportación
*/ */

View File

@ -11,9 +11,12 @@ using System.Windows;
using Xceed.Wpf.Toolkit.PropertyGrid; using Xceed.Wpf.Toolkit.PropertyGrid;
using Xceed.Wpf.Toolkit.PropertyGrid.Editors; using Xceed.Wpf.Toolkit.PropertyGrid.Editors;
using Xceed.Wpf.Toolkit.PropertyGrid.Attributes; using Xceed.Wpf.Toolkit.PropertyGrid.Attributes;
using static OliviaAddInPro.Model.OliviaConf;
namespace OliviaAddInPro.Model namespace OliviaAddInPro.Model
{ {
[CategoryOrder("General", 1)] [CategoryOrder("General", 1)]
[CategoryOrder("Campos Limpieza", 2)] [CategoryOrder("Campos Limpieza", 2)]
[CategoryOrder("Atributos Limpieza", 3)] [CategoryOrder("Atributos Limpieza", 3)]
@ -44,12 +47,30 @@ namespace OliviaAddInPro.Model
[Description("Usa 'Kg por Defecto'")] [Description("Usa 'Kg por Defecto'")]
UsaKgDef UsaKgDef
} }
[TypeConverter(typeof(EnumOpsNWToString))]
public enum OpsNW
{
nw_0,
nw_1,
nw_2,
nw_3,
nw_4,
}
private string m2s(int min) private string m2s(int min)
{ {
var val = min; var val = min;
int horas = val / 60; int horas = val / 60;
return string.Format("{0}:{1:D2}", horas, val - (horas * 60)); return string.Format("{0}:{1:D2}", horas, val - (horas * 60));
} }
public OliviaConfNW GetOliviaConfNW()
{
int i = (int)Tipo_eje_via;
if (ListaNw != null && ListaNw.Count() > i)
return ListaNw[i];
return null;
}
private int s2m(string str, int defec) private int s2m(string str, int defec)
{ {
var match = Regex.Match(str, @"^([0-9]*):([0-9]*)"); var match = Regex.Match(str, @"^([0-9]*):([0-9]*)");
@ -66,16 +87,15 @@ namespace OliviaAddInPro.Model
} }
return defec; return defec;
} }
public OliviaConf() public OliviaConf()
{ {
Ip = "127.0.0.1"; Ip = "127.0.0.1";
Puerto = 19995; Puerto = 19995;
TiempoOutSocket = 20; TiempoOutSocket = 20;
}
#region PropiedadesOcultas }
#region parametrosConexion #region PropiedadesOcultas
#region parametrosConexion
/** /**
* IP donde va a realizar la conexión a OliviaTask, se inicializa al arrancar con la local * IP donde va a realizar la conexión a OliviaTask, se inicializa al arrancar con la local
*/ */
@ -174,7 +194,8 @@ namespace OliviaAddInPro.Model
#endregion #endregion
#region ParametrosReco_Ocultos #region ParametrosReco_Ocultos
[Browsable(false)]
public List<OliviaConfNW> ListaNw { get; set; }
[Browsable(false)] [Browsable(false)]
public int t_vaciado_max { get; set; } public int t_vaciado_max { get; set; }
[Browsable(false)] [Browsable(false)]
@ -217,7 +238,15 @@ namespace OliviaAddInPro.Model
[PropertyOrder(1)] [PropertyOrder(1)]
[Description("Red de carreteras que se usa para la navegación")] [Description("Red de carreteras que se usa para la navegación")]
[Editor(typeof(PropertyGridFilePickerLine), typeof(PropertyGridFilePickerLine))] [Editor(typeof(PropertyGridFilePickerLine), typeof(PropertyGridFilePickerLine))]
public string Path_Eje_via { get; set; } public string Path_Eje_via { get; set; }
[Category("General")]
[DisplayName("Tipo Red de carreteras")]
[PropertyOrder(1)]
[Description("Tipo de Red de carreteras que se usa para la navegación")]
[RefreshProperties(System.ComponentModel.RefreshProperties.All)]
//[Editor(typeof(PropertyGridFilePickerLine), typeof(PropertyGridFilePickerLine))]
public OpsNW Tipo_eje_via { get; set; }
[Category("General")] [Category("General")]
[PropertyOrder(2)] [PropertyOrder(2)]
@ -1327,9 +1356,55 @@ namespace OliviaAddInPro.Model
public string atr_suelo { get; set; } public string atr_suelo { get; set; }
#endregion #endregion
}
public class EnumOpsNWToString : TypeConverter
{
public static List<OliviaConfNW> ListaNw { get; set; }
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
return (sourceType.Equals(typeof(OpsNW)));
}
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
{
return (destinationType.Equals(typeof(String)));
}
public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
{
return base.ConvertFrom(context, culture, value);
}
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
{
if (!destinationType.Equals(typeof(String)))
{
throw new ArgumentException("Can only convert to string.", "destinationType");
}
if (!value.GetType().Equals(typeof(OpsNW)))
{
throw new ArgumentException("Can only convert an instance of enum.", "value");
}
int i = 0;
if (int.TryParse(value.ToString().Substring(3), out i) && ListaNw != null && i < ListaNw.Count())
{
var aux = ListaNw[i];
if (aux == null)
return "";
else
return aux.nombre;
}
return "";
}
} }
public class EnumToStringUsingDescription : TypeConverter public class EnumToStringUsingDescription : TypeConverter
{ {
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{ {
return (sourceType.Equals(typeof(Enum))); return (sourceType.Equals(typeof(Enum)));

24
Model/OliviaConfNW.cs Normal file
View File

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace OliviaAddInPro.Model
{
[Serializable]
public class OliviaConfNW
{
public OliviaConfNW()
{
}
public string nombre { get; set; }
public string campo_velocidad { get; set; }
public string campo_nombre { get; set; }
public string campo_sentidoFT { get; set; }
public string campo_sentidoTf { get; set; }
public string campo_peatonal { get; set; }
}
}

View File

@ -598,7 +598,17 @@ namespace OliviaAddInPro.Model
/** /**
* Define el nombre para mandar a oliviatasks la configuración para planificación, ya se ha hecho sectorización * Define el nombre para mandar a oliviatasks la configuración para planificación, ya se ha hecho sectorización
*/ */
public const string SockConfTodo = "CONFIG_TODO"; public const string SockConfTodo = "CONFIG_TODO";
//atributos network por defecto------------------------------------------------------------------------------
public const string cons_camp_sentido_tf = "_sen_ft"; //<Campo que indica el sentido 0 1
public const string cons_camp_sentido_ft = "_sen_tf"; //<Campo que indica el sentido 0 1
public const string cons__camp_vel= "_vel"; //<Campo que indica la velocidad en kph
public const string cons_name="_nom"; //<Campo que indica el nombre de la calle
public const string cons_peat="_peat"; //Campo que indica el tipo de vial, si es peatonal o no
public const string cons_ev = "_ev"; //Campo que indica si hay que intentar evitar o no (0-1)
//-----------------------------------------------------------------------------------------------------------
//************************************************************************************* //*************************************************************************************
} }
} }

View File

@ -273,14 +273,15 @@ namespace OliviaAddInPro.Model
if (ft == null) if (ft == null)
return false; return false;
HelperGdb.Free(ft); HelperGdb.Free(ft);
int NCAMPS = 4; int NCAMPS = 5;
string[] camps; string[] camps;
camps = new string[NCAMPS]; camps = new string[NCAMPS];
camps[0] = ComunDef.CamposNW.cons_onew; camps[0] = ComunDef.CamposNW.cons_onewFT;
camps[1] = ComunDef.CamposNW.cons_kph; camps[1] = ComunDef.CamposNW.cons_onewTF;
camps[2] = ComunDef.CamposNW.cons_name; camps[2] = ComunDef.CamposNW.cons_kph;
camps[3] = ComunDef.CamposNW.cons_fow; camps[3] = ComunDef.CamposNW.cons_name;
return HelperGdb.CheckFileds(OliviaGlob.Paths.PathGdbNw, camps) == 0; camps[4] = ComunDef.CamposNW.cons_fow;
return true;// HelperGdb.CheckFileds(OliviaGlob.Paths.PathGdbNw, camps) == 0;
} }
/** /**
@ -620,15 +621,16 @@ namespace OliviaAddInPro.Model
ComunDef.BuffExport = c.buffer_export; ComunDef.BuffExport = c.buffer_export;
//Campos de la red navegable que se leen //Campos de la red navegable que se leen
ComunDef.CamposNW.cons_onew = c.cons_onew; /*ComunDef.CamposNW.cons_onew = c.cons_onew;
ComunDef.CamposNW.cons_kph = c.cons_kph; ComunDef.CamposNW.cons_kph = "_vel";
ComunDef.CamposNW.cons_fow = c.cons_fow; ComunDef.CamposNW.cons_fow = "_peat";
ComunDef.CamposNW.cons_name = c.cons_name; ComunDef.CamposNW.cons_name = c.cons_name;*/
//Atributos de la red navegable que se leen //Atributos de la red navegable que se leen
ComunDef.AtributosNW.atr_TF = c.atr_TF; ComunDef.AtributosNW.atr_TF = c.atr_TF;
ComunDef.AtributosNW.atr_FT = c.atr_FT; ComunDef.AtributosNW.atr_FT = c.atr_FT;
ComunDef.AtributosNW.atr_N = c.atr_N; ComunDef.AtributosNW.atr_N = c.atr_N;
ComunDef.AtributosNW.atr_pedes = c.atr_pedes; ComunDef.AtributosNW.atr_pedes = c.atr_pedes;
ComunDef.CamposNW.config = c.GetOliviaConfNW();
ComunDef.CamposCom.camp_oid = c.id; ComunDef.CamposCom.camp_oid = c.id;
ComunDef.CamposCom.consulta_sector = c.consulta_sector; ComunDef.CamposCom.consulta_sector = c.consulta_sector;

View File

@ -43,9 +43,9 @@ namespace OliviaAddInPro.Services
} }
if(res==null) if(res==null)
res = Default(); res = Default();
EnumOpsNWToString.ListaNw = res.ListaNw;
//pilla la IP //pilla la IP
if(res.Ip.CompareTo("0.0.0.0")==0) if (res.Ip.CompareTo("0.0.0.0")==0)
{ {
//coge la IP local //coge la IP local
res.Ip = OliviaGlob.Conexion.Ip; res.Ip = OliviaGlob.Conexion.Ip;

View File

@ -366,7 +366,12 @@ namespace OliviaAddInPro.Services
ErrStr = Resource1.String_cancel_progreso; ErrStr = Resource1.String_cancel_progreso;
return false; return false;
} }
//prepara campos estandar
if(!EstandarizaCamposNW(OliviaGlob.Paths.DirData+com.NombreShpExportNw))
{
ErrStr = "Error al estandarizar campos red navegable: " + HelperGdb.OutStr;
return false;
}
com.ProgrSrc.IncMessage(40, "Finalizada Exportación. Conectando con Olivia Tasks.");//100% com.ProgrSrc.IncMessage(40, "Finalizada Exportación. Conectando con Olivia Tasks.");//100%
} }
catch (Exception ex) catch (Exception ex)
@ -376,6 +381,64 @@ namespace OliviaAddInPro.Services
} }
return true; return true;
} }
bool EstandarizaCamposNW(string pathNW)
{
HelperGdb.FieldToAdd[] fields = new HelperGdb.FieldToAdd[6];
//campo SECTOR
int i = 0;
fields[i].Name = ComunDef.CamposNW.cons_kph;
fields[i].Alias = ComunDef.CamposNW.cons_kph;
fields[i].Tipo = "FLOAT";
fields[i].Length = 0;
i++;
fields[i].Name = ComunDef.CamposNW.cons_fow;
fields[i].Alias = ComunDef.CamposNW.cons_fow;
fields[i].Tipo = "LONG";
fields[i].Length = 0;
i++;
fields[i].Name = ComunDef.CamposNW.cons_onewFT;
fields[i].Alias = ComunDef.CamposNW.cons_onewFT;
fields[i].Tipo = "LONG";
fields[i].Length = 0;
i++;
fields[i].Name = ComunDef.CamposNW.cons_onewTF;
fields[i].Alias = ComunDef.CamposNW.cons_onewTF;
fields[i].Tipo = "LONG";
fields[i].Length = 0;
i++;
fields[i].Name = ComunDef.CamposNW.cons_evit;
fields[i].Alias = ComunDef.CamposNW.cons_evit;
fields[i].Tipo = "LONG";
fields[i].Length = 0;
i++;
fields[i].Name = ComunDef.CamposNW.cons_name;
fields[i].Alias = ComunDef.CamposNW.cons_name;
fields[i].Tipo = "TEXT";
fields[i].Length = 128;
if (!HelperGdb.AddFieldsSync(pathNW, fields))
return false;
if (!HelperGdb.CalculateFieldsSync(pathNW, ComunDef.CamposNW.cons_kph, ComunDef.CamposNW.config.campo_velocidad))
return false;
if (!HelperGdb.CalculateFieldsSync(pathNW, ComunDef.CamposNW.cons_name, ComunDef.CamposNW.config.campo_nombre))
return false;
if (!HelperGdb.CalculateFieldsSync(pathNW, ComunDef.CamposNW.cons_fow, ComunDef.CamposNW.config.campo_peatonal))
return false;
if (!HelperGdb.CalculateFieldsSync(pathNW, ComunDef.CamposNW.cons_onewTF, ComunDef.CamposNW.config.campo_sentidoTf))
return false;
if (!HelperGdb.CalculateFieldsSync(pathNW, ComunDef.CamposNW.cons_onewFT, ComunDef.CamposNW.config.campo_sentidoFT))
return false;
return true;
}
/** /**
* Actualiza la capa dada añadiendo una columna de sector y una de secuencia * Actualiza la capa dada añadiendo una columna de sector y una de secuencia
*/ */

View File

@ -61,6 +61,7 @@ namespace OliviaAddInPro.Services.LanzaSrv
{ {
str_cfg = str_cfg + str_cfg = str_cfg +
//campos de la red navegable //campos de la red navegable
/*
GeneralDef.EjecGeoParamSep + GeneralDef.GTC_onew + GeneralDef.EjecGeoParamIgual + ComunDef.CamposNW.cons_onew + " " + GeneralDef.EjecGeoParamSep + GeneralDef.GTC_onew + GeneralDef.EjecGeoParamIgual + ComunDef.CamposNW.cons_onew + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GTC_kph + GeneralDef.EjecGeoParamIgual + ComunDef.CamposNW.cons_kph + " " + GeneralDef.EjecGeoParamSep + GeneralDef.GTC_kph + GeneralDef.EjecGeoParamIgual + ComunDef.CamposNW.cons_kph + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GTC_fow + GeneralDef.EjecGeoParamIgual + ComunDef.CamposNW.cons_fow + " " + GeneralDef.EjecGeoParamSep + GeneralDef.GTC_fow + GeneralDef.EjecGeoParamIgual + ComunDef.CamposNW.cons_fow + " " +
@ -69,6 +70,7 @@ namespace OliviaAddInPro.Services.LanzaSrv
GeneralDef.EjecGeoParamSep + GeneralDef.GTA_FT + GeneralDef.EjecGeoParamIgual + ComunDef.AtributosNW.atr_FT + " " + GeneralDef.EjecGeoParamSep + GeneralDef.GTA_FT + GeneralDef.EjecGeoParamIgual + ComunDef.AtributosNW.atr_FT + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GTA_N + GeneralDef.EjecGeoParamIgual + ComunDef.AtributosNW.atr_N + " " + GeneralDef.EjecGeoParamSep + GeneralDef.GTA_N + GeneralDef.EjecGeoParamIgual + ComunDef.AtributosNW.atr_N + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GTA_pedes + GeneralDef.EjecGeoParamIgual + ComunDef.AtributosNW.atr_pedes + " " + GeneralDef.EjecGeoParamSep + GeneralDef.GTA_pedes + GeneralDef.EjecGeoParamIgual + ComunDef.AtributosNW.atr_pedes + " " +
*/
//nombre del tratamiento //nombre del tratamiento
GeneralDef.EjecGeoParamSep + GeneralDef.GG_strtto + GeneralDef.EjecGeoParamIgual + NombreTratamiento + " " + GeneralDef.EjecGeoParamSep + GeneralDef.GG_strtto + GeneralDef.EjecGeoParamIgual + NombreTratamiento + " " +
//paths de archivos //paths de archivos