Example #1
0
        private BuildingMeshBuilderProperties MakeProperties(VectorTileLayer layer)
        {
            var output = new BuildingMeshBuilderProperties
            {
                VectorTileLayer     = layer,
                FeatureCount        = layer?.FeatureCount() ?? 0,
                LayerFeatureFilters =
                    SubLayerProperties.filterOptions.filters.Select(m => m.GetFilterComparer()).ToArray(),
                LayerFeatureFilterCombiner = new LayerFilterComparer()
            };

            switch (SubLayerProperties.filterOptions.combinerType)
            {
            case LayerFilterCombinerOperationType.Any:
                output.LayerFeatureFilterCombiner = LayerFilterComparer.AnyOf(output.LayerFeatureFilters);
                break;

            case LayerFilterCombinerOperationType.All:
                output.LayerFeatureFilterCombiner = LayerFilterComparer.AllOf(output.LayerFeatureFilters);
                break;

            case LayerFilterCombinerOperationType.None:
                output.LayerFeatureFilterCombiner = LayerFilterComparer.NoneOf(output.LayerFeatureFilters);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            output.BuildingsWithUniqueIds = SubLayerProperties.honorBuildingIdSetting && SubLayerProperties.buildingsWithUniqueIds;
            return(output);
        }
Example #2
0
        protected IEnumerator ProcessLayer(VectorTileLayer layer, UnityTile tile, UnwrappedTileId tileId, Action <UnityTile, LayerVisualizerBase> callback = null)
        {
            if (tile == null)
            {
                yield break;
            }

            var tempLayerProperties = new VectorLayerVisualizerProperties
            {
                vectorTileLayer        = layer,
                featureProcessingStage = FeatureProcessingStage.PreProcess,
                layerFeatureFilters    =
                    _layerProperties.filterOptions.filters.Select(m => m.GetFilterComparer()).ToArray(),
                layerFeatureFilterCombiner = new LayerFilterComparer()
            };

            //Get all filters in the array.

            // Pass them to the combiner
            switch (_layerProperties.filterOptions.combinerType)
            {
            case LayerFilterCombinerOperationType.Any:
                tempLayerProperties.layerFeatureFilterCombiner = LayerFilterComparer.AnyOf(tempLayerProperties.layerFeatureFilters);
                break;

            case LayerFilterCombinerOperationType.All:
                tempLayerProperties.layerFeatureFilterCombiner = LayerFilterComparer.AllOf(tempLayerProperties.layerFeatureFilters);
                break;

            case LayerFilterCombinerOperationType.None:
                tempLayerProperties.layerFeatureFilterCombiner = LayerFilterComparer.NoneOf(tempLayerProperties.layerFeatureFilters);
                break;

            default:
                break;
            }

            tempLayerProperties.buildingsWithUniqueIds = (_layerProperties.honorBuildingIdSetting) && _layerProperties.buildingsWithUniqueIds;

            //find any replacement criteria and assign them
            foreach (var goModifier in _defaultStack.GoModifiers)
            {
                if (goModifier is IReplacementCriteria && goModifier.Active)
                {
                    SetReplacementCriteria((IReplacementCriteria)goModifier);
                }
            }

            #region PreProcess & Process.

            var featureCount = tempLayerProperties.vectorTileLayer?.FeatureCount() ?? 0;
            do
            {
                for (var i = 0; i < featureCount; i++)
                {
                    //checking if tile is recycled and changed
                    if (tile.UnwrappedTileId != tileId ||
                        !_activeCoroutines.ContainsKey(tile) ||
                        tile.TileState == Enums.TilePropertyState.Unregistered)
                    {
                        yield break;
                    }

                    ProcessFeature(i, tile, tempLayerProperties, layer.Extent);

                    if (!IsCoroutineBucketFull || Application.isEditor && !Application.isPlaying)
                    {
                        continue;
                    }
                    //Reset bucket..
                    _entityInCurrentCoroutine = 0;
                    yield return(null);
                }
                // move processing to next stage.
                tempLayerProperties.featureProcessingStage++;
            } while (tempLayerProperties.featureProcessingStage == FeatureProcessingStage.PreProcess ||
                     tempLayerProperties.featureProcessingStage == FeatureProcessingStage.Process);

            #endregion

            #region PostProcess
            // TODO : Clean this up to follow the same pattern.
            var mergedStack = _defaultStack as MergedModifierStack;
            if (mergedStack != null && tile != null)
            {
                mergedStack.End(tile, tile.gameObject, layer.Name);
            }
            #endregion

            callback?.Invoke(tile, this);
        }