コード例 #1
0
ファイル: support.cs プロジェクト: gisdevelope/MercuryGIS
        public static mapcontent createnewmapcontentofnolayer(string mapname, string server, string port, string username, string password, string database)
        {
            GeoDatabase  gdb       = PGGeoDatabase.GetGeoDatabase(server, port, username, password, database, new List <string>());
            List <Layer> layerlist = new List <Layer>();
            mapcontent   map       = new mapcontent(mapname, gdb, layerlist);

            return(map);
        }
コード例 #2
0
ファイル: support.cs プロジェクト: gisdevelope/MercuryGIS
 public mapcontent(string mapname, GeoDatabase gdb, List <Layer> layerlist)
 {
     this.name      = mapname;
     this.layerlist = layerlist;
     this.gdb       = gdb;
     //???SRS怎么办
     this.srs = new SRS();
     srs.srid = 0;
 }
コード例 #3
0
        private void Open_MouseDown(object sender, RoutedEventArgs e)
        {
            OpenFileDialog opendlg = new OpenFileDialog();

            opendlg.Filter = "smartgisproject(*.pro)|*.pro";
            if (opendlg.ShowDialog(this) == true)
            {
                mappro = MapProject.LoadMapProject(opendlg.FileName);
                if (mappro == null)
                {
                    //MessageBox.Show("打开地图失败!");
                    return;
                }

                mappro.projectpath = opendlg.FileName;
                List <string> datapathlist = mappro.dic_datapath.Values.ToList();
                mapControl.mapcontent = mapcontent.LoadMapContent(mappro.projectname, mappro.dic_datapath, mappro.dic_stylepath, mappro.server, mappro.port, mappro.username, mappro.password, mappro.database);
                this.gdb = mapControl.mapcontent.gdb;
                ShowTreeView(mapControl.mapcontent);
                mapControl.SetDefaultoffsetandDisplayScale(mapControl.mapcontent);
                mapControl.mapcontrol_refresh();
            }

            //OpenFileDialog dialog = new OpenFileDialog();
            //dialog.Filter = "Map File (.txt)|*.txt";
            //if (dialog.ShowDialog() == true)
            //{
            //    string path = dialog.FileName;
            //    mapControl.Map.OpenMap(path);
            //    List<Layer> layers = mapControl.Map.GetLayers();
            //    for (int i = 0; i < mapControl.Map.LayerCount; i++)
            //    {
            //        layers[i].Name = "test";
            //        treeView.Items.Add(new LayerModel(layers[i].Name));
            //        //items.Add(layers[i].Name);
            //    }
            //    mapControl.Refresh();
            //    this.Title = "Mercury GIS - " + System.IO.Path.GetFileNameWithoutExtension(path);
            //    curLayer = layers[0];
            //}
        }
コード例 #4
0
ファイル: support.cs プロジェクト: gisdevelope/MercuryGIS
        /// <summary>
        ///
        /// </summary>
        /// <param name="gdb"></param>
        /// <param name="mapname"></param>
        /// <param name="stylepath">mapproject必须给相同数量的stylepath,如果没有value应该为null,key为layername</param>
        /// <returns></returns>
        public static mapcontent LoadMapContent(string mapname, Dictionary <string, string> datasourcepath, Dictionary <string, string> stylepath, string server, string port, string username, string password, string database)
        {
            List <Layer> layerlist = new List <Layer>();
            GeoDatabase  gdb       = PGGeoDatabase.GetGeoDatabase(server, port, username, password, database, datasourcepath.Values.ToList());

            //Dictionary<String, FeatureSource> dic = gdb.featureSources;
            foreach (string layername in datasourcepath.Keys)
            {
                //获取featuresoucre
                FeatureSource featuresource = null;
                if (!gdb.featureSources.TryGetValue(datasourcepath[layername], out featuresource))
                {
                    continue;
                }

                Layer layer = Layer.LoadLayer(featuresource, layername, stylepath[layername]);
                layerlist.Add(layer);
            }
            mapcontent map = new mapcontent(mapname, gdb, layerlist);

            return(map);
        }
コード例 #5
0
        private void New_MouseDown(Object sender, RoutedEventArgs e)
        {
            NewMap dialog = new NewMap();

            if (dialog.ShowDialog() == true)
            {
                string name = dialog.mapName;
                //创建工程对象
                mappro          = MapProject.CreateMapProject(name);
                mappro.server   = dialog.server;
                mappro.port     = dialog.port;
                mappro.username = dialog.username;
                mappro.password = dialog.password;
                mappro.database = dialog.database;
                //创建mapcontent对象
                mapcontent mapcontent = mapcontent.createnewmapcontentofnolayer(name, dialog.server, dialog.port, dialog.username, dialog.password, dialog.database);
                gdb = mapcontent.gdb;
                mapControl.mapcontent = mapcontent;
                mapControl.mapcontrol_refresh();
                this.Title = "Mercury GIS - " + name;
                //刷新图层树
                //ShowTreeView(mapcontent);
            }
        }