[TASK] Initial commit with basic product setup
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using System;
|
||||
using Mapbox.Unity.MeshGeneration.Modifiers;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
[Serializable]
|
||||
public class CoreVectorLayerProperties : MapboxDataProperty, ISubLayerCoreOptions
|
||||
{
|
||||
[SerializeField]
|
||||
private string sourceId;
|
||||
[Tooltip("Is visualizer active.")]
|
||||
public bool isActive = true;
|
||||
[Tooltip("Name of the visualizer. ")]
|
||||
public string sublayerName = "untitled";
|
||||
[Tooltip("Primitive geometry type of the visualizer, allowed primitives - point, line, polygon")]
|
||||
public VectorPrimitiveType geometryType = VectorPrimitiveType.Polygon;
|
||||
[Tooltip("Name of the layer in the source tileset. This property is case sensitive.")]
|
||||
public string layerName = "layerName";
|
||||
[Tooltip("Snap features to the terrain elevation, use this option to draw features above terrain. ")]
|
||||
public bool snapToTerrain = true;
|
||||
[Tooltip("Groups features into one Unity GameObject.")]
|
||||
public bool combineMeshes = false;
|
||||
|
||||
|
||||
public override bool HasChanged
|
||||
{
|
||||
set
|
||||
{
|
||||
if (value == true)
|
||||
{
|
||||
OnPropertyHasChanged(new VectorLayerUpdateArgs { property = this });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Change the primtive type of the feature which will be used to decide
|
||||
/// what type of mesh operations features will require.
|
||||
/// In example, roads are generally visualized as lines and buildings are
|
||||
/// generally visualized as polygons.
|
||||
/// </summary>
|
||||
/// <param name="type">Primitive type of the featues in the layer.</param>
|
||||
public virtual void SetPrimitiveType(VectorPrimitiveType type)
|
||||
{
|
||||
if (geometryType != type)
|
||||
{
|
||||
geometryType = type;
|
||||
HasChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e8e0a452aae974d349c48ba51e8cbfff
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,33 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using Mapbox.Unity.MeshGeneration.Data;
|
||||
using Mapbox.Unity.MeshGeneration.Factories;
|
||||
|
||||
[Serializable]
|
||||
public class ElevationLayerProperties : LayerProperties
|
||||
{
|
||||
public ElevationSourceType sourceType = ElevationSourceType.MapboxTerrain;
|
||||
|
||||
public LayerSourceOptions sourceOptions = new LayerSourceOptions()
|
||||
{
|
||||
layerSource = new Style()
|
||||
{
|
||||
Id = "mapbox.terrain-rgb"
|
||||
},
|
||||
isActive = true
|
||||
};
|
||||
public ElevationLayerType elevationLayerType = ElevationLayerType.FlatTerrain;
|
||||
public ElevationRequiredOptions requiredOptions = new ElevationRequiredOptions();
|
||||
public TerrainColliderOptions colliderOptions = new TerrainColliderOptions();
|
||||
public ElevationModificationOptions modificationOptions = new ElevationModificationOptions();
|
||||
public UnityLayerOptions unityLayerOptions = new UnityLayerOptions();
|
||||
public TerrainSideWallOptions sideWallOptions = new TerrainSideWallOptions();
|
||||
|
||||
public override bool NeedsForceUpdate()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 46f40ce7b24394c41ae15d4a00746a90
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,25 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
[System.Serializable]
|
||||
public class ImageryLayerProperties : LayerProperties
|
||||
{
|
||||
public ImagerySourceType sourceType = ImagerySourceType.MapboxStreets;
|
||||
|
||||
public LayerSourceOptions sourceOptions = new LayerSourceOptions()
|
||||
{
|
||||
isActive = true,
|
||||
layerSource = MapboxDefaultImagery.GetParameters(ImagerySourceType.MapboxStreets)
|
||||
};
|
||||
|
||||
public ImageryRasterOptions rasterOptions = new ImageryRasterOptions();
|
||||
|
||||
public override bool NeedsForceUpdate()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7c3fb936e1c664e51ac872a0ce9fc699
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
using UnityEngine;
|
||||
using Mapbox.Unity.MeshGeneration.Modifiers;
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
public abstract class LayerProperties : MapboxDataProperty
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 620f750f82f0f4be1b830d83e9162d9d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,158 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Mapbox.Unity.MeshGeneration.Modifiers;
|
||||
using Mapbox.Unity.Utilities;
|
||||
using Mapbox.Unity.MeshGeneration.Filters;
|
||||
|
||||
[Serializable]
|
||||
public class PrefabItemOptions : VectorSubLayerProperties
|
||||
{
|
||||
#region Fixed Properties
|
||||
//Fixed primitiveType
|
||||
public readonly VectorPrimitiveType primitiveType = VectorPrimitiveType.Point;
|
||||
|
||||
//Group features turned off
|
||||
public readonly bool combineMeshes = false;
|
||||
|
||||
//No extrusion
|
||||
public readonly ExtrusionType extrusionType = ExtrusionType.None;
|
||||
|
||||
//Dictionary containing the layer names for each location prefab find by type
|
||||
public readonly Dictionary<LocationPrefabFindBy, string> layerNameFromFindByTypeDictionary = new Dictionary<LocationPrefabFindBy, string>
|
||||
{
|
||||
{LocationPrefabFindBy.AddressOrLatLon, ""},
|
||||
{LocationPrefabFindBy.MapboxCategory, "poi_label"},
|
||||
{LocationPrefabFindBy.POIName, "poi_label"},
|
||||
};
|
||||
|
||||
//Dictionary containing the property names in the layer for each location prefab find by type
|
||||
public readonly Dictionary<LocationPrefabFindBy, string> categoryPropertyFromFindByTypeDictionary = new Dictionary<LocationPrefabFindBy, string>
|
||||
{
|
||||
{LocationPrefabFindBy.AddressOrLatLon, ""},
|
||||
{LocationPrefabFindBy.MapboxCategory, "maki"},
|
||||
{LocationPrefabFindBy.POIName, "name"},
|
||||
};
|
||||
|
||||
//Dictionary containing the density names in the layer for each location prefab find by type
|
||||
public readonly Dictionary<LocationPrefabFindBy, string> densityPropertyFromFindByTypeDictionary = new Dictionary<LocationPrefabFindBy, string>
|
||||
{
|
||||
{LocationPrefabFindBy.AddressOrLatLon, ""},
|
||||
{LocationPrefabFindBy.MapboxCategory, "localrank"},
|
||||
{LocationPrefabFindBy.POIName, "localrank"},
|
||||
};
|
||||
|
||||
//Dictionary containing the density names in the layer for each location prefab find by type
|
||||
public readonly Dictionary<LocationPrefabFindBy, string> namePropertyFromFindByTypeDictionary = new Dictionary<LocationPrefabFindBy, string>
|
||||
{
|
||||
{LocationPrefabFindBy.AddressOrLatLon, ""},
|
||||
{LocationPrefabFindBy.MapboxCategory, ""},
|
||||
{LocationPrefabFindBy.POIName, "name"},
|
||||
};
|
||||
|
||||
//Force Move prefab feature position to the first vertex
|
||||
public readonly PositionTargetType _movePrefabFeaturePositionTo = PositionTargetType.FirstVertex;
|
||||
|
||||
public readonly LayerFilterCombinerOperationType _combinerType = LayerFilterCombinerOperationType.All;
|
||||
#endregion
|
||||
|
||||
#region User Choice Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether this <see cref="T:Mapbox.Unity.Map.PrefabItemOptions"/> item is active.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if is active; otherwise, <c>false</c>.</value>
|
||||
public bool isActive
|
||||
{
|
||||
get
|
||||
{
|
||||
return coreOptions.isActive;
|
||||
}
|
||||
set
|
||||
{
|
||||
coreOptions.isActive = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool snapToTerrain
|
||||
{
|
||||
get
|
||||
{
|
||||
return coreOptions.snapToTerrain;
|
||||
}
|
||||
set
|
||||
{
|
||||
coreOptions.snapToTerrain = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string prefabItemName
|
||||
{
|
||||
get
|
||||
{
|
||||
return coreOptions.sublayerName;
|
||||
}
|
||||
set
|
||||
{
|
||||
coreOptions.sublayerName = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The prefab to be spawned on the map
|
||||
/// </summary>
|
||||
public SpawnPrefabOptions spawnPrefabOptions;
|
||||
|
||||
/// <summary>
|
||||
/// Find points-of-interest to spawn prefabs using this enum
|
||||
/// </summary>
|
||||
public LocationPrefabFindBy findByType = LocationPrefabFindBy.MapboxCategory;//default to Mapbox Category
|
||||
|
||||
/// <summary>
|
||||
/// Spawn at any location in the categories selected
|
||||
/// </summary>
|
||||
public LocationPrefabCategories categories;
|
||||
|
||||
/// <summary>
|
||||
/// Spawn at any location containing this name string
|
||||
/// </summary>
|
||||
public string nameString = "Name";
|
||||
|
||||
/// <summary>
|
||||
/// Spawn at specific coordinates
|
||||
/// </summary>
|
||||
[Geocode]
|
||||
public string[] coordinates;
|
||||
|
||||
|
||||
[Range(1, 30)]
|
||||
public int density = 15;
|
||||
|
||||
public Action<List<GameObject>> OnAllPrefabsInstantiated
|
||||
{
|
||||
get
|
||||
{
|
||||
return spawnPrefabOptions.AllPrefabsInstatiated;
|
||||
}
|
||||
set
|
||||
{
|
||||
spawnPrefabOptions.AllPrefabsInstatiated = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
public override bool HasChanged
|
||||
{
|
||||
set
|
||||
{
|
||||
if (value == true)
|
||||
{
|
||||
OnPropertyHasChanged(new VectorLayerUpdateArgs { property = this });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 06b454a4295ed4bb2ba217a2196dfb15
|
||||
timeCreated: 1523915763
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,155 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using Mapbox.Unity.MeshGeneration.Filters;
|
||||
using Mapbox.Unity.MeshGeneration.Modifiers;
|
||||
|
||||
public static class PresetSubLayerPropertiesFetcher
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the default sub layer properties for the chosen preset type.
|
||||
/// </summary>
|
||||
/// <returns>The sub layer properties.</returns>
|
||||
/// <param name="type">Type.</param>
|
||||
public static VectorSubLayerProperties GetSubLayerProperties(PresetFeatureType type)
|
||||
{
|
||||
//CoreOptions properties
|
||||
VectorPrimitiveType geometryType = VectorPrimitiveType.Polygon;
|
||||
string layerName = "building";
|
||||
string sublayerName = "Untitled";
|
||||
float lineWidth = 1.0f;
|
||||
|
||||
//Geometry Extrusion Options
|
||||
ExtrusionType extrusionType = ExtrusionType.None;
|
||||
ExtrusionGeometryType extrusionGeometryType = ExtrusionGeometryType.RoofAndSide;
|
||||
string propertyName = "height";
|
||||
float extrusionScaleFactor = 1.0f;
|
||||
float extrusionHeight = 1.0f;
|
||||
|
||||
//Filter Options
|
||||
LayerFilterCombinerOperationType combinerType = LayerFilterCombinerOperationType.Any;
|
||||
List<LayerFilter> filters = new List<LayerFilter>();
|
||||
|
||||
|
||||
// Material Options
|
||||
StyleTypes style = StyleTypes.Realistic;
|
||||
|
||||
//Misc options
|
||||
bool buildingsWithUniqueIds = true;
|
||||
PositionTargetType positionTargetType = PositionTargetType.TileCenter;
|
||||
|
||||
//Modifiers
|
||||
List<MeshModifier> meshModifiers = new List<MeshModifier>();
|
||||
List<GameObjectModifier> gameObjectModifiers = new List<GameObjectModifier>();
|
||||
ColliderType colliderType = ColliderType.None;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case PresetFeatureType.Buildings:
|
||||
layerName = "building";
|
||||
geometryType = VectorPrimitiveType.Polygon;
|
||||
extrusionType = ExtrusionType.PropertyHeight;
|
||||
extrusionGeometryType = ExtrusionGeometryType.RoofAndSide;
|
||||
propertyName = "height";
|
||||
style = StyleTypes.Realistic;
|
||||
break;
|
||||
case PresetFeatureType.Roads:
|
||||
layerName = "road";
|
||||
geometryType = VectorPrimitiveType.Line;
|
||||
lineWidth = 1.0f;
|
||||
style = StyleTypes.Custom;
|
||||
extrusionType = ExtrusionType.AbsoluteHeight;
|
||||
extrusionGeometryType = ExtrusionGeometryType.RoofAndSide;
|
||||
break;
|
||||
case PresetFeatureType.Points:
|
||||
layerName = "poi_label";
|
||||
geometryType = VectorPrimitiveType.Point;
|
||||
break;
|
||||
case PresetFeatureType.Landuse:
|
||||
layerName = "landuse";
|
||||
geometryType = VectorPrimitiveType.Polygon;
|
||||
style = StyleTypes.Color;
|
||||
break;
|
||||
case PresetFeatureType.Custom:
|
||||
layerName = "";
|
||||
geometryType = VectorPrimitiveType.Custom;
|
||||
style = StyleTypes.Custom;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
VectorSubLayerProperties _properties = new VectorSubLayerProperties();
|
||||
|
||||
_properties.presetFeatureType = type;
|
||||
|
||||
_properties.coreOptions = new CoreVectorLayerProperties
|
||||
{
|
||||
isActive = true,
|
||||
layerName = layerName,
|
||||
geometryType = geometryType,
|
||||
snapToTerrain = true,
|
||||
combineMeshes = false,
|
||||
sublayerName = sublayerName
|
||||
};
|
||||
|
||||
_properties.lineGeometryOptions = new LineGeometryOptions
|
||||
{
|
||||
Width = lineWidth
|
||||
};
|
||||
|
||||
_properties.extrusionOptions = new GeometryExtrusionOptions
|
||||
{
|
||||
extrusionType = extrusionType,
|
||||
extrusionGeometryType = extrusionGeometryType,
|
||||
propertyName = propertyName,
|
||||
extrusionScaleFactor = extrusionScaleFactor,
|
||||
maximumHeight = extrusionHeight
|
||||
};
|
||||
|
||||
_properties.filterOptions = new VectorFilterOptions
|
||||
{
|
||||
combinerType = combinerType,
|
||||
filters = filters
|
||||
};
|
||||
|
||||
_properties.materialOptions = new GeometryMaterialOptions
|
||||
{
|
||||
style = style,
|
||||
colorStyleColor = UnityEngine.Color.green
|
||||
};
|
||||
_properties.materialOptions.SetDefaultMaterialOptions();
|
||||
_properties.buildingsWithUniqueIds = buildingsWithUniqueIds;
|
||||
_properties.moveFeaturePositionTo = positionTargetType;
|
||||
_properties.MeshModifiers = meshModifiers;
|
||||
_properties.GoModifiers = gameObjectModifiers;
|
||||
_properties.colliderOptions = new ColliderOptions
|
||||
{
|
||||
colliderType = colliderType
|
||||
};
|
||||
|
||||
return _properties;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the default preset type from supplied layerName.
|
||||
/// </summary>
|
||||
/// <param name="layerName">Layer name.</param>
|
||||
public static PresetFeatureType GetPresetTypeFromLayerName(string layerName)
|
||||
{
|
||||
switch (layerName)
|
||||
{
|
||||
case "building":
|
||||
return PresetFeatureType.Buildings;
|
||||
case "road":
|
||||
return PresetFeatureType.Roads;
|
||||
case "landuse":
|
||||
return PresetFeatureType.Landuse;
|
||||
case "poi_label":
|
||||
return PresetFeatureType.Points;
|
||||
default:
|
||||
return PresetFeatureType.Custom;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 59334930d1a6a4d2685461732ae3661d
|
||||
timeCreated: 1538589437
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,261 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Mapbox.Unity.MeshGeneration.Filters;
|
||||
using UnityEngine;
|
||||
using System.Linq;
|
||||
|
||||
[Serializable]
|
||||
public class VectorFilterOptions : MapboxDataProperty, ISubLayerFiltering
|
||||
{
|
||||
[SerializeField]
|
||||
private string _selectedLayerName;
|
||||
public List<LayerFilter> filters = new List<LayerFilter>();
|
||||
[Tooltip("Operator to combine filters. ")]
|
||||
public LayerFilterCombinerOperationType combinerType = LayerFilterCombinerOperationType.All;
|
||||
|
||||
public override bool HasChanged
|
||||
{
|
||||
set
|
||||
{
|
||||
if (value == true)
|
||||
{
|
||||
OnPropertyHasChanged(new VectorLayerUpdateArgs { property = this });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void UnRegisterFilters()
|
||||
{
|
||||
for (int i = 0; i < filters.Count; i++)
|
||||
{
|
||||
filters[i].PropertyHasChanged -= OnLayerFilterChanged;
|
||||
}
|
||||
}
|
||||
|
||||
public void RegisterFilters()
|
||||
{
|
||||
for (int i = 0; i < filters.Count; i++)
|
||||
{
|
||||
filters[i].PropertyHasChanged += OnLayerFilterChanged;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnLayerFilterChanged(object sender, System.EventArgs eventArgs)
|
||||
{
|
||||
HasChanged = true;
|
||||
}
|
||||
|
||||
private void AddFilterToList(LayerFilter layerFilter)
|
||||
{
|
||||
filters.Add(layerFilter);
|
||||
HasChanged = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a string filter that uses a contains operator.
|
||||
/// </summary>
|
||||
/// <returns>The filter.</returns>
|
||||
/// <param name="key">Key.</param>
|
||||
/// <param name="property">Property.</param>
|
||||
public virtual ILayerFilter AddStringFilterContains(string key, string property)
|
||||
{
|
||||
LayerFilter layerFilter = new LayerFilter()
|
||||
{
|
||||
Key = key,
|
||||
filterOperator = LayerFilterOperationType.Contains,
|
||||
PropertyValue = property
|
||||
};
|
||||
AddFilterToList(layerFilter);
|
||||
return layerFilter;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a number filter that uses an equals operator.
|
||||
/// </summary>
|
||||
/// <returns>The filter.</returns>
|
||||
/// <param name="key">Key.</param>
|
||||
/// <param name="value">Value.</param>
|
||||
public virtual ILayerFilter AddNumericFilterEquals(string key, float value)
|
||||
{
|
||||
LayerFilter layerFilter = new LayerFilter()
|
||||
{
|
||||
Key = key,
|
||||
filterOperator = LayerFilterOperationType.IsEqual,
|
||||
Min = value
|
||||
};
|
||||
AddFilterToList(layerFilter);
|
||||
return layerFilter;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a number filter that uses a less than operator.
|
||||
/// </summary>
|
||||
/// <returns>The filter.</returns>
|
||||
/// <param name="key">Key.</param>
|
||||
/// <param name="value">Value.</param>
|
||||
public virtual ILayerFilter AddNumericFilterLessThan(string key, float value)
|
||||
{
|
||||
LayerFilter layerFilter = new LayerFilter()
|
||||
{
|
||||
Key = key,
|
||||
filterOperator = LayerFilterOperationType.IsLess,
|
||||
Min = value
|
||||
};
|
||||
AddFilterToList(layerFilter);
|
||||
return layerFilter;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a number filter that uses a greater than operator.
|
||||
/// </summary>
|
||||
/// <returns>The filter.</returns>
|
||||
/// <param name="key">Key.</param>
|
||||
/// <param name="value">Value.</param>
|
||||
public virtual ILayerFilter AddNumericFilterGreaterThan(string key, float value)
|
||||
{
|
||||
LayerFilter layerFilter = new LayerFilter()
|
||||
{
|
||||
Key = key,
|
||||
filterOperator = LayerFilterOperationType.IsGreater,
|
||||
Min = value
|
||||
};
|
||||
AddFilterToList(layerFilter);
|
||||
return layerFilter;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a number filter that uses an in range operator.
|
||||
/// </summary>
|
||||
/// <returns>The filter.</returns>
|
||||
/// <param name="key">Key.</param>
|
||||
/// <param name="min">Minimum.</param>
|
||||
/// <param name="max">Max.</param>
|
||||
public virtual ILayerFilter AddNumericFilterInRange(string key, float min, float max)
|
||||
{
|
||||
LayerFilter layerFilter = new LayerFilter()
|
||||
{
|
||||
Key = key,
|
||||
filterOperator = LayerFilterOperationType.IsInRange,
|
||||
Min = min,
|
||||
Max = max
|
||||
};
|
||||
AddFilterToList(layerFilter);
|
||||
return layerFilter;
|
||||
}
|
||||
|
||||
public void AddFilter()
|
||||
{
|
||||
AddFilterToList(new LayerFilter());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all filters.
|
||||
/// </summary>
|
||||
public virtual void RemoveAllFilters()
|
||||
{
|
||||
for (int i = 0; i < filters.Count; i++)
|
||||
{
|
||||
LayerFilter filter = filters[i];
|
||||
if (filter != null)
|
||||
{
|
||||
RemoveFilter(filter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes a filter.
|
||||
/// </summary>
|
||||
/// <param name="layerFilter">Layer filter.</param>
|
||||
public virtual void RemoveFilter(LayerFilter layerFilter)
|
||||
{
|
||||
layerFilter.PropertyHasChanged -= OnLayerFilterChanged;
|
||||
if (filters.Contains(layerFilter))
|
||||
{
|
||||
filters.Remove(layerFilter);
|
||||
HasChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes a filter.
|
||||
/// </summary>
|
||||
/// <param name="filter">Filter.</param>
|
||||
public virtual void RemoveFilter(ILayerFilter filter)
|
||||
{
|
||||
RemoveFilter((LayerFilter)filter);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the filter using an index lookup.
|
||||
/// </summary>
|
||||
/// <param name="index">Index.</param>
|
||||
public virtual void RemoveFilter(int index)
|
||||
{
|
||||
if (index < filters.Count && filters[index] != null)
|
||||
{
|
||||
RemoveFilter(filters[index]);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a filter using an index lookup.
|
||||
/// </summary>
|
||||
/// <returns>The filter.</returns>
|
||||
/// <param name="index">Index.</param>
|
||||
public virtual ILayerFilter GetFilter(int index)
|
||||
{
|
||||
if (index < filters.Count && filters[index] != null)
|
||||
{
|
||||
return filters[index];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all filters.
|
||||
/// </summary>
|
||||
/// <returns>All filters.</returns>
|
||||
public virtual IEnumerable<ILayerFilter> GetAllFilters()
|
||||
{
|
||||
return (IEnumerable<ILayerFilter>)filters.AsEnumerable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the filters by query.
|
||||
/// </summary>
|
||||
/// <returns>Filters by query.</returns>
|
||||
/// <param name="query">Query.</param>
|
||||
public virtual IEnumerable<ILayerFilter> GetFiltersByQuery(Func<ILayerFilter, bool> query)
|
||||
{
|
||||
foreach (var filter in filters)
|
||||
{
|
||||
if (query(filter))
|
||||
{
|
||||
yield return filter;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the type of the filter combiner.
|
||||
/// </summary>
|
||||
/// <returns>The filter combiner type.</returns>
|
||||
public virtual LayerFilterCombinerOperationType GetFilterCombinerType()
|
||||
{
|
||||
return combinerType;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the type of the filter combiner.
|
||||
/// </summary>
|
||||
/// <param name="layerFilterCombinerOperationType">Layer filter combiner operation type.</param>
|
||||
public virtual void SetFilterCombinerType(LayerFilterCombinerOperationType layerFilterCombinerOperationType)
|
||||
{
|
||||
combinerType = layerFilterCombinerOperationType;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e9aaba31e5228477fa26423d86426c63
|
||||
timeCreated: 1538538304
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,87 @@
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Mapbox.Platform.TilesetTileJSON;
|
||||
using Mapbox.Unity.Utilities;
|
||||
using UnityEngine;
|
||||
using System.Linq;
|
||||
|
||||
[Serializable]
|
||||
public class VectorLayerProperties : LayerProperties
|
||||
{
|
||||
#region Events
|
||||
public event System.EventHandler SubLayerPropertyAdded;
|
||||
public virtual void OnSubLayerPropertyAdded(System.EventArgs e)
|
||||
{
|
||||
System.EventHandler handler = SubLayerPropertyAdded;
|
||||
if (handler != null)
|
||||
{
|
||||
handler(this, e);
|
||||
}
|
||||
}
|
||||
|
||||
public event System.EventHandler SubLayerPropertyRemoved;
|
||||
public virtual void OnSubLayerPropertyRemoved(System.EventArgs e)
|
||||
{
|
||||
System.EventHandler handler = SubLayerPropertyRemoved;
|
||||
if (handler != null)
|
||||
{
|
||||
handler(this, e);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
/// <summary>
|
||||
/// Raw tileJSON response received from the requested source tileset id(s)
|
||||
/// </summary>
|
||||
public TileJsonData tileJsonData = new TileJsonData();
|
||||
[SerializeField]
|
||||
protected VectorSourceType _sourceType = VectorSourceType.MapboxStreets;
|
||||
public VectorSourceType sourceType
|
||||
{
|
||||
get
|
||||
{
|
||||
return _sourceType;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != VectorSourceType.Custom)
|
||||
{
|
||||
sourceOptions.Id = MapboxDefaultVector.GetParameters(value).Id;
|
||||
}
|
||||
|
||||
if (value == VectorSourceType.None)
|
||||
{
|
||||
sourceOptions.isActive = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
sourceOptions.isActive = true;
|
||||
}
|
||||
|
||||
_sourceType = value;
|
||||
}
|
||||
}
|
||||
|
||||
public LayerSourceOptions sourceOptions = new LayerSourceOptions()
|
||||
{
|
||||
isActive = true,
|
||||
layerSource = MapboxDefaultVector.GetParameters(VectorSourceType.MapboxStreets)
|
||||
};
|
||||
[Tooltip("Use Mapbox style-optimized tilesets, remove any layers or features in the tile that are not represented by a Mapbox style. Style-optimized vector tiles are smaller, served over-the-wire, and a great way to reduce the size of offline caches.")]
|
||||
public bool useOptimizedStyle = false;
|
||||
[StyleSearch]
|
||||
public Style optimizedStyle;
|
||||
public LayerPerformanceOptions performanceOptions;
|
||||
[NodeEditorElementAttribute("Feature Sublayers")]
|
||||
public List<VectorSubLayerProperties> vectorSubLayers = new List<VectorSubLayerProperties>();
|
||||
[NodeEditorElementAttribute("POI Sublayers")]
|
||||
public List<PrefabItemOptions> locationPrefabList = new List<PrefabItemOptions>();
|
||||
|
||||
|
||||
public override bool NeedsForceUpdate()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c799956949e8c4c78ada7f1dbc61b03d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,171 @@
|
||||
using Mapbox.Unity.SourceLayers;
|
||||
|
||||
namespace Mapbox.Unity.Map
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Mapbox.Unity.MeshGeneration.Modifiers;
|
||||
using Mapbox.Unity.MeshGeneration.Data;
|
||||
using Mapbox.Unity.Utilities;
|
||||
using UnityEngine;
|
||||
|
||||
[Serializable]
|
||||
public class VectorSubLayerProperties : LayerProperties, IVectorSubLayer
|
||||
{
|
||||
public override bool HasChanged
|
||||
{
|
||||
set
|
||||
{
|
||||
if (value == true)
|
||||
{
|
||||
OnPropertyHasChanged(new VectorLayerUpdateArgs { property = this });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual string Key
|
||||
{
|
||||
get
|
||||
{
|
||||
return coreOptions.layerName;
|
||||
}
|
||||
}
|
||||
|
||||
public ISubLayerTexturing Texturing
|
||||
{
|
||||
get
|
||||
{
|
||||
return materialOptions;
|
||||
}
|
||||
}
|
||||
public ISubLayerModeling Modeling
|
||||
{
|
||||
get
|
||||
{
|
||||
if (modeling == null)
|
||||
{
|
||||
modeling = new SubLayerModeling(this);
|
||||
}
|
||||
return modeling;
|
||||
}
|
||||
}
|
||||
public ISubLayerFiltering Filtering
|
||||
{
|
||||
get
|
||||
{
|
||||
return filterOptions;
|
||||
}
|
||||
}
|
||||
public ISubLayerBehaviorModifiers BehaviorModifiers
|
||||
{
|
||||
get
|
||||
{
|
||||
if (behaviorModifiers == null)
|
||||
{
|
||||
behaviorModifiers = new SubLayerBehaviorModifiers(this);
|
||||
}
|
||||
return behaviorModifiers;
|
||||
}
|
||||
}
|
||||
protected SubLayerModeling modeling;
|
||||
protected SubLayerBehaviorModifiers behaviorModifiers;
|
||||
public CoreVectorLayerProperties coreOptions = new CoreVectorLayerProperties();
|
||||
public LineGeometryOptions lineGeometryOptions = new LineGeometryOptions();
|
||||
public VectorFilterOptions filterOptions = new VectorFilterOptions();
|
||||
public GeometryExtrusionOptions extrusionOptions = new GeometryExtrusionOptions
|
||||
{
|
||||
extrusionType = ExtrusionType.None,
|
||||
propertyName = "height",
|
||||
extrusionGeometryType = ExtrusionGeometryType.RoofAndSide,
|
||||
|
||||
};
|
||||
|
||||
public ColliderOptions colliderOptions = new ColliderOptions
|
||||
{
|
||||
colliderType = ColliderType.None,
|
||||
};
|
||||
|
||||
public GeometryMaterialOptions materialOptions = new GeometryMaterialOptions();
|
||||
|
||||
public LayerPerformanceOptions performanceOptions;
|
||||
|
||||
//HACK : workaround to avoid users accidentaly leaving the buildingsWithUniqueIds settign on and have missing buildings.
|
||||
public bool honorBuildingIdSetting = true;
|
||||
public bool buildingsWithUniqueIds = false;
|
||||
|
||||
public PositionTargetType moveFeaturePositionTo;
|
||||
[NodeEditorElement("Mesh Modifiers")]
|
||||
public List<MeshModifier> MeshModifiers;
|
||||
[NodeEditorElement("Game Object Modifiers")]
|
||||
public List<GameObjectModifier> GoModifiers;
|
||||
public PresetFeatureType presetFeatureType = PresetFeatureType.Custom;
|
||||
|
||||
[SerializeField]
|
||||
private int _maskValue;
|
||||
|
||||
public string selectedTypes;
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the layer name matches a given string.
|
||||
/// </summary>
|
||||
/// <returns><c>true</c>, if layer name matches exact was subed, <c>false</c> otherwise.</returns>
|
||||
/// <param name="layerName">Layer name.</param>
|
||||
public virtual bool SubLayerNameMatchesExact(string layerName)
|
||||
{
|
||||
return coreOptions.sublayerName == layerName;
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns true if the layer name contains a given string.
|
||||
/// </summary>
|
||||
/// <returns><c>true</c>, if layer name contains was subed, <c>false</c> otherwise.</returns>
|
||||
/// <param name="layerName">Layer name.</param>
|
||||
public virtual bool SubLayerNameContains(string layerName)
|
||||
{
|
||||
return coreOptions.sublayerName.Contains(layerName);
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns true if the layer uses a given style.
|
||||
/// </summary>
|
||||
/// <returns><c>true</c>, if layer uses style type was subed, <c>false</c> otherwise.</returns>
|
||||
/// <param name="style">Style.</param>
|
||||
public virtual bool SubLayerUsesStyleType(StyleTypes style)
|
||||
{
|
||||
return materialOptions.style == style;
|
||||
}
|
||||
|
||||
#region Setters
|
||||
|
||||
/// <summary>
|
||||
/// Sets the active.
|
||||
/// </summary>
|
||||
/// <param name="active">If set to <c>true</c> active.</param>
|
||||
public virtual void SetActive(bool active)
|
||||
{
|
||||
coreOptions.isActive = active;
|
||||
coreOptions.HasChanged = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Switch layer to custom style using provided mesh and game object modifier
|
||||
/// </summary>
|
||||
/// <param name="meshModifiers">Mesh modifiers to be used in layer</param>
|
||||
/// <param name="gameObjectModifiers">Game object modifiers to be used in layer</param>
|
||||
public virtual void CreateCustomStyle(List<MeshModifier> meshModifiers, List<GameObjectModifier> gameObjectModifiers)
|
||||
{
|
||||
coreOptions.geometryType = VectorPrimitiveType.Custom;
|
||||
coreOptions.HasChanged = true;
|
||||
|
||||
MeshModifiers.Clear();
|
||||
foreach (var meshModifier in meshModifiers)
|
||||
{
|
||||
MeshModifiers.Add(meshModifier);
|
||||
}
|
||||
foreach (var goModifier in gameObjectModifiers)
|
||||
{
|
||||
GoModifiers.Add(goModifier);
|
||||
}
|
||||
HasChanged = true;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1a58b487863d34fa69bac8a971ad2549
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user