Example #1
0
        private WorldFileInfo GetWorldFileInfo(Uri uri)
        {
            WorldFileInfo wInfo         = new WorldFileInfo();
            string        worldFileName = GetWorldFileName(uri.LocalPath);

            if (File.Exists(worldFileName))
            {
                wInfo.WorldFilePath = worldFileName;
            }
            else
            {
                if (RequireWorldFile)
                {
                    BoundingBoxWindow dialog = new BoundingBoxWindow();
                    if (dialog.ShowDialog().GetValueOrDefault())
                    {
                        BoundingBoxWindowViewModel worldFileEntity = dialog.SelectedBoundingBox;
                        RectangleShape             bboxShape       = new RectangleShape(worldFileEntity.Left, worldFileEntity.Top, worldFileEntity.Right, worldFileEntity.Bottom);
                        wInfo.ImageExtent = bboxShape;
                        wInfo.ImageWidth  = worldFileEntity.Width;
                        wInfo.ImageHeight = worldFileEntity.Height;
                        WarningToSave(bboxShape, worldFileEntity.Width, worldFileEntity.Height, worldFileName);
                    }
                }
            }
            return(wInfo);
        }
        protected override RasterLayer GetRasterLayer(Uri uri, WorldFileInfo wInfo)
        {
            WmsRasterLayer             layer     = null;
            WmsRasterLayerConfigWindow wmsWindow = new WmsRasterLayerConfigWindow();

            wmsWindow.ViewModel.AddToDataRepositoryVisibility = Visibility.Visible;
            if (wmsWindow.ShowDialog().GetValueOrDefault())
            {
                WmsRasterLayer wmsRasterlayer = wmsWindow.ViewModel.WmsRasterLayer;
                wmsRasterlayer.InitializeProj4Projection(GisEditor.ActiveMap.DisplayProjectionParameters);
                if (wmsRasterlayer != null && wmsRasterlayer.ActiveLayerNames.Count > 0)
                {
                    layer = wmsRasterlayer;
                }
                if (wmsWindow.ViewModel.DoesAddToDataRepository)
                {
                    var wmsDataPlugin = GisEditor.DataRepositoryManager.GetPlugins().OfType <WmsDataRepositoryPlugin>().FirstOrDefault();
                    if (wmsDataPlugin != null)
                    {
                        wmsDataPlugin.RootDataRepositoryItem.Children.Add(new WmsDataRepositoryItem(
                                                                              wmsWindow.ViewModel.Name,
                                                                              new ObservableCollection <string>(wmsWindow.ViewModel.AvailableLayers.Select(l => l.Name)),
                                                                              wmsWindow.ViewModel.WmsServerUrl,
                                                                              wmsWindow.ViewModel.UserName,
                                                                              wmsWindow.ViewModel.Password,
                                                                              wmsWindow.ViewModel.Parameters,
                                                                              wmsWindow.ViewModel.Formats,
                                                                              wmsWindow.ViewModel.Styles,
                                                                              wmsWindow.ViewModel.SelectedFormat,
                                                                              wmsWindow.ViewModel.SelectedStyle));
                    }
                }
            }
            return(layer);
        }
        protected override RasterLayer GetRasterLayer(Uri uri, WorldFileInfo wInfo)
        {
            GeoTiffRasterLayer layer = null;

            if (File.Exists(wInfo.WorldFilePath))
            {
                layer = new GeoTiffRasterLayer(uri.LocalPath, wInfo.WorldFilePath);
            }
            else
            {
                layer = new GeoTiffRasterLayer(uri.LocalPath);
            }

            layer.DrawingExceptionMode = DrawingExceptionMode.DrawException;
            //if (Environment.OSVersion.Version.Major <= 5)
            //{
            //    layer.LibraryType = GeoTiffLibraryType.ManagedLibTiff;
            //}
            //else
            //{
            //    layer.LibraryType = GeoTiffLibraryType.UnmanagedLibTiff;
            //}

            return(layer);
        }
        protected override RasterLayer GetRasterLayer(Uri uri, WorldFileInfo wInfo)
        {
            RasterLayer layer = null;

            if (File.Exists(wInfo.WorldFilePath))
            {
                layer = new MrSidRasterLayer(uri.LocalPath, wInfo.WorldFilePath);
            }
            else
            {
                layer = new MrSidRasterLayer(uri.LocalPath);
            }

            //layer.SafeProcess(() =>
            //{
            //    if (layer.HasProjectionText)
            //    {
            //        string proj = layer.GetProjectionText();
            //        if (!proj.Equals(GisEditor.ActiveMap.DisplayProjectionParameters, StringComparison.OrdinalIgnoreCase))
            //        {
            //            Proj4Projection projection = new Proj4Projection();
            //            projection.InternalProjectionParametersString = proj;
            //            projection.ExternalProjectionParametersString = GisEditor.ActiveMap.DisplayProjectionParameters;
            //            layer.ImageSource.Projection = projection;
            //        }
            //    }
            //});

            return(layer);
        }
Example #5
0
        protected override RasterLayer GetRasterLayer(Uri uri, WorldFileInfo wInfo)
        {
            RasterLayer layer = null;

            if (File.Exists(wInfo.WorldFilePath))
            {
                layer = new Jpeg2000RasterLayer(Path.GetFullPath(uri.LocalPath), wInfo.WorldFilePath);
            }
            else if (wInfo.ImageExtent != null)
            {
                layer = new Jpeg2000RasterLayer(Path.GetFullPath(uri.LocalPath), wInfo.ImageExtent);
            }
            return(layer);
        }
        protected override RasterLayer GetRasterLayer(Uri uri, WorldFileInfo wInfo)
        {
            EcwRasterLayer layer = null;

            if (File.Exists(wInfo.WorldFilePath))
            {
                layer = new EcwRasterLayer(uri.LocalPath, wInfo.WorldFilePath);
            }
            else
            {
                layer = new EcwRasterLayer(uri.LocalPath);
            }

            return(layer);
        }
Example #7
0
        protected override Collection <Layer> GetLayersCore(GetLayersParameters getLayersParameters)
        {
            Collection <Layer> layers = base.GetLayersCore(getLayersParameters);

            foreach (var uri in getLayersParameters.LayerUris)
            {
                WorldFileInfo wInfo = GetWorldFileInfo(uri);
                RasterLayer   layer = GetRasterLayer(uri, wInfo);

                if (layer != null)
                {
                    layer.UpperThreshold = double.MaxValue;
                    layer.LowerThreshold = 0d;
                    layer.Name           = Path.GetFileNameWithoutExtension(uri.LocalPath);

                    layer.Open();
                    if (!layer.HasProjectionText)
                    {
                        string proj4PathFileName = Path.ChangeExtension(uri.LocalPath, "prj");
                        string proj4Parameter    = LayerPluginHelper.GetProj4ProjectionParameter(proj4PathFileName);
                        if (!string.IsNullOrEmpty(proj4Parameter))
                        {
                            layer.InitializeProj4Projection(proj4Parameter);
                        }
                    }
                    else
                    {
                        string proj = layer.GetProjectionText().Trim();
                        if (!string.IsNullOrEmpty(proj))
                        {
                            layer.InitializeProj4Projection(proj);
                        }
                    }

                    layer.Close();

                    layers.Add(layer);
                }
            }

            return(layers);
        }
Example #8
0
 protected abstract RasterLayer GetRasterLayer(Uri uri, WorldFileInfo wInfo);