No demasiados avances en importación

Elena/develop
Elena 2022-05-26 11:12:21 +02:00
parent 9e8f4e6d25
commit e2ec0d2dc6
5 changed files with 100 additions and 45 deletions

View File

@ -1683,8 +1683,7 @@ namespace OliviaAddInPro.Helper
{ {
ArcGIS.Core.Geometry.SpatialReference spatref = GetSpatRef(fc); ArcGIS.Core.Geometry.SpatialReference spatref = GetSpatRef(fc);
var environments = Geoprocessing.MakeEnvironmentArray(outputCoordinateSystem: spatref); var environments = Geoprocessing.MakeEnvironmentArray(outputCoordinateSystem: spatref);
IGPResult gpResult = Geoprocessing.ExecuteToolAsync("FeatureClassToFeatureClass_conversion", args, IGPResult gpResult = Geoprocessing.ExecuteToolAsync("FeatureClassToFeatureClass_conversion", args, environments).Result;
environments, null, null).Result;
if (gpResult.IsCanceled) if (gpResult.IsCanceled)
{ {
return res; return res;
@ -1799,5 +1798,27 @@ namespace OliviaAddInPro.Helper
} }
} }
/**
* Abre en el mapa la capa seleccionada, con los parámetros seleccionados
*/
public static bool OpenLayer(string ftclasspath, string campValUniq, bool visible)
{
var mapView = MapView.Active;
int indexNumber = mapView.Map.Layers.Count;
string ftclassname = System.IO.Path.GetFileNameWithoutExtension(ftclasspath);
if (mapView != null)//Check if there is a map
{
System.Uri ftclass_uri = new System.Uri(ftclasspath); //creating uri for the ftclass
QueuedTask.Run(() =>
{
Layer layer = LayerFactory.Instance.CreateLayer(ftclass_uri, mapView.Map, indexNumber, ftclassname);
var selectedLayer = mapView.GetSelectedLayers()[0] as FeatureLayer;
//Do something with selected layer
selectedLayer.SetVisibility(visible);
});
}
return true;
}
} }
} }

View File

@ -125,10 +125,13 @@ namespace OliviaAddInPro.Model
auxi = auxi.Substring(0, indice); auxi = auxi.Substring(0, indice);
} }
auxl = indice - aux; auxl = indice - aux;
if (auxl <= 0) if (auxl > 0)
return; {
auxili = shapefile.Substring(aux, auxl); auxili = shapefile.Substring(aux, auxl);
ambitos = ambitos + auxili; ambitos = ambitos + auxili;
}
//concatena el timestamp
ambitos = ambitos + shapefile.Substring(aux);
} }
} }

View File

@ -146,11 +146,14 @@ namespace OliviaAddInPro.Model
auxi = auxi.Substring(0, indice); auxi = auxi.Substring(0, indice);
} }
auxl = indice - aux; auxl = indice - aux;
if (auxl <= 0) if (auxl > 0)
return; {
auxili = shapefile.Substring(aux, auxl); auxili = shapefile.Substring(aux, auxl);
carga = carga + auxili; carga = carga + auxili;
}
//concatena el timestamp
carga = carga + shapefile.Substring(aux);
} }
} }
} }

View File

@ -377,9 +377,15 @@ namespace OliviaAddInPro.Services
*/ */
public Respuesta<string> ImportSecto(string GdbFileName) public Respuesta<string> ImportSecto(string GdbFileName)
{ {
/*var res = new Respuesta<string> { Value = string.Empty }; var res = new Respuesta<string> { Value = string.Empty };
return res;*/ res = Import(GdbFileName, 0);
return Import(GdbFileName, 0); if (res.HasError)
return res;
//////////////////////////////////////////////////
//abre las capas, pintando los sectores
HelperGdb.CloseAllLayers();
return res;
} }
/** /**
* Realiza las funciones de importación, modo 0 secto, modo 1 planif * Realiza las funciones de importación, modo 0 secto, modo 1 planif
@ -436,7 +442,10 @@ namespace OliviaAddInPro.Services
HelperGlobal.ponMsg(err_spatref +", se ha creado un nuevo dataset "+ datasetNameOut ); HelperGlobal.ponMsg(err_spatref +", se ha creado un nuevo dataset "+ datasetNameOut );
tratamiento = datasetNameOut; tratamiento = datasetNameOut;
} }
string dataset = tratamiento;
//NO hace falta preguntar ni comprobar el ftclass porque pone el timestamp y el nombre es único
/*
///////////////////////////////////////// /////////////////////////////////////////
//pregunta a ver si se quiere ese nombre u otro //pregunta a ver si se quiere ese nombre u otro
bool replace = false; bool replace = false;
@ -475,6 +484,8 @@ namespace OliviaAddInPro.Services
HelperGlobal.ponMsg(err_spatref); HelperGlobal.ponMsg(err_spatref);
} }
} }
*/
///////////////////////////////////////// /////////////////////////////////////////
//todo ok, se pone a importar //todo ok, se pone a importar
string err_st=string.Empty; string err_st=string.Empty;
@ -542,7 +553,7 @@ namespace OliviaAddInPro.Services
for (i = 0; i < NIMPORT; i++) for (i = 0; i < NIMPORT; i++)
{ {
//mira a ver si hay que borrar para reemplazar //mira a ver si hay que borrar para reemplazar
if (replace) /*if (replace)
{ {
resp2 = HelperGdb.DeleteFeatureClass(GdbFileName, noms_gdb[i]); resp2 = HelperGdb.DeleteFeatureClass(GdbFileName, noms_gdb[i]);
if (!resp2.Value) if (!resp2.Value)
@ -552,7 +563,7 @@ namespace OliviaAddInPro.Services
err_st += " " + resp2.Error.First(); err_st += " " + resp2.Error.First();
break; break;
} }
} }*/
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]);
if (!resp2.Value) if (!resp2.Value)
{ {
@ -588,6 +599,23 @@ namespace OliviaAddInPro.Services
public Respuesta<string> ImportPlanif(string GdbFileName) public Respuesta<string> ImportPlanif(string GdbFileName)
{ {
var res = new Respuesta<string> { Value = string.Empty }; var res = new Respuesta<string> { Value = string.Empty };
res = Import(GdbFileName, 1);
if (res.HasError)
return res;
//abre las capas, pintando por sectores
/////////////////////////////////////////////////////
//la primera capa que se añade es la de ruta, se le quita la visualización porque lo que interesa
//de esa capa es poder acceder si fuera necesario a la tabla de atributos. shape + name_ruta_out
/////////////////////////////////////////////////////
//la siguiente es la de ruta2, se le quita la visualización porque lo que interesa
//de esa capa es poder acceder si fuera necesario a la tabla de atributos. shape + name_ruta2_out
/////////////////////////////////////////////////////
//se añade la capa de ruta_aux y se pinta por sectores - shape + name_ruta_out + name_aux
/////////////////////////////////////////////////////
//se añade la capa de ambitos original con la secto, y se pinta por sectores - shape
/////////////////////////////////////////////////////
//se añade la capa de la ruta a las instalaciones, comprueba si hay configurada coordenadas de la instalación - shape + name_inst_out
//se abre la capa de puntos de control y se pintan por el sector al que pertenecen - shape + name_control_out
return res; return res;
} }

View File

@ -152,14 +152,14 @@ namespace OliviaAddInPro.Services
OliviaGlob.progrDialog.Hide(); OliviaGlob.progrDialog.Hide();
//muestra la ventana //muestra la ventana
OliviaGlob.ShowHidePane(true); OliviaGlob.ShowHidePane(true);
/*var task = ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => var task = ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{ {
//borra los archivos que le toca borrar //borra los archivos que le toca borrar
BorraFiles(); BorraFiles();
}); });
task.Wait();*/ task.Wait();
//borra los archivos que le toca borrar //borra los archivos que le toca borrar
BorraFiles(); //BorraFiles();
} }
/** /**