private void CreateFeatureWithBuilder(UnityTile tile, string layerName, LayerVisualizerBase builder) { if (builder.Active) { if (_layerProgress.ContainsKey(tile)) { _layerProgress[tile].Add(builder); } else { _layerProgress.Add(tile, new HashSet <LayerVisualizerBase> { builder }); if (!_tilesWaitingProcessing.Contains(tile)) { _tilesWaitingProcessing.Add(tile); } } if (tile.VectorData == null) { return; } if (layerName != "") { builder.Create(tile.VectorData.Data.GetLayer(layerName), tile, DecreaseProgressCounter); } else { //just pass the first available layer - we should create a static null layer for this builder.Create(tile.VectorData.Data.GetLayer(tile.VectorData.Data.LayerNames()[0]), tile, DecreaseProgressCounter); } } }
public virtual LayerVisualizerBase AddPOIVectorLayerVisualizer(PrefabItemOptions poiSubLayer) { LayerVisualizerBase visualizer = CreateInstance <LocationPrefabsLayerVisualizer>(); poiSubLayer.performanceOptions = _properties.performanceOptions; ((LocationPrefabsLayerVisualizer)visualizer).SetProperties((PrefabItemOptions)poiSubLayer); visualizer.LayerVisualizerHasChanged += UpdateTileFactory; visualizer.Initialize(); if (visualizer == null) { return(null); } if (_layerBuilder.ContainsKey(visualizer.Key)) { _layerBuilder[visualizer.Key].Add(visualizer); } else { _layerBuilder.Add(visualizer.Key, new List <LayerVisualizerBase>() { visualizer }); } return(visualizer); }
/// <summary> /// Set up sublayers using VectorLayerVisualizers. /// </summary> protected override void OnInitialized() { _layerProgress = new Dictionary <UnityTile, HashSet <LayerVisualizerBase> >(); _layerBuilder = new Dictionary <string, List <LayerVisualizerBase> >(); DataFetcher = ScriptableObject.CreateInstance <VectorDataFetcher>(); DataFetcher.DataRecieved += OnVectorDataRecieved; DataFetcher.FetchingError += OnDataError; foreach (var item in _properties.locationPrefabList) { LayerVisualizerBase visualizer = CreateInstance <LocationPrefabsLayerVisualizer>(); item.performanceOptions = _properties.performanceOptions; ((LocationPrefabsLayerVisualizer)visualizer).SetProperties((PrefabItemOptions)item); visualizer.Initialize(); if (visualizer == null) { continue; } if (_layerBuilder.ContainsKey(visualizer.Key)) { _layerBuilder[visualizer.Key].Add(visualizer); } else { _layerBuilder.Add(visualizer.Key, new List <LayerVisualizerBase>() { visualizer }); } } foreach (var sublayer in _properties.vectorSubLayers) { //if its of type prefabitemoptions then separate the visualizer type LayerVisualizerBase visualizer = CreateInstance <VectorLayerVisualizer>(); sublayer.performanceOptions = _properties.performanceOptions; ((VectorLayerVisualizer)visualizer).SetProperties(sublayer); visualizer.Initialize(); if (visualizer == null) { continue; } if (_layerBuilder.ContainsKey(visualizer.Key)) { _layerBuilder[visualizer.Key].Add(visualizer); } else { _layerBuilder.Add(visualizer.Key, new List <LayerVisualizerBase>() { visualizer }); } } }
public void RemoveTilesFromLayer(VectorTileFactory factory, LayerVisualizerBase layerVisualizer) { foreach (KeyValuePair <UnwrappedTileId, UnityTile> tileBundle in _activeTiles) { factory.UnregisterLayer(tileBundle.Value, layerVisualizer); } factory.RemoveVectorLayerVisualizer(layerVisualizer); }
public void RemoveTilesFromLayer(VectorTileFactory factory, LayerVisualizerBase layerVisualizer) { foreach (var tileBundle in _activeTiles) { factory.UnregisterLayer(tileBundle.Value, layerVisualizer); } factory.RemoveVectorLayerVisualizer(layerVisualizer); }
public void UnregisterAndRedrawTilesFromLayer(VectorTileFactory factory, LayerVisualizerBase layerVisualizer) { foreach (KeyValuePair <UnwrappedTileId, UnityTile> tileBundle in _activeTiles) { factory.UnregisterLayer(tileBundle.Value, layerVisualizer); } layerVisualizer.UnbindSubLayerEvents(); layerVisualizer.SetProperties(layerVisualizer.SubLayerProperties); layerVisualizer.InitializeStack(); foreach (KeyValuePair <UnwrappedTileId, UnityTile> tileBundle in _activeTiles) { factory.RedrawSubLayer(tileBundle.Value, layerVisualizer); } }
public void UnregisterLayer(UnityTile tile, LayerVisualizerBase visualizer) { if (_layerProgress.ContainsKey(tile)) { _layerProgress.Remove(tile); } if (_tilesWaitingProcessing.Contains(tile)) { _tilesWaitingProcessing.Remove(tile); } if (visualizer != null) { visualizer.UnregisterTile(tile); } }
private void DecreaseProgressCounter(UnityTile tile, LayerVisualizerBase builder) { if (_layerProgress.ContainsKey(tile)) { if (_layerProgress[tile].Contains(builder)) { _layerProgress[tile].Remove(builder); } if (_layerProgress[tile].Count == 0) { _layerProgress.Remove(tile); _tilesWaitingProcessing.Remove(tile); tile.VectorDataState = TilePropertyState.Loaded; } } }
public virtual void RemoveVectorLayerVisualizer(LayerVisualizerBase subLayer) { subLayer.Clear(); if (_layerBuilder.ContainsKey(subLayer.Key)) { if (Properties.vectorSubLayers.Contains(subLayer.SubLayerProperties)) { Properties.vectorSubLayers.Remove(subLayer.SubLayerProperties); } else if (subLayer.SubLayerProperties is PrefabItemOptions && Properties.locationPrefabList.Contains(subLayer.SubLayerProperties as PrefabItemOptions)) { Properties.locationPrefabList.Remove(subLayer.SubLayerProperties as PrefabItemOptions); } subLayer.LayerVisualizerHasChanged -= UpdateTileFactory; subLayer.UnbindSubLayerEvents(); _layerBuilder[subLayer.Key].Remove(subLayer); } }
private void TrackFeatureWithBuilder(UnityTile tile, string layerName, LayerVisualizerBase builder) { if (builder.Active) { if (_layerProgress.ContainsKey(tile)) { _layerProgress[tile].Add(builder); } else { _layerProgress.Add(tile, new HashSet <LayerVisualizerBase> { builder }); if (!_tilesWaitingProcessing.Contains(tile)) { _tilesWaitingProcessing.Add(tile); } } } }
public virtual LayerVisualizerBase AddVectorLayerVisualizer(VectorSubLayerProperties subLayer) { //if its of type prefabitemoptions then separate the visualizer type LayerVisualizerBase visualizer = CreateInstance <VectorLayerVisualizer>(); //TODO : FIX THIS !! visualizer.LayerVisualizerHasChanged += UpdateTileFactory; // Set honorBuildingSettings - need to set here in addition to the UI. // Not setting it here can lead to wrong filtering. bool isPrimitiveTypeValidForBuidingIds = (subLayer.coreOptions.geometryType == VectorPrimitiveType.Polygon) || (subLayer.coreOptions.geometryType == VectorPrimitiveType.Custom); bool isSourceValidForBuildingIds = _properties.sourceType != VectorSourceType.MapboxStreets; subLayer.honorBuildingIdSetting = isPrimitiveTypeValidForBuidingIds && isSourceValidForBuildingIds; // Setup visualizer. ((VectorLayerVisualizer)visualizer).SetProperties(subLayer); visualizer.Initialize(); if (visualizer == null) { return(visualizer); } if (_layerBuilder.ContainsKey(visualizer.Key)) { _layerBuilder[visualizer.Key].Add(visualizer); } else { _layerBuilder.Add(visualizer.Key, new List <LayerVisualizerBase> { visualizer }); } return(visualizer); }
private void CreateLayerVisualizers() { foreach (var sublayer in _properties.vectorSubLayers) { //if its of type prefabitemoptions then separate the visualizer type LayerVisualizerBase visualizer = CreateInstance <VectorLayerVisualizer>(); // Set honorBuildingSettings - need to set here in addition to the UI. // Not setting it here can lead to wrong filtering. bool isPrimitiveTypeValidForBuidingIds = (sublayer.coreOptions.geometryType == VectorPrimitiveType.Polygon || sublayer.coreOptions.geometryType == VectorPrimitiveType.Custom); bool isSourceValidForBuildingIds = (_properties.sourceType != VectorSourceType.MapboxStreets); sublayer.honorBuildingIdSetting = isPrimitiveTypeValidForBuidingIds && isSourceValidForBuildingIds; // Setup visualizer. ((VectorLayerVisualizer)visualizer).SetProperties(sublayer); visualizer.Initialize(); if (visualizer == null) { continue; } if (_layerBuilder.ContainsKey(visualizer.Key)) { _layerBuilder[visualizer.Key].Add(visualizer); } else { _layerBuilder.Add(visualizer.Key, new List <LayerVisualizerBase>() { visualizer }); } } }
public void RedrawSubLayer(UnityTile tile, LayerVisualizerBase visualizer) { CreateFeatureWithBuilder(tile, visualizer.SubLayerProperties.coreOptions.layerName, visualizer); }
public virtual void UpdateProperty(LayerVisualizerBase layerVisualizer) { }