Permalink
Browse files

local changes for SDE geodatabases

  • Loading branch information...
ThomasEmge committed Dec 27, 2016
1 parent d9990e6 commit 98c299309b5ee183e92bafadc3b19d64f10a513f
Showing with 91 additions and 17 deletions.
  1. +26 −4 src/OSMGeoProcessing/OSMGPMultiLoader.cs
  2. +65 −13 src/OSMGeoProcessing/OSMToolHelper.cs
@@ -257,8 +257,19 @@ public void Execute(ESRI.ArcGIS.esriSystem.IArray paramvalues, ESRI.ArcGIS.esriS
IName lineWorkspaceName = gpUtilities3.CreateParentFromCatalogPath(osmLineFeatureClassGPValue.GetAsText());
IWorkspace2 lineFeatureWorkspace = lineWorkspaceName.Open() as IWorkspace2;
- string[] lineFCNameElements = osmLineFeatureClassGPValue.GetAsText().Split(System.IO.Path.DirectorySeparatorChar);
+ string targetLineFeatureClassLocation = osmLineFeatureClassGPValue.GetAsText();
+ string[] lineFCNameElements = targetLineFeatureClassLocation.Split(System.IO.Path.DirectorySeparatorChar);
+ string dbName = String.Empty;
+ string ownerName = String.Empty;
+ string lineFeatureClassName = String.Empty;
+
+ ISQLSyntax lineFCSQLSyntax = lineFeatureWorkspace as ISQLSyntax;
+
+ if (lineFCSQLSyntax != null)
+ lineFCSQLSyntax.ParseTableName(lineFCNameElements[lineFCNameElements.Length - 1], out dbName, out ownerName, out lineFeatureClassName);
+ else
+ lineFeatureClassName = lineFCNameElements[lineFCNameElements.Length - 1];
IGPParameter tagLineCollectionParameter = paramvalues.get_Element(in_lineFieldNamesNumber) as IGPParameter;
IGPMultiValue tagLineCollectionGPValue = gpUtilities3.UnpackGPValue(tagLineCollectionParameter) as IGPMultiValue;
@@ -320,7 +331,17 @@ public void Execute(ESRI.ArcGIS.esriSystem.IArray paramvalues, ESRI.ArcGIS.esriS
IName polygonWorkspaceName = gpUtilities3.CreateParentFromCatalogPath(osmPolygonFeatureClassGPValue.GetAsText());
IWorkspace2 polygonFeatureWorkspace = polygonWorkspaceName.Open() as IWorkspace2;
- string[] polygonFCNameElements = osmPolygonFeatureClassGPValue.GetAsText().Split(System.IO.Path.DirectorySeparatorChar);
+ string targetPolygonFeatureClassLocation = osmPolygonFeatureClassGPValue.GetAsText();
+ string[] polygonFCNameElements = targetPolygonFeatureClassLocation.Split(System.IO.Path.DirectorySeparatorChar);
+
+ string polygonFeatureClassName = String.Empty;
+
+ ISQLSyntax polygonFCSQLSyntax = polygonFeatureWorkspace as ISQLSyntax;
+
+ if (polygonFCSQLSyntax != null)
+ polygonFCSQLSyntax.ParseTableName(polygonFCNameElements[polygonFCNameElements.Length - 1], out dbName, out ownerName, out polygonFeatureClassName);
+ else
+ polygonFeatureClassName = polygonFCNameElements[polygonFCNameElements.Length - 1];
IGPParameter tagPolygonCollectionParameter = paramvalues.get_Element(in_polygonFieldNamesNumber) as IGPParameter;
IGPMultiValue tagPolygonCollectionGPValue = gpUtilities3.UnpackGPValue(tagPolygonCollectionParameter) as IGPMultiValue;
@@ -459,7 +480,7 @@ public void Execute(ESRI.ArcGIS.esriSystem.IArray paramvalues, ESRI.ArcGIS.esriS
}
#region load ways
- osmToolHelper.loadOSMWays(wayOSMFileNames, osmPointsFeatureClassGPValue.GetAsText(), wayGDBFileNames, lineFCNameElements[lineFCNameElements.Length - 1], polygonFCNameElements[polygonFCNameElements.Length - 1], lineTagstoExtract, polygonTagstoExtract, ref message, ref TrackCancel);
+ osmToolHelper.loadOSMWays(wayOSMFileNames, osmPointsFeatureClassGPValue.GetAsText(), wayGDBFileNames, lineFeatureClassName, targetLineFeatureClassLocation, polygonFeatureClassName, targetPolygonFeatureClassLocation, lineTagstoExtract, polygonTagstoExtract, ref message, ref TrackCancel);
#endregion
#region for local geodatabases enforce spatial integrity
@@ -543,7 +564,8 @@ public void Execute(ESRI.ArcGIS.esriSystem.IArray paramvalues, ESRI.ArcGIS.esriS
}
#region load relations
- osmToolHelper.loadOSMRelations(relationOSMFileNames, osmLineFeatureClassGPValue.GetAsText(), osmPolygonFeatureClassGPValue.GetAsText(), relationGDBFileNames, lineTagstoExtract, polygonTagstoExtract, ref TrackCancel, ref message);
+ osmToolHelper.loadOSMRelations(relationOSMFileNames, lineFeatureClassName, targetLineFeatureClassLocation, polygonFeatureClassName,
+ targetPolygonFeatureClassLocation, relationGDBFileNames, lineTagstoExtract, polygonTagstoExtract, ref TrackCancel, ref message);
#endregion
// check for user interruption
@@ -612,6 +612,12 @@ internal IFeatureClass CreateSmallPointFeatureClass(ESRI.ArcGIS.Geodatabase.IWor
// finally create and return the feature class
try
{
+ string dbName = String.Empty;
+ string ownerName = String.Empty;
+
+ if (sqlSyntax != null)
+ sqlSyntax.ParseTableName(featureClassName, out dbName, out ownerName, out featureClassName);
+
featureClass = featureWorkspace.CreateFeatureClass(featureClassName, validatedFields, CLSID, null, ESRI.ArcGIS.Geodatabase.esriFeatureType.esriFTSimple, strShapeField, strConfigKeyword);
}
catch
@@ -1431,11 +1437,17 @@ internal ESRI.ArcGIS.Geodatabase.IFeatureClass CreateSmallLineFeatureClass(ESRI.
// The enumFieldError enumerator can be inspected at this point to determine
// which fields were modified during validation.
+ string dbName = String.Empty;
+ string ownerName = String.Empty;
+
+ if (sqlSyntax != null)
+ sqlSyntax.ParseTableName(featureClassName, out dbName, out ownerName, out featureClassName);
+
// finally create and return the feature class
- featureClass = featureWorkspace.CreateFeatureClass(featureClassName, validatedFields, CLSID, null, ESRI.ArcGIS.Geodatabase.esriFeatureType.esriFTSimple, strShapeField, strConfigKeyword);
+ featureClass = featureWorkspace.CreateFeatureClass(featureClassName, validatedFields, CLSID, null, ESRI.ArcGIS.Geodatabase.esriFeatureType.esriFTSimple, strShapeField, strConfigKeyword);
- // create the openstreetmap spcific metadata
+ // create the openstreetmap specific metadata
_osmUtility.CreateOSMMetadata((IDataset)featureClass, metadataAbstract, metadataPurpose);
}
catch
@@ -1889,6 +1901,11 @@ internal ESRI.ArcGIS.Geodatabase.IFeatureClass CreateSmallPolygonFeatureClass(ES
// The enumFieldError enumerator can be inspected at this point to determine
// which fields were modified during validation.
+ string dbName = String.Empty;
+ string ownerName = String.Empty;
+
+ if (sqlSyntax != null)
+ sqlSyntax.ParseTableName(featureClassName, out dbName, out ownerName, out featureClassName);
// finally create and return the feature class
featureClass = featureWorkspace.CreateFeatureClass(featureClassName, validatedFields, CLSID, null, ESRI.ArcGIS.Geodatabase.esriFeatureType.esriFTSimple, strShapeField, strConfigKeyword);
@@ -2304,9 +2321,19 @@ internal void smallLoadOSMWay(string osmFileLocation, string sourcePointsFeature
IFeatureWorkspace tempWorkspace = workspaceFactory.OpenFromFile(fileGDBLocation, 0) as IFeatureWorkspace;
comReleaser.ManageLifetime(tempWorkspace);
+ ISQLSyntax sqlSyntax = tempWorkspace as ISQLSyntax;
+ string dbName = String.Empty;
+ string ownerName = string.Empty;
+
+ if (sqlSyntax != null)
+ sqlSyntax.ParseTableName(lineFeatureClassName, out dbName, out ownerName, out lineFeatureClassName);
+
IFeatureClass lineFeatureClass = tempWorkspace.OpenFeatureClass(lineFeatureClassName);
comReleaser.ManageLifetime(lineFeatureClass);
+ if (sqlSyntax != null)
+ sqlSyntax.ParseTableName(polygonFeatureClassName, out dbName, out ownerName, out polygonFeatureClassName);
+
IFeatureClass polygonFeatureClass = tempWorkspace.OpenFeatureClass(polygonFeatureClassName);
comReleaser.ManageLifetime(polygonFeatureClass);
@@ -2330,6 +2357,10 @@ internal void smallLoadOSMWay(string osmFileLocation, string sourcePointsFeature
comReleaser.ManageLifetime(sourceWorkspace);
}
+ sqlSyntax = sourceWorkspace as ISQLSyntax;
+ if (sqlSyntax != null)
+ sqlSyntax.ParseTableName(sourceFCNameString, out dbName, out ownerName, out sourceFCNameString);
+
IFeatureClass sourcePointsFeatureClass = sourceWorkspace.OpenFeatureClass(sourceFCNameString);
comReleaser.ManageLifetime(sourcePointsFeatureClass);
@@ -2668,11 +2699,18 @@ internal void smallLoadOSMNode(string osmFileLocation, string fileGDBLocation, s
try
{
- IWorkspaceFactory2 workspaceFactory = new FileGDBWorkspaceFactoryClass();
+ IWorkspaceFactory2 workspaceFactory = guessWorkspaceFactory(fileGDBLocation) as IWorkspaceFactory2;
comReleaser.ManageLifetime(workspaceFactory);
IFeatureWorkspace nodeWorkspace = workspaceFactory.OpenFromFile(fileGDBLocation, 0) as IFeatureWorkspace;
comReleaser.ManageLifetime(nodeWorkspace);
+ ISQLSyntax sqlSyntax = nodeWorkspace as ISQLSyntax;
+ string dbName = String.Empty;
+ string ownerName = string.Empty;
+
+ if (sqlSyntax != null)
+ sqlSyntax.ParseTableName(featureClassName, out dbName, out ownerName, out featureClassName);
+
IFeatureClass nodeFeatureClass = nodeWorkspace.OpenFeatureClass(featureClassName);
comReleaser.ManageLifetime(nodeFeatureClass);
@@ -3031,7 +3069,7 @@ internal void PythonLoadOSMNodes(System.Object args)
}
}
- internal void loadOSMWays(List<string> osmWayFileNames, string sourcePointFCName, List<string> wayGDBNames, string lineFeatureClassName, string polygonFeatureClassName, List<string> lineFieldNames, List<string> polygonFieldNames, ref IGPMessages toolMessages, ref ITrackCancel CancelTracker)
+ internal void loadOSMWays(List<string> osmWayFileNames, string sourcePointFCName, List<string> wayGDBNames, string lineFeatureClassName, string targetLineFeatureClassLocation, string polygonFeatureClassName, string targetPolygonFeatureClassLocation,List<string> lineFieldNames, List<string> polygonFieldNames, ref IGPMessages toolMessages, ref ITrackCancel CancelTracker)
{
// create the point feature classes in the temporary loading fgdbs
OSMToolHelper toolHelper = new OSMToolHelper();
@@ -3132,7 +3170,9 @@ internal void loadOSMWays(List<string> osmWayFileNames, string sourcePointFCName
// append all the lines
IVariantArray parameterArray = new VarArrayClass();
parameterArray.Add(String.Join(";", linesFCNamesArray.ToArray()));
- parameterArray.Add(String.Join(System.IO.Path.DirectorySeparatorChar.ToString(), new string[] { sourceFGDB, lineFeatureClassName }));
+ toolMessages.AddMessage(String.Join(";", linesFCNamesArray.ToArray()));
+ parameterArray.Add(targetLineFeatureClassLocation);
+ toolMessages.AddMessage(targetLineFeatureClassLocation);
gpResults = geoProcessor.Execute("Append_management", parameterArray, CancelTracker);
@@ -3149,7 +3189,7 @@ internal void loadOSMWays(List<string> osmWayFileNames, string sourcePointFCName
// append all the polygons
parameterArray = new VarArrayClass();
parameterArray.Add(String.Join(";", polygonFCNamesArray.ToArray()));
- parameterArray.Add(String.Join(System.IO.Path.DirectorySeparatorChar.ToString(), new string[] { sourceFGDB, polygonFeatureClassName }));
+ parameterArray.Add(targetPolygonFeatureClassLocation);
gpResults = geoProcessor.Execute("Append_management", parameterArray, CancelTracker);
@@ -3175,12 +3215,12 @@ internal void loadOSMWays(List<string> osmWayFileNames, string sourcePointFCName
}
// compute the OSM index on the target line featureclass
- parameterArray = CreateAddIndexParameterArray(String.Join(System.IO.Path.DirectorySeparatorChar.ToString(), new string[] { sourceFGDB, lineFeatureClassName }), "OSMID", "osmID_IDX", "UNIQUE", "");
+ parameterArray = CreateAddIndexParameterArray(targetLineFeatureClassLocation, "OSMID", "osmID_IDX", "UNIQUE", "");
gpResults = geoProcessor.Execute("AddIndex_management", parameterArray, CancelTracker);
toolMessages.AddMessages(gpResults.GetResultMessages());
// compute the OSM index on the target polygon featureclass
- parameterArray = CreateAddIndexParameterArray(String.Join(System.IO.Path.DirectorySeparatorChar.ToString(), new string[] { sourceFGDB, polygonFeatureClassName }), "OSMID", "osmID_IDX", "UNIQUE", "");
+ parameterArray = CreateAddIndexParameterArray(targetPolygonFeatureClassLocation, "OSMID", "osmID_IDX", "UNIQUE", "");
gpResults = geoProcessor.Execute("AddIndex_management", parameterArray, CancelTracker);
toolMessages.AddMessages(gpResults.GetResultMessages());
@@ -3229,12 +3269,24 @@ internal void loadOSMNodes(List<string> osmNodeFileNames, List<string> nodeGDBNa
{
using (ComReleaser comReleaser = new ComReleaser())
{
+ IWorkspaceFactory targetPointWorkspaceFactory = guessWorkspaceFactory(nodeGDBNames[0]);
+ comReleaser.ManageLifetime(targetPointWorkspaceFactory);
+
+ FileInfo targetGDBFileInfo = new FileInfo(nodeGDBNames[0]);
+
+ ISQLSyntax sqlSyntax = targetPointWorkspaceFactory.OpenFromFile(nodeGDBNames[0], 0) as ISQLSyntax;
+ string dbName = String.Empty;
+ string ownerName = String.Empty;
+ if (sqlSyntax != null)
+ sqlSyntax.ParseTableName(featureClassName, out dbName, out ownerName, out featureClassName);
+
IWorkspaceFactory workspaceFactory = new FileGDBWorkspaceFactoryClass();
comReleaser.ManageLifetime(workspaceFactory);
for (int gdbIndex = 1; gdbIndex < nodeGDBNames.Count; gdbIndex++)
{
FileInfo gdbFileInfo = new FileInfo(nodeGDBNames[gdbIndex]);
+
IWorkspaceName workspaceName = workspaceFactory.Create(gdbFileInfo.DirectoryName, gdbFileInfo.Name, new PropertySetClass(), 0);
comReleaser.ManageLifetime(workspaceName);
}
@@ -5080,7 +5132,7 @@ internal void countOSMStuff(string osmFileLocation, ref long nodeCapacity, ref l
return attributesDictionary;
}
- internal void loadOSMRelations(List<string> osmRelationFileNames, string sourceLineFCName, string sourcePolygonFCName, List<string> relationGDBNames, List<string> lineFieldNames, List<string> polygonFieldNames, ref ITrackCancel TrackCancel, ref IGPMessages toolMessages)
+ internal void loadOSMRelations(List<string> osmRelationFileNames, string lineFeatureClassName, string sourceLineFCName, string polygonFeatureClassName, string sourcePolygonFCName, List<string> relationGDBNames, List<string> lineFieldNames, List<string> polygonFieldNames, ref ITrackCancel TrackCancel, ref IGPMessages toolMessages)
{
// create the point feature classes in the temporary loading fgdbs
OSMToolHelper toolHelper = new OSMToolHelper();
@@ -5094,10 +5146,10 @@ internal void loadOSMRelations(List<string> osmRelationFileNames, string sourceL
string loadSuperRelationParameterValue = "DO_NOT_LOAD_SUPER_RELATION";
// take the name of the temp line and polygon featureclass from the source names
- string[] sourceLineNameElements = sourceLineFCName.Split(System.IO.Path.DirectorySeparatorChar);
- string lineFeatureClassName = sourceLineNameElements[sourceLineNameElements.Length - 1];
- string[] sourcePolygonNameElements = sourcePolygonFCName.Split(System.IO.Path.DirectorySeparatorChar);
- string polygonFeatureClassName = sourcePolygonNameElements[sourcePolygonNameElements.Length - 1];
+ //string[] sourceLineNameElements = sourceLineFCName.Split(System.IO.Path.DirectorySeparatorChar);
+ //string lineFeatureClassName = sourceLineNameElements[sourceLineNameElements.Length - 1];
+ //string[] sourcePolygonNameElements = sourcePolygonFCName.Split(System.IO.Path.DirectorySeparatorChar);
+ //string polygonFeatureClassName = sourcePolygonNameElements[sourcePolygonNameElements.Length - 1];
// in the case of a single thread we can use the parent process directly to convert the osm to the target featureclass
if (osmRelationFileNames.Count == 1)

0 comments on commit 98c2993

Please sign in to comment.