private void UpdateVisibleGroups() { visibleGroups.Clear(); if (activeSite != null) { var availableGroups = new HashSet <LayerGroup>(); foreach (var group in groups) { foreach (var layer in group.layers) { if (activeSite.HasDataLayer(layer)) { if (availableGroups.AddOnce(layer.Group)) { visibleGroups.Add(layer.Group); } } } } } else { visibleGroups.AddRange(groups); } }
private string AddAllValues(DataLayer dataLayer, string key, string value) { var uniqueCitations = new HashSet <string>(); string multiValues = value; uniqueCitations.Add(value); var patchCount = dataLayer.loadedPatchesInView.Count; for (int i = 1; i < patchCount; i++) { var otherValue = dataLayer.loadedPatchesInView[i].Data.metadata.Get(key); if (uniqueCitations.AddOnce(otherValue)) { multiValues += "\n" + otherValue; } } return(multiValues); }
private void RemapCategoriesAndRemoveUnused(string filename) { int categoriesCount = categories.Length; if (categoriesCount < 1) { return; } int valuesCount = values.Length; // Find all the unique values HashSet <int> uniqueValues = new HashSet <int>(); for (int i = 0; i < valuesCount; i++) { uniqueValues.AddOnce((int)values[i]); } // Create the map and list of used categories Dictionary <int, int> map = new Dictionary <int, int>(); List <IntCategory> usedCategories = new List <IntCategory>(); bool needsRemapping = false; int usedIndex = 0; for (int i = 0; i < categoriesCount; i++) { var cat = categories[i]; needsRemapping |= cat.value != usedIndex; if (uniqueValues.Contains(cat.value)) { uniqueValues.Remove(cat.value); map.Add(cat.value, usedIndex); cat.value = usedIndex; usedCategories.Add(cat); usedIndex++; } else { Debug.LogWarning("Removing unused category " + cat.name + " (" + cat.value + ") in " + filename); } } // Keep only the used categories and discard the rest if (categories.Length != usedCategories.Count) { categories = usedCategories.ToArray(); categoriesCount = categories.Length; if (categoriesCount < 1) { return; } } // Remaining unique values don't have a category if (uniqueValues.Count > 0) { needsRemapping = true; int unusedIndex = -2; foreach (var value in uniqueValues) { if (!map.ContainsKey(value)) { Debug.LogWarning("Missing category for value " + value + ". Remapped to " + unusedIndex + ". File: " + filename); map.Add(value, unusedIndex--); } } } minValue = 0; maxValue = categoriesCount - 1; if (!needsRemapping) { return; } for (int i = 0; i < valuesCount; i++) { values[i] = map[(int)values[i]]; } }