コード例 #1
1
ファイル: SFMap.cs プロジェクト: pedrolandaacurio/gvix
        public void ReadXml(XmlElement projectElement, ProgressLoadStatusHandler loadingDelegate)
        {
            XmlNodeList colorList = projectElement.GetElementsByTagName("MapBackColor");
            if (colorList != null && colorList.Count > 0)
            {
                MapBackColor = ColorTranslator.FromHtml(colorList[0].InnerText);
            }

            ClearShapeFiles();

            XmlNodeList layerNodeList = projectElement.GetElementsByTagName("layers");
            XmlNodeList sfList = ((XmlElement)layerNodeList[0]).GetElementsByTagName("shapefile");

            if (sfList != null && sfList.Count > 0)
            {

                for (int n = 0; n < sfList.Count; n++)
                {
                    EGIS.ShapeFileLib.ShapeFile sf = new EGIS.ShapeFileLib.ShapeFile();

                    sf.ReadXml((XmlElement)sfList[n]);
                    //sf.MapProjectionType = this.projectionType;

                    myShapefiles.Add(sf);

                    if (loadingDelegate != null)
                    {
                        loadingDelegate(sfList.Count, n + 1);
                    }

                }
                //set centre point to centre of shapefile and adjust zoom level to fit entire shapefile
                RectangleF r = ShapeFile.LLExtentToProjectedExtent(this.Extent, this.projectionType);
                
                this._centrePoint = new PointD(r.Left + r.Width / 2, r.Top + r.Height / 2);
                this._zoomLevel = this.ClientSize.Width / r.Width;
                dirtyScreenBuf = true;
                Refresh();
                OnShapeFilesChanged();
                OnZoomLevelChanged();

            }

        }
コード例 #2
0
        private void OpenRoadShapefile(string path)
        {
            // open the shapefile passing in the path, display name of the shapefile and
            // the field name to be used when rendering the shapes (we use an empty string
            // as the field name (3rd parameter) can not be null)
            EGIS.ShapeFileLib.ShapeFile sf = this.sfMap1.AddShapeFile(path, "ShapeFile", "");

            // Setup a dictionary collection of road types and colors
            // We will use this when creating a RoadTypeCustomRenderSettings class to setup which
            //colors should be used to render each type of road
            sf.RenderSettings.FieldName = "name";
            sf.RenderSettings.Font      = new Font(this.Font.FontFamily, 12);
            Dictionary <string, Color> colors = new Dictionary <string, Color>();

            colors.Add("service", Color.Green);
            colors.Add("secondary", Color.Green);
            colors.Add("residential", Color.Blue);
            colors.Add("primary", Color.Yellow);
            SaudiRenderSettings rs = new SaudiRenderSettings(sf.RenderSettings, "TYPE", colors);

            sf.RenderSettings.CustomRenderSettings = rs;
            sf.RenderSettings.UseToolTip           = true;
            sf.RenderSettings.ToolTipFieldName     = "name";
            sf.RenderSettings.MaxPixelPenWidth     = 20;
        }
コード例 #3
0
 private void zoomToSelectionToolStripMenuItem_Click(object sender, EventArgs e)
 {
     EGIS.ShapeFileLib.ShapeFile selectedLayer = layerContextMenu.Tag as EGIS.ShapeFileLib.ShapeFile;
     if (selectedLayer != null)
     {
         _map.ZoomToSelection(selectedLayer);
     }
 }
コード例 #4
0
 private void btnMoveUp_Click(object sender, EventArgs e)
 {
     if (_map != null && lstShapefiles.SelectedItem != null)
     {
         EGIS.ShapeFileLib.ShapeFile sf = lstShapefiles.SelectedItem as EGIS.ShapeFileLib.ShapeFile;
         _map.MoveShapeFileUp(lstShapefiles.SelectedItem as EGIS.ShapeFileLib.ShapeFile);
         lstShapefiles.SelectedItem = sf;
     }
 }
コード例 #5
0
        /// <summary>
        /// Opens the specified shapefile
        /// </summary>
        /// <param name="path">path to the shapefile to be opened</param>
        public void OpenShapeFile(string path)
        {
            string name = path.Substring(path.LastIndexOf("\\") + 1);

            EGIS.ShapeFileLib.ShapeFile sf = sfMap1.AddShapeFile(path, name, "NAME");
            //RectangleF r = sfMap1.Extent;
            //sf.RenderSettings.MinRenderLabelZoom = 25.0f * 512f / r.Width;
            this.shapeFileRenderPropertyGrid.SelectedObject = sf.RenderSettings;
        }
コード例 #6
0
 private void zoomToLayerToolStripMenuItem_Click(object sender, EventArgs e)
 {
     EGIS.ShapeFileLib.ShapeFile selectedLayer = layerContextMenu.Tag as EGIS.ShapeFileLib.ShapeFile;
     if (selectedLayer != null)
     {
         RectangleD extent = selectedLayer.Extent.Transform(selectedLayer.CoordinateReferenceSystem, _map.MapCoordinateReferenceSystem);
         _map.FitToExtent(extent);
     }
 }
コード例 #7
0
 private static void RenderMap(Graphics g, List <EGIS.ShapeFileLib.ShapeFile> layers, int w, int h, PointD centerPt, double zoom)
 {
     lock (EGIS.ShapeFileLib.ShapeFile.Sync)
     {
         for (int n = 0; n < layers.Count; n++)
         {
             EGIS.ShapeFileLib.ShapeFile sf = layers[n];
             //render layers using Mercator ProjectionType for the tiled images
             sf.Render(g, new Size(w, h), centerPt, zoom, ProjectionType.Mercator);
         }
     }
 }
コード例 #8
0
        void OpenRoadsfile(string path)
        {
            this.sfMap1.ClearShapeFiles();

            this.sfMap1.AddShapeFile(path, "Roads", "");

            EGIS.ShapeFileLib.ShapeFile sf = this.sfMap1[0];

            sf.RenderSettings.UseToolTip       = false;
            sf.RenderSettings.ToolTipFieldName = sf.RenderSettings.FieldName;
            sf.RenderSettings.IsSelectable     = false;
        }
コード例 #9
0
        private void HandleRemoveSelectedShapeFile()
        {
            if (_map != null && lstShapefiles.SelectedItem != null)
            {
                if (MessageBox.Show(this, "Remove Layer " + lstShapefiles.SelectedItem.ToString() + "?", "Confirm Layer Removal", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    EGIS.ShapeFileLib.ShapeFile sf = lstShapefiles.SelectedItem as EGIS.ShapeFileLib.ShapeFile;

                    _map.RemoveShapeFile(sf);
                    sf.Close();
                }
            }
        }
コード例 #10
0
        public SaudiRenderSettings(RenderSettings defaultSettings, string serialNbr, EGIS.ShapeFileLib.ShapeFile shpfile1)
        {
            this.defaultSettings = defaultSettings;
            //this.defaultSettings.FillColor = Color.Blue;
            this.defaultSettings.FillInterior = true;
            this.defaultSettings.OutlineColor = Color.Transparent;
            this.defaultSettings.MinZoomLevel = -1;
            this.defaultSettings.MaxZoomLevel = -1;
            //this.defaultSettings.RenderQuality = EGIS.ShapeFileLib.RenderQuality.High;

            this.defaultSettings.UseToolTip   = false;
            this.defaultSettings.IsSelectable = false;

            BuildColorList(defaultSettings, serialNbr, shpfile1);
        }
コード例 #11
0
        void OpenMetersfile(string path)
        {
            this.sfMap1.AddShapeFile(path, "meters", "");

            EGIS.ShapeFileLib.ShapeFile sf = this.sfMap1[1];

            rs = new SaudiRenderSettings(sf.RenderSettings, "Serial Num", sf);
            sf.RenderSettings.CustomRenderSettings = rs;

            sf.RenderSettings.UseToolTip       = false;
            sf.RenderSettings.ToolTipFieldName = sf.RenderSettings.FieldName;
            sf.RenderSettings.IsSelectable     = false;

            sf.SelectRecord(0, true);
        }
コード例 #12
0
 private void LoadFindTextAutoCompleteData(EGIS.ShapeFileLib.ShapeFile shapeFile, bool clearExisting)
 {
     if (clearExisting)
     {
         this.tsTxtFind.AutoCompleteCustomSource.Clear();
     }
     if (shapeFile == null || shapeFile.RenderSettings == null)
     {
         return;
     }
     if (shapeFile.RenderSettings.FieldIndex >= 0 && shapeFile.RenderSettings.IsSelectable)
     {
         string[] records = shapeFile.GetRecords(shapeFile.RenderSettings.FieldIndex);
         this.tsTxtFind.AutoCompleteCustomSource.AddRange(records);
     }
 }
コード例 #13
0
 private void map_ShapeFilesChanged(object sender, EventArgs args)
 {
     this.lstShapefiles.Items.Clear();
     if (Map == null)
     {
         return;
     }
     EGIS.ShapeFileLib.ShapeFile[] shapefiles = new EGIS.ShapeFileLib.ShapeFile[_map.ShapeFileCount];
     for (int n = 0; n < shapefiles.Length; n++)
     {
         shapefiles[n] = _map[n];
     }
     this.lstShapefiles.Items.AddRange(shapefiles);
     if (lstShapefiles.Items.Count > 0)
     {
         this.lstShapefiles.SelectedIndex = lstShapefiles.Items.Count - 1;
     }
 }
コード例 #14
0
        void BuildColorList(RenderSettings defaultSettings, string serialNbr, EGIS.ShapeFileLib.ShapeFile shpfile2)
        {
            int fieldIndex = defaultSettings.DbfReader.IndexOfFieldName(serialNbr);

            if (fieldIndex >= 0)
            {
                colorList     = new List <System.Drawing.Color>();
                metersListGIS = new Dictionary <string, int>(40000);

                int numRecords = defaultSettings.DbfReader.DbfRecordHeader.RecordCount;
                for (int n = 0; n < numRecords; ++n)
                {
                    colorList.Add(Color.Red);
                    metersListGIS.Add(shpfile2.GetAttributeFieldValues(n)[fieldIndex].Trim(), n);
                }
            }
            else
            {
                MessageBox.Show("Couldn't find Field Name");
            }
        }
コード例 #15
0
ファイル: SFMap.cs プロジェクト: pedrolandaacurio/gvix
 private EGIS.ShapeFileLib.ShapeFile OpenShapeFile(string path, string name, string renderFieldName)
 {
     if (path.EndsWith(".shp", StringComparison.OrdinalIgnoreCase))
     {
         path = path.Substring(0, path.Length - 4);
     }
     else
     {
         throw new ArgumentException("path does not end in \".shp\"");
     }
     
     EGIS.ShapeFileLib.ShapeFile sf = new EGIS.ShapeFileLib.ShapeFile();
    
     sf.LoadFromFile(path);
     sf.Name = name;
     //sf.MapProjectionType = this.projectionType;
     sf.RenderSettings = new EGIS.ShapeFileLib.RenderSettings(path, renderFieldName, new Font(this.Font.FontFamily, 6f));
     LoadOptimalRenderSettings(sf);
     myShapefiles.Add(sf);
     return sf;
 }
コード例 #16
0
 private void LoadFindTextAutoCompleteData(EGIS.ShapeFileLib.ShapeFile shapeFile)
 {
     LoadFindTextAutoCompleteData(shapeFile, true);
 }
コード例 #17
0
ファイル: SFMap.cs プロジェクト: pedrolandaacurio/gvix
        internal static MapProject ReadXml(XmlElement projectElement, string rootPath, SFMap mapRef)
        {
            MapProject mapProject = new MapProject();

            XmlNodeList colorList = projectElement.GetElementsByTagName("MapBackColor");
            if (colorList != null && colorList.Count > 0)
            {
                mapProject.BackgroundColor = ColorTranslator.FromHtml(colorList[0].InnerText);
                
            }
            else if (mapRef != null)
            {
                mapProject.BackgroundColor = mapRef.BackColor;
            }

            //clear layers
            List<EGIS.ShapeFileLib.ShapeFile> myShapefiles = new List<EGIS.ShapeFileLib.ShapeFile>();

            XmlNodeList layerNodeList = projectElement.GetElementsByTagName("layers");
            XmlNodeList sfList = ((XmlElement)layerNodeList[0]).GetElementsByTagName("shapefile");

            if (sfList != null && sfList.Count > 0)
            {

                for (int n = 0; n < sfList.Count; n++)
                {
                    EGIS.ShapeFileLib.ShapeFile sf = new EGIS.ShapeFileLib.ShapeFile();
                    XmlElement elem = sfList[n] as XmlElement;
                    elem.GetElementsByTagName("path")[0].InnerText = rootPath + elem.GetElementsByTagName("path")[0].InnerText;
                    sf.ReadXml(elem);
                    myShapefiles.Add(sf);
                }                
            }

            //EGIS.ShapeFileLib.ShapeFile.UseMercatorProjection = false;
            mapProject.Layers = myShapefiles;
            return mapProject;
        }