diff --git a/Assets/Editor/FilterStyleEditor.cs b/Assets/Editor/FilterStyleEditor.cs index ae7b2220..e2ebae02 100644 --- a/Assets/Editor/FilterStyleEditor.cs +++ b/Assets/Editor/FilterStyleEditor.cs @@ -30,7 +30,7 @@ public class FilterStyleEditor : EditorBase private int selectedLayer; [SerializeField] - private FeatureStyle.Matcher.Type selectedMatcherType; + private FeatureStyle.Matcher.MatcherType selectedMatcherType; [SerializeField] private List layerStyleEditors; @@ -59,7 +59,7 @@ public FilterStyleEditor(FeatureStyle.FilterStyle filterStyle) if (filterStyle.Matcher != null) { - selectedMatcherType = filterStyle.Matcher.MatcherType; + selectedMatcherType = filterStyle.Matcher.Type; this.matcherEditor = new MatcherEditor(filterStyle.Matcher); } } @@ -142,12 +142,9 @@ public void OnInspectorGUI() EditorGUI.indentLevel--; - var matcherTypeList = Enum.GetValues(typeof(FeatureStyle.Matcher.Type)).Cast(); - var matcherTypeStringList = matcherTypeList.Select(type => type.ToString()); var oldType = selectedMatcherType; - selectedMatcherType = (FeatureStyle.Matcher.Type)EditorGUILayout.Popup("Matcher:", - (int)selectedMatcherType, matcherTypeStringList.ToArray()); + selectedMatcherType = (FeatureStyle.Matcher.MatcherType)EditorGUILayout.EnumPopup("Matcher:", selectedMatcherType); if (selectedMatcherType != oldType) { @@ -155,7 +152,7 @@ public void OnInspectorGUI() } else { - if (selectedMatcherType == FeatureStyle.Matcher.Type.None) + if (selectedMatcherType == FeatureStyle.Matcher.MatcherType.None) { matcherEditor = null; } diff --git a/Assets/Editor/MapzenMapEditor.cs b/Assets/Editor/MapzenMapEditor.cs index 55fedeb2..ba0d63f1 100644 --- a/Assets/Editor/MapzenMapEditor.cs +++ b/Assets/Editor/MapzenMapEditor.cs @@ -51,7 +51,7 @@ public override void OnInspectorGUI() SavePreferences(); } - private void SceneGroupToggle(MapzenMap mapzenMap, SceneGroup.Type type) + private void SceneGroupToggle(MapzenMap mapzenMap, SceneGroup.GroupType type) { bool isSet = SceneGroup.Test(type, mapzenMap.GroupOptions); isSet = EditorGUILayout.Toggle(type.ToString(), isSet); @@ -74,13 +74,13 @@ private void TileDataFoldout() EditorGUI.indentLevel++; EditorGUILayout.BeginHorizontal(); - SceneGroupToggle(mapzenMap, SceneGroup.Type.Feature); - SceneGroupToggle(mapzenMap, SceneGroup.Type.Filter); + SceneGroupToggle(mapzenMap, SceneGroup.GroupType.Feature); + SceneGroupToggle(mapzenMap, SceneGroup.GroupType.Filter); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); - SceneGroupToggle(mapzenMap, SceneGroup.Type.Layer); - SceneGroupToggle(mapzenMap, SceneGroup.Type.Tile); + SceneGroupToggle(mapzenMap, SceneGroup.GroupType.Layer); + SceneGroupToggle(mapzenMap, SceneGroup.GroupType.Tile); EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel--; diff --git a/Assets/Editor/MatcherEditor.cs b/Assets/Editor/MatcherEditor.cs index 7cb388f1..cb54cd66 100644 --- a/Assets/Editor/MatcherEditor.cs +++ b/Assets/Editor/MatcherEditor.cs @@ -11,7 +11,7 @@ public class MatcherEditor : EditorBase { [SerializeField] - private FeatureStyle.Matcher.Type selectedMatcherType; + private FeatureStyle.Matcher.MatcherType selectedMatcherType; [SerializeField] private FeatureStyle.Matcher matcher; @@ -42,17 +42,13 @@ private MatcherEditor AddMatcherLayout() EditorGUILayout.BeginHorizontal(); { - var matcherTypeList = Enum.GetValues(typeof(FeatureStyle.Matcher.Type)).Cast(); - var matcherTypeStringList = matcherTypeList.Select(type => type.ToString()); - - selectedMatcherType = (FeatureStyle.Matcher.Type)EditorGUILayout.Popup("Matcher:", - (int)selectedMatcherType, matcherTypeStringList.ToArray()); + selectedMatcherType = (FeatureStyle.Matcher.MatcherType)EditorGUILayout.EnumPopup("Matcher:", selectedMatcherType); EditorConfig.SetColor(EditorConfig.AddButtonColor); if (GUILayout.Button(EditorConfig.AddButtonContent, EditorConfig.SmallButtonWidth) - && selectedMatcherType != FeatureStyle.Matcher.Type.None) + && selectedMatcherType != FeatureStyle.Matcher.MatcherType.None) { - var matcherType = (FeatureStyle.Matcher.Type)selectedMatcherType; + var matcherType = (FeatureStyle.Matcher.MatcherType)selectedMatcherType; var newMatcher = new FeatureStyle.Matcher(matcherType); editor = new MatcherEditor(newMatcher); @@ -79,13 +75,13 @@ public void OnInspectorGUI() } else { - switch (matcher.MatcherType) + switch (matcher.Type) { - case FeatureStyle.Matcher.Type.Property: + case FeatureStyle.Matcher.MatcherType.Property: matcher.HasProperty = EditorGUILayout.TextField("Has property:", matcher.HasProperty); break; - case FeatureStyle.Matcher.Type.PropertyRange: + case FeatureStyle.Matcher.MatcherType.PropertyRange: matcher.HasProperty = EditorGUILayout.TextField("Property:", matcher.HasProperty); EditorGUILayout.BeginHorizontal(); matcher.MinRange = EditorGUILayout.FloatField("min:", matcher.MinRange); @@ -97,12 +93,12 @@ public void OnInspectorGUI() EditorGUILayout.EndHorizontal(); break; - case FeatureStyle.Matcher.Type.PropertyValue: + case FeatureStyle.Matcher.MatcherType.PropertyValue: matcher.HasProperty = EditorGUILayout.TextField("Property:", matcher.HasProperty); matcher.PropertyValue = EditorGUILayout.TextField("Property value:", matcher.PropertyValue); break; - case FeatureStyle.Matcher.Type.PropertyRegex: + case FeatureStyle.Matcher.MatcherType.PropertyRegex: matcher.HasProperty = EditorGUILayout.TextField("Property:", matcher.HasProperty); matcher.RegexPattern = EditorGUILayout.TextField("Regex:", matcher.RegexPattern); break; @@ -113,7 +109,7 @@ public void OnInspectorGUI() { var editor = matcherEditors[i]; - var state = FoldoutEditor.OnInspectorGUI(editor.GUID.ToString(), editor.Matcher.MatcherType.ToString()); + var state = FoldoutEditor.OnInspectorGUI(editor.GUID.ToString(), editor.Matcher.Type.ToString()); if (state.show) { diff --git a/Assets/Mapzen/SceneGroup.cs b/Assets/Mapzen/SceneGroup.cs index 4066fe8f..877fa1c8 100644 --- a/Assets/Mapzen/SceneGroup.cs +++ b/Assets/Mapzen/SceneGroup.cs @@ -7,7 +7,7 @@ namespace Mapzen public class SceneGroup { [Flags] - public enum Type + public enum GroupType { None = 0, Tile = 1 << 0, @@ -24,9 +24,9 @@ public enum Type // The mesh data, may be empty public MeshData meshData; - public Type type; + public GroupType type; - public SceneGroup(Type type, string name) + public SceneGroup(GroupType type, string name) { this.childs = new Dictionary(); this.type = type; @@ -39,7 +39,7 @@ public SceneGroup(Type type, string name) /// /// The type to check. /// The group type options. - public static bool Test(Type type, Type options) + public static bool Test(GroupType type, GroupType options) { return ((int)type & (int)options) == (int)type; } @@ -49,14 +49,14 @@ public static bool Test(Type type, Type options) /// /// The type to check. /// The group type options. - public static bool IsLeaf(Type type, Type options) + public static bool IsLeaf(GroupType type, GroupType options) { return ((int)type ^ (int)options) < (int)type; } public override string ToString() { - if (type == Type.None || type == Type.All) + if (type == GroupType.None || type == GroupType.All) { return name; } diff --git a/Assets/Mapzen/Unity/FeatureStyle.cs b/Assets/Mapzen/Unity/FeatureStyle.cs index 5dc9c230..be2f2f28 100644 --- a/Assets/Mapzen/Unity/FeatureStyle.cs +++ b/Assets/Mapzen/Unity/FeatureStyle.cs @@ -68,7 +68,7 @@ public PolylineBuilder.Options GetPolylineOptions(Feature feature, float inverse [Serializable] public class Matcher { - public enum Type + public enum MatcherType { None, AllOf, @@ -81,7 +81,7 @@ public enum Type } [SerializeField] - private Type type; + private MatcherType type; [SerializeField] private List matchers; @@ -96,7 +96,7 @@ public enum Type public bool IsCompound() { - return type == Type.AllOf || type == Type.NoneOf || type == Type.AnyOf; + return type == MatcherType.AllOf || type == MatcherType.NoneOf || type == MatcherType.AnyOf; } public List Matchers @@ -123,13 +123,13 @@ public IFeatureMatcher GetFeatureMatcher() switch (type) { - case FeatureStyle.Matcher.Type.AllOf: + case MatcherType.AllOf: matcher = FeatureMatcher.AllOf(predicates.ToArray()); break; - case FeatureStyle.Matcher.Type.NoneOf: + case FeatureStyle.Matcher.MatcherType.NoneOf: matcher = FeatureMatcher.NoneOf(predicates.ToArray()); break; - case FeatureStyle.Matcher.Type.AnyOf: + case FeatureStyle.Matcher.MatcherType.AnyOf: matcher = FeatureMatcher.AnyOf(predicates.ToArray()); break; } @@ -138,19 +138,19 @@ public IFeatureMatcher GetFeatureMatcher() { switch (type) { - case FeatureStyle.Matcher.Type.PropertyRange: + case MatcherType.PropertyRange: double? min = MinRangeEnabled ? (double)MinRange : (double?)null; double? max = MaxRangeEnabled ? (double)MaxRange : (double?)null; matcher = FeatureMatcher.HasPropertyInRange(HasProperty, min, max); break; - case FeatureStyle.Matcher.Type.Property: + case MatcherType.Property: matcher = FeatureMatcher.HasProperty(HasProperty); break; - case FeatureStyle.Matcher.Type.PropertyValue: + case MatcherType.PropertyValue: matcher = FeatureMatcher.HasPropertyWithValue(HasProperty, PropertyValue); break; - case FeatureStyle.Matcher.Type.PropertyRegex: + case MatcherType.PropertyRegex: try { matcher = FeatureMatcher.HasPropertyWithRegex(HasProperty, RegexPattern); @@ -166,12 +166,12 @@ public IFeatureMatcher GetFeatureMatcher() return matcher; } - public Type MatcherType + public MatcherType Type { get { return type; } } - public Matcher(Type type) + public Matcher(MatcherType type) { this.matchers = new List(); this.type = type; diff --git a/Assets/Mapzen/Unity/TileTask.cs b/Assets/Mapzen/Unity/TileTask.cs index d8e5e2a1..b22db13b 100644 --- a/Assets/Mapzen/Unity/TileTask.cs +++ b/Assets/Mapzen/Unity/TileTask.cs @@ -13,11 +13,11 @@ public class TileTask private TileAddress address; private byte[] response; private bool ready; - private SceneGroup.Type groupOptions; + private SceneGroup.GroupType groupOptions; private float inverseTileScale; private Matrix4x4 transform; - public TileTask(TileAddress address, SceneGroup.Type groupOptions, byte[] response, float offsetX, float offsetY, float regionScaleRatio) + public TileTask(TileAddress address, SceneGroup.GroupType groupOptions, byte[] response, float offsetX, float offsetY, float regionScaleRatio) { this.address = address; this.response = response; @@ -40,7 +40,7 @@ public void Start(List featureStyling, SceneGroup root) // The leaf currently used (will hold the mesh data for the currently matched group) SceneGroup leaf = root; - var tileGroup = OnSceneGroupData(SceneGroup.Type.Tile, address.ToString(), root, ref leaf); + var tileGroup = OnSceneGroupData(SceneGroup.GroupType.Tile, address.ToString(), root, ref leaf); foreach (var style in featureStyling) { @@ -51,11 +51,11 @@ public void Start(List featureStyling, SceneGroup root) foreach (var filterStyle in style.FilterStyles) { - var filterGroup = OnSceneGroupData(SceneGroup.Type.Filter, filterStyle.Name, tileGroup, ref leaf); + var filterGroup = OnSceneGroupData(SceneGroup.GroupType.Filter, filterStyle.Name, tileGroup, ref leaf); foreach (var layer in tileData.FeatureCollections) { - var layerGroup = OnSceneGroupData(SceneGroup.Type.Layer, layer.Name, filterGroup, ref leaf); + var layerGroup = OnSceneGroupData(SceneGroup.GroupType.Layer, layer.Name, filterGroup, ref leaf); foreach (var feature in filterStyle.GetFilter().Filter(layer)) { @@ -69,7 +69,7 @@ public void Start(List featureStyling, SceneGroup root) featureName += identifier.ToString(); } - OnSceneGroupData(SceneGroup.Type.Feature, featureName, layerGroup, ref leaf); + OnSceneGroupData(SceneGroup.GroupType.Feature, featureName, layerGroup, ref leaf); if (feature.Type == GeometryType.Polygon || feature.Type == GeometryType.MultiPolygon) { @@ -100,7 +100,7 @@ public void Start(List featureStyling, SceneGroup root) ready = true; } - private SceneGroup OnSceneGroupData(SceneGroup.Type type, string name, SceneGroup parent, ref SceneGroup leaf) + private SceneGroup OnSceneGroupData(SceneGroup.GroupType type, string name, SceneGroup parent, ref SceneGroup leaf) { SceneGroup group = null; diff --git a/Assets/MapzenMap.cs b/Assets/MapzenMap.cs index c62b8ec7..39bd0c43 100644 --- a/Assets/MapzenMap.cs +++ b/Assets/MapzenMap.cs @@ -33,7 +33,7 @@ public class MapzenMap : MonoBehaviour [HideInInspector] [SerializeField] - private SceneGroup.Type groupOptions; + private SceneGroup.GroupType groupOptions; [HideInInspector] [SerializeField] @@ -52,7 +52,7 @@ public void DownloadTiles() tasks.Clear(); nTasksForArea = 0; - regionMap = new SceneGroup(SceneGroup.Type.None, RegionName); + regionMap = new SceneGroup(SceneGroup.GroupType.None, RegionName); foreach (var tileAddress in bounds.TileAddressRange) { @@ -142,7 +142,7 @@ public float RegionScaleRatio { set { regionScaleRatio = value; } } - public SceneGroup.Type GroupOptions + public SceneGroup.GroupType GroupOptions { get { return groupOptions; } set { groupOptions = value; }