public bool GetEntityNamesFromCode(SymbolSetType symbolSet, string entityCode, out string entityName, out string entityTypeName, out string entitySubTypeName) { Initialize(); entityName = string.Empty; entityTypeName = string.Empty; entitySubTypeName = string.Empty; if ((EntityTable == null) || (symbolSet == SymbolSetType.NotSet) || (entityCode == "000000") || entityCode.Length != 6) { return(false); } string entityCodeToSearch = entityCode; if (symbolSet == SymbolSetType.Land_Unit) { // See SymbolIdCode.IsLandUnitSpecialEntity for explanation of this exceptional case string entitySubType = entityCode.Substring(4, 2); if (TypeUtilities.EntitySubtypeCodeToLandUnitSpecialEntityName.Keys.Contains(entitySubType)) { entityCodeToSearch = entityCode.Substring(0, 4) + "00"; } } string symbolSetToSearch = TypeUtilities.EnumHelper.getEnumValAsString(symbolSet, 2); var results = from row in EntityTable.AsEnumerable() where ((row.Field <string>("SymbolSet") == symbolSetToSearch) & (row.Field <string>("Code") == entityCodeToSearch)) select row; int resultCount = results.Count(); if (resultCount < 1) { System.Diagnostics.Trace.WriteLine("Entity Code not found: " + entityCode); return(false); } foreach (DataRow row in results) { entityName = row["Entity"] as string; entityTypeName = row["EntityType"] as string; entitySubTypeName = row["EntitySubType"] as string; // We only care about the 1st result break; } return(true); }
public string GetEntityCode(SymbolSetType symbolSet, string entityNameString, string entityTypeNameString = "", string entitySubTypeNameString = "") { Initialize(); if (EntityTable == null) { return(string.Empty); } string symbolSetToSearch = TypeUtilities.EnumHelper.getEnumValAsString(symbolSet, 2); var results = from row in EntityTable.AsEnumerable() where ((row.Field <string>("SymbolSet") == symbolSetToSearch) & (row.Field <string>("Entity") == entityNameString)) select row; if (!string.IsNullOrEmpty(entityTypeNameString)) { // filter results if this is set results = from row in results where (row.Field <string>("EntityType") == entityTypeNameString) select row; } if (!string.IsNullOrEmpty(entitySubTypeNameString)) { // filter results if this is set results = from row in results where (row.Field <string>("EntitySubType") == entitySubTypeNameString) select row; } int resultCount = results.Count(); if (resultCount < 1) { System.Diagnostics.Trace.WriteLine("Entity Name not found: " + entityNameString); return(string.Empty); } string entityCode = string.Empty; foreach (DataRow row in results) { entityCode = row["Code"] as string; // We only care about the 1st result break; } return(entityCode); }
public CentralIconType GetEntityIconTypeFromCode(SymbolSetType symbolSet, string entityCode) { Initialize(); if ((EntityTable == null) || (symbolSet == SymbolSetType.NotSet) || (entityCode == "000000") || entityCode.Length != 6) { return(CentralIconType.NotSet); } string entityCodeToSearch = entityCode; if (symbolSet == SymbolSetType.Land_Unit) { // See SymbolIdCode.IsLandUnitSpecialEntity for explanation of this exceptional case string entitySubType = entityCode.Substring(4, 2); if (TypeUtilities.EntitySubtypeCodeToLandUnitSpecialEntityName.Keys.Contains(entitySubType)) { entityCodeToSearch = entityCode.Substring(0, 4) + "00"; } } string symbolSetToSearch = TypeUtilities.EnumHelper.getEnumValAsString(symbolSet, 2); var results = from row in EntityTable.AsEnumerable() where ((row.Field <string>("SymbolSet") == symbolSetToSearch) & (row.Field <string>("Code") == entityCodeToSearch)) select row; int resultCount = results.Count(); if (resultCount < 1) { System.Diagnostics.Trace.WriteLine("Entity Code not found: " + entityCode); return(CentralIconType.NotSet); } CentralIconType iconFormat = CentralIconType.NotSet; foreach (DataRow row in results) { string centralIconTypeString = row["IconType"] as string; iconFormat = (CentralIconType)TypeUtilities.EnumHelper.getEnumFromString(typeof(CentralIconType), centralIconTypeString); break; } return(iconFormat); }
/// <summary> /// Creates a symbol by looking up the SymbolSet + {any} Entity Name /// And then it sets the Affiliation if provided /// - this is just a simple/basic test /// </summary> public MilitarySymbol CreateSymbolByEntityName(string entityName, SymbolSetType symbolSet = SymbolSetType.NotSet, StandardIdentityAffiliationType affiliation = StandardIdentityAffiliationType.Unknown) { Initialize(); if (EntityTable == null) { return(null); } var results = from row in EntityTable.AsEnumerable() where ((row.Field <string>("EntitySubType").Contains(entityName) | (row.Field <string>("EntityType").Contains(entityName) | (row.Field <string>("Entity").Contains(entityName))))) select row; int resultCount = results.Count(); if (resultCount < 1) { System.Diagnostics.Trace.WriteLine("Entity Name not found: " + entityName); return(null); } if (symbolSet != SymbolSetType.NotSet) { // filter results if this is set string symbolSetToSearch = TypeUtilities.EnumHelper.getEnumValAsString(symbolSet, 2); results = from row in results where (row.Field <string>("SymbolSet") == symbolSetToSearch) select row; } resultCount = results.Count(); if (resultCount < 1) { System.Diagnostics.Trace.WriteLine("Entity Name not found: " + entityName + " in SymbolSet: " + symbolSet); return(null); } MilitarySymbol retSymbol = null; foreach (DataRow row in results) { string symbolSetString = row["SymbolSet"] as string; string entityCode = row["Code"] as string; string geoType = row["GeometryType"] as string; string entityNameFromLookup = row["Entity"] as string; string entityTypeNameFromLookup = row["EntityType"] as string; string entitySubTypeNameFromLookup = row["EntitySubType"] as string; string centralIconTypeString = row["IconType"] as string; retSymbol = CreateSymbolFromStringProperties( affiliation, symbolSetString, entityCode, geoType, entityNameFromLookup, entityTypeNameFromLookup, entitySubTypeNameFromLookup, centralIconTypeString); // TODO: figure out what to do if we get more than 1 result break; } return(retSymbol); }
/// <summary> /// Search based on the one or more attributes supplied /// Default param (symbolSet == NotSet) returns all symbols with affiliation set to Unknown /// </summary> public List <MilitarySymbol> GetMilitarySymbols(SymbolSetType symbolSet = SymbolSetType.NotSet, StandardIdentityAffiliationType affiliation = StandardIdentityAffiliationType.Unknown, string entityNameString = "", string entityTypeNameString = "", string entitySubTypeNameString = "", bool exactEntityMatchOnly = false) { Initialize(); List <MilitarySymbol> symbolList = new List <MilitarySymbol>(); if (EntityTable == null) { return(symbolList); // nothing } string symbolSetToSearch = TypeUtilities.EnumHelper.getEnumValAsString(symbolSet, 2); var results = from row in EntityTable.AsEnumerable() where (row.Field <string>("SymbolSet") == symbolSetToSearch) select row; if (symbolSet == SymbolSetType.NotSet) { results = from row in EntityTable.AsEnumerable() select row; } // Check that search returned something int resultCount = results.Count(); if (resultCount < 1) { System.Diagnostics.Trace.WriteLine("WARNING: Empty result of EntityTable search: " + symbolSetToSearch); // TODO: add search params to the debug output return(symbolList); // empty list } //////////////////////////////////////////////////////////////// // Filters for Entity, EntityType, EntitySubType if these are suppied // TRICKY: exactEntityMatchOnly if we only want the 1 that matches exactly, versus all of the // type, subtype matches if (exactEntityMatchOnly) { results = from row in results where ((row.Field <string>("Entity") == entityNameString) & (row.Field <string>("EntityType") == entityTypeNameString) & (row.Field <string>("EntitySubType") == entitySubTypeNameString)) select row; } else if (!string.IsNullOrEmpty(entityNameString)) { // filter results if this is set results = from row in results where (row.Field <string>("Entity") == entityNameString) select row; if (!string.IsNullOrEmpty(entityTypeNameString)) { // filter results if this is set results = from row in results where (row.Field <string>("EntityType") == entityTypeNameString) select row; if (!string.IsNullOrEmpty(entitySubTypeNameString)) { // filter results if this is set results = from row in results where (row.Field <string>("EntitySubType") == entitySubTypeNameString) select row; } } } // Check that search returned something resultCount = results.Count(); if (resultCount < 1) { System.Diagnostics.Trace.WriteLine("WARNING: Empty result of search"); // TODO: add search params to the debug output return(symbolList); // empty list } foreach (DataRow row in results) { string symbolSetString = row["SymbolSet"] as string; string entityCode = row["Code"] as string; string geoType = row["GeometryType"] as string; string entityName = row["Entity"] as string; string entityTypeName = row["EntityType"] as string; string entitySubTypeName = row["EntitySubType"] as string; string centralIconTypeString = row["IconType"] as string; MilitarySymbol createSymbol = CreateSymbolFromStringProperties( affiliation, symbolSetString, entityCode, geoType, entityName, entityTypeName, entitySubTypeName, centralIconTypeString); if (createSymbol != null) { symbolList.Add(createSymbol); } } return(symbolList); }
public List <string> GetDistinctEntries(SymbolSetType symbolSet, string entityNameString = "", string entityTypeNameString = "") { Initialize(); string symbolSetToSearch = TypeUtilities.EnumHelper.getEnumValAsString(symbolSet, 2); List <string> distinctResultStrings = new List <string>(); if (EntityTable == null) { return(distinctResultStrings); // nothing } // TODO: remove/refactor redundant code below if (string.IsNullOrEmpty(entityNameString)) { // Distinct Entities for a SymbolSet var results = (from row in EntityTable.AsEnumerable() where (row.Field <string>("SymbolSet") == symbolSetToSearch) select row.Field <string>("Entity")).Distinct(); int resultCount = results.Count(); if (resultCount < 1) { System.Diagnostics.Trace.WriteLine("WARNING: Empty result of search"); return(distinctResultStrings); // empty list } foreach (var result in results) { distinctResultStrings.Add(result); } } else if (string.IsNullOrEmpty(entityTypeNameString)) { // Distinct EntityType for Entities var results = (from row in EntityTable.AsEnumerable() where ((row.Field <string>("SymbolSet") == symbolSetToSearch) & (row.Field <string>("Entity") == entityNameString)) select row.Field <string>("EntityType")).Distinct(); int resultCount = results.Count(); if (resultCount < 1) { System.Diagnostics.Trace.WriteLine("WARNING: Empty result of search"); return(distinctResultStrings); // empty list } foreach (var result in results) { if (!string.IsNullOrWhiteSpace(result)) { distinctResultStrings.Add(result); } } } else { // Distinct EntitySubType for EntityTypes var results = (from row in EntityTable.AsEnumerable() where ((row.Field <string>("SymbolSet") == symbolSetToSearch) & (row.Field <string>("Entity") == entityNameString) & (row.Field <string>("EntityType") == entityTypeNameString)) select row.Field <string>("EntitySubType")).Distinct(); int resultCount = results.Count(); if (resultCount < 1) { System.Diagnostics.Trace.WriteLine("WARNING: Empty result of search"); return(distinctResultStrings); // empty list } foreach (var result in results) { if (!string.IsNullOrWhiteSpace(result)) { distinctResultStrings.Add(result); } } } return(distinctResultStrings); }