public void CanAddNode() { var levelOfDetails = new Range <int>(1, 1); var node = new Element(7, new GeoCoordinate[] { new GeoCoordinate(5, 5) }, new Dictionary <string, string>() { { "featurecla", "Populated place" } }, new Dictionary <string, string>()); _elementEditor.Add(MapStorageType.InMemory, node, levelOfDetails); Union <Element, Mesh> result = default(Union <Element, Mesh>); _dataLoader .Load(new Tile(new QuadKey(1, 0, 1), _stylesheet, _projection)) .Do(u => result = u) .Wait(); result.Match( e => CompareElements(node, e), mesh => { throw new ArgumentException(); }); }
void Start() { var rigidBody = gameObject.GetComponent <Rigidbody>(); rigidBody.isKinematic = true; _tileController .Where(tile => tile.IsDisposed) .ObserveOn(Scheduler.MainThread) .Subscribe(tile => { _trace.Info(LogCategory, "Remove tile: {0}", tile.ToString()); Destroy(tile.GameObject); }); _tileController .Where(tile => !tile.IsDisposed) .SelectMany(tile => _mapDataLoader.Load(tile) .Select(u => new Tuple <Tile, Union <Element, Mesh> >(tile, u)) .ObserveOn(Scheduler.MainThread) .DoOnCompleted(() => { if (rigidBody.isKinematic) { var position = transform.position; var coordinate = GeoUtils.ToGeoCoordinate(GetWorldZeroPoint(), position.x, position.z); var height = (float)_appManager.GetService <MapElevationLoader>().Load(tile.QuadKey, coordinate); transform.position = new Vector3(position.x, height + 2, position.z); rigidBody.isKinematic = false; } })) .SubscribeOn(Scheduler.ThreadPool) .ObserveOn(Scheduler.MainThread) .Subscribe(t => t.Item2.Match(e => _modelBuilder.BuildElement(t.Item1, e), m => _modelBuilder.BuildMesh(t.Item1, m))); _messageBus .AsObservable <OnZoomRequested>() .Subscribe(msg => { var newLevel = msg.IsZoomOut ? 14 : 16; if (newLevel == _levelOfDetails) { return; } _levelOfDetails = newLevel; _messageBus.Send(new OnZoomChanged(newLevel)); }); // NOTE: code below loads region tile by tile. // The region is specified by rectangle defined in world coordinates. // float size = 600; // square side size (in meters) // Scheduler.ThreadPool.Schedule(() => _tileController.OnRegion(new Rectangle(-size / 2, -size / 2, size, size), _levelOfDetails)); }
/// <summary> Loads quadkey waiting for completion callback. </summary> private void LoadQuadKeySync(QuadKey quadKey) { var manualResetEvent = new ManualResetEvent(false); var tile = new Tile(quadKey, _tileController.Stylesheet, _tileController.Projection); _mapDataLoader .Load(tile) .SubscribeOn(Scheduler.CurrentThread) .ObserveOn(Scheduler.CurrentThread) .Subscribe(AssertData, () => manualResetEvent.Set()); manualResetEvent.WaitOne(); }
// Loads all globe level tiles manually. private void LoadGlobe() { var tileController = _appManager.GetService <ITileController>(); int count = 2; for (var y = 0; y < count; ++y) { for (var x = 0; x < count; ++x) { var quadKey = new QuadKey(x, y, LevelOfDetails); var tile = new Tile(quadKey, tileController.Stylesheet, tileController.Projection); _mapDataLoader .Load(tile) .SubscribeOn(Scheduler.CurrentThread) .ObserveOn(Scheduler.MainThread) .Subscribe(u => u.Match(e => _modelBuilder.BuildElement(tile, e), m => _modelBuilder.BuildMesh(tile, m))); } } }
void Start() { var rigidBody = gameObject.GetComponent <Rigidbody>(); rigidBody.isKinematic = true; _tileController .Where(tile => tile.IsDisposed) .ObserveOn(Scheduler.MainThread) .Subscribe(tile => { _trace.Info(LogCategory, "Remove tile: {0}", tile.ToString()); Destroy(tile.GameObject); }); _tileController .Where(tile => !tile.IsDisposed) .SelectMany(tile => _mapDataLoader.Load(tile) .Select(u => new Tuple <Tile, Union <Element, Mesh> >(tile, u)) .ObserveOn(Scheduler.MainThread) .DoOnCompleted(() => { if (rigidBody.isKinematic) { rigidBody.isKinematic = false; } })) .SubscribeOn(Scheduler.ThreadPool) .ObserveOn(Scheduler.MainThread) .Subscribe(t => t.Item2.Match(e => _modelBuilder.BuildElement(t.Item1, e), m => _modelBuilder.BuildMesh(t.Item1, m))); // NOTE: code below loads region tile by tile. // The region is specified by rectangle defined in world coordinates. //float size = 600; // square side size (in meters) //Scheduler.ThreadPool.Schedule(() => _tileController.OnRegion(new Rectangle(-size / 2, -size / 2, size, size), LevelOfDetails)); }