Beispiel #1
0
        // ***************** Duplicate ***************
        // *******************************************
        public static ILegendCommand CreateCloneDrawingItemCommand(MapPresenter map, DrawingItemLayer layer)
        {
            var result = new LegendCommand()
            {
                PathMarkup = IRI.Jab.Common.Assets.ShapeStrings.Appbar.appbarPageCopy,
                Layer      = layer,
                ToolTip    = "ایجاد کپی از عارضه",
            };

            result.Command = new RelayCommand(async param =>
            {
                try
                {
                    var cloned = layer.Geometry.Clone();

                    map.AddDrawingItem(cloned, $"{layer.LayerName} cloned-{map.CurrentZoomLevel}");
                }
                catch (Exception ex)
                {
                    await map.DialogService.ShowMessageAsync(null, ex.Message, null, null);
                }
            });

            return(result);
        }
Beispiel #2
0
        public static ILegendCommand CreateExportAsShapefile(MapPresenter map, VectorLayer layer)
        {
            var result = new LegendCommand()
            {
                PathMarkup = IRI.Jab.Common.Assets.ShapeStrings.Appbar.appbarDownload,
                Layer      = layer,
                ToolTip    = _exportAsShapefileToolTip,
            };

            result.Command = new RelayCommand(async param =>
            {
                try
                {
                    var fileName = await map.DialogService.ShowSaveFileDialogAsync("*.shp|*.shp", null, layer.LayerName);

                    if (string.IsNullOrWhiteSpace(fileName))
                    {
                        return;
                    }

                    layer.ExportAsShapefile(fileName);
                }
                catch (Exception ex)
                {
                    await map.DialogService.ShowMessageAsync(null, ex.Message, null, null);
                }
            });

            return(result);
        }
Beispiel #3
0
        // ***************** Extract points **********
        // *******************************************
        public static ILegendCommand CreateBreakIntoPointsCommand(MapPresenter map, DrawingItemLayer layer)
        {
            var result = new LegendCommand()
            {
                PathMarkup = IRI.Jab.Common.Assets.ShapeStrings.SegoePrint.extractPoints,
                Layer      = layer,
                ToolTip    = "تفکیک به نقاط",
            };

            result.Command = new RelayCommand(async param =>
            {
                try
                {
                    var pointCollection = IRI.Ket.SqlServerSpatialExtension.SqlSpatialUtility.MakePointCollection(layer.Geometry.GetAllPoints());

                    map.AddDrawingItem(pointCollection.AsGeometry(), $"{layer.LayerName} Points");
                }
                catch (Exception ex)
                {
                    await map.DialogService.ShowMessageAsync(null, ex.Message, null, null);
                }
            });

            return(result);
        }
Beispiel #4
0
        // ***************** Simplify by Area ********
        // *******************************************
        public static ILegendCommand CreateSimplifyByAreaCommand(MapPresenter map, DrawingItemLayer layer)
        {
            var result = new LegendCommand()
            {
                PathMarkup = IRI.Jab.Common.Assets.ShapeStrings.Appbar.appbarFlag,
                Layer      = layer,
                ToolTip    = "ساده‌سازی روش مساحت",
            };

            result.Command = new RelayCommand(async param =>
            {
                try
                {
                    var simplified = layer.Geometry.Simplify(SimplificationType.AdditiveByArea, map.CurrentZoomLevel, new SimplificationParamters()
                    {
                        Retain3Points = true
                    });
                    //VisualSimplification.sim layer.Geometry.Simplify()
                    map.AddDrawingItem(simplified, $"{layer.LayerName} simplified-{map.CurrentZoomLevel}");
                }
                catch (Exception ex)
                {
                    await map.DialogService.ShowMessageAsync(null, ex.Message, null, null);
                }
            });

            return(result);
        }
Beispiel #5
0
        public static ILegendCommand CreateExportAsGeoJson(MapPresenter map, VectorLayer layer)
        {
            var result = new LegendCommand()
            {
                PathMarkup = IRI.Jab.Common.Assets.ShapeStrings.Appbar.appbarDownload,
                Layer      = layer,
                ToolTip    = _exportAsGeoJsonToolTip,
            };

            result.Command = new RelayCommand(async param =>
            {
                try
                {
                    var fileName = await map.DialogService.ShowSaveFileDialogAsync("*.json|*.json", null, layer.LayerName);

                    if (string.IsNullOrWhiteSpace(fileName))
                    {
                        return;
                    }

                    // 1400.02.31
                    // به خاطر خروجی برنامه البرز نگار
                    // چون در سایت ژئوجی‌سان دات آی‌او
                    // بارگذاری می شه خروجی‌ها
                    layer.ExportAsGeoJson(fileName, true);
                }
                catch (Exception ex)
                {
                    await map.DialogService.ShowMessageAsync(null, ex.Message, null, null);
                }
            });

            return(result);
        }
Beispiel #6
0
        // ***************** Break into geometries ***
        // *******************************************
        public static ILegendCommand CreateBreakIntoGeometriesCommand(MapPresenter map, DrawingItemLayer layer)
        {
            var result = new LegendCommand()
            {
                PathMarkup = IRI.Jab.Common.Assets.ShapeStrings.SegoePrint.extractGeometries,
                Layer      = layer,
                ToolTip    = "تفکیک به هندسه",
            };

            result.Command = new RelayCommand(async param =>
            {
                try
                {
                    var geometries = layer.Geometry.AsSqlGeometry().GetGeometries();

                    var counter = 0;

                    foreach (var geo in geometries)
                    {
                        map.AddDrawingItem(geo.AsGeometry(), $"{layer.LayerName} Geometry #{counter++}");
                    }
                }
                catch (Exception ex)
                {
                    await map.DialogService.ShowMessageAsync(null, ex.Message, null, null);
                }
            });

            return(result);
        }
Beispiel #7
0
        // ***************** Boundary ****************
        // *******************************************
        public static ILegendCommand CreateGetBoundaryCommand(MapPresenter map, DrawingItemLayer layer)
        {
            var result = new LegendCommand()
            {
                PathMarkup = IRI.Jab.Common.Assets.ShapeStrings.SegoePrint.boundary,
                Layer      = layer,
                ToolTip    = "مرز",
            };

            result.Command = new RelayCommand(async param =>
            {
                try
                {
                    var geometry = layer.Geometry.AsSqlGeometry().STBoundary();

                    map.AddDrawingItem(geometry.AsGeometry(), $"{layer.LayerName}-Boundary");
                }
                catch (Exception ex)
                {
                    await map.DialogService.ShowMessageAsync(null, ex.Message, null, null);
                }
            });

            return(result);
        }
Beispiel #8
0
        public static ILegendCommand CreateExportAsPng(MapPresenter map, VectorLayer layer)
        {
            var result = new LegendCommand()
            {
                PathMarkup = IRI.Jab.Common.Assets.ShapeStrings.Appbar.appbarImage,
                Layer      = layer,
                ToolTip    = _exportAsBitmapToolTip,
            };

            result.Command = new RelayCommand(async param =>
            {
                try
                {
                    var fileName = await map.DialogService.ShowSaveFileDialogAsync("*.png|*.png", null, layer.LayerName);

                    if (string.IsNullOrWhiteSpace(fileName))
                    {
                        return;
                    }

                    layer.SaveAsPng(fileName, map.CurrentExtent, map.ActualWidth, map.ActualHeight, map.MapScale);
                }
                catch (Exception ex)
                {
                    await map.DialogService.ShowMessageAsync(null, ex.Message, null, null);
                }
            });

            return(result);
        }
Beispiel #9
0
        // ***************** Export As Shapefile *****
        // *******************************************
        public static ILegendCommand CreateExportDrawingItemLayerAsShapefile(MapPresenter map, DrawingItemLayer layer)
        {
            var result = new LegendCommand()
            {
                PathMarkup = IRI.Jab.Common.Assets.ShapeStrings.Others.shapefile,
                Layer      = layer,
                ToolTip    = _saveAsShapefileToolTip,
            };

            result.Command = new RelayCommand(async param =>
            {
                try
                {
                    var file = map.DialogService.ShowSaveFileDialog("*.shp|*.shp", null, layer.LayerName);

                    if (string.IsNullOrWhiteSpace(file))
                    {
                        return;
                    }

                    var esriShape = layer.Geometry.AsSqlGeometry().AsEsriShape();

                    IRI.Ket.ShapefileFormat.Shapefile.Save(file, new List <Ket.ShapefileFormat.EsriType.IEsriShape>()
                    {
                        esriShape
                    }, true, true);
                }
                catch (Exception ex)
                {
                    await map.DialogService.ShowMessageAsync(null, ex.Message, null, null);
                }
            });

            return(result);
        }
Beispiel #10
0
        public static LegendCommand Create(ILayer layer, Action action, string markup, string tooltip)
        {
            var result = new LegendCommand()
            {
                PathMarkup = markup,
                Command    = new RelayCommand(param => action()),
                ToolTip    = tooltip,
                Layer      = layer
            };

            result.Command = new RelayCommand(param => action());

            return(result);
        }
Beispiel #11
0
        public static ILegendCommand CreateRemoveLayer(MapPresenter map, ILayer layer)
        {
            var result = new LegendCommand()
            {
                PathMarkup = IRI.Jab.Common.Assets.ShapeStrings.Appbar.appbarDelete,
                Layer      = layer,
                ToolTip    = "حذف لایه",
            };

            result.Command = new RelayCommand(param =>
            {
                map.ClearLayer(layer, true);
            });

            return(result);
        }
Beispiel #12
0
        // ***************** Edit ********************
        // *******************************************
        public static ILegendCommand CreateEditDrawingItemLayer(MapPresenter map, DrawingItemLayer layer)
        {
            var result = new LegendCommand()
            {
                PathMarkup = IRI.Jab.Common.Assets.ShapeStrings.Appbar.appbarEdit,
                Layer      = layer,
                ToolTip    = _editToolTip,
            };

            result.Command = new RelayCommand(async param =>
            {
                var editResult = await map.EditAsync(layer.Geometry, map.MapSettings.EditingOptions);

                if (!(editResult.IsCanceled == true))
                {
                    map.ClearLayer(layer);
                }

                if (editResult.HasNotNullResult())
                {
                    layer.Geometry = editResult.Result;

                    //shapeItem.AssociatedLayer = new VectorLayer(shapeItem.Title, new List<SqlGeometry>() { editResult.Result.AsSqlGeometry() }, VisualParameters.GetRandomVisualParameters(), LayerType.Drawing, RenderingApproach.Default, RasterizationApproach.DrawingVisual);

                    map.ClearLayer(layer);
                    map.AddLayer(layer);
                    //map.SetLayer(layer);

                    // 1400.03.08- remove highlighted geometry
                    layer.IsSelectedInToc = false;
                    //map.ClearLayer(layer.HighlightGeometryKey.ToString(), true, true);

                    //map.Refresh();

                    if (layer.OriginalSource != null)
                    {
                        layer.OriginalSource.Update(new SqlFeature(editResult.Result.AsSqlGeometry())
                        {
                            Id = layer.Id
                        });
                    }
                }
            });

            return(result);
        }
Beispiel #13
0
        // ***************** Remove ******************
        // *******************************************
        public static ILegendCommand CreateRemoveDrawingItemLayer(MapPresenter map, DrawingItemLayer layer)
        {
            var result = new LegendCommand()
            {
                PathMarkup = IRI.Jab.Common.Assets.ShapeStrings.Appbar.appbarDelete,
                Layer      = layer,
                ToolTip    = _removeToolTip,
            };

            result.Command = new RelayCommand(param =>
            {
                map.RemoveDrawingItem(layer);

                //map.Refresh();
            });

            return(result);
        }
Beispiel #14
0
        public static ILegendCommand CreateSelectByDrawing <T>(MapPresenter map, VectorLayer layer) where T : class, ISqlGeometryAware
        {
            var result = new LegendCommand()
            {
                PathMarkup = IRI.Jab.Common.Assets.ShapeStrings.Appbar.appbarVectorPenConvert,
                Layer      = layer,
                ToolTip    = "انتخاب عوارض محدودهٔ ترسیم",
            };

            result.Command = new RelayCommand(async param =>
            {
                var options = EditableFeatureLayerOptions.CreateDefaultForDrawing(false, false);

                options.IsOptionsAvailable = false;

                var drawingResult = await map.GetDrawingAsync(Model.DrawMode.Polygon, options);

                if (!drawingResult.HasNotNullResult())
                {
                    return;
                }

                var features = layer.GetFeatures <T>(drawingResult.Result.AsSqlGeometry());

                if (features == null)
                {
                    return;
                }

                var newLayer = new Model.Map.SelectedLayer <T>(layer)
                {
                    ShowSelectedOnMap = true
                };

                if (features != null)
                {
                    newLayer.Features = new System.Collections.ObjectModel.ObservableCollection <T>(features);
                }

                map.AddSelectedLayer(newLayer);
            });

            return(result);
        }
Beispiel #15
0
        public static ILegendCommand CreateClearSelected(MapPresenter map, VectorLayer layer)
        {
            var result = new LegendCommand()
            {
                PathMarkup       = IRI.Jab.Common.Assets.ShapeStrings.Appbar.appbarClose,
                Layer            = layer,
                ToolTip          = "پاک کردن عوارض انتخابی",
                IsCommandVisible = false,
            };

            result.Command = new RelayCommand(param =>
            {
                map.RemoveSelectedLayer(layer);
            });

            layer.OnSelectedFeaturesChanged += (sender, e) => { result.IsCommandVisible = e.Arg.HasSelectedFeatures; };

            return(result);
        }
Beispiel #16
0
        public static LegendCommand CreateZoomToExtentCommand(MapPresenter map, ILayer layer)
        {
            var result = new LegendCommand()
            {
                PathMarkup = IRI.Jab.Common.Assets.ShapeStrings.Appbar.appbarMagnify,
                Layer      = layer,
                ToolTip    = "محدودهٔ لایه"
            };

            result.Command = new RelayCommand((param) =>
            {
                if (layer == null || map == null)
                {
                    return;
                }

                map.ZoomToExtent(result.Layer.Extent, false);
            });

            return(result);
        }
Beispiel #17
0
        // ***************** Export As GeoJson *******
        // *******************************************
        public static ILegendCommand CreateExportDrawingItemLayerAsGeoJson(MapPresenter map, DrawingItemLayer layer)
        {
            var result = new LegendCommand()
            {
                PathMarkup = IRI.Jab.Common.Assets.ShapeStrings.Others.json,
                Layer      = layer,
                ToolTip    = _saveAsGeoJsonToolTip,
            };

            result.Command = new RelayCommand(async param =>
            {
                try
                {
                    var file = map.DialogService.ShowSaveFileDialog("*.json|*.json", null, layer.LayerName);

                    if (string.IsNullOrWhiteSpace(file))
                    {
                        return;
                    }

                    var feature = GeoJsonFeature.Create(layer.Geometry.Project(SrsBases.GeodeticWgs84).AsGeoJson());

                    GeoJsonFeatureSet featureSet = new GeoJsonFeatureSet()
                    {
                        Features = new List <GeoJsonFeature>()
                        {
                            feature
                        }, TotalFeatures = 1
                    };

                    featureSet.Save(file, false, false);
                }
                catch (Exception ex)
                {
                    await map.DialogService.ShowMessageAsync(null, ex.Message, null, null);
                }
            });

            return(result);
        }
Beispiel #18
0
        public static LegendCommand CreateShowAttributeTable <T>(MapPresenter map, VectorLayer layer) where T : class, ISqlGeometryAware
        {
            var result = new LegendCommand()
            {
                PathMarkup = IRI.Jab.Common.Assets.ShapeStrings.Appbar.appbarPageText,
                Layer      = layer,
                ToolTip    = "اطلاعات توصیفی",
            };

            result.Command = new RelayCommand((param) =>
            {
                if (layer == null || map == null)
                {
                    return;
                }

                //System.Diagnostics.Stopwatch watch = System.Diagnostics.Stopwatch.StartNew();

                //System.Diagnostics.Debug.WriteLine($"Command start");

                var features = (layer as VectorLayer).GetFeatures <T>();

                //var list = new List<SqlIndex250k>() {
                //    new SqlIndex250k(new Msh.Common.Mapping.Index250k()),
                //    new SqlIndex250k(new Msh.Common.Mapping.Index250k()),
                //    new SqlIndex250k(new Msh.Common.Mapping.Index250k()),
                //    new SqlIndex250k(new Msh.Common.Mapping.Index250k()),
                //    new SqlIndex250k(new Msh.Common.Mapping.Index250k())};

                //watch.Stop();
                //System.Diagnostics.Debug.WriteLine($"Get Features finished {watch.ElapsedMilliseconds}");
                //watch.Restart();

                var newLayer = new Model.Map.SelectedLayer <T>(layer);

                //newLayer.RequestSave = l =>
                //{
                //    layer.sou
                //};

                if (features == null)
                {
                    newLayer.Features = new System.Collections.ObjectModel.ObservableCollection <T>();
                }
                else
                {
                    newLayer.Features = new System.Collections.ObjectModel.ObservableCollection <T>(features);
                }


                map.AddSelectedLayer(newLayer);


                //map.SelectedLayers.Add(newLayer);

                //map.CurrentLayer = newLayer;

                //watch.Stop();
                //System.Diagnostics.Debug.WriteLine($"map.SelectedLayers.Add {watch.ElapsedMilliseconds}");
            });

            return(result);
        }