/*
         * Constructor for Google Maps API utilities
         */
        public GoogleMapsEngineAPI(ref log4net.ILog log)
        {
            // establish the Google APIs project key
            this.GOOGLE_API_KEY = Properties.Settings.Default.gme_api_key;

            // establish the Google Maps Engine API settings
            this.GME_API_PROTOCOL = Properties.Settings.Default.gme_api_protocol;
            this.GME_API_DOMAIN   = Properties.Settings.Default.gme_api_domain;
            this.GME_API_SERVICE  = Properties.Settings.Default.gme_api_service;
            this.GME_API_VERSION  = Properties.Settings.Default.gme_api_version;

            // set the log
            this.log = log;

            // retrieve a reference to the extension
            log.Debug("Retrieiving a reference to the extension object.");
            ext = GoogleMapsEngineToolsExtensionForArcGIS.GetExtension();

            // create a Google Maps Engine Session Id for this set of sessions
            GoogleMapsEngineAPISessionId = Guid.NewGuid();

            // if debug, create a debug folder to keep track of information
            if (log.IsDebugEnabled)
            {
                // create a temporary folder
                debugDirectory = System.IO.Directory.CreateDirectory(
                    ext.getLocalWorkspaceDirectory()
                    + "\\GME_API_TMP_"
                    + GoogleMapsEngineAPISessionId.ToString().Replace("-", ""));
            }
        }
        /*
         * Constructor for Google Maps API utilities
         */
        public GoogleMapsEngineAPI(ref log4net.ILog log)
        {
            // establish the Google APIs project key
            this.GOOGLE_API_KEY = Properties.Settings.Default.gme_api_key;

            // establish the Google Maps Engine API settings
            this.GME_API_PROTOCOL = Properties.Settings.Default.gme_api_protocol;
            this.GME_API_DOMAIN = Properties.Settings.Default.gme_api_domain;
            this.GME_API_SERVICE = Properties.Settings.Default.gme_api_service;
            this.GME_API_VERSION = Properties.Settings.Default.gme_api_version;

            // set the log
            this.log = log;

            // retrieve a reference to the extension
            log.Debug("Retrieiving a reference to the extension object.");
            ext = GoogleMapsEngineToolsExtensionForArcGIS.GetExtension();

            // create a Google Maps Engine Session Id for this set of sessions
            GoogleMapsEngineAPISessionId = Guid.NewGuid();

            // if debug, create a debug folder to keep track of information
            if (log.IsDebugEnabled)
            {
                // create a temporary folder
                debugDirectory = System.IO.Directory.CreateDirectory(
                    ext.getLocalWorkspaceDirectory() 
                    + "\\GME_API_TMP_" 
                    + GoogleMapsEngineAPISessionId.ToString().Replace("-",""));
            }
        }
 private void populate()
 {
     // populate the temporary storage location
     if (Properties.Settings.Default.temp_storage_location != null && Properties.Settings.Default.temp_storage_location.Length > 0)
     {
         // set the text box string as the properties value
         this.txtDefaultStorageLocation.Text = Properties.Settings.Default.temp_storage_location;
     }
     else
     {
         // the properties value does not exist, use default extension setting
         this.txtDefaultStorageLocation.Text = ext.getLocalWorkspaceDirectory().FullName;
     }
 }
        protected void uploadButtonClicked(String projectId, String name, String description, String tags, String aclName, String attribution)
        {
            try
            {
                // create a new Processing Dialog
                Dialogs.Processing.ProgressDialog processingDialog = new Processing.ProgressDialog();

                // check to see if the layer is valid
                // and destination is configured correctly
                if (isLayerValidated &&
                    projectId != null && projectId.Length > 0 &&
                    name != null && name.Length > 0 &&
                    aclName != null && aclName.Length > 0)
                {
                    // show the processing dialog
                    processingDialog.Show();

                    // create a reference to the Google Maps Engine API
                    MapsEngine.API.GoogleMapsEngineAPI api = new MapsEngine.API.GoogleMapsEngineAPI(ref log);

                    // establish a reference to the running ArcMap instance
                    ESRI.ArcGIS.ArcMapUI.IMxDocument mxDoc = (ESRI.ArcGIS.ArcMapUI.IMxDocument)ArcMap.Application.Document;

                    // retrieve a reference to the selected layer
                    ESRI.ArcGIS.Carto.ILayer selectedLayer = mxDoc.SelectedLayer;

                    // create a temporary working directory
                    System.IO.DirectoryInfo tempDir
                        = System.IO.Directory.CreateDirectory(ext.getLocalWorkspaceDirectory() + "\\" + System.Guid.NewGuid());

                    // determine what type of layer is selected
                    if (selectedLayer is ESRI.ArcGIS.Carto.IFeatureLayer)
                    {
                        // export a copy of the feature class to a "uploadable" Shapefile
                        // raise a processing notification
                        ext.publishRaiseDownloadProgressChangeEvent(false, "Extracting a copy of '" + selectedLayer.Name + "' (feature class) for data upload.");
                        ExportLayerToShapefile(tempDir.FullName, selectedLayer.Name, selectedLayer);

                        processingDialog.Update();
                        processingDialog.Focus();

                        // create a list of files in the temp directory
                        List <String> filesNames = new List <String>();
                        for (int k = 0; k < tempDir.GetFiles().Count(); k++)
                        {
                            if (!tempDir.GetFiles()[k].Name.EndsWith(".lock"))
                            {
                                filesNames.Add(tempDir.GetFiles()[k].Name);
                            }
                        }

                        // create a Google Maps Engine asset record
                        ext.publishRaiseDownloadProgressChangeEvent(false, "Requesting a new Google Maps Engine asset be created.");
                        MapsEngine.DataModel.gme.UploadingAsset uploadingAsset
                            = api.createVectorTableAssetForUploading(ext.getToken(),
                                                                     MapsEngine.API.GoogleMapsEngineAPI.AssetType.table,
                                                                     projectId,
                                                                     name,
                                                                     aclName,
                                                                     filesNames,
                                                                     description,
                                                                     tags.Split(",".ToCharArray()).ToList <String>(),
                                                                     "UTF-8");

                        // Initiate upload of file(s)
                        ext.publishRaiseDownloadProgressChangeEvent(false, "Starting to upload files...");
                        api.uploadFilesToAsset(ext.getToken(), uploadingAsset.id, tempDir.GetFiles());

                        // launch a web browser
                        ext.publishRaiseDownloadProgressChangeEvent(false, "Launching a web browser.");
                        System.Diagnostics.Process.Start("https://mapsengine.google.com/admin/#RepositoryPlace:cid=" + projectId + "&v=DETAIL_INFO&aid=" + uploadingAsset.id);
                    }
                    else if (selectedLayer is ESRI.ArcGIS.Carto.IRasterLayer)
                    {
                        // export a copy of the raster to a format that can be uploaded
                        // raise a processing notification
                        ext.publishRaiseDownloadProgressChangeEvent(false, "Extracting a copy of '" + selectedLayer.Name + "' (raster) for data upload.");
                        ExportLayerToUploadableRaster(tempDir.FullName, tempDir.Name, selectedLayer);

                        processingDialog.Update();
                        processingDialog.Focus();

                        // create a list of files in the temp directory
                        List <String> filesNames = new List <String>();
                        for (int k = 0; k < tempDir.GetFiles().Count(); k++)
                        {
                            if (!tempDir.GetFiles()[k].Name.EndsWith(".lock"))
                            {
                                filesNames.Add(tempDir.GetFiles()[k].Name);
                            }
                        }

                        // create a Google Maps Engine asset record
                        ext.publishRaiseDownloadProgressChangeEvent(false, "Requesting a new Google Maps Engine asset be created.");
                        MapsEngine.DataModel.gme.UploadingAsset uploadingAsset
                            = api.createRasterAssetForUploading(ext.getToken(),
                                                                projectId,
                                                                name,
                                                                aclName,
                                                                attribution, // attribution
                                                                filesNames,
                                                                description,
                                                                tags.Split(",".ToCharArray()).ToList <String>());

                        // Initiate upload of file(s)
                        ext.publishRaiseDownloadProgressChangeEvent(false, "Starting to upload files...");
                        api.uploadFilesToAsset(ext.getToken(), uploadingAsset.id, tempDir.GetFiles());

                        // launch a web browser
                        ext.publishRaiseDownloadProgressChangeEvent(false, "Launching a web browser.");
                        System.Diagnostics.Process.Start("https://mapsengine.google.com/admin/#RepositoryPlace:cid=" + projectId + "&v=DETAIL_INFO&aid=" + uploadingAsset.id);
                    }

                    // Delete temporary directory and containing files
                    // TODO: Remove temporary files, but can't remove them at the moment because they are in use by
                    // the ArcMap seesion.
                    //tempDir.Delete(true);

                    // close the processing dialog
                    ext.publishRaiseDownloadProgressChangeEvent(true, "Finished");
                    processingDialog.Close();
                }
                else
                {
                    // display an error dialog to the user
                    System.Windows.Forms.MessageBox.Show("The selected layer is invalid or the destination configuration has not been properly set.");
                }
            }
            catch (System.Exception ex)
            {
                // Ops.
                System.Windows.Forms.MessageBox.Show("An error occured. " + ex.Message);
            }

            // close the dialog
            this.Close();
        }
        public static IFeatureClass createGoogleMapsEngineCatalogFeatureClass(ref log4net.ILog log, ref GoogleMapsEngineToolsExtensionForArcGIS ext)
        {
            try
            {
                // temporary directory to store workspace 
                string workspacedirectory = ext.getLocalWorkspaceDirectory().FullName;

                // add the directory to the cleanup list
                // TODO: Replace with scratch
                ext.addTemporaryDirectory(new System.IO.DirectoryInfo(workspacedirectory));

                // determine the workspace name for the geodatabase
                //string workspacefoldername = Properties.Settings.Default.extension_gdb_workspacename;
                // TODO: Use sctach workspace instead of creating a temporary one
                string workspacefoldername = "GME_Data_" + System.Guid.NewGuid().ToString().Replace("-", "");

                // define a workspace to do work
                IWorkspace workspace = null;

                // attempt to open or create the workspace
                try
                {
                    // check to see if the workspace already exists, if so, open it
                    if (System.IO.Directory.Exists(workspacedirectory + "\\" + workspacefoldername))
                    {
                        workspace = Extension.Data.GeodatabaseUtilities.openFileGeodatabaseWorkspace(ref log, workspacedirectory, workspacefoldername);
                        ESRI.ArcGIS.Geodatabase.IFeatureWorkspace featureWorkspace = (ESRI.ArcGIS.Geodatabase.IFeatureWorkspace)workspace;
                        ESRI.ArcGIS.Geodatabase.IFeatureClass featureClass = featureWorkspace.OpenFeatureClass(Properties.Resources.GeodatabaseUtilities_schema_FeatureClassName);
                        ESRI.ArcGIS.Geodatabase.IDataset pdataset = (ESRI.ArcGIS.Geodatabase.IDataset)featureClass;
                        if (pdataset.CanDelete())
                            pdataset.Delete();

                        pdataset = null;
                        featureClass = null;
                        featureWorkspace = null;

                        // TODO: Open instead of delete/replace
                        //if (arcgis.ext.gdb.GeodatabaseUtilities.deleteFileGeodatabaseWorkspace(workspacedirectory, workspacefoldername))
                        //workspace = arcgis.ext.gdb.GeodatabaseUtilities.createFileGeodatabaseWorkspace(workspacedirectory, workspacefoldername);
                    }
                    else
                    {
                        // workspace doesn't exist, create the workspace
                        workspace = Extension.Data.GeodatabaseUtilities.createFileGeodatabaseWorkspace(ref log, workspacedirectory, workspacefoldername);
                    }
                }
                catch (System.Exception ex)
                {
                    // unable to create the fgdb or unable to delete the fc within the fgdb
                    log.Error(ex);
                    System.Windows.Forms.MessageBox.Show("Unable to create or delete an existing feature class.");
                }

                // verify the workspace is open
                if (workspace != null)
                {
                    // create a new feature workspace to work spatially
                    IFeatureWorkspace featureWorkspace = workspace as IFeatureWorkspace;

                    // create a spatial reference for the Google Earth Builder data (always in 4326)
                    SpatialReferenceEnvironment sRefEnvGEB = new SpatialReferenceEnvironment();
                    ISpatialReference sGEBRef = sRefEnvGEB.CreateGeographicCoordinateSystem(4326);

                    // for this feature class, create and determine the field
                    IFields fields = new FieldsClass();
                    IFieldsEdit fieldsEdit = (IFieldsEdit)fields;
                    fieldsEdit.FieldCount_2 = 10;

                    //Create the Object ID field.
                    IField fusrDefinedField = new Field();
                    IFieldEdit fusrDefinedFieldEdit = (IFieldEdit)fusrDefinedField;
                    fusrDefinedFieldEdit.Name_2 = Properties.Resources.GeodatabaseUtilities_schema_OBJECTID_Name;
                    fusrDefinedFieldEdit.AliasName_2 = Properties.Resources.GeodatabaseUtilities_schema_OBJECTID_AliasName;
                    fusrDefinedFieldEdit.Type_2 = esriFieldType.esriFieldTypeOID;
                    fieldsEdit.set_Field(0, fusrDefinedField);

                    //Create the CustomerId field.
                    fusrDefinedField = new Field();
                    fusrDefinedFieldEdit = (IFieldEdit)fusrDefinedField;
                    fusrDefinedFieldEdit.Name_2 = Properties.Resources.GeodatabaseUtilities_schema_CustomerId_Name;
                    fusrDefinedFieldEdit.AliasName_2 = Properties.Resources.GeodatabaseUtilities_schema_CustomerId_AliasName;
                    fusrDefinedFieldEdit.Type_2 = esriFieldType.esriFieldTypeString;
                    fieldsEdit.set_Field(1, fusrDefinedField);

                    //Create the MapAssetId field.
                    fusrDefinedField = new Field();
                    fusrDefinedFieldEdit = (IFieldEdit)fusrDefinedField;
                    fusrDefinedFieldEdit.Name_2 = Properties.Resources.GeodatabaseUtilities_schema_MapAssetId_Name;
                    fusrDefinedFieldEdit.AliasName_2 = Properties.Resources.GeodatabaseUtilities_schema_MapAssetId_AliasName;
                    fusrDefinedFieldEdit.Type_2 = esriFieldType.esriFieldTypeString;
                    fieldsEdit.set_Field(2, fusrDefinedField);

                    //Create the AssetId field.
                    fusrDefinedField = new Field();
                    fusrDefinedFieldEdit = (IFieldEdit)fusrDefinedField;
                    fusrDefinedFieldEdit.Name_2 = Properties.Resources.GeodatabaseUtilities_schema_AssetId_Name;
                    fusrDefinedFieldEdit.AliasName_2 = Properties.Resources.GeodatabaseUtilities_schema_AssetId_AliasName;
                    fusrDefinedFieldEdit.Type_2 = esriFieldType.esriFieldTypeString;
                    fieldsEdit.set_Field(3, fusrDefinedField);

                    //Create the ParentAssetId field.
                    fusrDefinedField = new Field();
                    fusrDefinedFieldEdit = (IFieldEdit)fusrDefinedField;
                    fusrDefinedFieldEdit.Name_2 = Properties.Resources.GeodatabaseUtilities_schema_ParentAssetId_Name;
                    fusrDefinedFieldEdit.AliasName_2 = Properties.Resources.GeodatabaseUtilities_schema_ParentAssetId_AliasName;
                    fusrDefinedFieldEdit.Type_2 = esriFieldType.esriFieldTypeString;
                    fieldsEdit.set_Field(4, fusrDefinedField);

                    //Create the AssetType field.
                    fusrDefinedField = new Field();
                    fusrDefinedFieldEdit = (IFieldEdit)fusrDefinedField;
                    fusrDefinedFieldEdit.Name_2 = Properties.Resources.GeodatabaseUtilities_schema_AssetType_Name;
                    fusrDefinedFieldEdit.AliasName_2 = Properties.Resources.GeodatabaseUtilities_schema_AssetType_AliasName;
                    fusrDefinedFieldEdit.Type_2 = esriFieldType.esriFieldTypeString;
                    fieldsEdit.set_Field(5, fusrDefinedField);

                    //Create the AssetName field.
                    fusrDefinedField = new Field();
                    fusrDefinedFieldEdit = (IFieldEdit)fusrDefinedField;
                    fusrDefinedFieldEdit.Name_2 = Properties.Resources.GeodatabaseUtilities_schema_AssetName_Name;
                    fusrDefinedFieldEdit.AliasName_2 = Properties.Resources.GeodatabaseUtilities_schema_AssetName_AliasName;
                    fusrDefinedFieldEdit.Type_2 = esriFieldType.esriFieldTypeString;
                    fieldsEdit.set_Field(6, fusrDefinedField);

                    //Create the AssetDescription field.
                    fusrDefinedField = new Field();
                    fusrDefinedFieldEdit = (IFieldEdit)fusrDefinedField;
                    fusrDefinedFieldEdit.Name_2 = Properties.Resources.GeodatabaseUtilities_schema_AssetDescription_Name;
                    fusrDefinedFieldEdit.AliasName_2 = Properties.Resources.GeodatabaseUtilities_schema_AssetDescription_AliasName;
                    fusrDefinedFieldEdit.Type_2 = esriFieldType.esriFieldTypeString;
                    fieldsEdit.set_Field(7, fusrDefinedField);

                    //Create the MapSharedWith field.
                    fusrDefinedField = new Field();
                    fusrDefinedFieldEdit = (IFieldEdit)fusrDefinedField;
                    fusrDefinedFieldEdit.Name_2 = Properties.Resources.GeodatabaseUtilities_schema_MapSharedWith_Name;
                    fusrDefinedFieldEdit.AliasName_2 = Properties.Resources.GeodatabaseUtilities_schema_MapSharedWith_AliasName;
                    fusrDefinedFieldEdit.Type_2 = esriFieldType.esriFieldTypeString;
                    fieldsEdit.set_Field(8, fusrDefinedField);

                    // Create the Shape field.
                    fusrDefinedField = new Field();
                    fusrDefinedFieldEdit = (IFieldEdit)fusrDefinedField;
                    // Set up the geometry definition for the Shape field.
                    IGeometryDef geometryDef = new GeometryDefClass();
                    IGeometryDefEdit geometryDefEdit = (IGeometryDefEdit)geometryDef;
                    geometryDefEdit.GeometryType_2 = ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon;
                    // By setting the grid size to 0, you're allowing ArcGIS to determine the appropriate grid sizes for the feature class. 
                    // If in a personal geodatabase, the grid size will be 1000. If in a file or ArcSDE geodatabase, the grid size
                    // will be based on the initial loading or inserting of features.
                    geometryDefEdit.GridCount_2 = 1;
                    geometryDefEdit.set_GridSize(0, 0);
                    geometryDefEdit.HasM_2 = false;
                    geometryDefEdit.HasZ_2 = false;
                    //Assign the spatial reference that was passed in, possibly from
                    //IGeodatabase.SpatialReference for the containing feature dataset.
                    geometryDefEdit.SpatialReference_2 = sGEBRef;
                    // Set standard field properties.
                    fusrDefinedFieldEdit.Name_2 = "SHAPE";
                    fusrDefinedFieldEdit.Type_2 = esriFieldType.esriFieldTypeGeometry;
                    fusrDefinedFieldEdit.GeometryDef_2 = geometryDef;
                    fusrDefinedFieldEdit.IsNullable_2 = true;
                    fusrDefinedFieldEdit.Required_2 = true;
                    fieldsEdit.set_Field(9, fusrDefinedField);

                    // Create a feature class description object to use for specifying the CLSID and EXTCLSID.
                    IFeatureClassDescription fcDesc = new FeatureClassDescriptionClass();
                    IObjectClassDescription ocDesc = (IObjectClassDescription)fcDesc;

                    IFeatureClass fc = featureWorkspace.CreateFeatureClass(
                        Properties.Resources.GeodatabaseUtilities_schema_FeatureClassName, // Feature Class Name
                        fields, // Feature Class Fields (defined above)
                        ocDesc.InstanceCLSID, 
                        ocDesc.ClassExtensionCLSID, 
                        esriFeatureType.esriFTSimple, 
                        fcDesc.ShapeFieldName, // Shape Field Name
                        "" // Keyword Configurations
                        );

                    // return the feature class
                    return fc;
                }
                else
                {
                    // end gracefully, maybe prompt the user that the toolbar wasn't able to create a workspcae
                    throw new Exception("Unable to open local geodatabase.");
                }
            }
            catch (System.Exception ex)
            {
                // an error occured
                log.Error(ex);

                // throw an exception
                throw new Exception("An unknown exception occured while attempting to create a local feature class.");
            }
        }
Esempio n. 6
0
        public static IFeatureClass createGoogleMapsEngineCatalogFeatureClass(ref log4net.ILog log, ref GoogleMapsEngineToolsExtensionForArcGIS ext)
        {
            try
            {
                // temporary directory to store workspace
                string workspacedirectory = ext.getLocalWorkspaceDirectory().FullName;

                // add the directory to the cleanup list
                // TODO: Replace with scratch
                ext.addTemporaryDirectory(new System.IO.DirectoryInfo(workspacedirectory));

                // determine the workspace name for the geodatabase
                //string workspacefoldername = Properties.Settings.Default.extension_gdb_workspacename;
                // TODO: Use sctach workspace instead of creating a temporary one
                string workspacefoldername = "GME_Data_" + System.Guid.NewGuid().ToString().Replace("-", "");

                // define a workspace to do work
                IWorkspace workspace = null;

                // attempt to open or create the workspace
                try
                {
                    // check to see if the workspace already exists, if so, open it
                    if (System.IO.Directory.Exists(workspacedirectory + "\\" + workspacefoldername))
                    {
                        workspace = Extension.Data.GeodatabaseUtilities.openFileGeodatabaseWorkspace(ref log, workspacedirectory, workspacefoldername);
                        ESRI.ArcGIS.Geodatabase.IFeatureWorkspace featureWorkspace = (ESRI.ArcGIS.Geodatabase.IFeatureWorkspace)workspace;
                        ESRI.ArcGIS.Geodatabase.IFeatureClass     featureClass     = featureWorkspace.OpenFeatureClass(Properties.Resources.GeodatabaseUtilities_schema_FeatureClassName);
                        ESRI.ArcGIS.Geodatabase.IDataset          pdataset         = (ESRI.ArcGIS.Geodatabase.IDataset)featureClass;
                        if (pdataset.CanDelete())
                        {
                            pdataset.Delete();
                        }

                        pdataset         = null;
                        featureClass     = null;
                        featureWorkspace = null;

                        // TODO: Open instead of delete/replace
                        //if (arcgis.ext.gdb.GeodatabaseUtilities.deleteFileGeodatabaseWorkspace(workspacedirectory, workspacefoldername))
                        //workspace = arcgis.ext.gdb.GeodatabaseUtilities.createFileGeodatabaseWorkspace(workspacedirectory, workspacefoldername);
                    }
                    else
                    {
                        // workspace doesn't exist, create the workspace
                        workspace = Extension.Data.GeodatabaseUtilities.createFileGeodatabaseWorkspace(ref log, workspacedirectory, workspacefoldername);
                    }
                }
                catch (System.Exception ex)
                {
                    // unable to create the fgdb or unable to delete the fc within the fgdb
                    log.Error(ex);
                    System.Windows.Forms.MessageBox.Show("Unable to create or delete an existing feature class.");
                }

                // verify the workspace is open
                if (workspace != null)
                {
                    // create a new feature workspace to work spatially
                    IFeatureWorkspace featureWorkspace = workspace as IFeatureWorkspace;

                    // create a spatial reference for the Google Earth Builder data (always in 4326)
                    SpatialReferenceEnvironment sRefEnvGEB = new SpatialReferenceEnvironment();
                    ISpatialReference           sGEBRef    = sRefEnvGEB.CreateGeographicCoordinateSystem(4326);

                    // for this feature class, create and determine the field
                    IFields     fields     = new FieldsClass();
                    IFieldsEdit fieldsEdit = (IFieldsEdit)fields;
                    fieldsEdit.FieldCount_2 = 10;

                    //Create the Object ID field.
                    IField     fusrDefinedField     = new Field();
                    IFieldEdit fusrDefinedFieldEdit = (IFieldEdit)fusrDefinedField;
                    fusrDefinedFieldEdit.Name_2      = Properties.Resources.GeodatabaseUtilities_schema_OBJECTID_Name;
                    fusrDefinedFieldEdit.AliasName_2 = Properties.Resources.GeodatabaseUtilities_schema_OBJECTID_AliasName;
                    fusrDefinedFieldEdit.Type_2      = esriFieldType.esriFieldTypeOID;
                    fieldsEdit.set_Field(0, fusrDefinedField);

                    //Create the CustomerId field.
                    fusrDefinedField                 = new Field();
                    fusrDefinedFieldEdit             = (IFieldEdit)fusrDefinedField;
                    fusrDefinedFieldEdit.Name_2      = Properties.Resources.GeodatabaseUtilities_schema_CustomerId_Name;
                    fusrDefinedFieldEdit.AliasName_2 = Properties.Resources.GeodatabaseUtilities_schema_CustomerId_AliasName;
                    fusrDefinedFieldEdit.Type_2      = esriFieldType.esriFieldTypeString;
                    fieldsEdit.set_Field(1, fusrDefinedField);

                    //Create the MapAssetId field.
                    fusrDefinedField                 = new Field();
                    fusrDefinedFieldEdit             = (IFieldEdit)fusrDefinedField;
                    fusrDefinedFieldEdit.Name_2      = Properties.Resources.GeodatabaseUtilities_schema_MapAssetId_Name;
                    fusrDefinedFieldEdit.AliasName_2 = Properties.Resources.GeodatabaseUtilities_schema_MapAssetId_AliasName;
                    fusrDefinedFieldEdit.Type_2      = esriFieldType.esriFieldTypeString;
                    fieldsEdit.set_Field(2, fusrDefinedField);

                    //Create the AssetId field.
                    fusrDefinedField                 = new Field();
                    fusrDefinedFieldEdit             = (IFieldEdit)fusrDefinedField;
                    fusrDefinedFieldEdit.Name_2      = Properties.Resources.GeodatabaseUtilities_schema_AssetId_Name;
                    fusrDefinedFieldEdit.AliasName_2 = Properties.Resources.GeodatabaseUtilities_schema_AssetId_AliasName;
                    fusrDefinedFieldEdit.Type_2      = esriFieldType.esriFieldTypeString;
                    fieldsEdit.set_Field(3, fusrDefinedField);

                    //Create the ParentAssetId field.
                    fusrDefinedField                 = new Field();
                    fusrDefinedFieldEdit             = (IFieldEdit)fusrDefinedField;
                    fusrDefinedFieldEdit.Name_2      = Properties.Resources.GeodatabaseUtilities_schema_ParentAssetId_Name;
                    fusrDefinedFieldEdit.AliasName_2 = Properties.Resources.GeodatabaseUtilities_schema_ParentAssetId_AliasName;
                    fusrDefinedFieldEdit.Type_2      = esriFieldType.esriFieldTypeString;
                    fieldsEdit.set_Field(4, fusrDefinedField);

                    //Create the AssetType field.
                    fusrDefinedField                 = new Field();
                    fusrDefinedFieldEdit             = (IFieldEdit)fusrDefinedField;
                    fusrDefinedFieldEdit.Name_2      = Properties.Resources.GeodatabaseUtilities_schema_AssetType_Name;
                    fusrDefinedFieldEdit.AliasName_2 = Properties.Resources.GeodatabaseUtilities_schema_AssetType_AliasName;
                    fusrDefinedFieldEdit.Type_2      = esriFieldType.esriFieldTypeString;
                    fieldsEdit.set_Field(5, fusrDefinedField);

                    //Create the AssetName field.
                    fusrDefinedField                 = new Field();
                    fusrDefinedFieldEdit             = (IFieldEdit)fusrDefinedField;
                    fusrDefinedFieldEdit.Name_2      = Properties.Resources.GeodatabaseUtilities_schema_AssetName_Name;
                    fusrDefinedFieldEdit.AliasName_2 = Properties.Resources.GeodatabaseUtilities_schema_AssetName_AliasName;
                    fusrDefinedFieldEdit.Type_2      = esriFieldType.esriFieldTypeString;
                    fieldsEdit.set_Field(6, fusrDefinedField);

                    //Create the AssetDescription field.
                    fusrDefinedField                 = new Field();
                    fusrDefinedFieldEdit             = (IFieldEdit)fusrDefinedField;
                    fusrDefinedFieldEdit.Name_2      = Properties.Resources.GeodatabaseUtilities_schema_AssetDescription_Name;
                    fusrDefinedFieldEdit.AliasName_2 = Properties.Resources.GeodatabaseUtilities_schema_AssetDescription_AliasName;
                    fusrDefinedFieldEdit.Type_2      = esriFieldType.esriFieldTypeString;
                    fieldsEdit.set_Field(7, fusrDefinedField);

                    //Create the MapSharedWith field.
                    fusrDefinedField                 = new Field();
                    fusrDefinedFieldEdit             = (IFieldEdit)fusrDefinedField;
                    fusrDefinedFieldEdit.Name_2      = Properties.Resources.GeodatabaseUtilities_schema_MapSharedWith_Name;
                    fusrDefinedFieldEdit.AliasName_2 = Properties.Resources.GeodatabaseUtilities_schema_MapSharedWith_AliasName;
                    fusrDefinedFieldEdit.Type_2      = esriFieldType.esriFieldTypeString;
                    fieldsEdit.set_Field(8, fusrDefinedField);

                    // Create the Shape field.
                    fusrDefinedField     = new Field();
                    fusrDefinedFieldEdit = (IFieldEdit)fusrDefinedField;
                    // Set up the geometry definition for the Shape field.
                    IGeometryDef     geometryDef     = new GeometryDefClass();
                    IGeometryDefEdit geometryDefEdit = (IGeometryDefEdit)geometryDef;
                    geometryDefEdit.GeometryType_2 = ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon;
                    // By setting the grid size to 0, you're allowing ArcGIS to determine the appropriate grid sizes for the feature class.
                    // If in a personal geodatabase, the grid size will be 1000. If in a file or ArcSDE geodatabase, the grid size
                    // will be based on the initial loading or inserting of features.
                    geometryDefEdit.GridCount_2 = 1;
                    geometryDefEdit.set_GridSize(0, 0);
                    geometryDefEdit.HasM_2 = false;
                    geometryDefEdit.HasZ_2 = false;
                    //Assign the spatial reference that was passed in, possibly from
                    //IGeodatabase.SpatialReference for the containing feature dataset.
                    geometryDefEdit.SpatialReference_2 = sGEBRef;
                    // Set standard field properties.
                    fusrDefinedFieldEdit.Name_2        = "SHAPE";
                    fusrDefinedFieldEdit.Type_2        = esriFieldType.esriFieldTypeGeometry;
                    fusrDefinedFieldEdit.GeometryDef_2 = geometryDef;
                    fusrDefinedFieldEdit.IsNullable_2  = true;
                    fusrDefinedFieldEdit.Required_2    = true;
                    fieldsEdit.set_Field(9, fusrDefinedField);

                    // Create a feature class description object to use for specifying the CLSID and EXTCLSID.
                    IFeatureClassDescription fcDesc = new FeatureClassDescriptionClass();
                    IObjectClassDescription  ocDesc = (IObjectClassDescription)fcDesc;

                    IFeatureClass fc = featureWorkspace.CreateFeatureClass(
                        Properties.Resources.GeodatabaseUtilities_schema_FeatureClassName, // Feature Class Name
                        fields,                                                            // Feature Class Fields (defined above)
                        ocDesc.InstanceCLSID,
                        ocDesc.ClassExtensionCLSID,
                        esriFeatureType.esriFTSimple,
                        fcDesc.ShapeFieldName, // Shape Field Name
                        ""                     // Keyword Configurations
                        );

                    // return the feature class
                    return(fc);
                }
                else
                {
                    // end gracefully, maybe prompt the user that the toolbar wasn't able to create a workspcae
                    throw new Exception("Unable to open local geodatabase.");
                }
            }
            catch (System.Exception ex)
            {
                // an error occured
                log.Error(ex);

                // throw an exception
                throw new Exception("An unknown exception occured while attempting to create a local feature class.");
            }
        }