// *********** Command Line Error Codes & Meaning ************* /// <summary> /// Copies feature from inputFeatureClassString to Military Feature destinationGeodatabase /// Set the Representation Rule ID based on sidcFieldName field /// </summary> /// <returns>Success: True/False</returns> public bool Process(string inputFeatureClassString, string destinationGeodatabase, string sidcFieldName, string standard) { bool success = false; string installPath = new System.IO.FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).DirectoryName; string sidcToFeatureClassRulesDataFile = System.IO.Path.Combine(installPath, @"Data\SymbolIDToFeatureClassRules.xml"); string fieldMappingDataFile = System.IO.Path.Combine(installPath, @"Data\FieldMapping.xml"); InitializeFieldMapping(fieldMappingDataFile); mapper = new SicToFeatureClassMapper(sidcToFeatureClassRulesDataFile); if (!mapper.Initialized) { lastErrorCode = 0; detailedErrorMessage = "Failed to load mapping data file " + sidcToFeatureClassRulesDataFile; Console.WriteLine(detailedErrorMessage); return(false); } IFeatureClass inputFeatureClass = getFeatureClassFromName(inputFeatureClassString); if (inputFeatureClass == null) { lastErrorCode = 2; detailedErrorMessage = "Could not open Input Feature Class: " + inputFeatureClassString; Console.WriteLine(detailedErrorMessage); return(false); } if (inputFeatureClass.FindField(sidcFieldName) < 0) { lastErrorCode = 6; detailedErrorMessage = "Could not find [SIDC] field: " + sidcFieldName + " in Input Feature Class: " + inputFeatureClassString; Console.WriteLine(detailedErrorMessage); return(false); } HashSet <string> matchedRules = getMatchedRules(inputFeatureClass, sidcFieldName); if (matchedRules.Count <= 0) { lastErrorCode = 3; detailedErrorMessage = "No matching military features found in input: " + inputFeatureClassString; Console.WriteLine(detailedErrorMessage); return(false); } militaryFeatures = new MilitaryFeatureClassHelper(); militaryFeatures.FullWorkspacePath = destinationGeodatabase; IFeatureWorkspace ws = militaryFeatures.Workspace; if (!militaryFeatures.Initialized) { lastErrorCode = 4; detailedErrorMessage = "Output Workspace could not be found/opened: " + destinationGeodatabase; Console.WriteLine(detailedErrorMessage); return(false); } symbolCreator = new SymbolCreator(standard); bool initialized = symbolCreator.Initialize(); if (!initialized) { lastErrorCode = 7; detailedErrorMessage = "Could not load required Style Files. Check ArcGIS/Styles folder."; Console.WriteLine("Failed to initialize - could not load required Style Files"); return(false); } // where the main work is done of updating the output success = updateMatchedRules(matchedRules, inputFeatureClass, sidcFieldName); return(success); }
// *********** Command Line Error Codes & Meaning ************* /// <summary> /// Copies feature from inputFeatureClassString to Military Feature destinationGeodatabase /// Set the Representation Rule ID based on sidcFieldName field /// </summary> /// <returns>Success: True/False</returns> public bool Process(string inputFeatureClassString, string destinationGeodatabase, string sidcFieldName, string standard) { bool success = false; string installPath = new System.IO.FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).DirectoryName; string sidcToFeatureClassRulesDataFile = System.IO.Path.Combine(installPath, @"Data\SymbolIDToFeatureClassRules.xml"); string fieldMappingDataFile = System.IO.Path.Combine(installPath, @"Data\FieldMapping.xml"); InitializeFieldMapping(fieldMappingDataFile); mapper = new SicToFeatureClassMapper(sidcToFeatureClassRulesDataFile); if (!mapper.Initialized) { lastErrorCode = 0; detailedErrorMessage = "Failed to load mapping data file " + sidcToFeatureClassRulesDataFile; Console.WriteLine(detailedErrorMessage); return false; } IFeatureClass inputFeatureClass = getFeatureClassFromName(inputFeatureClassString); if (inputFeatureClass == null) { lastErrorCode = 2; detailedErrorMessage = "Could not open Input Feature Class: " + inputFeatureClassString; Console.WriteLine(detailedErrorMessage); return false; } if (inputFeatureClass.FindField(sidcFieldName) < 0) { lastErrorCode = 6; detailedErrorMessage = "Could not find [SIDC] field: " + sidcFieldName + " in Input Feature Class: " + inputFeatureClassString; Console.WriteLine(detailedErrorMessage); return false; } HashSet<string> matchedRules = getMatchedRules(inputFeatureClass, sidcFieldName); if (matchedRules.Count <= 0) { lastErrorCode = 3; detailedErrorMessage = "No matching military features found in input: " + inputFeatureClassString; Console.WriteLine(detailedErrorMessage); return false; } militaryFeatures = new MilitaryFeatureClassHelper(); militaryFeatures.FullWorkspacePath = destinationGeodatabase; IFeatureWorkspace ws = militaryFeatures.Workspace; if (!militaryFeatures.Initialized) { lastErrorCode = 4; detailedErrorMessage = "Output Workspace could not be found/opened: " + destinationGeodatabase; Console.WriteLine(detailedErrorMessage); return false; } symbolCreator = new SymbolCreator(standard); bool initialized = symbolCreator.Initialize(); if (!initialized) { lastErrorCode = 7; detailedErrorMessage = "Could not load required Style Files. Check ArcGIS/Styles folder."; Console.WriteLine("Failed to initialize - could not load required Style Files"); return false; } // where the main work is done of updating the output success = updateMatchedRules(matchedRules, inputFeatureClass, sidcFieldName); return success; }