Geographic Information Systems Asked on March 24, 2021
We have an ArcGIS Engine-based production system. It is a legacy system handling data in shapefile format.
We migrated it to a file geodatabase and got a better performance. However, we are noticing varying performance (12 hours range) for the same volume of data. We noticed the same when we ran the tool on a different system with the same configuration.
Any suggestions to address the issue?
Sharing samples:
CopyTemplate() took 2400 ms,2900 ms ,4800 ms at different times.
ImportGCS2UTM() took 2800 ms,2900 ms,3761 ms for different runs
There 40 feature classes(overall 1000 records) and 1000 Lakes.
A similar trend observed for all FGDB transactions.
//Copy a template GDB to destination
//Rename it to <LAKE>.gdb
public string CopyTemplate(object passedTuple)
{
var stopwatch = new Stopwatch();
stopwatch.Start();
try
{
var myParamObj = passedTuple as Tuple<string, string, string>;
string strUTMGDBemplatePath = myParamObj.Item1; // For a given LAKE, get the UTM zone in which it falls .
string strLAKEPath = myParamObj.Item2;
string strLAKE = myParamObj.Item3;
Type factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.FileGDBWorkspaceFactory");
IWorkspaceFactory pworkspaceFactory = (IWorkspaceFactory)Activator.CreateInstance(factoryType);
string temp = strLAKEPath + "" + strLAKE + ".gdb";
// Delete <LAKE>.GDB if already exists
if (pworkspaceFactory.IsWorkspace(temp))
{
IWorkspace pWorkspace_GDB = pworkspaceFactory.OpenFromFile(temp, 0);
IDataset pDataset = (IDataset)pWorkspace_GDB;
if (pDataset.CanDelete())
{
pDataset.Delete();
}
if (pWorkspace_GDB != null)
Marshal.ReleaseComObject(pWorkspace_GDB);
}
// Create new workspace name objects.
IWorkspaceName sourceWorkspaceName = new WorkspaceNameClass();
IWorkspaceName targetWorkspaceName = new WorkspaceNameClass();
// Set the workspace name properties.
sourceWorkspaceName.PathName = strUTMGDBemplatePath;
sourceWorkspaceName.WorkspaceFactoryProgID = "esriDataSourcesGDB.FileGDBWorkspaceFactory";
Type factoryType2 = Type.GetTypeFromProgID("esriDataSourcesGDB.FileGDBWorkspaceFactory");
IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance(factoryType);
// Copy this UTM template GDB to the LAKE folder
workspaceFactory.Copy(sourceWorkspaceName, strLAKEPath, out targetWorkspaceName);
// Rename the GDB as <LAKE>.GDB
// pworkspaceFactory = new FileGDBWorkspaceFactory();
IWorkspace pWorkspace_GDB = pworkspaceFactory.OpenFromFile(targetWorkspaceName.PathName, 0);
IDataset pDataset = (IDataset)pWorkspace_GDB;
if (pDataset.CanRename())
{
pDataset.Rename(strLAKE);
}
Marshal.ReleaseComObject(workspaceFactory);
Marshal.ReleaseComObject(targetWorkspaceName);
Marshal.ReleaseComObject(pWorkspace_GDB);
Marshal.ReleaseComObject(pworkspaceFactory);
workspaceFactory = null;
targetWorkspaceName = null;
pWorkspace_GDB = null;
pworkspaceFactory = null;
stopwatch.Stop();
long elapsed_time = stopwatch.ElapsedMilliseconds;
return strLAKE;
}
catch (Exception ex)
{
return string.Empty;
}
}
public void ImportFileFeatureClass_GDB(IFeatureClass srcFeatureClass, IFeatureClass tgtFeatureClass, string strLake)
{
try
{
IFeatureBuffer ddFBuffer = tgtFeatureClass.CreateFeatureBuffer();
IFeatureCursor dbbFCursor = tgtFeatureClass.Insert(true);
IFeatureCursor srcFCursor = srcFeatureClass.Search(null, true);
IFeature objFeature = srcFCursor.NextFeature();
while (objFeature != null)
{
try
{
for (var i = 1; i < objFeature.Fields.FieldCount; i++)
{
string fldName = objFeature.Fields.get_Field(i).Name;
if (tgtFeatureClass.FindField(objFeature.Fields.get_Field(i).Name) >= 0 && !objFeature.Fields.get_Field(i).Name.Equals("Shape"))
{
int indx = tgtFeatureClass.FindField(objFeature.Fields.get_Field(i).Name);
if (tgtFeatureClass.Fields.Field[indx].Editable)
ddFBuffer.set_Value(tgtFeatureClass.FindField(objFeature.Fields.get_Field(i).Name), objFeature.get_Value(i));
}
}
ddFBuffer.Shape = objFeature.Shape;
dbbFCursor.InsertFeature(ddFBuffer);
objFeature = srcFCursor.NextFeature();
}
catch (Exception ex)
{
}
}
dbbFCursor.Flush();
Marshal.ReleaseComObject(dbbFCursor);
Marshal.ReleaseComObject(srcFCursor);
GC.Collect();
}
catch (Exception ex)
{
}
}
private void ImportGCS2UTM(IWorkspace pGDBwrkSpace, string strGCSdatasetName, string strLake)
{
IFeatureWorkspace pFtrWorkSpace = pGDBwrkSpace as IFeatureWorkspace;
try
{
IFeatureDataset pGCSDtSet = pFtrWorkSpace.OpenFeatureDataset(strGCSdatasetName);
IEnumDataset pEnumDtSet = pGCSDtSet.Subsets;
pEnumDtSet.Reset();
IDataset pSrcDtset = pEnumDtSet.Next();
while (pSrcDtset != null)
{
IFeatureClass pSourceFC_GCS = pSrcDtset as IFeatureClass;
IFeatureClass pTragetFC_UTM = pFtrWorkSpace.OpenFeatureClass(pSourceFC_GCS.AliasName + "_UTM");
if (pTragetFC_UTM != null)
{
ImportFileFeatureClass_GDB(pSourceFC_GCS, pTragetFC_UTM, strLake);
}
pSrcDtset = pEnumDtSet.Next();
}
if (pFtrWorkSpace != null)
Marshal.ReleaseComObject(pFtrWorkSpace);
}
catch (Exception ex)
{
if (pFtrWorkSpace != null)
Marshal.ReleaseComObject(pFtrWorkSpace);
}
}
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP