Modificaciones para exportar OID y otras de nombres de campos
parent
a056f6d78b
commit
407d06bf00
|
|
@ -263,6 +263,12 @@ namespace OliviaAddInPro.Model
|
||||||
[DisplayName("Ignorar aislados")]
|
[DisplayName("Ignorar aislados")]
|
||||||
[Description("Indica si por defecto se van a ignorar elementos aislados")]
|
[Description("Indica si por defecto se van a ignorar elementos aislados")]
|
||||||
public bool Igno_ais { get; set; }
|
public bool Igno_ais { get; set; }
|
||||||
|
|
||||||
|
[Category("General")]
|
||||||
|
[PropertyOrder(9)]
|
||||||
|
[DisplayName("Campo para exportar ID")]
|
||||||
|
[Description("Nombre del campo que indica el ID del ámbito")]
|
||||||
|
public string id { get; set; }
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 02CamposLimp
|
#region 02CamposLimp
|
||||||
|
|
@ -378,11 +384,6 @@ namespace OliviaAddInPro.Model
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 04CamposRecogida
|
#region 04CamposRecogida
|
||||||
[Category("Campos Recogida")]
|
|
||||||
[DisplayName("ID")]
|
|
||||||
[Description("Nombre del campo que indica el ID del contenedor")]
|
|
||||||
public string id { get; set; }
|
|
||||||
|
|
||||||
[Category("Campos Recogida")]
|
[Category("Campos Recogida")]
|
||||||
[DisplayName("Tipo de carga")]
|
[DisplayName("Tipo de carga")]
|
||||||
[Description("Nombre del campo que indica el tipo de carga")]
|
[Description("Nombre del campo que indica el tipo de carga")]
|
||||||
|
|
|
||||||
|
|
@ -164,7 +164,7 @@ namespace OliviaAddInPro.Model
|
||||||
public override string[] GetCampos(string capa=null)
|
public override string[] GetCampos(string capa=null)
|
||||||
{
|
{
|
||||||
string[] camps = {
|
string[] camps = {
|
||||||
RecogidaDef.campos_def.cons_id,
|
//RecogidaDef.campos_def.cons_id,
|
||||||
RecogidaDef.campos_def.cons_nomrec,
|
RecogidaDef.campos_def.cons_nomrec,
|
||||||
RecogidaDef.campos_def.cons_lateral ,
|
RecogidaDef.campos_def.cons_lateral ,
|
||||||
RecogidaDef.campos_def.cons_fracc,
|
RecogidaDef.campos_def.cons_fracc,
|
||||||
|
|
|
||||||
|
|
@ -137,6 +137,8 @@ namespace OliviaAddInPro.Model
|
||||||
set { err_str = value; }
|
set { err_str = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ObservableCollection<string> nombCamposOrig = new ObservableCollection<string>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Para la ventana de progreso
|
* Para la ventana de progreso
|
||||||
*/
|
*/
|
||||||
|
|
@ -202,10 +204,30 @@ namespace OliviaAddInPro.Model
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Restaura el nombre original del campo si se ha truncado a 10 car al exportar a shp
|
* Restaura el nombre original del campo si se ha truncado a 10 car al exportar a shp
|
||||||
*/
|
*/
|
||||||
public Respuesta<bool> RestauraNomCampos(string nombFtClass)
|
public virtual string[] GetCamposOrig()
|
||||||
|
{
|
||||||
|
string[] camps = null;
|
||||||
|
|
||||||
|
if (nombCamposOrig.Count > 0)
|
||||||
|
{
|
||||||
|
camps = new string[nombCamposOrig.Count];
|
||||||
|
for (int i=0;i<nombCamposOrig.Count;i++)
|
||||||
|
{
|
||||||
|
camps[i] = nombCamposOrig[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return camps;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Restaura el nombre original del campo si se ha truncado a 10 car al exportar a shp
|
||||||
|
*/
|
||||||
|
public Respuesta<bool> RestauraNomCampos(string nombFtClass)
|
||||||
{
|
{
|
||||||
int LENGTHCAMPSHP = 10;
|
int LENGTHCAMPSHP = 10;
|
||||||
Respuesta<bool> resp = new Respuesta<bool> { Value = false };
|
Respuesta<bool> resp = new Respuesta<bool> { Value = false };
|
||||||
|
|
@ -213,7 +235,9 @@ namespace OliviaAddInPro.Model
|
||||||
if (fc == null)
|
if (fc == null)
|
||||||
return resp;
|
return resp;
|
||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
string[] camps = GetCampos();
|
string[] camps = GetCamposOrig();
|
||||||
|
if (camps == null)
|
||||||
|
return resp;
|
||||||
|
|
||||||
ObservableCollection<string> fields = HelperGdb.GetFieldsSync(fc);
|
ObservableCollection<string> fields = HelperGdb.GetFieldsSync(fc);
|
||||||
HelperGdb.Free(fc);
|
HelperGdb.Free(fc);
|
||||||
|
|
@ -228,6 +252,8 @@ namespace OliviaAddInPro.Model
|
||||||
{
|
{
|
||||||
if (camps[i].Length <= LENGTHCAMPSHP)
|
if (camps[i].Length <= LENGTHCAMPSHP)
|
||||||
continue;
|
continue;
|
||||||
|
if (EstaRepeNomb(fields, camps[i]))
|
||||||
|
continue;
|
||||||
campTrunc = camps[i].Substring(0, LENGTHCAMPSHP);
|
campTrunc = camps[i].Substring(0, LENGTHCAMPSHP);
|
||||||
//si tiene más de 10 caracteres, lo ha truncado al exportar
|
//si tiene más de 10 caracteres, lo ha truncado al exportar
|
||||||
//busca el nombre actual del campo en la fc
|
//busca el nombre actual del campo en la fc
|
||||||
|
|
@ -251,5 +277,30 @@ namespace OliviaAddInPro.Model
|
||||||
|
|
||||||
return resp;
|
return resp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool EstaRepeNomb(ObservableCollection<string> fields, string nomb)
|
||||||
|
{
|
||||||
|
foreach( string fnomb in fields)
|
||||||
|
{
|
||||||
|
if (string.Compare(fnomb, nomb, true)==0)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Guarda el nombre de los campos originales para luego restaurarlos
|
||||||
|
*/
|
||||||
|
public void GuardaNombCamposOrig(string pathFtClass)
|
||||||
|
{
|
||||||
|
FeatureClass fc = HelperGdb.GetFtClassSync(pathFtClass);
|
||||||
|
if (fc != null)
|
||||||
|
{
|
||||||
|
nombCamposOrig = HelperGdb.GetFieldsSync(fc);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
nombCamposOrig = new ObservableCollection<string>();
|
||||||
|
HelperGdb.Free(fc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,12 @@ namespace OliviaAddInPro.Services
|
||||||
ErrStr = Resource1.String_cancel_progreso;
|
ErrStr = Resource1.String_cancel_progreso;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////
|
||||||
|
///Se guarda el nombre de los campos originales
|
||||||
|
///
|
||||||
|
com.GuardaNombCamposOrig(com.CapaElems);
|
||||||
|
|
||||||
//Cuenta las filas que cumplen la consulta
|
//Cuenta las filas que cumplen la consulta
|
||||||
int nelems = HelperGdb.GetNumElemsSync(com.CapaElems, com.ConsultaAmbs);
|
int nelems = HelperGdb.GetNumElemsSync(com.CapaElems, com.ConsultaAmbs);
|
||||||
if (nelems <= 0)
|
if (nelems <= 0)
|
||||||
|
|
@ -535,67 +541,71 @@ namespace OliviaAddInPro.Services
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
//Coge los ids de la capa de la que ha exportado
|
//Coge los ids de la capa de la que ha exportado
|
||||||
FeatureClass fc_orig = HelperGdb.GetFtClassSync(pathCapaOrig);
|
using (FeatureClass fc_orig = HelperGdb.GetFtClassSync(pathCapaOrig))
|
||||||
if (fc_orig == null)
|
|
||||||
return false;
|
|
||||||
List<long> ids = new List<long>();
|
|
||||||
//Añade a la lista los ids que cumplen el filtro espacial
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
ids = fc_orig.Select(filter, SelectionType.ObjectID, SelectionOption.Normal).GetObjectIDs().ToList();
|
if (fc_orig == null)
|
||||||
}
|
return false;
|
||||||
catch
|
List<long> ids = new List<long>();
|
||||||
{
|
//Añade a la lista los ids que cumplen el filtro espacial
|
||||||
ids = new List<long>();
|
try
|
||||||
}
|
|
||||||
//Comprueba que hay tantos ids como elementos en el shp
|
|
||||||
FeatureClass fc_shp = HelperGdb.GetFtClassSync(pathCapa);
|
|
||||||
if (fc_shp == null)
|
|
||||||
return false;
|
|
||||||
int nelem_shp = HelperGdb.GetNumElemsSync(fc_shp);
|
|
||||||
if (nelem_shp != ids.Count)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
//ahora rellena las columnas
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using (RowCursor rc_shp = fc_shp.Search())
|
|
||||||
{
|
{
|
||||||
if (rc_shp == null)
|
ids = fc_orig.Select(filter, SelectionType.ObjectID, SelectionOption.Normal).GetObjectIDs().ToList();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
int nelem_shp = HelperGdb.GetNumElemsSync(fc_shp);
|
||||||
|
if (nelem_shp != ids.Count)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var modifyOp = new ArcGIS.Desktop.Editing.EditOperation();
|
/////////////////////////////////////////////////////
|
||||||
modifyOp.Name = "Actualiza OID";
|
//ahora rellena las columnas
|
||||||
bool ex = false;
|
try
|
||||||
//modifyOp.Callback((context) =>
|
|
||||||
//{
|
|
||||||
int i = 0;
|
|
||||||
while (rc_shp.MoveNext() && i < ids.Count)
|
|
||||||
{
|
{
|
||||||
using (Row rowshp = rc_shp.Current)
|
using (RowCursor rc_shp = fc_shp.Search())
|
||||||
{
|
{
|
||||||
//context.Invalidate(rowshp);
|
if (rc_shp == null)
|
||||||
// modify and execute
|
return false;
|
||||||
modifyOp.Modify(rowshp, ComunDef.CamposCom.camp_oid, ids[i++]);
|
|
||||||
rowshp.Store();
|
var modifyOp = new ArcGIS.Desktop.Editing.EditOperation();
|
||||||
//context.Invalidate(rowshp);
|
modifyOp.Name = "Actualiza OID";
|
||||||
|
bool ex = false;
|
||||||
|
//modifyOp.Callback((context) =>
|
||||||
|
//{
|
||||||
|
int i = 0;
|
||||||
|
while (rc_shp.MoveNext() && i < ids.Count)
|
||||||
|
{
|
||||||
|
using (Row rowshp = rc_shp.Current)
|
||||||
|
{
|
||||||
|
//context.Invalidate(rowshp);
|
||||||
|
// modify and execute
|
||||||
|
modifyOp.Modify(rowshp, ComunDef.CamposCom.camp_oid, ids[i++]);
|
||||||
|
rowshp.Store();
|
||||||
|
//context.Invalidate(rowshp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//}, fc_shp);
|
||||||
|
ex = modifyOp.Execute();
|
||||||
|
ArcGIS.Desktop.Core.Project.Current.SaveEditsAsync();
|
||||||
|
if (ex && modifyOp.IsDone)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//}, fc_shp);
|
catch
|
||||||
ex = modifyOp.Execute();
|
{
|
||||||
ArcGIS.Desktop.Core.Project.Current.SaveEditsAsync();
|
|
||||||
if (ex && modifyOp.IsDone)
|
|
||||||
return true;
|
|
||||||
else
|
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -28,15 +28,16 @@ namespace OliviaAddInPro.Services
|
||||||
*/
|
*/
|
||||||
public int CompruebaCamposReco(string pathCapa)
|
public int CompruebaCamposReco(string pathCapa)
|
||||||
{
|
{
|
||||||
int NCAMPS = 6;
|
int NCAMPS = 5;
|
||||||
string[] camps;
|
string[] camps;
|
||||||
camps = new string[NCAMPS];
|
camps = new string[NCAMPS];
|
||||||
camps[0] = RecogidaDef.campos_def.cons_id;
|
|
||||||
camps[1] = RecogidaDef.campos_def.cons_fracc;
|
camps[0] = RecogidaDef.campos_def.cons_fracc;
|
||||||
camps[2] = RecogidaDef.campos_def.cons_nomrec;
|
camps[1] = RecogidaDef.campos_def.cons_nomrec;
|
||||||
camps[3] = RecogidaDef.campos_def.cons_lateral;
|
camps[2] = RecogidaDef.campos_def.cons_lateral;
|
||||||
camps[4] = RecogidaDef.campos_def.cons_uds;
|
camps[3] = RecogidaDef.campos_def.cons_uds;
|
||||||
camps[5] = RecogidaDef.campos_def.cons_kgrec;
|
camps[4] = RecogidaDef.campos_def.cons_kgrec;
|
||||||
|
//camps[5] = RecogidaDef.campos_def.cons_id;
|
||||||
int compCamp = HelperGdb.CheckFileds(pathCapa, camps);
|
int compCamp = HelperGdb.CheckFileds(pathCapa, camps);
|
||||||
ErrStr = HelperGdb.OutStr;
|
ErrStr = HelperGdb.OutStr;
|
||||||
if (compCamp == 0)
|
if (compCamp == 0)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue