Esempio n. 1
0
        internal async Task <StorageFile> UpdateAndSaveBuffer(Models.Buffer buffer, string text)
        {
            UpdateBuffer(buffer, text);
            StorageFile file;

            if (!buffer.IsInFileSystem)
            {
                file = await PickSaveFileAsync(buffer);

                file = await BufferOrganizer.SaveBufferToFile(buffer, file);
            }

            file = await BufferOrganizer.SaveBufferToFile(buffer);

            RaisePropertyChanged();
            return(file);
        }
Esempio n. 2
0
        private async Task <StorageFile> PickSaveFileAsync(Models.Buffer buffer)
        {
            var fileSavePicker = new Windows.Storage.Pickers.FileSavePicker
            {
                SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary
            };

            fileSavePicker.FileTypeChoices.Add("Plain Text", new List <string>()
            {
                ".txt"
            });
            fileSavePicker.SuggestedFileName = buffer.Name;

            // TODO: actually handle the case in which the file saving fail
            var file = await fileSavePicker.PickSaveFileAsync();

            if (file == null)
            {
                var dialog = new MessageDialog("Cannot save file. Please retry!!");
                await dialog.ShowAsync();
            }
            return(file);
        }
Esempio n. 3
0
 private void DisplayBuffer(Models.Buffer buffer)
 {
     editor.Document.SetText(Windows.UI.Text.TextSetOptions.None, buffer.Text);
     pageHeader.Text = buffer.Name;
 }
Esempio n. 4
0
        public BufferModule()
            : base("/rest/services/Geometry/GeometryServer/")
        {
            Get["/buffer"] = parameters =>
            {
                var model = new Models.Buffer();

                #region Required Parameter

                if (Request.Query["inSR"].Value != null)
                {
                    model.InputSpatialReference = Convert.ToInt32(Request.Query["sr"].Value);
                }

                if (Request.Query["outSR"].Value != null)
                {
                    model.OutputSpatialReference = Convert.ToInt32(Request.Query["outSR"].Value);
                }

                if (Request.Query["bufferSR"].Value != null)
                {
                    model.BufferSpatialReference = Convert.ToInt32(Request.Query["bufferSR"].Value);
                }

                if (Request.Query["distances"].Value != null)
                {
                    model.BufferDistance = Convert.ToInt32(Request.Query["distances"].Value);
                }

                if (Request.Query["unit"].Value != null)
                {
                    model.DistanceUnit = Convert.ToInt32(Request.Query["unit"].Value);
                }

                if (Request.Query["geometries"].Value != null)
                {
                    model.InputGeometries = Request.Query["geometries"].Value;
                }
                #endregion

                #region Optional Parameter
                if (Request.Query["f"].Value != null)
                {
                    model.Format = Request.Query["f"].Value;
                }
                else
                {
                    model.Format = "HTML";
                }
                #endregion

                if (model.InputGeometries != null)
                {

                    var inputgeom = Services.Utilities.GetGeometries(model.InputGeometries);

                    var buffergeometries = Services.Compute.Buffer(inputgeom,model.BufferDistance);

                    var gispolygon = Services.Utilities.GetGISGeometries(buffergeometries);

                    switch (model.Format)
                    {
                        case "json":
                            model.Result = Services.Utilities.getJSON(gispolygon);
                            break;
                        case "pjson":
                            model.Result = Services.Utilities.getPJSON(gispolygon);
                            break;
                        default:
                            model.Result = Services.Utilities.getPJSON(gispolygon);
                            break;
                    }

                }

                if (model.Format.Equals("HTML"))
                {
                    return View["Buffer", model];
                }
                else
                {
                    return model.Result;
                }
            };
        }
Esempio n. 5
0
 private void UpdateBuffer(Models.Buffer buffer, string text) => buffer.Text = text;
        public BufferModule()
            : base("/rest/services/Geometry/GeometryServer/")
        {
            Get["/buffer"] = parameters =>
            {
                var model = new Models.Buffer();

                #region Required Parameter

                if (Request.Query["inSR"].Value != null)
                {
                    model.InputSpatialReference = Convert.ToInt32(Request.Query["sr"].Value);
                }

                if (Request.Query["outSR"].Value != null)
                {
                    model.OutputSpatialReference = Convert.ToInt32(Request.Query["outSR"].Value);
                }

                if (Request.Query["bufferSR"].Value != null)
                {
                    model.BufferSpatialReference = Convert.ToInt32(Request.Query["bufferSR"].Value);
                }

                if (Request.Query["distances"].Value != null)
                {
                    model.BufferDistance = Convert.ToInt32(Request.Query["distances"].Value);
                }

                if (Request.Query["unit"].Value != null)
                {
                    model.DistanceUnit = Convert.ToInt32(Request.Query["unit"].Value);
                }

                if (Request.Query["geometries"].Value != null)
                {
                    model.InputGeometries = Request.Query["geometries"].Value;
                }
                #endregion

                #region Optional Parameter
                if (Request.Query["f"].Value != null)
                {
                    model.Format = Request.Query["f"].Value;
                }
                else
                {
                    model.Format = "HTML";
                }
                #endregion

                if (model.InputGeometries != null)
                {
                    var inputgeom = Services.Utilities.GetGeometries(model.InputGeometries);

                    var buffergeometries = Services.Compute.Buffer(inputgeom, model.BufferDistance);

                    var gispolygon = Services.Utilities.GetGISGeometries(buffergeometries);


                    switch (model.Format)
                    {
                    case "json":
                        model.Result = Services.Utilities.getJSON(gispolygon);
                        break;

                    case "pjson":
                        model.Result = Services.Utilities.getPJSON(gispolygon);
                        break;

                    default:
                        model.Result = Services.Utilities.getPJSON(gispolygon);
                        break;
                    }
                }


                if (model.Format.Equals("HTML"))
                {
                    return(View["Buffer", model]);
                }
                else
                {
                    return(model.Result);
                }
            };
        }