private async void StartGeodatabaseGeneration() { // Update the geodatabase path _gdbPath = GetGdbPath(); // Create a task for generating a geodatabase (GeodatabaseSyncTask) _gdbSyncTask = await GeodatabaseSyncTask.CreateAsync(_featureServiceUri); // Get the current extent of the red preview box Envelope extent = MyMapView.GraphicsOverlays.First().Graphics.First().Geometry as Envelope; // Get the default parameters for the generate geodatabase task GenerateGeodatabaseParameters generateParams = await _gdbSyncTask.CreateDefaultGenerateGeodatabaseParametersAsync(extent); // Create a generate geodatabase job _generateGdbJob = _gdbSyncTask.GenerateGeodatabase(generateParams, _gdbPath); // Handle the job changed event _generateGdbJob.JobChanged += GenerateGdbJobChanged; // Handle the progress changed event (to show progress bar) _generateGdbJob.ProgressChanged += ((sender, e) => { UpdateProgressBar(); }); // Start the job _generateGdbJob.Start(); }
private async void StartGeodatabaseGeneration() { // Create a task for generating a geodatabase (GeodatabaseSyncTask) _gdbSyncTask = await GeodatabaseSyncTask.CreateAsync(_featureServiceUri); // Get the (only) graphic in the map view GraphicsOverlay redPreviewBox = myMapView.GraphicsOverlays.FirstOrDefault(); // Get the current extent of the red preview box Envelope extent = redPreviewBox.Extent as Envelope; // Get the default parameters for the generate geodatabase task GenerateGeodatabaseParameters generateParams = await _gdbSyncTask.CreateDefaultGenerateGeodatabaseParametersAsync(extent); // Create a generate geodatabase job GenerateGeodatabaseJob generateGdbJob = _gdbSyncTask.GenerateGeodatabase(generateParams, _gdbPath); // Handle the job changed event generateGdbJob.JobChanged += GenerateGdbJobChanged; // Handle the progress changed event with an inline (lambda) function to show the progress bar generateGdbJob.ProgressChanged += ((object sender, EventArgs e) => { // Get the job GenerateGeodatabaseJob job = sender as GenerateGeodatabaseJob; // Update the progress bar UpdateProgressBar(job.Progress); }); // Start the job generateGdbJob.Start(); }
private async Task StartGeodatabaseGeneration() { // Create a task for generating a geodatabase (GeodatabaseSyncTask). _gdbSyncTask = await GeodatabaseSyncTask.CreateAsync(_featureServiceUri); // Get the current extent of the red preview box. Envelope extent = MyMapView.GraphicsOverlays.First().Graphics.First().Geometry as Envelope; // Get the default parameters for the generate geodatabase task. GenerateGeodatabaseParameters generateParams = await _gdbSyncTask.CreateDefaultGenerateGeodatabaseParametersAsync(extent); // Create a generate geodatabase job. _generateGdbJob = _gdbSyncTask.GenerateGeodatabase(generateParams, _gdbPath); // Handle the progress changed event (to show progress bar). _generateGdbJob.ProgressChanged += (sender, e) => { UpdateProgressBar(); }; // Show the progress bar. MyProgressBar.Visibility = Visibility.Visible; // Start the job. _generateGdbJob.Start(); // Get the result. Geodatabase resultGdb = await _generateGdbJob.GetResultAsync(); // Hide the progress bar. MyProgressBar.Visibility = Visibility.Hidden; // Do the rest of the work. await HandleGenerationCompleted(resultGdb); }
private async Task StartGeodatabaseGeneration() { // Update geodatabase path. _gdbPath = $"{Path.GetTempFileName()}.geodatabase"; // Create a task for generating a geodatabase (GeodatabaseSyncTask). _gdbSyncTask = await GeodatabaseSyncTask.CreateAsync(_featureServiceUri); // Get the current extent of the red preview box. Envelope extent = _myMapView.GraphicsOverlays.First().Graphics.First().Geometry as Envelope; // Get the default parameters for the generate geodatabase task. GenerateGeodatabaseParameters generateParams = await _gdbSyncTask.CreateDefaultGenerateGeodatabaseParametersAsync(extent); // Create a generate geodatabase job. _generateGdbJob = _gdbSyncTask.GenerateGeodatabase(generateParams, _gdbPath); // Handle the progress changed event (to show progress bar). _generateGdbJob.ProgressChanged += GenerateGdbJob_ProgressChanged; // Start the job. _generateGdbJob.Start(); // Get the result. Geodatabase resultGdb = await _generateGdbJob.GetResultAsync(); // Do the rest of the work. await HandleGenerationStatusChange(_generateGdbJob, resultGdb); }
private async void StartGeodatabaseGeneration() { // 同期させたいレイヤーで ジオデータベースタスク オブジェクトを作成する (GeodatabaseSyncTask) _gdbSyncTask = await GeodatabaseSyncTask.CreateAsync(FEATURELAYER_SERVICE_URL); // ジオデータベース作成のためのパラメータを取得する Envelope extent = myMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry).TargetGeometry as Envelope; // ジオデータベース作成 タスクオブジェクトのデフォルトパラメータを取得する GenerateGeodatabaseParameters generateParams = await _gdbSyncTask.CreateDefaultGenerateGeodatabaseParametersAsync(extent); // ジオデータベースの作成ジョブオブジェクトを作成する GenerateGeodatabaseJob generateGdbJob = _gdbSyncTask.GenerateGeodatabase(generateParams, _gdbPath); // ジョブ変更イベントを処理する generateGdbJob.JobChanged += GenerateGdbJobChanged; //進行状況を変更したイベントをインライン(ラムダ)関数で処理してプログレスバーを表示する generateGdbJob.ProgressChanged += ((object sender, EventArgs e) => { // ジョブを取得 GenerateGeodatabaseJob job = sender as GenerateGeodatabaseJob; // プログレスバーの更新 UpdateProgressBar(job.Progress); }); // ジオデータベース作成のジョブをスタートする generateGdbJob.Start(); }
/** * GeoDatabaseを新規に作成する * ③ 同期させたいArcGIS Online の Feature Layer でローカル geodatabase を作成する **/ private void generateGeodatabase() { // TODO geodatabaseファイル作成ジョブオブヘジェクトを作成する generateJob = geodatabaseSyncTask.GenerateGeodatabase(generateParams, mGeodatabasePath); // JobChanged イベントを処理してジョブのステータスをチェックする generateJob.JobChanged += (s, e) => { // report error (if any) if (generateJob.Error != null) { Console.WriteLine("Error creating geodatabase: " + generateJob.Error.Message); return; } // check the job status if (generateJob.Status == JobStatus.Succeeded) { // ジョブが成功した場合はローカルデータをマップに追加する readGeoDatabase(); } else if (generateJob.Status == JobStatus.Failed) { // report failure Console.WriteLine("Unable to create local geodatabase."); } else { // job is still running, report last message Console.WriteLine(generateJob.Messages[generateJob.Messages.Count - 1].Message); } }; generateJob.ProgressChanged += ((object sender, EventArgs e) => { this.Dispatcher.Invoke(() => { MyProgressBar.Value = generateJob.Progress / 1.0; }); }); // ジョブを開始し、ジョブIDをコンソール上に表示 generateJob.Start(); Console.WriteLine("Submitted job #" + generateJob.ServerJobId + " to create local geodatabase"); }
private async Task StartGeodatabaseGeneration() { // Update the geodatabase path. _gdbPath = $"{Path.GetTempFileName()}.geodatabase"; // Create a task for generating a geodatabase (GeodatabaseSyncTask). _gdbSyncTask = await GeodatabaseSyncTask.CreateAsync(_featureServiceUri); // Get the (only) graphic in the map view. Graphic redPreviewBox = myMapView.GraphicsOverlays.First().Graphics.First(); // Get the current extent of the red preview box. Envelope extent = redPreviewBox.Geometry as Envelope; // Get the default parameters for the generate geodatabase task. GenerateGeodatabaseParameters generateParams = await _gdbSyncTask.CreateDefaultGenerateGeodatabaseParametersAsync(extent); // Create a generate geodatabase job. GenerateGeodatabaseJob generateGdbJob = _gdbSyncTask.GenerateGeodatabase(generateParams, _gdbPath); // Show the progress bar. myProgressBar.IsVisible = true; // Handle the progress changed event with an inline (lambda) function to show the progress bar. generateGdbJob.ProgressChanged += (sender, e) => { // Get the job. GenerateGeodatabaseJob job = (GenerateGeodatabaseJob)sender; // Update the progress bar. UpdateProgressBar(job.Progress); }; // Start the job. generateGdbJob.Start(); // Get the result. _resultGdb = await generateGdbJob.GetResultAsync(); // Hide the progress bar. myProgressBar.IsVisible = false; // Handle the job completion. HandleGenerationStatusChange(generateGdbJob); }
private async Task StartGeodatabaseGeneration() { // Create a task for generating a geodatabase (GeodatabaseSyncTask). _gdbSyncTask = await GeodatabaseSyncTask.CreateAsync(_featureServiceUri); // Get the (only) graphic in the map view. Graphic redPreviewBox = MyMapView.GraphicsOverlays.First().Graphics.First(); // Get the current extent of the red preview box. Envelope extent = redPreviewBox.Geometry as Envelope; // Get the default parameters for the generate geodatabase task. GenerateGeodatabaseParameters generateParams = await _gdbSyncTask.CreateDefaultGenerateGeodatabaseParametersAsync(extent); // Create a generate geodatabase job. GenerateGeodatabaseJob generateGdbJob = _gdbSyncTask.GenerateGeodatabase(generateParams, _gdbPath); // Handle the progress changed event with an inline (lambda) function to show the progress bar. generateGdbJob.ProgressChanged += (sender, e) => { // Update the progress bar. UpdateProgressBar(generateGdbJob.Progress); }; // Show the progress bar. MyProgressBar.Visibility = Visibility.Visible; // Start the job. generateGdbJob.Start(); // Get the result of the job. _resultGdb = await generateGdbJob.GetResultAsync(); // Hide the progress bar. MyProgressBar.Visibility = Visibility.Collapsed; // Do the rest of the work. HandleGenerationCompleted(generateGdbJob); }
private async Task StartGeodatabaseGeneration() { _generateButton.Enabled = false; // Update geodatabase path. _gdbPath = $"{Path.GetTempFileName()}.geodatabase"; // Create a task for generating a geodatabase (GeodatabaseSyncTask). _gdbSyncTask = await GeodatabaseSyncTask.CreateAsync(_featureServiceUri); // Get the (only) graphic in the map view. Graphic redPreviewBox = _myMapView.GraphicsOverlays.First().Graphics.First(); // Get the current extent of the red preview box. Envelope extent = redPreviewBox.Geometry as Envelope; // Get the default parameters for the generate geodatabase task. GenerateGeodatabaseParameters generateParams = await _gdbSyncTask.CreateDefaultGenerateGeodatabaseParametersAsync(extent); // Create a generate geodatabase job. _gdbGenJob = _gdbSyncTask.GenerateGeodatabase(generateParams, _gdbPath); // Handle the progress changed event. _gdbGenJob.ProgressChanged += GenerateGdbJob_ProgressChanged; // Show the progress bar. _progressBar.Hidden = false; // Start the job. _gdbGenJob.Start(); // Get the result. _resultGdb = await _gdbGenJob.GetResultAsync(); // Do the rest of the work. HandleGenerationCompleted(_gdbGenJob); }
private async Task GetLocalGeodatabase() { // Get the path to the local geodatabase for this platform (temp directory, for example) string localGeodatabasePath = GetGdbPath(); try { // See if the geodatabase file is already present if (File.Exists(localGeodatabasePath)) { // If the geodatabase is already available, open it, hide the progress control, and update the message _localGeodatabase = await Geodatabase.OpenAsync(localGeodatabasePath); _progressBar.Visibility = Android.Views.ViewStates.Gone; _messageTextBlock.Text = "Using local geodatabase from '" + _localGeodatabase.Path + "'"; } else { // Create a new GeodatabaseSyncTask with the uri of the feature server to pull from GeodatabaseSyncTask gdbTask = await GeodatabaseSyncTask.CreateAsync(new Uri(SyncServiceUrl)); // Create parameters for the task: layers and extent to include, out spatial reference, and sync model GenerateGeodatabaseParameters gdbParams = await gdbTask.CreateDefaultGenerateGeodatabaseParametersAsync(_extent); gdbParams.OutSpatialReference = _mapView.SpatialReference; gdbParams.SyncModel = SyncModel.Layer; gdbParams.LayerOptions.Clear(); gdbParams.LayerOptions.Add(new GenerateLayerOption(0)); gdbParams.LayerOptions.Add(new GenerateLayerOption(1)); // Create a geodatabase job that generates the geodatabase GenerateGeodatabaseJob generateGdbJob = gdbTask.GenerateGeodatabase(gdbParams, localGeodatabasePath); // Handle the job changed event and check the status of the job; store the geodatabase when it's ready generateGdbJob.JobChanged += (s, e) => { // Call a function to update the progress bar RunOnUiThread(() => UpdateProgressBar(generateGdbJob.Progress)); // See if the job succeeded if (generateGdbJob.Status == JobStatus.Succeeded) { RunOnUiThread(() => { // Hide the progress control and update the message _progressBar.Visibility = Android.Views.ViewStates.Gone; _messageTextBlock.Text = "Created local geodatabase"; }); } else if (generateGdbJob.Status == JobStatus.Failed) { RunOnUiThread(() => { // Hide the progress control and report the exception _progressBar.Visibility = Android.Views.ViewStates.Gone; _messageTextBlock.Text = "Unable to create local geodatabase: " + generateGdbJob.Error.Message; }); } }; // Start the generate geodatabase job _localGeodatabase = await generateGdbJob.GetResultAsync(); } } catch (Exception ex) { // Show a message for the exception encountered RunOnUiThread(() => { ShowStatusMessage("Generate Geodatabase", "Unable to create offline database: " + ex.Message); }); } }
private async Task GetLocalGeodatabase() { string localGeodatabasePath = GetGdbPath(); try { // See if the geodatabase file is already present. if (File.Exists(localGeodatabasePath)) { // If the geodatabase is already available, open it, hide the progress control, and update the message. _localGeodatabase = await Geodatabase.OpenAsync(localGeodatabasePath); _progressBar.Hidden = true; _statusLabel.Text = "Using local geodatabase."; } else { // Create a new GeodatabaseSyncTask with the URI of the feature server to pull from. Uri uri = new Uri(SyncServiceUrl); GeodatabaseSyncTask gdbTask = await GeodatabaseSyncTask.CreateAsync(uri); // Create parameters for the task: layers and extent to include, out spatial reference, and sync model. GenerateGeodatabaseParameters gdbParams = await gdbTask.CreateDefaultGenerateGeodatabaseParametersAsync(_extent); gdbParams.OutSpatialReference = _mapView.SpatialReference; gdbParams.SyncModel = SyncModel.Layer; gdbParams.LayerOptions.Clear(); gdbParams.LayerOptions.Add(new GenerateLayerOption(0)); gdbParams.LayerOptions.Add(new GenerateLayerOption(1)); // Create a geodatabase job that generates the geodatabase. GenerateGeodatabaseJob generateGdbJob = gdbTask.GenerateGeodatabase(gdbParams, localGeodatabasePath); // Handle the job changed event and check the status of the job; store the geodatabase when it's ready. generateGdbJob.JobChanged += (s, e) => { // Call a function to update the progress bar. InvokeOnMainThread(() => UpdateProgressBar(generateGdbJob.Progress)); switch (generateGdbJob.Status) { // See if the job succeeded. case JobStatus.Succeeded: InvokeOnMainThread(() => { // Hide the progress control and update the message. _progressBar.Hidden = true; _statusLabel.Text = "Created local geodatabase"; }); break; case JobStatus.Failed: InvokeOnMainThread(() => { // Hide the progress control and report the exception. _progressBar.Hidden = true; _statusLabel.Text = "Unable to create local geodatabase: " + generateGdbJob.Error.Message; }); break; } }; // Start the generate geodatabase job. _localGeodatabase = await generateGdbJob.GetResultAsync(); } } catch (Exception ex) { // Show a message for the exception encountered. InvokeOnMainThread(() => { ShowMessage("Generate Geodatabase", "Unable to create offline database: " + ex.Message, "OK"); }); } }
private async Task GetLocalGeodatabase() { // Get the path to the local geodatabase for this platform (temp directory, for example) string localGeodatabasePath = GetGdbPath(); try { // See if the geodatabase file is already present if (File.Exists(localGeodatabasePath)) { // If the geodatabase is already available, open it, hide the progress control, and update the message _localGeodatabase = await Geodatabase.OpenAsync(localGeodatabasePath); LoadingProgressBar.IsVisible = false; MessageTextBlock.Text = "Using local geodatabase from '" + _localGeodatabase.Path + "'"; } else { // Create a new GeodatabaseSyncTask with the uri of the feature server to pull from Uri uri = new Uri(SyncServiceUrl); GeodatabaseSyncTask gdbTask = await GeodatabaseSyncTask.CreateAsync(uri); // Create parameters for the task: layers and extent to include, out spatial reference, and sync model GenerateGeodatabaseParameters gdbParams = await gdbTask.CreateDefaultGenerateGeodatabaseParametersAsync(_extent); gdbParams.OutSpatialReference = MyMapView.SpatialReference; gdbParams.SyncModel = SyncModel.Layer; gdbParams.LayerOptions.Clear(); gdbParams.LayerOptions.Add(new GenerateLayerOption(0)); gdbParams.LayerOptions.Add(new GenerateLayerOption(1)); // Create a geodatabase job that generates the geodatabase GenerateGeodatabaseJob generateGdbJob = gdbTask.GenerateGeodatabase(gdbParams, localGeodatabasePath); // Handle the job changed event and check the status of the job; store the geodatabase when it's ready generateGdbJob.JobChanged += (s, e) => { // See if the job succeeded if (generateGdbJob.Status == JobStatus.Succeeded) { Device.BeginInvokeOnMainThread(() => { // Hide the progress control and update the message LoadingProgressBar.IsVisible = false; MessageTextBlock.Text = "Created local geodatabase"; }); } else if (generateGdbJob.Status == JobStatus.Failed) { Device.BeginInvokeOnMainThread(() => { // Hide the progress control and report the exception LoadingProgressBar.IsVisible = false; MessageTextBlock.Text = "Unable to create local geodatabase: " + generateGdbJob.Error.Message; }); } }; // Start the generate geodatabase job _localGeodatabase = await generateGdbJob.GetResultAsync(); } } catch (Exception ex) { // Show a message for the exception encountered Device.BeginInvokeOnMainThread(() => { Application.Current.MainPage.DisplayAlert("Generate Geodatabase", "Unable to create offline database: " + ex.Message, "OK"); }); } }