Compare commits

..

14 Commits

34 changed files with 1101 additions and 2964 deletions

View File

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<ArcGIS defaultAssembly="OliviaAddInPro.dll" defaultNamespace="OliviaAddInPro" xmlns="http://schemas.esri.com/DADF/Registry" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schemas.esri.com/DADF/Registry file:///C:/Program%20Files/ArcGIS/Pro/bin/ArcGIS.Desktop.Framework.xsd">
<AddInInfo id="{10742570-cf59-42f2-bea2-2a38002a06ee}" version="3.2" desktopVersion="3.0.3.36057">
<AddInInfo id="{10742570-cf59-42f2-bea2-2a38002a06ee}" version="4.0" desktopVersion="3.0.3.36057">
<Name>OliviaAddInPro</Name>
<Description>AddIn de Optimización de la Limpieza Viaria para ArcGIs Pro</Description>
<Image>Images\AddinDesktop32.png</Image>
<Author>VSM</Author>
<Company>VSM - Narvaling</Company>
<Date>18/04/2023 12:00:00, 2023</Date>
<Date>12/04/2024 12:00:00, 2024</Date>
<Subject>Framework</Subject>
<!-- Note subject can be one or more of these topics:
Content, Framework, Editing, Geodatabase, Geometry, Geoprocessing, Layouts, Map Authoring, Map Exploration -->

View File

@ -28,6 +28,8 @@ using System.Threading;
using ArcGIS.Core.Data.Exceptions;
using Microsoft.Win32;
using Microsoft.WindowsAPICodePack.Dialogs;
using System.Security.Cryptography;
using ArcGIS.Desktop.Internal.Mapping;
namespace OliviaAddInPro.Helper
{
@ -466,7 +468,7 @@ namespace OliviaAddInPro.Helper
{
ftclss = dtset.OpenDataset<FeatureClass>(ftclassName);
}
catch (Exception ex)
catch/* (Exception ex)*/
{
ftclss = null;
}
@ -477,7 +479,7 @@ namespace OliviaAddInPro.Helper
{
ftclss = gdb.OpenDataset<FeatureClass>(ftclassName);
}
catch (Exception ex)
catch /*(Exception ex)*/
{
ftclss = null;
}
@ -525,7 +527,7 @@ namespace OliviaAddInPro.Helper
{
ftclss = dtset.OpenDataset<FeatureClass>(ftclassName);
}
catch (Exception ex)
catch /*(Exception ex)*/
{
ftclss = null;
}
@ -536,7 +538,7 @@ namespace OliviaAddInPro.Helper
{
ftclss = gdb.OpenDataset<FeatureClass>(ftclassName);
}
catch (Exception ex)
catch /*(Exception ex)*/
{
ftclss = null;
}
@ -672,7 +674,7 @@ namespace OliviaAddInPro.Helper
public static ArcGIS.Core.Data.SpatialQueryFilter CreateFiler(string consulta, ArcGIS.Core.Geometry.Geometry geom, SpatialRelationship rel = SpatialRelationship.Contains)
{
ArcGIS.Core.Data.SpatialQueryFilter filt = null;
if (geom != null)
if (geom != null && !geom.IsEmpty)
{
SpatialQueryFilter filtSpat = new SpatialQueryFilter
{
@ -705,7 +707,7 @@ namespace OliviaAddInPro.Helper
{
if (filt == null)
filt = new ArcGIS.Core.Data.QueryFilter();
sel = fc.Select(filt, SelectionType.ObjectID, SelectionOption.Normal);
sel = fc.Select(filt, ArcGIS.Core.Data.SelectionType.ObjectID, SelectionOption.Normal);
long nsel = sel.GetCount();
IReadOnlyList<long> ids_ = sel.GetObjectIDs();
ids = ids_.ToList();
@ -736,7 +738,7 @@ namespace OliviaAddInPro.Helper
{
if (filt == null)
filt = new ArcGIS.Core.Data.QueryFilter();
sel = fc.Select(filt, SelectionType.ObjectID, SelectionOption.Normal);
sel = fc.Select(filt, ArcGIS.Core.Data.SelectionType.ObjectID, SelectionOption.Normal);
var nsel = sel.GetCount();
IReadOnlyList<long> ids_ = sel.GetObjectIDs();
ids = ids_.ToList();
@ -1182,6 +1184,16 @@ namespace OliviaAddInPro.Helper
geomIni = GeometryEngine.Instance.ConvexHull(geomIni);
return geomIni;
}
public static ArcGIS.Core.Geometry.Geometry GetGeomUnique(String path, ArcGIS.Core.Data.QueryFilter filtro)
{
FeatureClass fc = GetFtClassSync(path);
if (fc == null)
{
OutStr = "Error al abrir Feature Class:" + path;
return null; ;
}
return GetGeomUnique(fc, filtro);
}
/*
* A partir de una capa recorre todos los elementos que cumplen el filtro y los une en una única geometría
*/
@ -1193,6 +1205,7 @@ namespace OliviaAddInPro.Helper
try
{
var geom = new List<ArcGIS.Core.Geometry.Geometry>();
using (RowCursor rowCursor = fclss.Search(filtro))
{
@ -1201,7 +1214,10 @@ namespace OliviaAddInPro.Helper
using (Row row = rowCursor.Current)
{
if (row is Feature ft)
{
geom.Add(ft.GetShape());
}
}
}
geomsal = GeometryEngine.Instance.Union(geom);
@ -1342,7 +1358,7 @@ namespace OliviaAddInPro.Helper
//realiza consulta
n = 0;
//fc.GetDefinition().GetFields().First().Name kfadpskfpasp
using (Selection sel = fc.Select(new ArcGIS.Core.Data.QueryFilter { WhereClause = consulta }, SelectionType.ObjectID, SelectionOption.Normal))
using (Selection sel = fc.Select(new ArcGIS.Core.Data.QueryFilter { WhereClause = consulta }, ArcGIS.Core.Data.SelectionType.ObjectID, SelectionOption.Normal))
n = sel.GetCount();
}
}
@ -1373,7 +1389,7 @@ namespace OliviaAddInPro.Helper
{
//realiza consulta
n = 0;
using (Selection sel = fc.Select(new ArcGIS.Core.Data.QueryFilter { WhereClause = consulta }, SelectionType.ObjectID, SelectionOption.Normal))
using (Selection sel = fc.Select(new ArcGIS.Core.Data.QueryFilter { WhereClause = consulta }, ArcGIS.Core.Data.SelectionType.ObjectID, SelectionOption.Normal))
n = sel.GetCount();
}
}
@ -1444,7 +1460,7 @@ namespace OliviaAddInPro.Helper
if (!System.IO.Directory.Exists(outpath))
System.IO.Directory.CreateDirectory(outpath);
FeatureClass fc = null;
bool debug = true;
bool debug = false;
/////////////////////////////////////////////////////////
//Prepara una where_clause con las entidades que cumplen el filtro
//Abre la featureclass
@ -1463,12 +1479,19 @@ namespace OliviaAddInPro.Helper
if (debug)
HelperGlobal.ponMsg("fc " + fc.GetName() + " tipo " + fc.GetType().Name);
/////////////////////////////////////////////////////////
/////TODO comprobar que el object id no está indexado en la capa de nw, cómo hacerlo indexado
///https://pro.arcgis.com/en/pro-app/3.0/tool-reference/data-management/add-attribute-index.htm
///
//Añade a la lista los ids que cumplen el filtro espacial
try
{
ids = fc.Select(filter, SelectionType.ObjectID, SelectionOption.Normal).GetObjectIDs().ToList();
var aux = fc.Select(filter, ArcGIS.Core.Data.SelectionType.ObjectID, SelectionOption.Normal);
var aux2 = aux.GetObjectIDs();
//ids = fc.Select(filter, SelectionType.ObjectID, SelectionOption.Normal).GetObjectIDs().ToList();
ids = aux2.ToList();
}
catch(Exception ex)
catch (Exception ex)
{
OutStr = "Error al seleccionar IDs. "+ex.Message;
ids = new List<long>();
@ -1489,6 +1512,8 @@ namespace OliviaAddInPro.Helper
OutStr = "Error al aplicar filtro espacial en exportación: "+ OutStr;
return false;
}
if (debug)
HelperGlobal.ponMsg("Número de líneas a exportar "+ids.Count);
/////////////////////////////////////////////////////////
if (cps.Getcancelled())
{
@ -1498,7 +1523,8 @@ namespace OliviaAddInPro.Helper
//convierte la lista de ids a string para la clause de la forma
//(id1, id2, id3..)
string whereClause = GetWhereClauseFromIds(ids,fc.GetDefinition().GetObjectIDField());
if (debug)
HelperGlobal.ponMsg(whereClause);
///////////////////////////////////////////////////////////
///Exporta
string[] args = { pathLayerIn, outpath, nameShp, whereClause };
@ -1742,11 +1768,49 @@ namespace OliviaAddInPro.Helper
ArcGIS.Core.Geometry.Geometry geomBuff = null;
try
{
geomBuff = GeometryEngine.Instance.Buffer(geom, buffer);
}
catch
//GeometryEngine.Instance.Buffer(geom.)
//geomBuff= GeometryEngine.Instance.ConvexHull(geom);
//convierte las unidades del buffer a las unidades de la geometría
double buff_aux = buffer;
//comprueba que la geometría tenga unidades de metros para aplicar el buffer
if (geom.SpatialReference.Unit.FactoryCode != (int)ArcGIS.Core.Geometry.UnitTypeCode.Meters)
{
switch (geom.SpatialReference.Unit.FactoryCode)
{
case (int)ArcGIS.Core.Geometry.UnitTypeCode.Degrees://9102
//360º = 40.075 km
buff_aux = 360 * buffer / 40075000;
break;
case (int)ArcGIS.Core.Geometry.UnitTypeCode.Radians:
//2pi
buff_aux = 2 * Math.PI * buffer / 40075000;
break;
default:
if (geom.SpatialReference.Unit.UnitType == ArcGIS.Core.Geometry.UnitType.Linear)
{
//es de tipo lineal pero otras unidades que no son metros
buff_aux = ArcGIS.Core.Geometry.LinearUnit.Meters.ConvertTo(buffer, (ArcGIS.Core.Geometry.LinearUnit)geom.SpatialReference.Unit);
}
else
{
resp.Error = new List<string>();
resp.Error.Add("Error al aplicar buffer, la geometría del polígono de entrada es de tipo " + geom.SpatialReference.Unit.Name);
geomBuff = null;
buff_aux = 0;
}
break;
}
}
if(resp.Error.IsNullOrEmpty())
geomBuff = GeometryEngine.Instance.Buffer(geom, buff_aux);
}
catch( Exception e)
{
//resp.HasError = true;
if (resp.Error.IsNullOrEmpty())
resp.Error = new List<string>();
resp.Error.Add(e.Message);
return resp;
}
resp.Value = geomBuff;
return resp;
@ -1758,7 +1822,7 @@ namespace OliviaAddInPro.Helper
{
Respuesta<ArcGIS.Core.Geometry.Geometry> resp = new Respuesta<ArcGIS.Core.Geometry.Geometry>();
double buffer = 0;//m de distancia desde la instalación
bool repite = true;
//bool repite = true;
ArcGIS.Core.Geometry.Geometry geom_pto, geom_sal;
try
{
@ -1791,7 +1855,7 @@ namespace OliviaAddInPro.Helper
}
while (repite);*/
buffer = buff;
geom_pto = GeometryEngine.Instance.Buffer(pto.ToMapPoint(), buffer);
geom_pto = HelperGdb.BufferGeom((ArcGIS.Core.Geometry.Geometry)pto.ToMapPoint(geom.SpatialReference),buffer).Value; //GeometryEngine.Instance.Buffer(pto.ToMapPoint(), buffer);
if (geom_pto == null || geom_pto.IsEmpty)
{
resp.Value = null;
@ -2069,7 +2133,7 @@ namespace OliviaAddInPro.Helper
MapView.Active.Map.RemoveLayer(lyr);
return true;
}
catch (Exception ex)
catch/*(Exception ex)*/
{
return false;
}
@ -2129,7 +2193,7 @@ namespace OliviaAddInPro.Helper
else
return string.Empty;
}
catch(Exception ex)
catch/*(Exception ex)*/
{
return string.Empty;
}
@ -2217,7 +2281,7 @@ namespace OliviaAddInPro.Helper
return 0;
return 2;
}
catch (Exception ex)
catch /*(Exception ex)*/
{
return 1;
}
@ -2247,8 +2311,8 @@ namespace OliviaAddInPro.Helper
return res;
}
//comprueba si extiste ya el dataset
bool repite = false;
bool crea = false;
//bool repite = false;
//bool crea = false;
int idat = 1;
int r = 2;
bool refspatdif = false;
@ -2348,7 +2412,7 @@ namespace OliviaAddInPro.Helper
/**
* Importa el shp en la gdb y el dataset, como una featureclass
*/
public static Respuesta<bool> ImportShp(string nom_shp, string Gdb_dataset, string namefc)
public static Respuesta<bool> ImportShp(string nom_shp, string Gdb_dataset, string namefc, ArcGIS.Core.Geometry.SpatialReference spatref=null)
{
var res = new Respuesta<bool> { Value = false };
string[] args = { nom_shp, Gdb_dataset, namefc };
@ -2356,11 +2420,12 @@ namespace OliviaAddInPro.Helper
try
{
ArcGIS.Core.Geometry.SpatialReference spatref = GetSpatRef(nom_shp);
if(spatref==null)
spatref = GetSpatRef(nom_shp);
var environments = Geoprocessing.MakeEnvironmentArray(outputCoordinateSystem: spatref);
//CancelableProgressorSource cps = new CancelableProgressorSource();
var _cts = new System.Threading.CancellationTokenSource();
var completa = false;
//var completa = false;
var gpres = Geoprocessing.ExecuteToolAsync("FeatureClassToFeatureClass_conversion", args, environments, _cts.Token,
(event_name, o) => // implement delegate and handle events
{
@ -2675,7 +2740,7 @@ namespace OliviaAddInPro.Helper
featureLayer.SetRenderer(uniqueValueRenderer);
}
catch (Exception ex)
catch /*(Exception ex)*/
{
}
@ -2807,6 +2872,69 @@ namespace OliviaAddInPro.Helper
{
}
return res;
}
public static bool ExplodeAll(string pahtFc)
{
/*
var ft = GetFtClassSync(pahtFc);
var ids=ft.Select(new ArcGIS.Core.Data.QueryFilter() { WhereClause = "true" }, SelectionType.ObjectID, SelectionOption.Normal).GetObjectIDs().ToList();
var explodeFeatures = new EditOperation();
explodeFeatures.Name = "Explode Features";
//Take a multipart and convert it into one feature per part
//Provide a list of ids to convert multiple
explodeFeatures.Explode(ft, ids, true);
//Execute to execute the operation
//Must be called within QueuedTask.Run
if (!explodeFeatures.IsEmpty)
{
var result = explodeFeatures.Execute(); //Execute and ExecuteAsync will return true if the operation was successful and false if not
}
return true;
//or use async flavor
//await explodeFeatures.ExecuteAsync();
*/
return true;
}
/*
* 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;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -10,18 +10,28 @@ namespace OliviaAddInPro.Model
//*************************************************************************************
//Enums y structs generales
public static int BuffExport = 1000;
//public static int MaxCaracteresBBDD = 10;
//public static int MaxCaracteresBBDD = 10;
public static OliviaConfMV configMV; //configuracion para modos de viaje
/**
* Nombre de los campos de la cartografía de la red navegable que se consultan para la exportación
*/
public struct CamposNW
{
public static string cons_onew; //<Campo que indica el sentido
public static string cons_kph; //<Campo que indica la velocidad en kph
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_onewFT="_sen_ft"; //<Campo que indica el sentido
public static string cons_onewTF="_sen_tf"; //<Campo que indica el sentido
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 string cons_ele_f = "_elev_f"; //altura from
public static string cons_ele_t = "_elev_t"; //altura to
public static string cons_angulo = "_angulo"; //altura to
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
*/

View File

@ -65,6 +65,9 @@ namespace OliviaAddInPro.Model
Respuesta<bool> res = new Respuesta<bool> { Value=false};
Respuesta<TiposEjecucion> res2 = new Respuesta<TiposEjecucion> (){ Value = TiposEjecucion.FinEjecNOk };
Serv.TipoMv = TipoMV;
res = Serv.Ejecuta(modo);
if (res.Value)
{

View File

@ -11,9 +11,12 @@ using System.Windows;
using Xceed.Wpf.Toolkit.PropertyGrid;
using Xceed.Wpf.Toolkit.PropertyGrid.Editors;
using Xceed.Wpf.Toolkit.PropertyGrid.Attributes;
using static OliviaAddInPro.Model.OliviaConf;
namespace OliviaAddInPro.Model
{
[CategoryOrder("General", 1)]
[CategoryOrder("Campos Limpieza", 2)]
[CategoryOrder("Atributos Limpieza", 3)]
@ -44,12 +47,30 @@ namespace OliviaAddInPro.Model
[Description("Usa 'Kg por Defecto'")]
UsaKgDef
}
[TypeConverter(typeof(EnumOpsNWToString))]
public enum OpsNW
{
nw_0, //TomTom
nw_1, //Streetmap
nw_2, //
nw_3,
nw_4,
}
private string m2s(int min)
{
var val = min;
int horas = val / 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)
{
var match = Regex.Match(str, @"^([0-9]*):([0-9]*)");
@ -66,16 +87,20 @@ namespace OliviaAddInPro.Model
}
return defec;
}
public OliviaConf()
{
Ip = "127.0.0.1";
Puerto = 19995;
TiempoOutSocket = 20;
}
}
#region PropiedadesOcultas
#region parametrosConexion
/**
* Version de las configuraciones
*/
[Browsable(false)]
public string Version { get; set; }
/**
* IP donde va a realizar la conexión a OliviaTask, se inicializa al arrancar con la local
*/
@ -174,7 +199,10 @@ namespace OliviaAddInPro.Model
#endregion
#region ParametrosReco_Ocultos
[Browsable(false)]
public List<OliviaConfNW> ListaNw { get; set; }
[Browsable(false)]
public List<OliviaConfMV> ListaMV { get; set; }
[Browsable(false)]
public int t_vaciado_max { get; set; }
[Browsable(false)]
@ -218,6 +246,19 @@ namespace OliviaAddInPro.Model
[Description("Red de carreteras que se usa para la navegación")]
[Editor(typeof(PropertyGridFilePickerLine), typeof(PropertyGridFilePickerLine))]
public string Path_Eje_via { get; set; }
[Category("General")]
[DisplayName("Conjunciones red de carreteras")]
[PropertyOrder(1)]
[Description("Conjunciones red de carreteras que se usa para la navegación")]
[Editor(typeof(PropertyGridFilePickerPto), typeof(PropertyGridFilePickerPto))]
public string Path_Conj_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")]
[PropertyOrder(2)]
@ -589,21 +630,25 @@ namespace OliviaAddInPro.Model
#endregion
#region 06CambosNW
[Browsable(false)]
[Category("Campos Red Navegable")]
[DisplayName("Sentido de la vía")]
[Description("Nombre del campo que indica si la vía es de doble sentido o no")]
public string cons_onew { get; set; }
[Browsable(false)]
[Category("Campos Red Navegable")]
[DisplayName("Velocidad de la vía")]
[Description("Nombre del campo que indica la velociad máxima permitida de la vía")]
public string cons_kph { get; set; }
[Browsable(false)]
[Category("Campos Red Navegable")]
[DisplayName("Tipo de vía")]
[Description("Nombre del campo que indica el tipo de la vía (usado para ver si es vía peatonal).")]
public string cons_fow { get; set; }
[Browsable(false)]
[Category("Campos Red Navegable")]
[DisplayName("Nombre de la vía")]
[Description("Nombre del campo que indica el nombre de la vía")]
@ -611,24 +656,28 @@ namespace OliviaAddInPro.Model
#endregion
#region 07AtrNw
[Browsable(false)]
[Category("Atributos Red Navegable")]
[PropertyOrder(1)]
[DisplayName("To-From")]
[Description("Valor del campo 'Sentido de la vía' que indica sentido de la vía To-From")]
public string atr_TF { get; set; }
[Browsable(false)]
[Category("Atributos Red Navegable")]
[PropertyOrder(2)]
[DisplayName("From-To")]
[Description("Valor del campo 'Sentido de la vía' que indica sentido de la vía From-To")]
public string atr_FT { get; set; }
[Browsable(false)]
[Category("Atributos Red Navegable")]
[PropertyOrder(3)]
[DisplayName("Sin circulación")]
[Description("Valor del campo 'Sentido de la vía' que indica no circulación")]
public string atr_N { get; set; }
[Browsable(false)]
[Category("Atributos Red Navegable")]
[PropertyOrder(4)]
[DisplayName("Peatonal")]
@ -1327,9 +1376,55 @@ namespace OliviaAddInPro.Model
public string atr_suelo { get; set; }
#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 override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
return (sourceType.Equals(typeof(Enum)));

30
Model/OliviaConfMV.cs Normal file
View File

@ -0,0 +1,30 @@
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 OliviaConfMV
{
public OliviaConfMV()
{
nombre = "default";
filtro_omitir = "";
campo_prioridad = "0";
vehiculo_def_reco = -1;
vehiculo_def_lim = -1;
}
public string nombre { get; set; }
public string filtro_omitir { get; set; }
public string campo_prioridad { get; set; }
public int vehiculo_def_reco { get; set; }
public int vehiculo_def_lim { get; set; }
}
}

31
Model/OliviaConfNW.cs Normal file
View File

@ -0,0 +1,31 @@
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; }
public string campo_elevacion_to { get; set; }
public string campo_elevacion_from { get; set; }
public bool comprueba_elevacion { get; set; }
public bool revisa_topologia { get; set; }
public bool revisa_conjunciones { get; set; }
public bool revisa_angulos { get; set; }
public string campo_angulos { get; set; }
}
}

View File

@ -142,6 +142,7 @@ namespace OliviaAddInPro.Model
public const string GG_pt = "path_temp";
public const string GG_pd = "path_data";
public const string GG_pn = "path_nw";
public const string GG_pnj = "path_cnw";
public const string GG_pcar = "path_cart";
public const string GG_pcfg = "path_cfgeo";
public const string GG_strtto = "str_tto";
@ -160,7 +161,10 @@ namespace OliviaAddInPro.Model
public const string GG_hini = "h_inicio";
public const string GG_trafic = "trafico";
public const string GG_ais = "aislados";
public const string GG_elev = "elevacion";
public const string GG_topo = "reviTopo";
public const string GG_conj = "reviConj";
public const string GG_angu = "reviAng";
/**
* Define las propiedades de limpieza a enviar a oliviatasks
*/
@ -599,6 +603,16 @@ namespace OliviaAddInPro.Model
* 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";
//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

@ -51,10 +51,12 @@ namespace OliviaAddInPro.Model
public static string DirData; //<Dir donde están los shapefiles data y nw
public static string PathData; //<Path del shp con datos a planificar, ya filtrados e intersecados con las zonas y niveles
public static string PathNW; //<Path del shp con la red navegable
public static string PathNW_c; //<Path del shp con las conjunciones de la red navegable
//paths GDBs
public static string PathGdbGen; //<Path de la gdb general de la que se extraen los datos de interés
public static string PathGdbNw; //<Path de la gdb referente a la red de carreteras de TOMTOM
public static string PathGdbNw; //<Path de la gdb referente a la red de carreteras de
public static string PathGdbNw_conj; //<Path de la gdb referente a las conjunciones de la red de carreteras
public static string PathSimbVSM; //<Path de la galeria de estilos aplicada por VSM
public static string PathSimbESRI; //<Path de la galeria de estilos de ESRI
@ -84,8 +86,8 @@ namespace OliviaAddInPro.Model
public struct Capas
{
public static string pathEjeVia;
public static string ftclass_ejes; //<Nombre de la capa de ejes de carretera
public static string ftclass_muni; //<Nombre de la capa de municipios de TOMTOM
//public static string ftclass_ejes; //<Nombre de la capa de ejes de carretera
//public static string ftclass_muni; //<Nombre de la capa de municipios de TOMTOM
};
private static TiposEjecucion tipoEjec;
public static Limpieza limp;
@ -273,14 +275,16 @@ namespace OliviaAddInPro.Model
if (ft == null)
return false;
HelperGdb.Free(ft);
int NCAMPS = 4;
/*int NCAMPS = 5;
string[] camps;
camps = new string[NCAMPS];
camps[0] = ComunDef.CamposNW.cons_onew;
camps[1] = ComunDef.CamposNW.cons_kph;
camps[2] = ComunDef.CamposNW.cons_name;
camps[3] = ComunDef.CamposNW.cons_fow;
return HelperGdb.CheckFileds(OliviaGlob.Paths.PathGdbNw, camps) == 0;
camps[0] = ComunDef.CamposNW.cons_onewFT;
camps[1] = ComunDef.CamposNW.cons_onewTF;
camps[2] = ComunDef.CamposNW.cons_kph;
camps[3] = ComunDef.CamposNW.cons_name;
camps[4] = ComunDef.CamposNW.cons_fow;
return HelperGdb.CheckFileds(OliviaGlob.Paths.PathGdbNw, camps) == 0;*/
return true;
}
/**
@ -389,7 +393,7 @@ namespace OliviaAddInPro.Model
*/
public static void OpenManual()
{
string[] archivos = null;
//string[] archivos = null;
try
{
@ -429,6 +433,7 @@ namespace OliviaAddInPro.Model
Paths.PathGdbGen = c.PathGdbGen;
Paths.PathGdbNw = c.Path_Eje_via;
Paths.PathGdbNw_conj = c.Path_Conj_Eje_via;
Paths.PathSimbVSM = c.PathSimbVSM;
Paths.PathSimbESRI = c.PathSimbESRI;
Conexion.Puerto = c.Puerto;
@ -440,6 +445,7 @@ namespace OliviaAddInPro.Model
//Capas.ftclass_ejes = c.eje_via;
//Capas.ftclass_muni = c.municipios;
Capas.pathEjeVia = c.Path_Eje_via;
//Capas.Path_Conj_Eje_via = c.Path_Conj_Eje_via;
///////////////////////////////////////
//Capas, consultas, atributos y filtros de LIMPIEZA
LimpiezaDef.Campos.consulta_entidad = c.cons_tip_ent;
@ -493,6 +499,7 @@ namespace OliviaAddInPro.Model
LimpiezaDef.Parametros.h_inicio = c.hora_inicio;
LimpiezaDef.Parametros.reduc_traf = c.reduc_traf;
LimpiezaDef.Parametros.igno_ais = c.Igno_ais;
LimpiezaDef.Parametros.ancho_viaM = c.ancho_via_max;
LimpiezaDef.Parametros.ancho_viam = c.ancho_via_min;
LimpiezaDef.Parametros.ancho_via = c.ancho_via;
@ -620,16 +627,16 @@ namespace OliviaAddInPro.Model
ComunDef.BuffExport = c.buffer_export;
//Campos de la red navegable que se leen
ComunDef.CamposNW.cons_onew = c.cons_onew;
ComunDef.CamposNW.cons_kph = c.cons_kph;
ComunDef.CamposNW.cons_fow = c.cons_fow;
ComunDef.CamposNW.cons_name = c.cons_name;
/*ComunDef.CamposNW.cons_onew = c.cons_onew;
ComunDef.CamposNW.cons_kph = "_vel";
ComunDef.CamposNW.cons_fow = "_peat";
ComunDef.CamposNW.cons_name = c.cons_name;*/
//Atributos de la red navegable que se leen
ComunDef.AtributosNW.atr_TF = c.atr_TF;
ComunDef.AtributosNW.atr_FT = c.atr_FT;
ComunDef.AtributosNW.atr_N = c.atr_N;
ComunDef.AtributosNW.atr_pedes = c.atr_pedes;
ComunDef.CamposNW.config = c.GetOliviaConfNW();
ComunDef.CamposCom.camp_oid = c.id;
ComunDef.CamposCom.consulta_sector = c.consulta_sector;
ComunDef.CamposCom.consulta_secuen = c.consulta_secuen;

View File

@ -91,6 +91,7 @@ namespace OliviaAddInPro.Model
{
Respuesta<bool> res = new Respuesta<bool> { Value = false };
Respuesta<TiposEjecucion> res2 = new Respuesta<TiposEjecucion>() { Value = TiposEjecucion.FinEjecNOk };
Serv.TipoMv = TipoMV;
res = Serv.Ejecuta(modo);
if (res.Value)
{

View File

@ -405,9 +405,13 @@ namespace OliviaAddInPro.Model
int n, i_def, icar, iveh;
//Rellena las opciones de carga máxima por vehículo
//////////////////////////////////////////////////
//Carga Trasera
////////////////////////////////////////////////
//Trasera-satelite
n = 4;
i_def = 2;
//Rellena volumenes
info[0] = 2;
info[1] = 3;
info[2] = 5;
@ -425,6 +429,7 @@ namespace OliviaAddInPro.Model
//Trasera-2 ejes
n = 6;
i_def = 2;
//Rellena volumenes
info[0] = 8;
info[1] = 10;
info[2] = 12;
@ -447,6 +452,7 @@ namespace OliviaAddInPro.Model
//Trasera-3ejes
n = 4;
i_def = 3;
//Rellena volumenes
info[0] = 18;
info[1] = 20;
info[2] = 22;
@ -454,6 +460,9 @@ namespace OliviaAddInPro.Model
rellena_carg((int)RecogidaDef.TiposCarga.Trasera,
(int)RecogidaDef.TiposVehic.Ejes3, n, i_def, info);
//////////////////////////////////////////////////
//Carga Lateral
////////////////////////////////////////////////
//Lateral-satelite, no hay
rellena_carg((int)RecogidaDef.TiposCarga.Lateral,
(int)RecogidaDef.TiposVehic.Satelite, 0, 0, null);
@ -461,6 +470,7 @@ namespace OliviaAddInPro.Model
//Lateral - 2 ejes
n = 2;
i_def = 1;
//Rellena volumenes
info[0] = 15;
info[1] = 17;
rellena_carg((int)RecogidaDef.TiposCarga.Lateral,
@ -476,6 +486,7 @@ namespace OliviaAddInPro.Model
//Lateral - 3 ejes
n = 3;
i_def = 2;
//Rellena volumenes
info[0] = 21;
info[1] = 23;
info[2] = 26;
@ -486,9 +497,13 @@ namespace OliviaAddInPro.Model
rellena_carg((int)RecogidaDef.TiposCarga.Superior,
(int)RecogidaDef.TiposVehic.Satelite, 0, 0, null);
//////////////////////////////////////////////////
//Carga Superior
////////////////////////////////////////////////
//Superior - 2 ejes
n = 2;
i_def = 0;
//Rellena volumenes
info[0] = 16;
info[1] = 17;
rellena_carg((int)RecogidaDef.TiposCarga.Superior,
@ -497,6 +512,7 @@ namespace OliviaAddInPro.Model
//Superior - 3 ejes
n = 3;
i_def = 2;
//Rellena volumenes
info[0] = 20;
info[1] = 23;
info[2] = 25;
@ -507,47 +523,9 @@ namespace OliviaAddInPro.Model
rellena_carg((int)RecogidaDef.TiposCarga.Bilateral,
(int)RecogidaDef.TiposVehic.Satelite, 0, 0, null);
//Bilateral - 2 ejes
n = 3;
i_def = 1;
info[0] = 14;
info[1] = 16;
info[2] = 18;
rellena_carg((int)RecogidaDef.TiposCarga.Bilateral,
(int)RecogidaDef.TiposVehic.Ejes2, n, i_def, info);
//Bilateral - 3 ejes
n = 3;
i_def = 1;
info[0] = 20;
info[1] = 23;
info[2] = 26;
rellena_carg((int)RecogidaDef.TiposCarga.Bilateral,
(int)RecogidaDef.TiposVehic.Ejes3, n, i_def, info);
//Bolseo - todas, no hay
//Lavado - todas, no hay
//Otra - todas, no hay
for (icar = (int)RecogidaDef.TiposCarga.BolseoPtaPta; icar < (int)RecogidaDef.TiposCarga.N; icar++)
{
for (iveh = (int)RecogidaDef.TiposVehic.Ejes3; iveh < (int)RecogidaDef.TiposVehic.N; iveh++)
{
rellena_carg(icar, iveh, 0, 0, null);
}
}
////////////////////////////////////////////////////////
//Barcelona new
rellena_offsets_bcn();
}
private static void rellena_offsets_bcn()
{
int[] info = new int[10];
int n, i_def;
////////////////////////////////////////////////////////
//Barcelona new
//////////////////////////////////////////////////
//Carga Bilateral
////////////////////////////////////////////////
//Bilateral - satelite
n = 1;
i_def = 0;
@ -577,6 +555,50 @@ namespace OliviaAddInPro.Model
info[0] = -2050;
rellena_carg_offset((int)RecogidaDef.TiposCarga.Bilateral,
(int)RecogidaDef.TiposVehic.Satelite, (int)RecogidaDef.TiposFracción.Vidrio, n, info);
//Bilateral - 2 ejes
n = 3;
i_def = 1;
//Rellena volumenes
info[0] = 14;
info[1] = 16;
info[2] = 18;
rellena_carg((int)RecogidaDef.TiposCarga.Bilateral,
(int)RecogidaDef.TiposVehic.Ejes2, n, i_def, info);
//Bilateral - 3 ejes
n = 3;
i_def = 1;
//Rellena volumenes
info[0] = 20;
info[1] = 23;
info[2] = 26;
rellena_carg((int)RecogidaDef.TiposCarga.Bilateral,
(int)RecogidaDef.TiposVehic.Ejes3, n, i_def, info);
//Bolseo - todas, no hay
//Lavado - todas, no hay
//Otra - todas, no hay
for (icar = (int)RecogidaDef.TiposCarga.BolseoPtaPta; icar < (int)RecogidaDef.TiposCarga.N; icar++)
{
for (iveh = (int)RecogidaDef.TiposVehic.Ejes3; iveh < (int)RecogidaDef.TiposVehic.N; iveh++)
{
rellena_carg(icar, iveh, 0, 0, null);
}
}
////////////////////////////////////////////////////////
//Rellena offsets
rellena_offsets_bcn();
}
private static void rellena_offsets_bcn()
{
int[] info = new int[10];
int n, i_def;
////////////////////////////////////////////////////////
//Barcelona revisado abril 24
////////////////////////////////////////////////////////////////////////////////////////////////
//Trasera - satélite - organico, resto
@ -817,19 +839,12 @@ namespace OliviaAddInPro.Model
(int)RecogidaDef.TiposVehic.Ejes3, (int)RecogidaDef.TiposFracción.Vidrio, n, info);
//Bilateral - 2 ejes - papel
info[0] = 1820;
info[1] = 2080;
info[2] = 2340;
info[0] = 1540;
info[1] = 1760;
info[2] = 1980;
rellena_carg_offset((int)RecogidaDef.TiposCarga.Bilateral,
(int)RecogidaDef.TiposVehic.Ejes2, (int)RecogidaDef.TiposFracción.Papel, n, info);
//Bilateral - 2 ejes - vidrio
info[0] = -140;
info[1] = -160;
info[2] = -180;
rellena_carg_offset((int)RecogidaDef.TiposCarga.Bilateral,
(int)RecogidaDef.TiposVehic.Ejes2, (int)RecogidaDef.TiposFracción.Vidrio, n, info);
////////////////////////////////////////////////////////////////////////////////////////////////
//Bilateral - 3 ejes - resto, org
n = 3;

View File

@ -25,10 +25,19 @@ namespace OliviaAddInPro.Model
* String para Tipo de tratamiento, se guarda como columna en el shp
*/
public string TipoTtoStr { get; set; } = String.Empty;
/**
* Tipo modo de viaje
*/
public int TipoMV { get; set; } = -1;
/**
* Capa de ámbitos
*/
public string CapaElems { get; set; } = string.Empty;
/**
* Capa de ámbitos de referencia.
* Cuando se hace tratamiento con ejes de calle, se guarda la capa de referencia
*/
public string CapaElemsRef { get; set; } = string.Empty;
/**
* Capa de ámbitos después de haber planificado
*/
@ -45,6 +54,7 @@ namespace OliviaAddInPro.Model
* Nombre dle shp exportado de nw
*/
public string NombreShpExportNw { get; set; } = string.Empty;
public string NombreShpExportNw_C { get; set; } = string.Empty;
/**
* Velocidad de desplazamiento, en km/h. Si es 0, es determinada por la vía
*/

View File

@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("VSM - Narvaling")]
[assembly: AssemblyProduct("OliviaAddInPro")]
[assembly: AssemblyCopyright("Copyright © VSM 2023")]
[assembly: AssemblyCopyright("Copyright © VSM 2024")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.2.0.0")]
[assembly: AssemblyFileVersion("3.2.0.0")]
[assembly: AssemblyVersion("4.0.0.0")]
[assembly: AssemblyFileVersion("4.0.0.0")]

View File

@ -7,6 +7,7 @@ using System.Threading.Tasks;
using System.IO;
using Newtonsoft.Json;
using Microsoft.Win32;
using static OliviaAddInPro.Model.OliviaConf;
namespace OliviaAddInPro.Services
{
@ -15,10 +16,10 @@ namespace OliviaAddInPro.Services
private static string pathConfigDef = "C:\\Olivia";
private static ConfigServ configServ=null;
private static string nameDirWork = "%dir_work%";
public const string OlvRegKey = "SOFTWARE\\Narvaling\\Olivia_3_1";
public const string OlvRegKey = "SOFTWARE\\Narvaling\\Olivia_4_0";
public const string OlvRegName = "workdir";
public const string OlvConfigName = "olv.conf";
public const string VersionConfiguracion = "1.2.0.0";
public static ConfigServ Serv
{
get {
@ -41,11 +42,12 @@ namespace OliviaAddInPro.Services
var ee = e;
res = null;
}
if(res==null)
if(res==null || res.Version==null || res.Version != VersionConfiguracion)
res = Default();
EnumOpsNWToString.ListaNw = res.ListaNw;
//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
res.Ip = OliviaGlob.Conexion.Ip;
@ -169,7 +171,7 @@ namespace OliviaAddInPro.Services
c.path_work = "C:\\Olivia\\";
}
c.Version = VersionConfiguracion;
c.PathGdbGen = @"%dir_work%gdb\\BASE DE DATOS.gdb";
c.PathSimbVSM = @"%dir_work%styles\\Simbologia.style";
c.PathSimbESRI = @"%dir_work%styles\\ESRI.style";
@ -307,7 +309,7 @@ namespace OliviaAddInPro.Services
c.v_desp_LS=0;
//Reco
c.id= "ID";
c.id= "_ID";
c.nomrec= "NOMB_TIP_REC";
c.lateralidad= "LATERALIDAD";
c.frac= "FRACCION";
@ -352,13 +354,13 @@ namespace OliviaAddInPro.Services
c.dens_vehi_org=500;
c.dens_vehi_res=500;
c.dens_vehi_env=120;
c.dens_vehi_pap=250;
c.dens_vehi_pap=360;
c.dens_vehi_vid=350;
c.dens_vehi_otr=100;
c.dens_cont_org=150;
c.dens_cont_org=200;
c.dens_cont_res=100;
c.dens_cont_env=28;
c.dens_cont_pap=90;
c.dens_cont_pap=75;
c.dens_cont_vid=250;
c.dens_cont_otr=100;
c.anch_vehi_3=2.4000000;
@ -396,7 +398,87 @@ namespace OliviaAddInPro.Services
c.Giro_max_vehiculo = 175.0000000;
c.Desv_max = 0.1500000;
c.Desv_max_abs = 1800.0000000;
c.Tipo_eje_via = OpsNW.nw_0;
c.ListaNw = new List<OliviaConfNW>();
c.ListaNw.Add(new OliviaConfNW()
{
nombre = "TomTom",
campo_velocidad = "$feature.KPH",
campo_nombre = "$feature.NAME",
campo_peatonal = "IIf( $feature.FOW == 14 || $feature.FOW == 15 || $feature.FOW == 19 || $feature.ONEWAY == 'N', 1, 0)",
campo_sentidoFT = "IIF($feature.ONEWAY== 'TF' || $feature.ONEWAY == 'N', 0 , 1)",
campo_sentidoTf = "IIF($feature.ONEWAY == 'FT' || $feature.ONEWAY == 'N', 0, 1)",
campo_elevacion_from = "$feature.F_ELEV",
campo_elevacion_to = "$feature.T_ELEV",
comprueba_elevacion = true,
revisa_topologia = false,
revisa_conjunciones = false,
revisa_angulos = false,
campo_angulos = "0"
}); ;
/*
c.ListaNw.Add(new OliviaConfNW()
{
nombre = "StreetMapPremiun",
campo_velocidad = "max($feature.FT_RST_SPE, $feature.TF_RST_SPE)",
campo_nombre = "$feature.FULL_STREE",
campo_peatonal = "IIF( $feature.FT_RST_AUT == 'Y' && $feature.TF_RST_AUT == 'Y', 1, 0)",
campo_sentidoFT = "IIf( $feature.FT_RST_AUT == 'N', 1, 0)",
campo_sentidoTf = "IIf( $feature.TF_RST_AUT == 'N', 1, 0)",
campo_elevacion_from = "IIf( $feature.F_ZLEV != null, $feature.F_ZLEV, 0)",
campo_elevacion_to = "IIf( $feature.T_ZLEV != null, $feature.T_ZLEV, 0)",
comprueba_elevacion = false,
revisa_topologia = false,
revisa_conjunciones = true,
revisa_angulos = true,
campo_angulos = "IIF($feature.ROAD_CLASS== '3 - Highway Ramp' || $feature.ROAD_CLASS== '6 - Major Road' || $feature.ROAD_CLASS == '1 - Surface Street', 90 , 0)"
});
*/
c.ListaMV = new List<OliviaConfMV>();
c.ListaMV.Add(new OliviaConfMV()
{
nombre = "Default",
filtro_omitir = "",
campo_prioridad = "0",
vehiculo_def_reco = -1,
vehiculo_def_lim = -1
}) ;
c.ListaMV.Add(new OliviaConfMV()
{
nombre = "Peaton",
filtro_omitir = "(FREEWAY <> 1 AND SLIPRD = 0)",
campo_prioridad = "0",
vehiculo_def_reco = -1,
vehiculo_def_lim = 0
});
c.ListaMV.Add(new OliviaConfMV()
{
nombre = "Vehiculo pequeño",
filtro_omitir = "(FREEWAY <> 1 AND SLIPRD = 0)",
campo_prioridad = "IIF($feature.PRIVATERD>1 || ($feature.FOW>13 && $feature.FOW<16) , -2 , 0)",
vehiculo_def_reco = 2,
vehiculo_def_lim = 1
});
c.ListaMV.Add(new OliviaConfMV()
{
nombre = "Vehiculo mediano",
filtro_omitir = "(ONEWAY <> 'N' AND FOW NOT IN (14, 15, 19))",
campo_prioridad = "IIF($feature.PRIVATERD>1 || $feature.RDCOND>1 , -2 , 0)",
vehiculo_def_reco = 1,
vehiculo_def_lim = -1
});
c.ListaMV.Add(new OliviaConfMV()
{
nombre = "Vehiculo grande",
filtro_omitir = "(ONEWAY <> 'N' AND FOW NOT IN (14, 15, 19))",
campo_prioridad = "IIF($feature.RDCOND>1,-3, (IIF($feature.PRIVATERD>1 , -2 , 0)))",
vehiculo_def_reco =0,
vehiculo_def_lim = -1
});
return c;
}
}

View File

@ -11,6 +11,7 @@ using ArcGIS.Core.Internal.Data;
using ArcGIS.Desktop.Framework.Threading.Tasks;
using System.Windows;
using System.IO;
using ArcGIS.Core.Data.UtilityNetwork.Trace;
namespace OliviaAddInPro.Services
{
@ -28,6 +29,7 @@ namespace OliviaAddInPro.Services
public string PREF_NAME_EXPORT = "data_";
public string EXT_SHP = ".shp";
public string PREF_NAME_EXPORT_NW = "nw_";
public string PREF_NAME_EXPORT_NW_CONJ = "nw_c_";
public string NAME_CSV = "_L";
public string EXT_CSV = ".csv";
public string NAME_RUTA2 = "_R2";
@ -42,9 +44,10 @@ namespace OliviaAddInPro.Services
public string NAME_INSTAL = "_I";
public string NAME_INSTAL_OUT = "_Instalacion";
public int TipoMv { get; set; }
public string ErrStr = "";
SpatialQueryFilter filtroEspacial = null;
SpatialReference spatRef = null;
//SpatialReference spatRef = null;
SpatialReference spatRefData = null;
public TratamientoComun com;
@ -59,6 +62,7 @@ namespace OliviaAddInPro.Services
ErrStr = string.Empty;
OliviaGlob.Paths.PathData = string.Empty;
OliviaGlob.Paths.PathNW = string.Empty;
OliviaGlob.Paths.PathNW_c= string.Empty;
if (com.ProgrSrc._ProgrSrc.Getcancelled())
{
ErrStr = Resource1.String_cancel_progreso;
@ -70,7 +74,7 @@ namespace OliviaAddInPro.Services
//Comprueba que tiene las columnas necesarias para planificar
if ((modo == ModosEjec.Planifica) && !CompruebaPlanif())
{
ErrStr = "En la capa de ámbitos seleccionada no se encuentran columnas de SECTOR y/o SECUENCIA, necesarias para planificar";
ErrStr = "En la capa de ámbitos seleccionada no se encuentran columnas de SECTOR y/o SECUENCIA, necesarias para planificar, o bien han cambiado los datos configurados";
return false;
}
if (com.ProgrSrc._ProgrSrc.Getcancelled())
@ -142,8 +146,17 @@ namespace OliviaAddInPro.Services
return false;
}
//mira spatialreference de los datos de entrada
spatRefData = geom_export.SpatialReference;
spatref = HelperGdb.GetSpatRefSync(com.CapaElemsRef);
spatRefData = spatref;
if (spatref != null)
{
geom_export = HelperGdb.ReproyectaGeom(geom_export, spatref);
}
if (geom_export == null)
{
ErrStr = "Error al reproyectar geometría para la exportacion de los ámbitos";
return false;
}
//crea el filtro de exportación
filtroEspacial = HelperGdb.CreateFiler(com.ConsultaAmbs, geom_export);
if (filtroEspacial == null)
@ -169,7 +182,7 @@ namespace OliviaAddInPro.Services
//Guarda el nombre
OliviaGlob.Paths.PathData = OliviaGlob.Paths.DirData + com.NombreShpExport;
//exporta los datos de entrada
if (!HelperGdb.ExportShp2(com.CapaElems, filtroEspacial, com.NombreShpExport, OliviaGlob.Paths.DirData, com.ProgrSrc._ProgrSrc, null, 50))
if (!HelperGdb.ExportShp2(com.CapaElems, filtroEspacial, com.NombreShpExport, OliviaGlob.Paths.DirData, com.ProgrSrc._ProgrSrc, spatref, 50))
{
ErrStr = "Error al exportar los ámbitos: " + HelperGdb.OutStr;
return false;
@ -183,7 +196,7 @@ namespace OliviaAddInPro.Services
/////////////////////////////////////////////////////////////////////
///Comprueba si está la columna de ObjectId y si no, la crea
if(!ComprCreaColOid(OliviaGlob.Paths.PathData, com.CapaElems, filtroEspacial))
if(!ComprCreaColOid(OliviaGlob.Paths.PathData, com.CapaElems, null))
{
ErrStr = "Error al exportar columna " + ComunDef.CamposCom.camp_oid;
return false;
@ -250,7 +263,7 @@ namespace OliviaAddInPro.Services
//a todos los ámbitos y la instalación, ampliada un buffer, mayor si hay
//restricciones de circulación
geom_export = HelperGdb.BufferGeom(geom_export, com.BuffExport).Value;
if (geom_export == null)
if (geom_export == null || geom_export.IsEmpty)
{
ErrStr = "Error al añadir buffer a la geometría";
return false;
@ -335,20 +348,24 @@ namespace OliviaAddInPro.Services
//guarda la mima de la geometría de la red navegable a exportar
com.MimaNw = geom_export.Extent;
//////////////////////////////////////
///
//Hace el filtro con la geometría final
filtroEspacial = HelperGdb.CreateFiler(String.Empty, geom_export);
var where = String.Empty;
if (!String.IsNullOrEmpty(ComunDef.configMV.filtro_omitir))
{
where = ComunDef.configMV.filtro_omitir;
}
if (com.ProgrSrc._ProgrSrc.Getcancelled())
{
ErrStr = Resource1.String_cancel_progreso;
return false;
}
filtroEspacial = HelperGdb.CreateFiler(where, geom_export);
if (filtroEspacial == null)
{
ErrStr = "Error al crear el filtro de exportacion de la red navegable";
return false;
}
if (com.ProgrSrc._ProgrSrc.Getcancelled())
{
ErrStr = Resource1.String_cancel_progreso;
return false;
}
com.ProgrSrc.IncMessage(10, "Exportando red navegable");//60%
//Prepara nombre de exportación
@ -356,7 +373,26 @@ namespace OliviaAddInPro.Services
//guarda los nombres del shape
OliviaGlob.Paths.PathNW = OliviaGlob.Paths.DirData + com.NombreShpExportNw;
//exporta los datos de entrada
if (!HelperGdb.ExportShp2(OliviaGlob.Paths.PathGdbNw, filtroEspacial, com.NombreShpExportNw, OliviaGlob.Paths.DirData, com.ProgrSrc._ProgrSrc, spatRefData,100))
if (!HelperGdb.ExportShp2(OliviaGlob.Paths.PathGdbNw, filtroEspacial, com.NombreShpExportNw, OliviaGlob.Paths.DirData, com.ProgrSrc._ProgrSrc, spatref,100))
{
ErrStr = "Error al exportar la red navegable: " + HelperGdb.OutStr;
return false;
}
//OliviaGlob.Paths.PathGdbNw.Replace("1.", ".");
if (com.ProgrSrc._ProgrSrc.Getcancelled())
{
ErrStr = Resource1.String_cancel_progreso;
return false;
}
com.ProgrSrc.IncMessage(10, "Termina de exportar red navegable");//60%
com.NombreShpExportNw_C = PREF_NAME_EXPORT_NW_CONJ + fechaHora + EXT_SHP;
OliviaGlob.Paths.PathNW_c = OliviaGlob.Paths.DirData + com.NombreShpExportNw_C;
if (ComunDef.CamposNW.config.revisa_conjunciones)
{
filtroEspacial = HelperGdb.CreateFiler(String.Empty, geom_export);
com.ProgrSrc.IncMessage(10, "Revisando conjunciones de la red");//60%
if (!HelperGdb.ExportShp2(OliviaGlob.Paths.PathGdbNw_conj, filtroEspacial, com.NombreShpExportNw_C, OliviaGlob.Paths.DirData, com.ProgrSrc._ProgrSrc, spatRefData, 100))
{
ErrStr = "Error al exportar la red navegable: " + HelperGdb.OutStr;
return false;
@ -366,7 +402,25 @@ namespace OliviaAddInPro.Services
ErrStr = Resource1.String_cancel_progreso;
return false;
}
}
/////////////////////////////////////////////////////////////////////
///Comprueba si está la columna de ObjectId y si no, la crea
/*if (!ComprCreaColOid(OliviaGlob.Paths.PathNW, OliviaGlob.Paths.PathGdbNw, null))
{
ErrStr = "Error al exportar columna " + ComunDef.CamposCom.camp_oid;
return false;
}
//lo añade la siguiente función
*/
//prepara campos estandar
com.ProgrSrc.IncMessage(10, "Estandarizando campos de la red");//60%
if (!EstandarizaCamposNW(OliviaGlob.Paths.PathNW))
{
ErrStr = "Error al estandarizar campos red navegable: " + HelperGdb.OutStr;
return false;
}
com.ProgrSrc.IncMessage(40, "Finalizada Exportación. Conectando con Olivia Tasks.");//100%
}
catch (Exception ex)
@ -376,6 +430,101 @@ namespace OliviaAddInPro.Services
}
return true;
}
bool EstandarizaCamposNW(string pathNW)
{
HelperGdb.FieldToAdd[] fields = new HelperGdb.FieldToAdd[10];
//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_ele_f;
fields[i].Alias = ComunDef.CamposNW.cons_ele_f;
fields[i].Tipo = "FLOAT";
fields[i].Length = 0;
i++;
fields[i].Name = ComunDef.CamposNW.cons_ele_t;
fields[i].Alias = ComunDef.CamposNW.cons_ele_t;
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;
i++;
fields[i].Name = ComunDef.CamposNW.cons_angulo;
fields[i].Alias = ComunDef.CamposNW.cons_angulo;
fields[i].Tipo = "FLOAT";
fields[i].Length = 128;
i++;
fields[i].Name = ComunDef.CamposCom.camp_oid;
fields[i].Alias = ComunDef.CamposCom.camp_oid;
fields[i].Tipo = "LONG";
fields[i].Length = 0;
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;
if (!HelperGdb.CalculateFieldsSync(pathNW, ComunDef.CamposNW.cons_ele_t, ComunDef.CamposNW.config.campo_elevacion_to))
return false;
if (!HelperGdb.CalculateFieldsSync(pathNW, ComunDef.CamposNW.cons_ele_f, ComunDef.CamposNW.config.campo_elevacion_from))
return false;
if (!HelperGdb.CalculateFieldsSync(pathNW, ComunDef.CamposNW.cons_evit, ComunDef.configMV.campo_prioridad))
return false;
if (!HelperGdb.CalculateFieldsSync(pathNW, ComunDef.CamposNW.cons_angulo, ComunDef.CamposNW.config.campo_angulos))
return false;
using (FeatureClass fc =HelperGdb.GetFtClassSync(pathNW))
{
if (!HelperGdb.CalculateFieldsSync(pathNW, ComunDef.CamposCom.camp_oid, "$feature."+fc.GetDefinition().GetObjectIDField()))
return false;
}
return true;
}
/**
* Actualiza la capa dada añadiendo una columna de sector y una de secuencia
*/
@ -516,7 +665,7 @@ namespace OliviaAddInPro.Services
/**
* Comrpueba si existe la columna de oid y si no, la crea y la rellena
*/
public bool ComprCreaColOid(string pathCapa, string pathCapaOrig, SpatialQueryFilter filter)
public bool ComprCreaColOid(string pathCapa, string pathCapaOrig, SpatialQueryFilter filter=null)
{
//comprueba si está el campo
bool compCamp = HelperGdb.CheckField(pathCapa, ComunDef.CamposCom.camp_oid);
@ -535,6 +684,7 @@ namespace OliviaAddInPro.Services
if (!HelperGdb.AddFieldsSync(pathCapa, fields))
return false;
//vuelve a cerrar la capa
string capa_principal = System.IO.Path.GetFileNameWithoutExtension(pathCapa);
HelperGdb.CloseLayer(capa_principal);
@ -542,9 +692,22 @@ namespace OliviaAddInPro.Services
/////////////////////////////////////////////////////
//Coge los ids de la capa de la que ha exportado
using (FeatureClass fc_orig = HelperGdb.GetFtClassSync(pathCapaOrig))
{
using (FeatureClass fc_shp = HelperGdb.GetFtClassSync(pathCapa))
{
if (fc_orig == null)
return false;
if (fc_shp == null)
return false;
if (filter == null)
{
filter = HelperGdb.CreateFiler("", null);
//coge la geom de todos los ámbitos del shp
var geomExport = HelperGdb.GetGeomUnique(fc_shp, filter);
filter = HelperGdb.CreateFiler("", geomExport);
}
List<long> ids = new List<long>();
//Añade a la lista los ids que cumplen el filtro espacial
try
@ -556,10 +719,6 @@ namespace OliviaAddInPro.Services
ids = new List<long>();
}
//Comprueba que hay tantos ids como elementos en el shp
using (FeatureClass fc_shp = HelperGdb.GetFtClassSync(pathCapa))
{
if (fc_shp == null)
return false;
long nelem_shp = HelperGdb.GetNumElemsSync(fc_shp);
if (nelem_shp != ids.Count)
return false;
@ -603,7 +762,7 @@ namespace OliviaAddInPro.Services
{
return false;
}
return true;
//return true;
}
}
}
@ -611,6 +770,48 @@ namespace OliviaAddInPro.Services
/**
* Prepara la geometría para exportar los ámbitos
*/
public Geometry GetZonasBuffer()
{
Geometry geomAux = null;
ErrStr = string.Empty;
//Hace la intersección de zonas y niveles
geomAux = null;
/*
if (com.GeomNiv != null || com.GeomZon != null)
{
geomAux = HelperGdb.IntersectGeom(com.GeomNiv, com.GeomZon);
if (geomAux == null)
{
ErrStr = "Error al intersecar zonas y/o niveles.";
return null;
}
if (geomAux.IsEmpty)
{
ErrStr = "No existen ámbitos en la intersección entre zonas y/o niveles.";
return null;
}
}
else
{
return null;
}*/
FeatureClass fc = HelperGdb.GetFtClassSync(OliviaGlob.Paths.PathData);
if (fc == null)
{
ErrStr = "No se ha podido abrir la clase " + OliviaGlob.Paths.PathData;
return null;
}
SpatialQueryFilter filtro = HelperGdb.CreateFiler("",null);
var geomAmbits = HelperGdb.GetGeomUnique(fc, filtro);
if (geomAmbits == null || geomAmbits.IsEmpty)
{
ErrStr = "No se ha podido generar geometría de los ámbitos" + com.ConsultaAmbs + HelperGdb.OutStr;
HelperGdb.Free(fc);
return null;
}
return geomAmbits;
}
public Geometry GetGeomAmbitsExport()
{
Geometry geomAux = null;
@ -1004,7 +1205,7 @@ namespace OliviaAddInPro.Services
}
}
resp2 = HelperGdb.ImportShp(dir_shp + "\\" + noms_shp[i] + HelperGdb.SHP_EXT, GdbFileName + "\\" + dataset, noms_gdb[i]);
resp2 = HelperGdb.ImportShp(dir_shp + "\\" + noms_shp[i] + HelperGdb.SHP_EXT, GdbFileName + "\\" + dataset, noms_gdb[i], spatRefData);
if (!resp2.Value)
{
err_st = "Error al importar la capa " + noms_gdb[i];
@ -1058,6 +1259,11 @@ namespace OliviaAddInPro.Services
string capa_principal_nw = System.IO.Path.GetFileNameWithoutExtension(OliviaGlob.Paths.PathNW);
HelperGdb.CloseLayer(capa_principal_nw);
}
if (!string.IsNullOrEmpty(OliviaGlob.Paths.PathNW_c))
{
string capa_principal_nw_c = System.IO.Path.GetFileNameWithoutExtension(OliviaGlob.Paths.PathNW_c);
HelperGdb.CloseLayer(capa_principal_nw_c);
}
}
}
}

View File

@ -162,7 +162,7 @@ namespace OliviaAddInPro.Services
public static void BorraFiles()
{
string[] list = null;
string capa_principal, capa_principal_nw;
string capa_principal, capa_principal_nw, capa_principal_nw_c;
if (!string.IsNullOrEmpty(OliviaGlob.Paths.PathData))
capa_principal = System.IO.Path.GetFileNameWithoutExtension(OliviaGlob.Paths.PathData);
else
@ -171,7 +171,10 @@ namespace OliviaAddInPro.Services
capa_principal_nw = System.IO.Path.GetFileNameWithoutExtension(OliviaGlob.Paths.PathNW);
else
capa_principal_nw = null;
if (!string.IsNullOrEmpty(OliviaGlob.Paths.PathNW_c))
capa_principal_nw_c = System.IO.Path.GetFileNameWithoutExtension(OliviaGlob.Paths.PathNW_c);
else
capa_principal_nw_c = null;
try
{
if (capa_principal != null && HelperGdb.CloseLayer(capa_principal))
@ -200,6 +203,19 @@ namespace OliviaAddInPro.Services
}
}
}
if (capa_principal_nw_c != null && HelperGdb.CloseLayer(capa_principal_nw_c))
{
list = System.IO.Directory.GetFiles(OliviaGlob.Paths.DirData, capa_principal_nw_c + "*");
if (list.Length > 0)
{
foreach (string f in list)
{
if (System.IO.Path.GetExtension(f) == ".lock")
continue;
System.IO.File.Delete(f);
}
}
}
}
catch (Exception ex)
{
@ -218,7 +234,7 @@ namespace OliviaAddInPro.Services
System.IO.Path.GetFileNameWithoutExtension(OliviaGlob.Paths.PathData) + inst.ServCom.NAME_CSV + ".*");
string Title = "Directorio para guardar Secuencia de la Planificación";
string Filter = "Secuencia en formato CSV (*.csv)|*.csv";
//string Filter = "Secuencia en formato CSV (*.csv)|*.csv";
inst.decode_gdb(System.IO.Path.GetFileNameWithoutExtension(OliviaGlob.Paths.PathData),
out auxi, out nombre);
if (!string.IsNullOrEmpty(pathImport))

View File

@ -80,6 +80,10 @@ namespace OliviaAddInPro.Services.LanzaSrv
GeneralDef.EjecGeoParamSep + GeneralDef.GG_coox + GeneralDef.EjecGeoParamIgual + limp.CoordsInstal.X + " " +//coordenadas
GeneralDef.EjecGeoParamSep + GeneralDef.GG_cooy + GeneralDef.EjecGeoParamIgual + limp.CoordsInstal.Y + " " +//coordenadas
GeneralDef.EjecGeoParamSep + GeneralDef.GG_ais + GeneralDef.EjecGeoParamIgual + (limp.IgnoAis ? 1 : 0) + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GG_elev + GeneralDef.EjecGeoParamIgual + (ComunDef.CamposNW.config.comprueba_elevacion ? 1 : 0) + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GG_topo + GeneralDef.EjecGeoParamIgual + (ComunDef.CamposNW.config.revisa_topologia ? 1 : 0) + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GG_conj + GeneralDef.EjecGeoParamIgual + (ComunDef.CamposNW.config.revisa_conjunciones ? 1 : 0) + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GG_angu + GeneralDef.EjecGeoParamIgual + (ComunDef.CamposNW.config.revisa_angulos ? 1 : 0) + " " +
//campos del dbf de limpieza para leer
GeneralDef.EjecGeoParamSep + GeneralDef.GAA_obser + GeneralDef.EjecGeoParamIgual + LimpiezaDef.Campos.consulta_observ + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GAA_anch_tip + GeneralDef.EjecGeoParamIgual + LimpiezaDef.Campos.consulta_anch_tip + " " +

View File

@ -61,6 +61,7 @@ namespace OliviaAddInPro.Services.LanzaSrv
{
str_cfg = str_cfg +
//campos de la red navegable
/*
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_fow + GeneralDef.EjecGeoParamIgual + ComunDef.CamposNW.cons_fow + " " +
@ -69,11 +70,13 @@ namespace OliviaAddInPro.Services.LanzaSrv
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_pedes + GeneralDef.EjecGeoParamIgual + ComunDef.AtributosNW.atr_pedes + " " +
*/
//nombre del tratamiento
GeneralDef.EjecGeoParamSep + GeneralDef.GG_strtto + GeneralDef.EjecGeoParamIgual + NombreTratamiento + " " +
//paths de archivos
GeneralDef.EjecGeoParamSep + GeneralDef.GG_pd + GeneralDef.EjecGeoParamIgual + OliviaGlob.Paths.PathData + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GG_pn + GeneralDef.EjecGeoParamIgual + OliviaGlob.Paths.PathNW + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GG_pnj + GeneralDef.EjecGeoParamIgual + OliviaGlob.Paths.PathNW_c + " " +
//nombres de cols de sector y secuencia
GeneralDef.EjecGeoParamSep + GeneralDef.GTO_camp_sector + GeneralDef.EjecGeoParamIgual + ComunDef.CamposCom.consulta_sector + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GTO_camp_secuencia + GeneralDef.EjecGeoParamIgual + ComunDef.CamposCom.consulta_secuen + " " +

View File

@ -91,6 +91,10 @@ namespace OliviaAddInPro.Services.LanzaSrv
GeneralDef.EjecGeoParamSep + GeneralDef.GR_sens_fechaf + GeneralDef.EjecGeoParamIgual + "0 " +
GeneralDef.EjecGeoParamSep + GeneralDef.GR_sens_modo + GeneralDef.EjecGeoParamIgual + "0 " +
GeneralDef.EjecGeoParamSep + GeneralDef.GG_ais + GeneralDef.EjecGeoParamIgual + (reco.IgnoAis?1:0) + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GG_elev + GeneralDef.EjecGeoParamIgual + (ComunDef.CamposNW.config.comprueba_elevacion ? 1 : 0) + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GG_topo + GeneralDef.EjecGeoParamIgual + (ComunDef.CamposNW.config.revisa_topologia ? 1 : 0) + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GG_conj + GeneralDef.EjecGeoParamIgual + (ComunDef.CamposNW.config.revisa_conjunciones ? 1 : 0) + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GG_angu + GeneralDef.EjecGeoParamIgual + (ComunDef.CamposNW.config.revisa_angulos ? 1 : 0) + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GR_lateral + GeneralDef.EjecGeoParamIgual + reco.TipoLate + " " +
//mima de la nw
GeneralDef.EjecGeoParamSep + GeneralDef.GTO_mima_xmin + GeneralDef.EjecGeoParamIgual + reco.MimaNw.XMin + " " +

View File

@ -2,10 +2,12 @@
using ArcGIS.Core.Geometry;
using ArcGIS.Core.Internal.CIM;
using ArcGIS.Desktop.Framework.Threading.Tasks;*/
using ActiproSoftware.Windows.Extensions;
using OliviaAddInPro.Helper;
using OliviaAddInPro.Model;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -31,6 +33,15 @@ namespace OliviaAddInPro.Services
*/
public Respuesta<bool> Ejecuta(ModosEjec modo)
{
var modos_viaje = ConfigServ.Serv.Leer().ListaMV;
if (modos_viaje != null && modos_viaje.Count > TipoMv && TipoMv >= 0)
{
ComunDef.configMV = modos_viaje[TipoMv];
}
else
{
ComunDef.configMV = new OliviaConfMV();
}
var res = new Respuesta<bool>()
{
Value = false
@ -73,7 +84,7 @@ namespace OliviaAddInPro.Services
{
nombFileAmbs = string.Empty;
limp.ConsultaAmbs = DameAmbsConsulta(out nombFileAmbs);
if (string.IsNullOrEmpty(limp.ConsultaAmbs))
if (null==limp.ConsultaAmbs)
{
return false;
}
@ -105,7 +116,44 @@ namespace OliviaAddInPro.Services
return consulta;
}
public ObservableCollection<string> GetNombreModosViajes()
{
var conf=ConfigServ.Serv.Leer();
var res = new ObservableCollection<string>();
if (conf.ListaMV==null || conf.ListaMV.Count<=0 )
return res;
res.AddRange(conf.ListaMV.Select(c => c.nombre));
return res;
}
public int GetModosViajesDefecto(int vehiculo)
{
var conf = ConfigServ.Serv.Leer();
var res = new ObservableCollection<string>();
if (conf.ListaMV == null || conf.ListaMV.Count <= 0)
return -1;
for(int i=0; i< conf.ListaMV.Count; i++)
{
if (conf.ListaMV[i].vehiculo_def_reco == vehiculo)
return i;
}
return 0;
}
public int GetModosViajesDefecto(bool rcircu)
{
int vehiculo= rcircu? 1: 0;
var conf = ConfigServ.Serv.Leer();
var res = new ObservableCollection<string>();
if (conf.ListaMV == null || conf.ListaMV.Count <= 0)
return -1;
for (int i = 0; i < conf.ListaMV.Count; i++)
{
if (conf.ListaMV[i].vehiculo_def_lim == vehiculo)
return i;
}
return 0;
}
/**
* Comprueba lo necesario para ver si hay campos para la planificación
*/
@ -152,7 +200,7 @@ namespace OliviaAddInPro.Services
public bool CompruebaCamposLimp(string pathCapa)
{
string[] camps = limp.GetCampos(pathCapa);
int res = 1;
//int res = 1;
if ((camps == null) || (HelperGdb.CheckFileds(pathCapa, camps) != 0))
{
ErrStr = HelperGdb.OutStr;
@ -168,10 +216,8 @@ namespace OliviaAddInPro.Services
string consulta;
long 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, consulta);
if (numero_lin > 0)

View File

@ -14,11 +14,11 @@ namespace OliviaAddInPro.Services
public class ProcesoEjecServ
{
Cstr_socket soc = null;
int m_out=0;
//int m_out=0;
int m_miliseconds=200;
int m_tm_progr=1000;
int modo_fin = 0;
bool cancela = false;
//bool cancela = false;
bool cancela_fin = false;
bool conectado = false;
bool permu = false;
@ -509,7 +509,7 @@ namespace OliviaAddInPro.Services
*/
private void pon_barstate(TiposActu actu)
{
int col = 1;
//int col = 1;
if ((actu == TiposActu.ActuMal) || (actu == TiposActu.ActuFinNOk))

View File

@ -70,7 +70,15 @@ namespace OliviaAddInPro.Services
{
Value = false
};
var modos_viaje = ConfigServ.Serv.Leer().ListaMV;
if (modos_viaje != null && modos_viaje.Count > TipoMv && TipoMv>=0)
{
ComunDef.configMV = modos_viaje[TipoMv];
}
else
{
ComunDef.configMV = new OliviaConfMV();
}
com = (TratamientoComun)reco;
string nombFileAmbs = string.Empty;

View File

@ -0,0 +1,14 @@
<UserControl x:Class="OliviaAddInPro.View.Configuracion.PropertyGridFilePickerPto"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:OliviaAddInPro.View.Configuracion"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
x:Name="TheControl">
<DockPanel>
<Button x:Name="PickFileButton" Content="…" Click="PickFileButton_Click" DockPanel.Dock="Right" Width="15" />
<TextBox Text="{Binding ElementName=TheControl, Path=Value}" />
</DockPanel>
</UserControl>

View File

@ -0,0 +1,65 @@
using Microsoft.Win32;
using OliviaAddInPro.Helper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Xceed.Wpf.Toolkit.PropertyGrid;
using Xceed.Wpf.Toolkit.PropertyGrid.Editors;
using static OliviaAddInPro.Helper.HelperGdb;
namespace OliviaAddInPro.View.Configuracion
{
/// <summary>
/// Lógica de interacción para PropertyGridFilePicker.xaml
/// </summary>
public partial class PropertyGridFilePickerPto : ITypeEditor
{
public PropertyGridFilePickerPto()
{
InitializeComponent();
}
public string Value
{
get { return (string)GetValue(ValueProperty); }
set { SetValue(ValueProperty, value); }
}
// Using a DependencyProperty as the backing store for Value. This enables animation, styling, binding, etc...
public static readonly DependencyProperty ValueProperty =
DependencyProperty.Register("Value", typeof(string), typeof(PropertyGridFilePickerPto), new PropertyMetadata(null));
public FrameworkElement ResolveEditor(PropertyItem propertyItem)
{
Binding binding = new Binding("Value");
binding.Source = propertyItem;
binding.Mode = propertyItem.IsReadOnly ? BindingMode.OneWay : BindingMode.TwoWay;
BindingOperations.SetBinding(this, ValueProperty, binding);
return this;
}
private void PickFileButton_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog fd = new OpenFileDialog();
var st = HelperGdb.OpenFileDialog(TiposOpenFileDlg.OpenFtrClassPoint, Value);
if (!string.IsNullOrEmpty(st))
{
Value = st;
}
}
}
}

View File

@ -64,20 +64,20 @@
<ContentPresenter Name="PaneEjecutar">
<ContentPresenter.Content>
<StackPanel Orientation="Vertical">
<Grid Margin="0,10,0,0">
<Grid Margin="0,30,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"/>
<Button x:Name="button_planif" Grid.Column="2" Style="{DynamicResource Esri_Button}" Content="Planificar" Margin="10,0,0,0" Click="button_planif_Click"/>
</Grid>
</StackPanel>
</ContentPresenter.Content>
</ContentPresenter>
</StackPanel>
<StackPanel Grid.Row="3" Margin="0,70,10,0">
<StackPanel Grid.Row="3" Margin="0,90,10,0">
<Button x:Name="button_help" Content="" Margin="274,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Width="16" Height="16" BorderThickness="0" RenderTransformOrigin="16.875,0.375" Click="button_help_Click">
<Button.Background>
<ImageBrush ImageSource="../../Images/help16Pro.png"/>

View File

@ -32,6 +32,10 @@
<ComboBox x:Name="comboBox_tto" IsEnabled="{Binding Path=CapaAbierta, Mode = TwoWay}" ItemsSource="{Binding Path=TiposTto, Mode = TwoWay}" HorizontalAlignment="Left" Margin="20,0,0,0"
VerticalAlignment="Top" Width="260" DropDownOpened="ComboBox_DropDownOpened" SelectionChanged="comboBox_tto_SelectionChanged"
SelectedIndex="{Binding Path=TipoTto, Mode = TwoWay}"/>
<Label Content="Modos de viaje" HorizontalAlignment="Left" Margin="15,0,0,0" VerticalAlignment="Top" FontWeight="DemiBold"/>
<ComboBox x:Name="comboBox_mv" IsEnabled="{Binding Path=CapaAbierta, Mode = TwoWay}" ItemsSource="{Binding Path=TiposMv, Mode = TwoWay}" HorizontalAlignment="Left" Margin="20,0,0,0"
VerticalAlignment="Top" Width="260" SelectionChanged="comboBox_mv_SelectionChanged"
SelectedIndex="{Binding Path=TipoMv, Mode = TwoWay}"/>
<Label Content="Ámbitos de Trabajo" HorizontalAlignment="Left" Margin="15,0,0,0" VerticalAlignment="Top" RenderTransformOrigin="-0.391,-0.203" FontWeight="DemiBold"/>
<ComboBox x:Name="comboBox_ambitos" IsEnabled="{Binding Path=CapaAbierta, Mode = TwoWay}" ItemsSource="{Binding Path=OpsAmbs, Mode = TwoWay}" HorizontalAlignment="Left" Margin="20,0,0,0"
VerticalAlignment="Top" Width="260" SelectionChanged="comboBox_ambitos_SelectionChanged"

View File

@ -80,7 +80,20 @@ namespace OliviaAddInPro
}
}
private void comboBox_mv_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
int i = -1;
if (sender is System.Windows.Controls.ComboBox combo)
{
i = combo.SelectedIndex;
if (DataContext is PaneLimpiezaSub1ViewModel mod)
{
mod.ComboMvSel(i);
}
}
}
private void comboBox_ambitos_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
int i = -1;

View File

@ -5,7 +5,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:extensions="clr-namespace:ArcGIS.Desktop.Extensions;assembly=ArcGIS.Desktop.Extensions"
xmlns:ui="clr-namespace:OliviaAddInPro"
mc:Ignorable="d" d:DesignWidth="300" Height="390"
mc:Ignorable="d" d:DesignWidth="300" Height="422"
d:DataContext="{Binding Path=ui.PaneRecogidaSub1ViewModel}" Loaded="UserControl_Loaded" Unloaded="UserControl_Unloaded" >
<UserControl.Resources>
<ResourceDictionary>
@ -94,6 +94,10 @@
<TextBox x:Name="txtBox_kgCapac" IsEnabled="{Binding Path=CapaAbierta, Mode = TwoWay}" Grid.Column="1" Margin="5,0,0,3" TextWrapping="NoWrap" Text="{Binding Path=TextKgCapac, Mode = TwoWay}" TextAlignment="Right" MaxLength="8" PreviewTextInput="txtBox_kgCapac_PreviewTextInput"/>
<Label x:Name="label_kgmax" Grid.Column="2" Content="kg máx. por viaje" Margin="0,-1,0,0"/>
</Grid>
<Label Content="Modos de viaje" HorizontalAlignment="Left" Margin="15,0,0,0" VerticalAlignment="Top" FontWeight="DemiBold"/>
<ComboBox x:Name="comboBox_mv" IsEnabled="{Binding Path=CapaAbierta, Mode = TwoWay}" ItemsSource="{Binding Path=TiposMv, Mode = TwoWay}" HorizontalAlignment="Left" Margin="20,0,0,0"
VerticalAlignment="Top" Width="260" SelectionChanged="comboBox_mv_SelectionChanged"
SelectedIndex="{Binding Path=TipoMv, Mode = TwoWay}"/>
<Label Content="Tiempo de vaciado de contenedor" HorizontalAlignment="Left" Margin="15,0,0,0" VerticalAlignment="Top" RenderTransformOrigin="-0.391,-0.203" FontWeight="DemiBold"/>
<Grid Margin="20,0,0,0">
<Grid.ColumnDefinitions>

View File

@ -110,7 +110,20 @@ namespace OliviaAddInPro
}
}
}
private void comboBox_mv_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
int i = -1;
if (sender is System.Windows.Controls.ComboBox combo)
{
i = combo.SelectedIndex;
if (DataContext is PaneRecogidaSub1ViewModel mod)
{
mod.ComboMvSel(i);
}
}
}
private void comboBox_tipoCapac_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
int i = -1;

View File

@ -27,6 +27,7 @@ namespace OliviaAddInPro
{
private ObservableCollection<string> tiposTto = new ObservableCollection<string>(LimpiezaDef.tipos_tto_str);
private ObservableCollection<string> tiposMv = new ObservableCollection<string>();
private ObservableCollection<string> opsAmbs=new ObservableCollection<string>();
private int selOpAmb = -1;
private ObservableCollection<CheckedListItem<string>> ambitos = new ObservableCollection<CheckedListItem<string>>();
@ -114,7 +115,27 @@ namespace OliviaAddInPro
base.NotifyPropertyChanged("TiposTto");
}
}
public ObservableCollection<string> TiposMv
{
get { return tiposMv; }
set
{
tiposMv = value;
base.NotifyPropertyChanged("TiposMv");
}
}
private int tipoMv = -1;
public int TipoMv
{
get { return tipoMv; }
set
{
tipoMv = value;
base.NotifyPropertyChanged("TipoMv");
}
}
private int tipoTto = -1;
private int tipoTto_old = -2;
public int TipoTto
{
get { return tipoTto; }
@ -199,6 +220,8 @@ namespace OliviaAddInPro
lblUdsVeloDespl = "km/h";
limpServ = new LimpiezaServ(null); //no hace falta instancia limp
textAnchoVia = LimpiezaDef.Parametros.ancho_via.ToString();
tiposMv = limpServ.GetNombreModosViajes();
tipoMv = -1;
}
/**
* Realiza las comprobaciones para cuando se ha abierto una capa
@ -244,24 +267,33 @@ namespace OliviaAddInPro
CapaElems = capa;
CapaAbierta = true;
return true;
}
public void ComboMvSel(int tto)
{
if (tto < 0)
return;
TipoMv = tto;
}
/**
* Realiza los cambios en los ámbitos cuando se ha seleccionado un tratamiento
*/
public void ComboTtoSel(int tto)
{
if (tto < 0)
if (tto < 0 || tto== tipoTto_old)
return;
TipoTto = tto;
cambia_tiempo_tto();
ambitosSel = new bool[(int)LimpiezaDef.AmbitsTra.AmbN]; //reinicia los ambitos seleccionados
tipoTto_old = tto;
////////////////////////////////////////
//Otros cambios que dependen del tratamiento
if (TipoTto != (int)LimpiezaDef.TiposTto.TtoNoDef)
{
RespCirc = LimpiezaDef.rest_circ[TipoTto];
int tv = limpServ.GetModosViajesDefecto(RespCirc);
if (tv >= 0)
TipoMv = tv;
if (LimpiezaDef.v_desplazamiento[TipoTto] > 0)
{
TextVeloDespl = Convert.ToString(LimpiezaDef.v_desplazamiento[TipoTto]);

View File

@ -80,6 +80,7 @@ namespace OliviaAddInPro
return false;
}
limp.CapaElems = _subPanel1ViewModel.CapaElems;
limp.CapaElemsRef = limp.CapaElems;
//pone que la capa de elementos es la red navegable, que es la que va a exportar
if (_subPanel1ViewModel.SelOpAmb == 1)
{
@ -92,6 +93,8 @@ namespace OliviaAddInPro
err_str = "No se ha seleccionado ningún Tipo de Tratamiento";
return false;
}
limp.TipoMV = _subPanel1ViewModel.TipoMv;
limp.TipoTto = _subPanel1ViewModel.TipoTto;
limp.TipoTtoStr = LimpiezaDef.tto_gdb[_subPanel1ViewModel.TipoTto];
//lee el/los ámbito seleccionado

View File

@ -32,7 +32,7 @@ namespace OliviaAddInPro
private ObservableCollection<string> tiposVehic = new ObservableCollection<string>();
private ObservableCollection<string> tiposCapac = new ObservableCollection<string>();
private RecogidaServ recoServ = new RecogidaServ(null); //no hace falta instancia reco aquí
private ObservableCollection<string> tiposMv = new ObservableCollection<string>();
/**
* Array de booleanos enumerando si se existen en la capa seleccionada los tipos de fracción
*/
@ -47,6 +47,31 @@ namespace OliviaAddInPro
public bool[] tipos_vehic_bool = new bool[(int)RecogidaDef.TiposVehic.N];
#region Properties
public ObservableCollection<string> TiposMv
{
get { return tiposMv; }
set
{
tiposMv = value;
base.NotifyPropertyChanged("TiposMv");
}
}
private int tipoMv = -1;
public int TipoMv
{
get { return tipoMv; }
set
{
tipoMv = value;
base.NotifyPropertyChanged("TipoMv");
}
}
public void ComboMvSel(int tto)
{
if (tto < 0)
return;
TipoMv = tto;
}
public override string DisplayName
{
@ -98,6 +123,7 @@ namespace OliviaAddInPro
}
}
private int tipoFrac = -1;
private int tipoFrac_old = -2;
public int TipoFrac
{
get { return tipoFrac; }
@ -108,6 +134,7 @@ namespace OliviaAddInPro
}
}
private int tipoCarg = -1;
private int tipoCarg_old = -2;
public int TipoCarg
{
get { return tipoCarg; }
@ -118,6 +145,7 @@ namespace OliviaAddInPro
}
}
private int tipoVehic = -1;
private int tipoVehic_old = -2;
public int TipoVehic
{
get { return tipoVehic; }
@ -128,6 +156,7 @@ namespace OliviaAddInPro
}
}
private int tipoCapac = -1;
private int tipoCapac_old = -2;
public int TipoCapac
{
get { return tipoCapac; }
@ -138,6 +167,7 @@ namespace OliviaAddInPro
}
}
private int tipoLate = -1;
private int tipoLate_old = -2;
public int TipoLate
{
get { return tipoLate; }
@ -261,6 +291,7 @@ namespace OliviaAddInPro
{
KgCont = RecogidaDef.kgrec_cont;
}
tiposMv = new LimpiezaServ(null).GetNombreModosViajes();
}
/**
* Realiza las comprobaciones para cuando se ha abierto una capa
@ -409,7 +440,7 @@ namespace OliviaAddInPro
*/
public bool ComboFracSel(int tto)
{
if (tto < 0)
if (tto < 0 || tto== tipoFrac_old)
return false;
if (!tipos_fracc_bool[tto])
{
@ -420,6 +451,7 @@ namespace OliviaAddInPro
{
//cuando se selecciona un item pintado en gris (que no existe en la GDB) se actúa como si no se hubiera seleccionado item
TipoFrac = tto;
tipoFrac_old = tto;
if ((TipoVehic >= 0) && (TipoCarg >= 0))
{
//si también se ha seleccionado tipo de carga y de vehículo, se rellena la lista de capacidades
@ -522,7 +554,7 @@ namespace OliviaAddInPro
public bool ComboCargSel(int tto)
{
VisCombLate = Visibility.Hidden;
if (tto < 0)
if (tto < 0 || tto== tipoCarg_old)
return false;
if (!tipos_carg_bool[tto])
{
@ -531,6 +563,8 @@ namespace OliviaAddInPro
try
{
TipoCarg=tto;
tipoCarg_old = tto;
if (TipoCarg == (int)RecogidaDef.TiposCarga.Lateral)
VisCombLate = Visibility.Visible;
@ -571,16 +605,25 @@ namespace OliviaAddInPro
*/
public void ComboVehicSel(int tto)
{
if (tto < 0)
if (tto < 0 )
return;
try
{
TipoVehic = tto;
if (TipoVehic >= 0)
{
if (tipoVehic_old != tto)
{
int tmv = new LimpiezaServ(null).GetModosViajesDefecto(TipoVehic);
if (tmv >= 0)
{
TipoMv = tmv;
}
}
//si también se ha seleccionado tipo de carga, se rellena la lista de capacidades
rellena_capac();
}
tipoVehic_old = tto;
}
catch (Exception)
{
@ -599,6 +642,7 @@ namespace OliviaAddInPro
try
{
TipoCapac = tto;
tipoCapac_old = tto;
rellena_kgmax();
}
catch (Exception)
@ -612,11 +656,12 @@ namespace OliviaAddInPro
*/
public void ComboLatSel(int tto)
{
if (tto < 0)
if (tto < 0 || tto== tipoLate_old)
return;
try
{
TipoLate = tto;
tipoLate_old = tto;
}
catch (Exception)
{

View File

@ -105,6 +105,7 @@ namespace OliviaAddInPro
return false;
}
reco.CapaElems = _subPanel1ViewModel.CapaElems;
reco.CapaElemsRef = reco.CapaElems;
//lee la fracción
reco.TipoFrac = _subPanel1ViewModel.TipoFrac;
if (reco.TipoFrac == -1)
@ -112,6 +113,7 @@ namespace OliviaAddInPro
err_str = "No se ha seleccionado ningún Tipo de Fracción";
return false;
}
reco.TipoMV = _subPanel1ViewModel.TipoMv;
reco.TipoFracStr = RecogidaDef.tipos_fracc_str[reco.TipoFrac];
reco.TipoTto = reco.TipoFrac;
reco.TipoTtoStr = RecogidaDef.tipos_fracc_str[reco.TipoFrac];