Ejemplo n.º 1
0
        public ImageLayer(LayerManager lm, GravurGIS.MapPanelBindings.ImageLayerInfo info, string name, string path)
        {
            this.Description = "Rasterbild";
            this._layerType  = LayerType.Image;
            this.Visible     = true;
            this.Changed     = true;

            this.layerID = info.id;

            this._boundingBox = new GravurGIS.Topology.WorldBoundingBoxD(info.minBX,
                                                                         info.maxBY, info.maxBX, info.minBY);

            this.LayerName     = name;
            this.layerInfo     = new LayerInfo(path + "\\" + name);
            this.layermanager  = lm;
            this.resolution    = new double[2];
            this.resolution[0] = info.resolutionX;
            this.resolution[1] = info.resolutionY;
        }
Ejemplo n.º 2
0
        public ImageLayer(LayerManager lm, GravurGIS.MapPanelBindings.ImageLayerInfo info, string name, string path)
        {
            this.Description = "Rasterbild";
            this._layerType = LayerType.Image;
            this.Visible = true;
            this.Changed = true;

            this.layerID = info.id;

            this._boundingBox = new GravurGIS.Topology.WorldBoundingBoxD(info.minBX,
                info.maxBY, info.maxBX, info.minBY);

            this.LayerName = name;
            this.layerInfo = new LayerInfo(path + "\\" + name);
            this.layermanager = lm;
            this.resolution = new double[2];
            this.resolution[0] = info.resolutionX;
            this.resolution[1] = info.resolutionY;
        }
Ejemplo n.º 3
0
 public void addImageLayer(string filePath, LayerInfo layerInfo)
 {
     //TODO: sollte man testen, ob alle Werte in layerInfo sinnvoll sind, bzw, von Standardkonstruktor abweichen
     ImageLayer imgLayer = addImageLayer(filePath);
     if (layerInfo != null) imgLayer.LayerInfo = layerInfo;
 }
Ejemplo n.º 4
0
 public void addShapefileLayer(string filePath, LayerInfo layerInfo, VectorInfo vectorInfo)
 {
     //TODO: sollte man testen, ob alle Werte in layerInfo sinnvoll sind, bzw, von Standardkonstruktor abweichen
     ShapeObject shp = addShapefileLayer(filePath);
     if (layerInfo != null) shp.LayerInfo = layerInfo;
     if (vectorInfo != null) {
         shp.VectorInfo = vectorInfo;
         shp.Visible = vectorInfo.IsVisible;
     }
     if (LayerChanged != null) LayerChanged(shp);
 }
Ejemplo n.º 5
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="fileName">gets openFileDialog.FileName as input, its path + fileName of an mwd File</param>
        public void importMWD(string fileName)
        {
            string[] pathnamearray = fileName.Split('\\');
            string pathName = ""; //its the path of the file + "\\"
            for (int i = 0; i <= pathnamearray.Length - 2; i++) pathName += pathnamearray[i] + '\\';

            bool pathFound = false;
            LayerInfo layerInfo = null;
            VectorInfo vectorInfo = null;
            bool isVisible = false;

            LayerType tempType = LayerType.Undefined;
            string tempName = "";
            string file = "";
            double[] Min = { 0, 0 };
            double[] Max = { 0, 0 };
            //check indicates wether all four bbox values are found
            int check = 0;
            bool oneLayerFound = false;
            string errFileNotFound = "";
            System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(fileName); ;

            while (reader.Read())
            {
                if (reader.NodeType == System.Xml.XmlNodeType.Element)
                    if (reader.Name == "z:row")
                    {
                            while (reader.MoveToNextAttribute())
                            {
                                #region im while

                                if (reader.Name == "Xmin") { Min[0] = Convert.ToDouble(reader.Value); check++; }
                                if (reader.Name == "Xmax") { Max[0] = Convert.ToDouble(reader.Value); check++; }
                                if (reader.Name == "Ymin") { Min[1] = Convert.ToDouble(reader.Value); check++; }
                                if (reader.Name == "Ymax") { Max[1] = Convert.ToDouble(reader.Value); check++; }

                                if (reader.Name == "LayerPfad") //LayerPfad muss vor anderen Attributen stehen
                                {
                                    file = reader.Value;
                                    if (File.Exists(file)) pathFound = true;
                                    else if (File.Exists(pathName + Path.GetFileName(file)))
                                    {
                                        file = pathName + Path.GetFileName(file);
                                        pathFound = true;
                                    }
                                    else
                                    {
                                        for (int i = 0; i < config.SearchDirList.Count; i++)
                                        {
                                            if (File.Exists(config.SearchDirList[i] + "\\" + Path.GetFileName(file)))
                                            {
                                                file = config.SearchDirList[i] + "\\" + Path.GetFileName(file);

                                                pathFound = true;
                                                break;
                                            }
                                        }

                                        if (!pathFound) //one of the layer in mwd file could not be found
                                        {
                                            errFileNotFound += file + "\r\n";
                                            //should look after other layerFiles
                                            break;
                                        }
                                    }
                                    if (pathFound)
                                    {
                                        oneLayerFound = true;
                                        layerInfo = new LayerInfo();
                                        vectorInfo = new VectorInfo();
                                        layerInfo.FilePath = file;
                                    }
                                }
                                if (pathFound)
                                {
                                    try
                                    {
                                        if (reader.Name == "Punktfarbe") vectorInfo.PointColor = Color.FromArgb(Int32.Parse(reader.Value));
                                        else if (reader.Name == "Linienfarbe") vectorInfo.LineColor = Color.FromArgb(Convert.ToInt32(reader.Value));
                                        else if (reader.Name == "Fuellfarbe") vectorInfo.FillColor = Color.FromArgb(Int32.Parse(reader.Value));
                                        else if (reader.Name == "Layergefuellt") vectorInfo.Fill = (reader.Value == "True");
                                        else if (reader.Name == "LayerBeschriftung") tempName = reader.Value;
                                        else if (reader.Name == "Visible") vectorInfo.IsVisible = Boolean.Parse(reader.Value);
                                        else if (reader.Name == "Linienstaerke") vectorInfo.LayerPen.Width = float.Parse(reader.Value);
                                        else if (reader.Name == "Punktgroesse") vectorInfo.LayerPen.Width = float.Parse(reader.Value);
                                        else if (reader.Name.ToLower() == "layertype")
                                                {
                                                    if (reader.Value.ToLower() == "image") tempType = LayerType.Image;
                                                    if (reader.Value.ToLower() == "shapefile") tempType = LayerType.Shape;
                                                }
                                    }
                                    catch (Exception)
                                    {
                                        MessageBox.Show("Fehler 0x6221: Die Projektdatei ist fehlerhaft - Layereinstellungen wird ignoriert\nGelesener Wert: "
                                            + reader.Value + "\nDatei: " + layerInfo.FilePath);
                                    }
                                }
                                #endregion
                            }
                        if(pathFound)
                            switch (tempType)
                            {
                                case LayerType.Shape:
                                    addShapefileLayer(file, layerInfo, vectorInfo);
                                    break;
                                case LayerType.Image:
                                    addImageLayer(file,layerInfo);
                                    break;

                                default:
                                    break;
                            }
                        pathFound = false;
                        tempType = LayerType.Undefined;
                        tempName = "";
                        isVisible = false;
                        layerInfo = null;
                        vectorInfo = null;
                    }
            }
            if ((check == 4) && (oneLayerFound)) // all bounding values are found + onelayer -> draw details of map
            {
                // scale und firstscale sind schon gesetzt durch das Laden der Layer

                MapPanel mp = mainControler.MapPanel;
                double zoom = mainControler.MapPanel.calculateZoomFactor(
                        (Max[0] - Min[0]) * scale, (Max[1] - Min[1]) * scale);

                double newAbsoluteZoom = mp.AbsolutZoom * zoom;

                PointD newD = new PointD(
                        Min[0] * firstScale * newAbsoluteZoom,
                        Max[1] * firstScale * newAbsoluteZoom);

                mainControler.PerformAction(
                            new ZoomAction(
                                mp.AbsolutZoom,
                                mainControler.MapPanel.D,
                                newD,
                                newAbsoluteZoom,
                                new PointD(Max[0], -Min[1]),
                                getMaxAbsoluteZoom(),
                                mainControler));
            }
            else {
                if(!oneLayerFound) MessageBox.Show("Die Standardprojektdateien konnten nicht gefunden werden.");
                //wenn die vier werte nicht gefunden werden, bleiben die Ansicht bei der BBox des 1. Layers
            }
            reader.Close();
            //ensure that not two errorMessages appear if no layer was found
            if (!errFileNotFound.Equals("") && oneLayerFound){
                ErrorDialog fileNotFoundDialog = new ErrorDialog();
                fileNotFoundDialog.ShowDialog("Fehler 0x0500 - Folgende Dateien konnten nicht gefunden werden:\r\n" + errFileNotFound + "Projekt wurde ohne diese Dateien geladen.");
            }
            mainControler.MapPanel.ScreenChanged = true;
            mainControler.MapPanel.Invalidate();
            mainControler.MapPanel.Update();
        }