コード例 #1
0
        /// <summary>
        /// Import an SIT formatted dataset.
        /// mdb, accdb, xls, or xlsx are supported
        /// </summary>
        private static void Method1()
        {
            string excelPath   = @"C:\Program Files (x86)\Operational-Scale CBM-CFS3\Tutorials\Tutorial 6\Tutorial6.xls";
            string projectPath = @"C:\Program Files (x86)\Operational-Scale CBM-CFS3\Projects\tutorial6\tutorial6.mdb";

            var data = Sitplugin.ParseSITData(
                path: excelPath,
                AgeClassTableName: "AgeClasses$",
                ClassifiersTableName: "Classifiers$",
                DisturbanceEventsTableName: "DistEvents$",
                DisturbanceTypesTableName: "DistType$",
                InventoryTableName: "Inventory$",
                TransitionRulesTableName: "Transitions$",
                YieldTableName: "Growth$");

            Sitplugin sitplugin = new Sitplugin(
                outputPath: projectPath,
                initializeMapping: false,
                dataset: data);

            sitplugin.SetSingleSpatialUnit(42);
            //see archive index tblSPUDefault/tblAdminBoundaryDefault/tblEcoBoundaryDefault for code definitions

            sitplugin.SetSpeciesClassifier("Species");//the classifier name as defined in the spreadsheet
            sitplugin.SetNonForestClassifier("Forest type");

            // in the following mappings, the left value is something that appears in the import data,
            // and the right value is something that appears in the archive index database.
            sitplugin.MapSpecies("Hispaniolan pine", "Pine");
            sitplugin.MapSpecies("Nonforest", "Not stocked");
            sitplugin.MapSpecies("Improved pine stock", "Pine");

            sitplugin.MapNonForest("Afforestation", "Gleysolic");
            sitplugin.MapNonForest("Natural forest", Sitplugin.ForestOnly);
            sitplugin.MapNonForest("Control", Sitplugin.ForestOnly);

            sitplugin.MapDisturbanceType("Fire", "Wildfire");
            sitplugin.MapDisturbanceType("Firewood collection", "Firewood Collection - post logging");
            sitplugin.MapDisturbanceType("Clearcut", "Clear-cut with slash-burn");
            sitplugin.MapDisturbanceType("Afforestation", "Afforestation");
            sitplugin.MapDisturbanceType("Hurricane", "Generic 50% mortality");


            sitplugin.Import();
        }
コード例 #2
0
 private static void MapNonForest(Sitplugin sitplugin, JToken mappingConfig)
 {
     if (mappingConfig == null || !mappingConfig.HasValues)
     {
         return;
     }
     sitplugin.SetNonForestClassifier((string)mappingConfig["nonforest_classifier"]);
     foreach (var item in mappingConfig["nonforest_mapping"])
     {
         var default_nonforest_type = (string)item["default_nonforest_type"];
         if (default_nonforest_type == null)
         {
             //allow null here so that users are not forced
             //to look up and use the localized "Forest Only" magic string
             default_nonforest_type = Sitplugin.ForestOnly;
         }
         sitplugin.MapNonForest((string)item["user_nonforest_type"], default_nonforest_type);
     }
 }