public void Execute(ESRI.ArcGIS.esriSystem.IArray paramvalues, ESRI.ArcGIS.esriSystem.ITrackCancel TrackCancel, ESRI.ArcGIS.Geoprocessing.IGPEnvironmentManager envMgr, ESRI.ArcGIS.Geodatabase.IGPMessages message)
        {
            IFeatureClass osmPointFeatureClass = null;
            IFeatureClass osmLineFeatureClass = null;
            IFeatureClass osmPolygonFeatureClass = null;
            OSMToolHelper osmToolHelper = null;

            try
            {
                DateTime syncTime = DateTime.Now;

                IGPUtilities3 gpUtilities3 = new GPUtilitiesClass();
                osmToolHelper = new OSMToolHelper();

                if (TrackCancel == null)
                {
                    TrackCancel = new CancelTrackerClass();
                }

                IGPParameter osmFileParameter = paramvalues.get_Element(in_osmFileNumber) as IGPParameter;
                IGPValue osmFileLocationString = gpUtilities3.UnpackGPValue(osmFileParameter) as IGPValue;

                // ensure that the specified file does exist
                bool osmFileExists = false;

                try
                {
                    osmFileExists = System.IO.File.Exists(osmFileLocationString.GetAsText());
                }
                catch (Exception ex)
                {
                    message.AddError(120029, String.Format(resourceManager.GetString("GPTools_OSMGPMultiLoader_problemaccessingfile"), ex.Message));
                    return;
                }

                if (osmFileExists == false)
                {
                    message.AddError(120030, String.Format(resourceManager.GetString("GPTools_OSMGPFileReader_osmfiledoesnotexist"), osmFileLocationString.GetAsText()));
                    return;
                }

                long nodeCapacity = 0;
                long wayCapacity = 0;
                long relationCapacity = 0;

                // this assume a clean, tidy XML file - if this is not the case, there will by sync issues later on
                osmToolHelper.countOSMStuffFast(osmFileLocationString.GetAsText(), ref nodeCapacity, ref wayCapacity, ref relationCapacity, ref TrackCancel);

                if (nodeCapacity == 0 && wayCapacity == 0 && relationCapacity == 0)
                {
                    return;
                }

                message.AddMessage(String.Format(resourceManager.GetString("GPTools_OSMGPMultiLoader_countedElements"), nodeCapacity, wayCapacity, relationCapacity));

                // determine the number of threads to be used
                IGPEnvironment parallelProcessingFactorEnvironment = OSMToolHelper.getEnvironment(envMgr, "parallelProcessingFactor");
                IGPString parallelProcessingFactorString = parallelProcessingFactorEnvironment.Value as IGPString;

                // the default value is to use half the cores for additional threads - I am aware that we are comparing apples and oranges but I need a number
                int numberOfThreads = Convert.ToInt32(System.Environment.ProcessorCount / 2);

                if (!(parallelProcessingFactorEnvironment.Value.IsEmpty()))
                {
                    if (!Int32.TryParse(parallelProcessingFactorString.Value, out numberOfThreads))
                    {
                        // this case we have a percent string
                        string resultString = Regex.Match(parallelProcessingFactorString.Value, @"\d+").Value;
                        numberOfThreads = Convert.ToInt32(Int32.Parse(resultString) / 100 * System.Environment.ProcessorCount);
                    }
                }

                // tread the special case of 0
                if (numberOfThreads <= 0)
                    numberOfThreads = 1;

                IGPEnvironment configKeyword = OSMToolHelper.getEnvironment(envMgr, "configKeyword");
                IGPString gpString = configKeyword.Value as IGPString;

                string storageKeyword = String.Empty;

                if (gpString != null)
                {
                    storageKeyword = gpString.Value;
                }

                // determine the temp folder to be use for the intermediate files
                IGPEnvironment scratchWorkspaceEnvironment = OSMToolHelper.getEnvironment(envMgr, "scratchWorkspace");
                IDEWorkspace deWorkspace = scratchWorkspaceEnvironment.Value as IDEWorkspace;
                String scratchWorkspaceFolder = String.Empty;

                if (deWorkspace != null)
                {
                    if (scratchWorkspaceEnvironment.Value.IsEmpty())
                    {
                        scratchWorkspaceFolder = (new System.IO.FileInfo(osmFileLocationString.GetAsText())).DirectoryName;
                    }
                    else
                    {
                        if (deWorkspace.WorkspaceType == esriWorkspaceType.esriRemoteDatabaseWorkspace)
                        {
                            scratchWorkspaceFolder = System.IO.Path.GetTempPath();
                        }
                        else if (deWorkspace.WorkspaceType == esriWorkspaceType.esriFileSystemWorkspace)
                        {
                            scratchWorkspaceFolder = ((IDataElement)deWorkspace).CatalogPath;
                        }
                        else
                        {
                            scratchWorkspaceFolder = (new System.IO.FileInfo(((IDataElement)deWorkspace).CatalogPath)).DirectoryName;
                        }
                    }
                }
                else
                {
                    scratchWorkspaceFolder = (new System.IO.FileInfo(osmFileLocationString.GetAsText())).DirectoryName;
                }

                string metadataAbstract = resourceManager.GetString("GPTools_OSMGPFileReader_metadata_abstract");
                string metadataPurpose = resourceManager.GetString("GPTools_OSMGPFileReader_metadata_purpose");

                IGPParameter osmPointsFeatureClassParameter = paramvalues.get_Element(out_osmPointsNumber) as IGPParameter;
                IGPValue osmPointsFeatureClassGPValue = gpUtilities3.UnpackGPValue(osmPointsFeatureClassParameter) as IGPValue;

                IName workspaceName = gpUtilities3.CreateParentFromCatalogPath(osmPointsFeatureClassGPValue.GetAsText());
                IWorkspace2 pointFeatureWorkspace = workspaceName.Open() as IWorkspace2;

                string[] pointFCNameElements = osmPointsFeatureClassGPValue.GetAsText().Split(System.IO.Path.DirectorySeparatorChar);

                IGPParameter tagPointCollectionParameter = paramvalues.get_Element(in_pointFieldNamesNumber) as IGPParameter;
                IGPMultiValue tagPointCollectionGPValue = gpUtilities3.UnpackGPValue(tagPointCollectionParameter) as IGPMultiValue;

                List<String> pointTagstoExtract = null;

                if (tagPointCollectionGPValue.Count > 0)
                {
                    pointTagstoExtract = new List<string>();

                    for (int valueIndex = 0; valueIndex < tagPointCollectionGPValue.Count; valueIndex++)
                    {
                        string nameOfTag = tagPointCollectionGPValue.get_Value(valueIndex).GetAsText();

                        pointTagstoExtract.Add(nameOfTag);
                    }
                }
                else
                {
                    pointTagstoExtract = OSMToolHelper.OSMSmallFeatureClassFields();
                }

                // points
                try
                {
                    osmPointFeatureClass = osmToolHelper.CreateSmallPointFeatureClass(pointFeatureWorkspace,
                        pointFCNameElements[pointFCNameElements.Length - 1], storageKeyword, metadataAbstract,
                        metadataPurpose, pointTagstoExtract);
                }
                catch (Exception ex)
                {
                    message.AddError(120035, String.Format(resourceManager.GetString("GPTools_OSMGPDownload_nullpointfeatureclass"), ex.Message));
                    return;
                }

                if (osmPointFeatureClass == null)
                {
                    return;
                }

                int osmPointIDFieldIndex = osmPointFeatureClass.FindField("OSMID");
                Dictionary<string, int> mainPointAttributeFieldIndices = new Dictionary<string, int>();

                foreach (string fieldName in OSMToolHelper.OSMSmallFeatureClassFields())
                {
                    int currentFieldIndex = osmPointFeatureClass.FindField(fieldName);

                    if (currentFieldIndex != -1)
                    {
                        mainPointAttributeFieldIndices.Add(fieldName, currentFieldIndex);
                    }
                }

                int tagCollectionPointFieldIndex = osmPointFeatureClass.FindField("osmTags");
                int osmSupportingElementPointFieldIndex = osmPointFeatureClass.FindField("osmSupportingElement");

                IGPParameter osmLineFeatureClassParameter = paramvalues.get_Element(out_osmLinesNumber) as IGPParameter;
                IGPValue osmLineFeatureClassGPValue = gpUtilities3.UnpackGPValue(osmLineFeatureClassParameter) as IGPValue;

                IName lineWorkspaceName = gpUtilities3.CreateParentFromCatalogPath(osmLineFeatureClassGPValue.GetAsText());
                IWorkspace2 lineFeatureWorkspace = lineWorkspaceName.Open() as IWorkspace2;

                string[] lineFCNameElements = osmLineFeatureClassGPValue.GetAsText().Split(System.IO.Path.DirectorySeparatorChar);

                IGPParameter tagLineCollectionParameter = paramvalues.get_Element(in_lineFieldNamesNumber) as IGPParameter;
                IGPMultiValue tagLineCollectionGPValue = gpUtilities3.UnpackGPValue(tagLineCollectionParameter) as IGPMultiValue;

                List<String> lineTagstoExtract = null;

                if (tagLineCollectionGPValue.Count > 0)
                {
                    lineTagstoExtract = new List<string>();

                    for (int valueIndex = 0; valueIndex < tagLineCollectionGPValue.Count; valueIndex++)
                    {
                        string nameOfTag = tagLineCollectionGPValue.get_Value(valueIndex).GetAsText();

                        lineTagstoExtract.Add(nameOfTag);
                    }
                }
                else
                {
                    lineTagstoExtract = OSMToolHelper.OSMSmallFeatureClassFields();
                }

                // lines
                try
                {
                    osmLineFeatureClass = osmToolHelper.CreateSmallLineFeatureClass(lineFeatureWorkspace, lineFCNameElements[lineFCNameElements.Length -1],
                        storageKeyword, metadataAbstract, metadataPurpose, lineTagstoExtract);
                }
                catch (Exception ex)
                {
                    message.AddError(120036, String.Format(resourceManager.GetString("GPTools_OSMGPDownload_nulllinefeatureclass"), ex.Message));
                    return;
                }

                if (osmLineFeatureClass == null)
                {
                    return;
                }

                int osmLineIDFieldIndex = osmLineFeatureClass.FindField("OSMID");

                Dictionary<string, int> mainLineAttributeFieldIndices = new Dictionary<string, int>();
                foreach (string fieldName in OSMToolHelper.OSMSmallFeatureClassFields())
                {
                    int currentFieldIndex = osmLineFeatureClass.FindField(fieldName);

                    if (currentFieldIndex != -1)
                    {
                        mainLineAttributeFieldIndices.Add(fieldName, currentFieldIndex);
                    }
                }

                int tagCollectionPolylineFieldIndex = osmLineFeatureClass.FindField("osmTags");
                int osmSupportingElementPolylineFieldIndex = osmLineFeatureClass.FindField("osmSupportingElement");

                IGPParameter osmPolygonFeatureClassParameter = paramvalues.get_Element(out_osmPolygonsNumber) as IGPParameter;
                IGPValue osmPolygonFeatureClassGPValue = gpUtilities3.UnpackGPValue(osmPolygonFeatureClassParameter) as IGPValue;

                IName polygonWorkspaceName = gpUtilities3.CreateParentFromCatalogPath(osmPolygonFeatureClassGPValue.GetAsText());
                IWorkspace2 polygonFeatureWorkspace = polygonWorkspaceName.Open() as IWorkspace2;

                string[] polygonFCNameElements = osmPolygonFeatureClassGPValue.GetAsText().Split(System.IO.Path.DirectorySeparatorChar);

                IGPParameter tagPolygonCollectionParameter = paramvalues.get_Element(in_polygonFieldNamesNumber) as IGPParameter;
                IGPMultiValue tagPolygonCollectionGPValue = gpUtilities3.UnpackGPValue(tagPolygonCollectionParameter) as IGPMultiValue;

                List<String> polygonTagstoExtract = null;

                if (tagPolygonCollectionGPValue.Count > 0)
                {
                    polygonTagstoExtract = new List<string>();

                    for (int valueIndex = 0; valueIndex < tagPolygonCollectionGPValue.Count; valueIndex++)
                    {
                        string nameOfTag = tagPolygonCollectionGPValue.get_Value(valueIndex).GetAsText();

                        polygonTagstoExtract.Add(nameOfTag);
                    }
                }
                else
                {
                    polygonTagstoExtract = OSMToolHelper.OSMSmallFeatureClassFields();
                }

                // polygons
                try
                {
                    osmPolygonFeatureClass = osmToolHelper.CreateSmallPolygonFeatureClass(polygonFeatureWorkspace,
                        polygonFCNameElements[polygonFCNameElements.Length -1], storageKeyword, metadataAbstract,
                        metadataPurpose, polygonTagstoExtract);
                }
                catch (Exception ex)
                {
                    message.AddError(120037, String.Format(resourceManager.GetString("GPTools_OSMGPDownload_nullpolygonfeatureclass"), ex.Message));
                    return;
                }

                if (osmPolygonFeatureClass == null)
                {
                    return;
                }

                int osmPolygonIDFieldIndex = osmPolygonFeatureClass.FindField("OSMID");

                Dictionary<string, int> mainPolygonAttributeFieldIndices = new Dictionary<string, int>();
                foreach (var fieldName in OSMToolHelper.OSMSmallFeatureClassFields())
                {
                    int currentFieldIndex = osmPolygonFeatureClass.FindField(fieldName);

                    if (currentFieldIndex != -1)
                    {
                        mainPolygonAttributeFieldIndices.Add(fieldName, currentFieldIndex);
                    }
                }

                int tagCollectionPolygonFieldIndex = osmPolygonFeatureClass.FindField("osmTags");
                int osmSupportingElementPolygonFieldIndex = osmPolygonFeatureClass.FindField("osmSupportingElement");

                ComReleaser.ReleaseCOMObject(osmPointFeatureClass);
                osmPointFeatureClass = null;

                ComReleaser.ReleaseCOMObject(osmLineFeatureClass);
                osmLineFeatureClass = null;

                ComReleaser.ReleaseCOMObject(osmPolygonFeatureClass);
                osmPolygonFeatureClass = null;

                List<string> nodeOSMFileNames = new List<string>(numberOfThreads);
                List<string> nodeGDBFileNames = new List<string>(numberOfThreads);

                List<string> wayOSMFileNames = new List<string>(numberOfThreads);
                List<string> wayGDBFileNames = new List<string>(numberOfThreads);

                List<string> relationOSMFileNames = new List<string>(numberOfThreads);
                List<string> relationGDBFileNames = new List<string>(numberOfThreads);

                if (TrackCancel.Continue() == false)
                {
                    return;
                }

                // split the original OSM xml file into smaller pieces for the python processes
                osmToolHelper.splitOSMFile(osmFileLocationString.GetAsText(), scratchWorkspaceFolder, nodeCapacity, wayCapacity, relationCapacity, numberOfThreads,
                    out nodeOSMFileNames, out nodeGDBFileNames, out wayOSMFileNames, out wayGDBFileNames, out relationOSMFileNames, out relationGDBFileNames);

                IGPParameter deleteSourceOSMFileParameter = paramvalues.get_Element(in_deleteOSMSourceFileNumber) as IGPParameter;
                IGPBoolean deleteSourceOSMFileGPValue = gpUtilities3.UnpackGPValue(deleteSourceOSMFileParameter) as IGPBoolean;

                if (deleteSourceOSMFileGPValue.Value)
                {
                    try
                    {
                        System.IO.File.Delete(osmFileLocationString.GetAsText());
                    }
                    catch (Exception ex)
                    {
                        message.AddWarning(ex.Message);
                    }
                }

                if (TrackCancel.Continue() == false)
                {
                    return;
                }

                if (nodeOSMFileNames.Count == 0)
                {
                    nodeOSMFileNames.Add(osmFileLocationString.GetAsText());
                    nodeGDBFileNames.Add(osmPointsFeatureClassGPValue.GetAsText());

                    wayOSMFileNames.Add(osmFileLocationString.GetAsText());
                    wayGDBFileNames.Add(osmLineFeatureClassGPValue.GetAsText());

                    relationOSMFileNames.Add(osmFileLocationString.GetAsText());
                    relationGDBFileNames.Add(osmPolygonFeatureClassGPValue.GetAsText());
                }
                else
                {
                    // for the nodes let's load one of the parts directly into the target file geodatabase
                    nodeGDBFileNames[0] = ((IWorkspace)pointFeatureWorkspace).PathName;
                }

                // define variables helping to invoke core tools for data management
                IGeoProcessorResult2 gpResults2 = null;
                IGeoProcessor2 geoProcessor = new GeoProcessorClass();

                IGPParameter deleteSupportingNodesParameter = paramvalues.get_Element(in_deleteSupportNodesNumber) as IGPParameter;
                IGPBoolean deleteSupportingNodesGPValue = gpUtilities3.UnpackGPValue(deleteSupportingNodesParameter) as IGPBoolean;

                #region load points
                osmToolHelper.loadOSMNodes(nodeOSMFileNames, nodeGDBFileNames, pointFCNameElements[pointFCNameElements.Length - 1], osmPointsFeatureClassGPValue.GetAsText(), pointTagstoExtract, deleteSupportingNodesGPValue.Value, ref message, ref TrackCancel);
                #endregion

                if (TrackCancel.Continue() == false)
                {
                    return;
                }

                #region load ways
                osmToolHelper.loadOSMWays(wayOSMFileNames, osmPointsFeatureClassGPValue.GetAsText(), wayGDBFileNames, lineFCNameElements[lineFCNameElements.Length - 1], polygonFCNameElements[polygonFCNameElements.Length - 1], lineTagstoExtract, polygonTagstoExtract, ref message,  ref TrackCancel);
                #endregion

                #region for local geodatabases enforce spatial integrity

                bool storedOriginalLocal = geoProcessor.AddOutputsToMap;
                geoProcessor.AddOutputsToMap = false;

                try
                {
                    osmLineFeatureClass = ((IFeatureWorkspace)lineFeatureWorkspace).OpenFeatureClass(lineFCNameElements[lineFCNameElements.Length - 1]);

                    if (osmLineFeatureClass != null)
                    {

                        if (((IDataset)osmLineFeatureClass).Workspace.Type == esriWorkspaceType.esriLocalDatabaseWorkspace)
                        {
                            gpUtilities3 = new GPUtilitiesClass() as IGPUtilities3;

                            IGPParameter outLinesParameter = paramvalues.get_Element(out_osmLinesNumber) as IGPParameter;
                            IGPValue lineFeatureClass = gpUtilities3.UnpackGPValue(outLinesParameter);

                            DataManagementTools.RepairGeometry repairlineGeometry = new DataManagementTools.RepairGeometry(osmLineFeatureClass);

                            IVariantArray repairGeometryParameterArray = new VarArrayClass();
                            repairGeometryParameterArray.Add(lineFeatureClass.GetAsText());
                            repairGeometryParameterArray.Add("DELETE_NULL");

                            gpResults2 = geoProcessor.Execute(repairlineGeometry.ToolName, repairGeometryParameterArray, TrackCancel) as IGeoProcessorResult2;
                            message.AddMessages(gpResults2.GetResultMessages());

                            ComReleaser.ReleaseCOMObject(gpUtilities3);
                        }
                    }
                }
                catch { }
                finally
                {
                    ComReleaser.ReleaseCOMObject(osmLineFeatureClass);
                }

                try
                {
                    osmPolygonFeatureClass = ((IFeatureWorkspace)polygonFeatureWorkspace).OpenFeatureClass(polygonFCNameElements[polygonFCNameElements.Length - 1]);

                    if (osmPolygonFeatureClass != null)
                    {
                        if (((IDataset)osmPolygonFeatureClass).Workspace.Type == esriWorkspaceType.esriLocalDatabaseWorkspace)
                        {
                            gpUtilities3 = new GPUtilitiesClass() as IGPUtilities3;

                            IGPParameter outPolygonParameter = paramvalues.get_Element(out_osmPolygonsNumber) as IGPParameter;
                            IGPValue polygonFeatureClass = gpUtilities3.UnpackGPValue(outPolygonParameter);

                            DataManagementTools.RepairGeometry repairpolygonGeometry = new DataManagementTools.RepairGeometry(osmPolygonFeatureClass);

                            IVariantArray repairGeometryParameterArray = new VarArrayClass();
                            repairGeometryParameterArray.Add(polygonFeatureClass.GetAsText());
                            repairGeometryParameterArray.Add("DELETE_NULL");

                            gpResults2 = geoProcessor.Execute(repairpolygonGeometry.ToolName, repairGeometryParameterArray, TrackCancel) as IGeoProcessorResult2;
                            message.AddMessages(gpResults2.GetResultMessages());

                            ComReleaser.ReleaseCOMObject(gpUtilities3);
                        }
                    }
                }
                catch { }
                finally
                {
                    ComReleaser.ReleaseCOMObject(osmPolygonFeatureClass);
                }

                geoProcessor.AddOutputsToMap = storedOriginalLocal;

                #endregion

                if (TrackCancel.Continue() == false)
                {
                    return;
                }

                #region load relations
                osmToolHelper.loadOSMRelations(relationOSMFileNames, osmLineFeatureClassGPValue.GetAsText(), osmPolygonFeatureClassGPValue.GetAsText(), relationGDBFileNames, lineTagstoExtract, polygonTagstoExtract, ref TrackCancel, ref message);
                #endregion

                // check for user interruption
                if (TrackCancel.Continue() == false)
                {
                    return;
                }

                #region for local geodatabases enforce spatial integrity
                //storedOriginalLocal = geoProcessor.AddOutputsToMap;
                //geoProcessor.AddOutputsToMap = false;

                //try
                //{
                //    osmLineFeatureClass = ((IFeatureWorkspace)lineFeatureWorkspace).OpenFeatureClass(lineFCNameElements[lineFCNameElements.Length - 1]);

                //    if (osmLineFeatureClass != null)
                //    {

                //        if (((IDataset)osmLineFeatureClass).Workspace.Type == esriWorkspaceType.esriLocalDatabaseWorkspace)
                //        {
                //            gpUtilities3 = new GPUtilitiesClass() as IGPUtilities3;

                //            IGPParameter outLinesParameter = paramvalues.get_Element(out_osmLinesNumber) as IGPParameter;
                //            IGPValue lineFeatureClass = gpUtilities3.UnpackGPValue(outLinesParameter);

                //            DataManagementTools.RepairGeometry repairlineGeometry = new DataManagementTools.RepairGeometry(osmLineFeatureClass);

                //            IVariantArray repairGeometryParameterArray = new VarArrayClass();
                //            repairGeometryParameterArray.Add(lineFeatureClass.GetAsText());
                //            repairGeometryParameterArray.Add("DELETE_NULL");

                //            gpResults2 = geoProcessor.Execute(repairlineGeometry.ToolName, repairGeometryParameterArray, TrackCancel) as IGeoProcessorResult2;
                //            message.AddMessages(gpResults2.GetResultMessages());

                //            ComReleaser.ReleaseCOMObject(gpUtilities3);
                //        }
                //    }
                //}
                //catch { }
                //finally
                //{
                //    ComReleaser.ReleaseCOMObject(osmLineFeatureClass);
                //}

                //try
                //{
                //    osmPolygonFeatureClass = ((IFeatureWorkspace)polygonFeatureWorkspace).OpenFeatureClass(polygonFCNameElements[polygonFCNameElements.Length - 1]);

                //    if (osmPolygonFeatureClass != null)
                //    {
                //        if (((IDataset)osmPolygonFeatureClass).Workspace.Type == esriWorkspaceType.esriLocalDatabaseWorkspace)
                //        {
                //            gpUtilities3 = new GPUtilitiesClass() as IGPUtilities3;

                //            IGPParameter outPolygonParameter = paramvalues.get_Element(out_osmPolygonsNumber) as IGPParameter;
                //            IGPValue polygonFeatureClass = gpUtilities3.UnpackGPValue(outPolygonParameter);

                //            DataManagementTools.RepairGeometry repairpolygonGeometry = new DataManagementTools.RepairGeometry(osmPolygonFeatureClass);

                //            IVariantArray repairGeometryParameterArray = new VarArrayClass();
                //            repairGeometryParameterArray.Add(polygonFeatureClass.GetAsText());
                //            repairGeometryParameterArray.Add("DELETE_NULL");

                //            gpResults2 = geoProcessor.Execute(repairpolygonGeometry.ToolName, repairGeometryParameterArray, TrackCancel) as IGeoProcessorResult2;
                //            message.AddMessages(gpResults2.GetResultMessages());

                //            ComReleaser.ReleaseCOMObject(gpUtilities3);
                //        }
                //    }
                //}
                //catch { }
                //finally
                //{
                //    ComReleaser.ReleaseCOMObject(osmPolygonFeatureClass);
                //}

                //geoProcessor.AddOutputsToMap = storedOriginalLocal;

                #endregion

                if (TrackCancel.Continue() == false)
                {
                    return;
                }

                if (deleteSupportingNodesGPValue.Value)
                {
                    message.AddMessage(String.Format(resourceManager.GetString("GPTools_OSMGPMultiLoader_remove_supportNodes")));

                    storedOriginalLocal = geoProcessor.AddOutputsToMap;
                    geoProcessor.AddOutputsToMap = false;

                    // create a layer file to select the points that have attributes
                    osmPointFeatureClass = ((IFeatureWorkspace)pointFeatureWorkspace).OpenFeatureClass(pointFCNameElements[pointFCNameElements.Length - 1]);

                    IVariantArray makeFeatureLayerParameterArray = new VarArrayClass();
                    makeFeatureLayerParameterArray.Add(osmPointsFeatureClassGPValue.GetAsText());

                    string tempLayerFile = System.IO.Path.GetTempFileName();
                    makeFeatureLayerParameterArray.Add(tempLayerFile);
                    makeFeatureLayerParameterArray.Add(String.Format("{0} = 'no'", osmPointFeatureClass.SqlIdentifier("osmSupportingElement")));

                    geoProcessor.Execute("MakeFeatureLayer_management", makeFeatureLayerParameterArray, TrackCancel);

                    // copy the features into its own feature class
                    IVariantArray copyFeatureParametersArray = new VarArrayClass();
                    copyFeatureParametersArray.Add(tempLayerFile);

                    string tempFeatureClass = String.Join("\\", new string[] {
                        ((IWorkspace)pointFeatureWorkspace).PathName, "t_" + pointFCNameElements[pointFCNameElements.Length - 1] });
                    copyFeatureParametersArray.Add(tempFeatureClass);

                    geoProcessor.Execute("CopyFeatures_management", copyFeatureParametersArray, TrackCancel);

                    // delete the temp file
                    System.IO.File.Delete(tempLayerFile);

                    // delete the original feature class
                    IVariantArray deleteParameterArray = new VarArrayClass();
                    deleteParameterArray.Add(osmPointsFeatureClassGPValue.GetAsText());

                    geoProcessor.Execute("Delete_management", deleteParameterArray, TrackCancel);

                    // rename the temp feature class back to the original
                    IVariantArray renameParameterArray = new VarArrayClass();
                    renameParameterArray.Add(tempFeatureClass);
                    renameParameterArray.Add(osmPointsFeatureClassGPValue.GetAsText());

                    geoProcessor.Execute("Rename_management", renameParameterArray, TrackCancel);

                    geoProcessor.AddOutputsToMap = storedOriginalLocal;

                    ComReleaser.ReleaseCOMObject(osmPointFeatureClass);
                    ComReleaser.ReleaseCOMObject(geoProcessor);
                }

                gpUtilities3 = new GPUtilitiesClass() as IGPUtilities3;

                // repackage the feature class into their respective gp values
                IGPParameter pointFeatureClassParameter = paramvalues.get_Element(out_osmPointsNumber) as IGPParameter;
                IGPValue pointFeatureClassGPValue = gpUtilities3.UnpackGPValue(pointFeatureClassParameter);
                gpUtilities3.PackGPValue(pointFeatureClassGPValue, pointFeatureClassParameter);

                IGPParameter lineFeatureClassParameter = paramvalues.get_Element(out_osmLinesNumber) as IGPParameter;
                IGPValue line1FeatureClassGPValue = gpUtilities3.UnpackGPValue(lineFeatureClassParameter);
                gpUtilities3.PackGPValue(line1FeatureClassGPValue, lineFeatureClassParameter);

                IGPParameter polygonFeatureClassParameter = paramvalues.get_Element(out_osmPolygonsNumber) as IGPParameter;
                IGPValue polygon1FeatureClassGPValue = gpUtilities3.UnpackGPValue(polygonFeatureClassParameter);
                gpUtilities3.PackGPValue(polygon1FeatureClassGPValue, polygonFeatureClassParameter);

                ComReleaser.ReleaseCOMObject(osmFileLocationString);

                gpUtilities3.ReleaseInternals();
                ComReleaser.ReleaseCOMObject(gpUtilities3);
            }
            catch (Exception ex)
            {
                message.AddError(120055, ex.Message);
                message.AddError(120055, ex.StackTrace);
            }
            finally
            {
                try
                {
                    osmToolHelper = null;

                    System.GC.Collect();
                    System.GC.WaitForPendingFinalizers();
                }
                catch (Exception ex)
                {
                    message.AddError(120056, ex.ToString());
                }
            }
        }
        public void Execute(ESRI.ArcGIS.esriSystem.IArray paramvalues, ESRI.ArcGIS.esriSystem.ITrackCancel TrackCancel, ESRI.ArcGIS.Geoprocessing.IGPEnvironmentManager envMgr, ESRI.ArcGIS.Geodatabase.IGPMessages message)
        {
            IGPUtilities3 gpUtilities3 = new GPUtilitiesClass();
            OSMToolHelper osmToolHelper = new OSMToolHelper();

            if (TrackCancel == null)
            {
                TrackCancel = new CancelTrackerClass();
            }

            IGPEnvironment configKeyword = OSMToolHelper.getEnvironment(envMgr, "configKeyword");
            IGPString gpString = configKeyword.Value as IGPString;

            string storageKeyword = String.Empty;

            if (gpString != null)
            {
                storageKeyword = gpString.Value;
            }

            IGPParameter osmFileParameter = paramvalues.get_Element(0) as IGPParameter;
            IGPValue osmFileLocationString = gpUtilities3.UnpackGPValue(osmFileParameter) as IGPValue;

            IGPParameter loadSuperRelationParameter = paramvalues.get_Element(1) as IGPParameter;
            IGPBoolean loadSuperRelationGPValue = gpUtilities3.UnpackGPValue(loadSuperRelationParameter) as IGPBoolean;

            IGPParameter osmSourceLineFeatureClassParameter = paramvalues.get_Element(2) as IGPParameter;
            IGPValue osmSourceLineFeatureClassGPValue = gpUtilities3.UnpackGPValue(osmSourceLineFeatureClassParameter) as IGPValue;

            IGPParameter osmSourcePolygonFeatureClassParameter = paramvalues.get_Element(3) as IGPParameter;
            IGPValue osmSourcePolygonFeatureClassGPValue = gpUtilities3.UnpackGPValue(osmSourcePolygonFeatureClassParameter) as IGPValue;

            IGPParameter osmTargetLineFeatureClassParameter = paramvalues.get_Element(6) as IGPParameter;
            IGPValue osmTargetLineFeatureClassGPValue = gpUtilities3.UnpackGPValue(osmTargetLineFeatureClassParameter) as IGPValue;

            IName workspaceName = gpUtilities3.CreateParentFromCatalogPath(osmTargetLineFeatureClassGPValue.GetAsText());
            IWorkspace2 lineFeatureWorkspace = workspaceName.Open() as IWorkspace2;

            string[] lineFCNameElements = osmTargetLineFeatureClassGPValue.GetAsText().Split(System.IO.Path.DirectorySeparatorChar);

            IFeatureClass osmLineFeatureClass = null;

            IGPParameter tagLineCollectionParameter = paramvalues.get_Element(4) as IGPParameter;
            IGPMultiValue tagLineCollectionGPValue = gpUtilities3.UnpackGPValue(tagLineCollectionParameter) as IGPMultiValue;

            List<String> lineTagstoExtract = null;

            if (tagLineCollectionGPValue.Count > 0)
            {
                lineTagstoExtract = new List<string>();

                for (int valueIndex = 0; valueIndex < tagLineCollectionGPValue.Count; valueIndex++)
                {
                    string nameOfTag = tagLineCollectionGPValue.get_Value(valueIndex).GetAsText();

                    lineTagstoExtract.Add(nameOfTag);
                }
            }
            else
            {
                lineTagstoExtract = OSMToolHelper.OSMSmallFeatureClassFields();
            }

            // lines
            try
            {
                osmLineFeatureClass = osmToolHelper.CreateSmallLineFeatureClass(lineFeatureWorkspace,
                    lineFCNameElements[lineFCNameElements.Length - 1], storageKeyword, "", "", lineTagstoExtract);
            }
            catch (Exception ex)
            {
                message.AddError(120035, String.Format(resourceManager.GetString("GPTools_OSMGPDownload_nullpointfeatureclass"), ex.Message));
                return;
            }

            if (osmLineFeatureClass == null)
            {
                return;
            }

            IGPParameter osmTargetPolygonFeatureClassParameter = paramvalues.get_Element(7) as IGPParameter;
            IGPValue osmTargetPolygonFeatureClassGPValue = gpUtilities3.UnpackGPValue(osmTargetPolygonFeatureClassParameter) as IGPValue;

            workspaceName = gpUtilities3.CreateParentFromCatalogPath(osmTargetPolygonFeatureClassGPValue.GetAsText());
            IWorkspace2 polygonFeatureWorkspace = workspaceName.Open() as IWorkspace2;

            string[] polygonFCNameElements = osmTargetPolygonFeatureClassGPValue.GetAsText().Split(System.IO.Path.DirectorySeparatorChar);

            IFeatureClass osmPolygonFeatureClass = null;

            IGPParameter tagPolygonCollectionParameter = paramvalues.get_Element(5) as IGPParameter;
            IGPMultiValue tagPolygonCollectionGPValue = gpUtilities3.UnpackGPValue(tagPolygonCollectionParameter) as IGPMultiValue;

            List<String> polygonTagstoExtract = null;

            if (tagPolygonCollectionGPValue.Count > 0)
            {
                polygonTagstoExtract = new List<string>();

                for (int valueIndex = 0; valueIndex < tagPolygonCollectionGPValue.Count; valueIndex++)
                {
                    string nameOfTag = tagPolygonCollectionGPValue.get_Value(valueIndex).GetAsText();

                    polygonTagstoExtract.Add(nameOfTag);
                }
            }
            else
            {
                polygonTagstoExtract = OSMToolHelper.OSMSmallFeatureClassFields();
            }
            // polygons
            try
            {
                osmPolygonFeatureClass = osmToolHelper.CreateSmallPolygonFeatureClass(polygonFeatureWorkspace,
                    polygonFCNameElements[polygonFCNameElements.Length - 1], storageKeyword, "", "", polygonTagstoExtract);
            }
            catch (Exception ex)
            {
                message.AddError(120035, String.Format(resourceManager.GetString("GPTools_OSMGPDownload_nullpointfeatureclass"), ex.Message));
                return;
            }

            if (osmPolygonFeatureClass == null)
            {
                return;
            }

            ComReleaser.ReleaseCOMObject(osmPolygonFeatureClass);
            ComReleaser.ReleaseCOMObject(osmLineFeatureClass);

            string[] gdbComponents = new string[polygonFCNameElements.Length - 1];
            System.Array.Copy(lineFCNameElements, gdbComponents, lineFCNameElements.Length - 1);
            string fileGDBLocation = String.Join(System.IO.Path.DirectorySeparatorChar.ToString(), gdbComponents);

            osmToolHelper.smallLoadOSMRelations(osmFileLocationString.GetAsText(),
                osmSourceLineFeatureClassGPValue.GetAsText(),
                osmSourcePolygonFeatureClassGPValue.GetAsText(),
                osmTargetLineFeatureClassGPValue.GetAsText(),
                osmTargetPolygonFeatureClassGPValue.GetAsText(),
                lineTagstoExtract, polygonTagstoExtract, loadSuperRelationGPValue.Value);
        }