Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions Assets/Editor/FilterStyleEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<LayerStyleEditor> layerStyleEditors;
Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -142,20 +142,17 @@ public void OnInspectorGUI()

EditorGUI.indentLevel--;

var matcherTypeList = Enum.GetValues(typeof(FeatureStyle.Matcher.Type)).Cast<FeatureStyle.Matcher.Type>();
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)
{
matcherEditor = new MatcherEditor(new FeatureStyle.Matcher(selectedMatcherType));
}
else
{
if (selectedMatcherType == FeatureStyle.Matcher.Type.None)
if (selectedMatcherType == FeatureStyle.Matcher.MatcherType.None)
{
matcherEditor = null;
}
Expand Down
10 changes: 5 additions & 5 deletions Assets/Editor/MapzenMapEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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--;
Expand Down
24 changes: 10 additions & 14 deletions Assets/Editor/MatcherEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
public class MatcherEditor : EditorBase
{
[SerializeField]
private FeatureStyle.Matcher.Type selectedMatcherType;
private FeatureStyle.Matcher.MatcherType selectedMatcherType;

[SerializeField]
private FeatureStyle.Matcher matcher;
Expand Down Expand Up @@ -42,17 +42,13 @@ private MatcherEditor AddMatcherLayout()

EditorGUILayout.BeginHorizontal();
{
var matcherTypeList = Enum.GetValues(typeof(FeatureStyle.Matcher.Type)).Cast<FeatureStyle.Matcher.Type>();
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);
Expand All @@ -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);
Expand All @@ -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;
Expand All @@ -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)
{
Expand Down
12 changes: 6 additions & 6 deletions Assets/Mapzen/SceneGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Mapzen
public class SceneGroup
{
[Flags]
public enum Type
public enum GroupType
{
None = 0,
Tile = 1 << 0,
Expand All @@ -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<string, SceneGroup>();
this.type = type;
Expand All @@ -39,7 +39,7 @@ public SceneGroup(Type type, string name)
/// </summary>
/// <param name="type">The type to check.</param>
/// <param name="options">The group type options.</param>
public static bool Test(Type type, Type options)
public static bool Test(GroupType type, GroupType options)
{
return ((int)type & (int)options) == (int)type;
}
Expand All @@ -49,14 +49,14 @@ public static bool Test(Type type, Type options)
/// </summary>
/// <param name="type">The type to check.</param>
/// <param name="options">The group type options.</param>
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;
}
Expand Down
24 changes: 12 additions & 12 deletions Assets/Mapzen/Unity/FeatureStyle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public PolylineBuilder.Options GetPolylineOptions(Feature feature, float inverse
[Serializable]
public class Matcher
{
public enum Type
public enum MatcherType
{
None,
AllOf,
Expand All @@ -81,7 +81,7 @@ public enum Type
}

[SerializeField]
private Type type;
private MatcherType type;

[SerializeField]
private List<Matcher> matchers;
Expand All @@ -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<Matcher> Matchers
Expand All @@ -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;
}
Expand All @@ -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);
Expand All @@ -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<Matcher>();
this.type = type;
Expand Down
14 changes: 7 additions & 7 deletions Assets/Mapzen/Unity/TileTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -40,7 +40,7 @@ public void Start(List<FeatureStyle> 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)
{
Expand All @@ -51,11 +51,11 @@ public void Start(List<FeatureStyle> 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))
{
Expand All @@ -69,7 +69,7 @@ public void Start(List<FeatureStyle> 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)
{
Expand Down Expand Up @@ -100,7 +100,7 @@ public void Start(List<FeatureStyle> 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;

Expand Down
6 changes: 3 additions & 3 deletions Assets/MapzenMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class MapzenMap : MonoBehaviour

[HideInInspector]
[SerializeField]
private SceneGroup.Type groupOptions;
private SceneGroup.GroupType groupOptions;

[HideInInspector]
[SerializeField]
Expand All @@ -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)
{
Expand Down Expand Up @@ -142,7 +142,7 @@ public float RegionScaleRatio {
set { regionScaleRatio = value; }
}

public SceneGroup.Type GroupOptions
public SceneGroup.GroupType GroupOptions
{
get { return groupOptions; }
set { groupOptions = value; }
Expand Down