コード例 #1
0
        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 tagCollectionParameter = paramvalues.get_Element(1) as IGPParameter;
            IGPMultiValue tagCollectionGPValue = gpUtilities3.UnpackGPValue(tagCollectionParameter) as IGPMultiValue;

            List<String> tagstoExtract = null;

            if (tagCollectionGPValue.Count > 0)
            {
                tagstoExtract = new List<string>();

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

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

            IGPParameter useFeatureBufferParameter = paramvalues.get_Element(2) as IGPParameter;
            IGPBoolean useFeatureBufferGPValue = gpUtilities3.UnpackGPValue(useFeatureBufferParameter) as IGPBoolean;

            IGPParameter osmPointsFeatureClassParameter = paramvalues.get_Element(3) 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);

            IFeatureClass osmPointFeatureClass = null;

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

            if (osmPointFeatureClass == null)
            {
                return;
            }

            string[] gdbComponents = new string[pointFCNameElements.Length - 1];
            System.Array.Copy(pointFCNameElements, gdbComponents, pointFCNameElements.Length - 1);
            string fileGDBLocation = String.Join(System.IO.Path.DirectorySeparatorChar.ToString(), gdbComponents);
            osmToolHelper.smallLoadOSMNode(osmFileLocationString.GetAsText(), fileGDBLocation, pointFCNameElements[pointFCNameElements.Length - 1], tagstoExtract, useFeatureBufferGPValue.Value);
        }