129 lines
4.3 KiB
C#
129 lines
4.3 KiB
C#
using ArcGIS.Core.Geometry;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using OliviaAddInPro.Helper;
|
|
using System.Collections.ObjectModel;
|
|
using ArcGIS.Core.CIM;
|
|
using ArcGIS.Core.Data;
|
|
|
|
namespace OliviaAddInPro.Model
|
|
{
|
|
class Limpieza : Comun
|
|
{
|
|
//**********************************************
|
|
//Se recogen en PaneLimpiezaSub1
|
|
/**
|
|
* Tipo de tratamiento elegidos
|
|
*/
|
|
public int TipoTto = -1;
|
|
/**
|
|
* Ámbitos de trabajo elegidos
|
|
*/
|
|
public bool[] AmbitosSel = new bool[(int)LimpiezaDef.AmbitsTra.AmbN];
|
|
/**
|
|
* Indica si respeta el sentido de circulación o no
|
|
*/
|
|
public bool RespCirc = false;
|
|
/**
|
|
* Tipo de unidades del tiempo de tto
|
|
*/
|
|
public int UdsTTto = (int)GeneralDef.OlvTiposTto.OlvTipTtoNoDef;
|
|
|
|
public Limpieza()
|
|
{
|
|
|
|
}
|
|
/**
|
|
* Lee la gdb y devuelve el array de ámbitos en función de si hay en la gdb o no
|
|
*/
|
|
public bool[] BuscAmbGdb()
|
|
{
|
|
string consulta;
|
|
int numero_lin;
|
|
bool[] amb_gdb = new bool[(int)LimpiezaDef.AmbitsTra.AmbN];//se inician a false
|
|
string ftclass;
|
|
|
|
//mira a ver si hay ejes de calle
|
|
ftclass = LimpiezaDef.ftclass[(int)LimpiezaDef.AmbitsTra.AmbEjeCalle];
|
|
consulta = LimpiezaDef.filtro_str[(int)LimpiezaDef.AmbitsTra.AmbEjeCalle];
|
|
numero_lin = HelperGdb.GetNumElems(OliviaGlob.Paths.PathGdbNw, ftclass, consulta);
|
|
if (numero_lin > 0)
|
|
{
|
|
amb_gdb[(int)LimpiezaDef.AmbitsTra.AmbEjeCalle] = true;
|
|
}
|
|
//mira a ver si hay el resto de capas y tienen entidades
|
|
for (int i = (int)LimpiezaDef.AmbitsTra.AmbBordLibreMec; i < (int)LimpiezaDef.AmbitsTra.AmbN; i++)
|
|
{
|
|
consulta = LimpiezaDef.filtro_str[i];
|
|
numero_lin = HelperGdb.GetNumElems(CapaElems, consulta);
|
|
|
|
if (numero_lin > 0)
|
|
{
|
|
amb_gdb[i] = true;
|
|
}
|
|
}
|
|
|
|
return amb_gdb;
|
|
}
|
|
/**Devuelve el array de los ámbitos comunes y no comunes de las opciones de un tratamiento tto
|
|
* Es un array de longitud el número de ámbitos totales, con true en las posiciones en los que el ámbito sea común o
|
|
* no común en las opciones
|
|
*/
|
|
public bool[] DameAmbTto(int tto)
|
|
{
|
|
int i;
|
|
bool sig;
|
|
bool[] amb_com = new bool[(int)LimpiezaDef.AmbitsTra.AmbN];
|
|
|
|
for (int j = 0; j < (int)LimpiezaDef.AmbitsTra.AmbN; j++)
|
|
{
|
|
sig = false;
|
|
for (i = 0; i < LimpiezaDef.ambs_val[tto].n_ops && !sig; i++)
|
|
{
|
|
if (LimpiezaDef.ambs_val[tto].ambs_ops[i].ambs[j]) //con que encuentre uno true lo pone y pasa al siguiente
|
|
{
|
|
amb_com[j] = sig = true;
|
|
}
|
|
}
|
|
}
|
|
return amb_com;
|
|
}
|
|
|
|
/*
|
|
* Lee la capa que se ha seleccionzdo de limpieza y se comprueba que los campos que se han editado corresponden con la capa
|
|
* (es decir, se puede leer la capa con los campos configurados)
|
|
*/
|
|
public bool CompruebaCamposLimp()
|
|
{
|
|
int NCAMPS = 2;
|
|
string[] camps;
|
|
int i;
|
|
camps = new string[NCAMPS];
|
|
camps[0] = LimpiezaDef.Campos.consulta_entidad;
|
|
camps[1] = LimpiezaDef.Campos.consulta_mecan;
|
|
FeatureClass fc = HelperGdb.GetFtClass(CapaElems);
|
|
if (fc == null)
|
|
{
|
|
ErrStr = "No se puede abrir la capa";
|
|
return false;
|
|
}
|
|
|
|
ObservableCollection<string> fields = HelperGdb.GetFields(fc).Result;
|
|
for (i = 0; i < NCAMPS; i++)
|
|
{
|
|
if (!fields.Contains(camps[i]))
|
|
{
|
|
ErrStr = "No se encuentra el campo " + camps[i];
|
|
break;
|
|
}
|
|
}
|
|
if (i < NCAMPS)
|
|
return false;
|
|
return true;
|
|
}
|
|
}
|
|
}
|