Ejemplo n.º 1
0
        /// <summary>
        /// 查询数据,将查询到的结果放到新建的 temp 类中
        /// </summary>
        /// <param name="className">要查询的类的名字</param>
        /// <param name="search">查询语句</param>
        /// <param name="tempClass">要创建的临时类</param>
        /// <returns></returns>
        public static bool SearchData(string className, string search, string tempClass)
        {
            //定义变量
            IVectorCls VectorCls = new SFeatureCls();
            //打开简单要素类
            bool rtn = VectorCls.Open("GDBP://MapGisLocal/Templates/sfcls/" + className);

            if (!rtn)
            {
                PUMessageBox.ShowDialog("简单要素类 " + className + " 打开失败", "失败");
                return(false);
            }

            QueryDef def = new QueryDef();

            //设置属性查询条件
            def.Filter = search;
            //查询要素
            RecordSet recordSet = VectorCls.Select(def);

            if (recordSet != null)
            {
                int num = recordSet.Count;
            }
            else
            {
                return(false);
            }

            Server svr = new Server();

            //连接数据源
            svr.Connect("MapGISLocal", "", "");
            DataBase    GDB      = svr.OpenGDB("templates");
            SFeatureCls tmpSFCls = new SFeatureCls(GDB);
            int         id       = tmpSFCls.Create(tempClass, GeomType.Pnt, 0, 0, null);

            if (id == 0)
            {
                bool temp = SFeatureCls.Remove(GDB, tempClass);
                id = tmpSFCls.Create(tempClass, GeomType.Pnt, 0, 0, null);
                if (id == 0)
                {
                    PUMessageBox.ShowDialog("无法操作简单要素类,请检查是否有其他进程正在使用 " + tempClass, "失败");
                    return(false);
                }
            }

            rtn = tmpSFCls.CopySet(recordSet);
            if (rtn == false)
            {
                tmpSFCls.Close();
                SFeatureCls.Remove(GDB, id);
            }
            //关闭类
            VectorCls.Close();
            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 向数据库添加点数据
        /// </summary>
        public static bool ImportSFCLSData(DataTable dataTable, string className)
        {
            DataBase gdb = DataBase.OpenByURL("GDBP://MapGisLocal/Templates");
            //打开简单要素类
            SFeatureCls sfcls = gdb.GetXClass(XClsType.SFCls) as SFeatureCls;
            bool        op    = sfcls.Open(className, 0);

            GeoPoints pnts   = null;
            Dot3D     newdot = new Dot3D();
            //PntInfo pntInfo = new PntInfo();

            int i = 0;

            foreach (DataRow dr in dataTable.Rows)
            {
                double.TryParse(dr["x 坐标"].ToString(), out double x);
                double.TryParse(dr["y 坐标"].ToString(), out double y);
                //点要素坐标
                newdot.X = y;
                newdot.Y = x;
                newdot.Z = 0;
                pnts     = new GeoPoints();
                pnts.Append(newdot);

                Record rcd  = new Record();
                Fields Flds = sfcls.Fields;
                if (Flds == null)
                {
                    return(false);
                }

                PntInfo pntInfo = new PntInfo();
                //点参数
                pntInfo.LibID  = 0;
                pntInfo.SymID  = 1;
                pntInfo.Width  = 10;
                pntInfo.Height = 10;


                rcd.Fields = Flds;

                //设置属性字段的值
                rcd.set_FldVal(1, (i++).ToString());
                rcd.set_FldVal(2, dr["车牌"].ToString());
                string time = dr["时间"].ToString().Replace('T', ' ');
                rcd.set_FldVal(3, time);
                rcd.set_FldVal(4, time);
                rcd.set_FldVal(5, x);
                rcd.set_FldVal(6, y);

                //添加点要素
                long oid = sfcls.Append(pnts, rcd, pntInfo);
            }

            Debug.WriteLine("Done.");
            return(true);
        }
Ejemplo n.º 3
0
        private void 添加图层ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //判断地图视图中是否有处于显示状态中的地图
            if (this.mapCtrl.ActiveMap == null)
            {
                MessageBox.Show("请先在地图视图中显示一幅地图!!!");
                return;
            }

            //选择待添加的图层
            GDBOpenFileDialog ofDlg = new GDBOpenFileDialog();

            //ofDlg.Filter = "简单要素类、注记类|sfcls;acls";
            if (ofDlg.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            string fileName = ofDlg.FileName;

            IVectorCls sfcls = new SFeatureCls();

            if (sfcls.Open(fileName))
            {
                MessageBox.Show("打开成功");
            }
            else
            {
                MessageBox.Show("打开失败");
            }
            return;

            this._Tree.WorkSpace.BeginUpdateTree();

            //附加矢量图层
            VectorLayer vecLayer = new VectorLayer(VectorLayerType.SFclsLayer);

            vecLayer.AttachData(sfcls);
            //将图层添加到地图中
            vecLayer.Name = sfcls.ClsName;
            //获取激活地图
            Map activeMap = this.mapCtrl.ActiveMap;

            activeMap.Append(vecLayer);
            //复位
            this.mapCtrl.ActiveMap = activeMap;
            this.mapCtrl.Restore();

            this._Tree.WorkSpace.EndUpdateTree();

            return;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 获取一天的骑行量
        /// </summary>
        /// <returns></returns>
        public static double[] GetOneDayData(string className)
        {
            //0:00 1:00 ... 23:00
            double[] results = new double[24] {
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
            };

            //定义变量
            IVectorCls VectorCls = new SFeatureCls();
            //打开简单要素类
            bool rtn = VectorCls.Open("GDBP://MapGisLocal/Templates/sfcls/" + className);

            if (!rtn)
            {
                PUMessageBox.ShowDialog("简单要素类 " + className + " 打开失败", "失败");
                return(null);
            }

            QueryDef  def       = new QueryDef();
            RecordSet recordSet = null;

            for (int i = 0; i < 23; i++)
            {
                //设置属性查询条件
                def.Filter = "ParkTime > '" + i + ":00:00' AND ParkTime < '" + (i + 1).ToString() + ":00:00'";
                //查询要素
                recordSet = VectorCls.Select(def);
                if (recordSet != null)
                {
                    results[i] = recordSet.Count;
                }
            }

            def.Filter = "ParkTime > '23:00:00'";
            //查询要素
            recordSet = VectorCls.Select(def);
            if (recordSet != null)
            {
                results[23] = recordSet.Count;
            }

            //关闭类
            VectorCls.Close();
            return(results);
        }
Ejemplo n.º 5
0
        void test()
        {
            //设置转换源数据url,67数据为区简单要素类
            string SrcUrl = @"D:\武汉地质调查中心---矿产资源潜力评价项目\广西壮族自治区\铝土矿种潜力评价图库\DZ_成矿地质背景\CJGZ_预测工作区沉积建造构造图\JWMAP_经纬坐标图件\MDZCJGZDFSPX_扶绥-凭祥预测工作区沉积建造构造图\LDLYAAB002.WT";
            //目的数据的名称
            string DesSFname = "convertsfcls";

            SFeatureCls decsfc = null;

            Server   Svr = null;
            DataBase GDB = null;

            Svr = new Server();

            Svr.Connect("MapGISLocal", "", "");
            GDB = Svr.OpenGDB("test");

            decsfc = new SFeatureCls(GDB);

            //创建区简单要素类目的数据
            decsfc.Create(DesSFname, GeomType.Pnt, 0, 0, null);

            //设置转换类型
            DataConvert dataConvert = new DataConvert();

            dataConvert.SetOption(ConvertOptionType.OPT_6TO7, 0);

            //打开源数据和目的数据
            if (dataConvert.OpenSource(SrcUrl) > 0 && dataConvert.OpenDestination(decsfc) > 0)
            {
                //转换数据
                bool rtn = dataConvert.Convert() > 0;
                if (rtn)
                {
                    MessageBox.Show("数据迁移成功");
                }
                else
                {
                    MessageBox.Show("数据转换失败");
                }
                dataConvert.Close();
                decsfc.Close();
            }
        }
        /// <summary>
        /// 获取类的所有字段显示到列表中
        /// </summary>
        /// <param name="className"></param>
        private void ShowFlds(string className)
        {
            AttrListView.Items.Clear();
            FldsNames = new List <string>();

            //打开选中的简单要素类
            Server svr = new Server();

            svr.Connect("MapGISLocal", "", "");
            DataBase    GDB   = svr.OpenGDB("Templates");
            SFeatureCls SFCls = new SFeatureCls(GDB);

            SFCls.Open(className, 0);

            Fields Flds = null; //获取属性结构
            Field  Fld  = null; //获取属性字段信息

            Fld  = new Field();
            Flds = new Fields();

            //直接取它的属性结构
            Flds = SFCls.Fields;
            if (Flds == null)
            {
                return;
            }

            //可以查看属性结构对象中的字段数目
            int cou = Flds.Count;

            //获取属性字段
            int i = 0;

            while (i < cou)
            {
                Fld = Flds.GetItem(i);
                AttrListView.Items.Add(Fld.FieldName + " (" + GetFieldTypeText(Fld.FieldType) + ")");
                FldsNames.Add(Fld.FieldName);
                i++;
            }
            SFCls.Close();
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 获取热点数据
        /// </summary>
        /// <param name="className"></param>
        /// <returns></returns>
        public static double[] GetGeoHeatMapData(string className)
        {
            double[] results = new double[81];
            for (int i = 0; i < 81; i++)
            {
                results[i] = 0;
            }

            //定义变量
            IVectorCls VectorCls = new SFeatureCls();
            //打开简单要素类
            bool rtn = VectorCls.Open("GDBP://MapGisLocal/Templates/sfcls/" + className);

            if (!rtn)
            {
                PUMessageBox.ShowDialog("简单要素类 " + className + " 打开失败", "失败");
                return(null);
            }

            QueryDef  def       = new QueryDef();
            RecordSet recordSet = null;
            int       index     = 0;
            double    xStart    = 113.750;
            double    yStart    = 31.000;

            for (int y = 0; y < 9; y++)
            {
                for (int x = 0; x < 9; x++)
                {
                    def.Filter = "yAsis > " + (xStart + 0.125 * x).ToString() + " AND yAsis < " + (xStart + 0.125 * x + 0.125).ToString() + " AND xAsis < " + (yStart - 0.125 * y).ToString() + " AND xAsis > " + (yStart - 0.125 * y - 0.125) + "";
                    recordSet  = VectorCls.Select(def);
                    if (recordSet != null)
                    {
                        results[index++] = recordSet.Count;
                    }
                }
            }

            //关闭类
            VectorCls.Close();
            return(results);
        }
Ejemplo n.º 8
0
        private void 打开ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //定义数据源
            Server svr = new Server();

            //连接数据源
            if (svr.Connect("MapGISLocal", "", ""))
            {
                ;
            }
            {
                //打开数据库
                DataBase gdb = svr.OpenGDB("sample");
                if (gdb != null)
                {
                    //打开简单要素类
                    SFeatureCls sfcls = new SFeatureCls(gdb);
                    if (sfcls.Open("等值线", 0))
                    {
                        MessageBox.Show("读取数据成功");
                        //显示简单要素类,实例地图显示控件
                        //实例化地图显示控件
                        MapControl mapCtrl = new MapControl();
                        mapCtrl.Dock = DockStyle.Fill;
                        //添加控件
                        this.splitContainer1.Panel2.Controls.Add(mapCtrl);
                        //创建图层
                        VectorLayer layer = new VectorLayer(VectorLayerType.SFclsLayer);
                        if (layer.AttachData(sfcls))
                        {
                            Map map = new Map();
                            map.Append(layer);
                            mapCtrl.ActiveMap = map;
                            //复位显示地图
                            mapCtrl.Restore();
                        }
                    }
                }
            }
        }
Ejemplo n.º 9
0
        private void  择ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Map      acMap    = this.mapCtrl.ActiveMap;
            MapLayer mapLayer = null;

            if (acMap.LayerCount > 0)
            {
                mapLayer = acMap.get_Layer(0);
            }
            SFeatureCls Sfcls  = mapLayer.GetData() as SFeatureCls;
            FileLayer6x file6x = mapLayer as FileLayer6x;

            VectorLayer veclayer = file6x.get_Item(0) as VectorLayer;

            Sfcls = veclayer.GetData() as SFeatureCls;

            SFeatureCls tesfcl = new SFeatureCls();

            if (!tesfcl.Open("file:///c:\\users\\tangchao\\desktop\\ppp.wp"))
            {
                int i = 0;
            }

            QueryDef def = new QueryDef();

            def.Filter = "NAME=吉林省";
            RecordSet rst = Sfcls.Select(def);

            this.mapCtrl.FlashSelectSet();
            //设置为拉框查询
            SelectType seltype = SelectType.Rectangle;

            //创建拉框选择类对象
            mapCtrl.SetBasTool(null);
            CirSelectToolClass basTool = new CirSelectToolClass(mapCtrl, SelectDataType.Anyone, attCtrl, seltype);

            mapCtrl.SetBasTool(basTool);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 获取简单要素类列表
        /// </summary>
        /// <param name="url">要打开的地理数据库的url</param>
        /// <returns></returns>
        public static List <string> GetXClasses(string url)
        {
            List <string> names = new List <string>();
            Server        Svr   = new Server();

            Svr.Connect("MapGISLocal", "", "");
            DataBase GDB = Svr.OpenGDB("Templates");

            int count;

            List <int> dsIDs   = null; //要素数据集ID列表
            List <int> sfIDs   = null; //要素数据集中矢量类的ID列表
            List <int> dbSFIDs = null; //数据库中矢量类的ID列表

            List <string> allnames = new List <string>();

            //先查找要素数据集中的矢量类信息
            if (true)
            {
                dsIDs = GDB.GetXclses(XClsType.Fds, 0);

                if (dsIDs != null)
                {
                    count = dsIDs.Count;

                    while (count > 0)
                    {
                        sfIDs = GDB.GetXclses(XClsType.SFCls, dsIDs[count - 1]);
                        if (sfIDs == null)
                        {
                            break;
                        }

                        int n = sfIDs.Count;
                        while (n > 0)
                        {
                            string ClsName = GDB.GetXclsName(XClsType.SFCls, sfIDs[n - 1]);
                            string FdsName = GDB.GetXclsName(XClsType.Fds, dsIDs[count - 1]);
                            allnames.Add(sfIDs[n - 1].ToString() + ". " + ClsName);

                            allnames.Add(dsIDs[count - 1].ToString() + ". " + FdsName);
                            n--;
                        }
                        count--;
                    }
                }
            }

            //再查找数据库中的矢量类,如果查询的是要素数据集,则只需要执行下面语句就可以了
            dbSFIDs = GDB.GetXclses(XClsType.SFCls, 0);
            if (dbSFIDs != null)
            {
                count = dbSFIDs.Count;
                while (count > 0)
                {
                    string SFName = GDB.GetXclsName(XClsType.SFCls, dbSFIDs[count - 1]);
                    allnames.Add(dbSFIDs[count - 1].ToString() + " " + SFName);

                    //如果是简单要素类,则添加其几何类型
                    if (true)
                    {
                        SFeatureCls sfcls = new SFeatureCls(GDB);
                        sfcls.Open(SFName, 0);
                        sfcls.Close();
                    }
                    count--;
                }
            }
            return(allnames);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 创建简单要素类
        /// </summary>
        /// <param name="layerName">要素类名</param>
        /// <param name="geomType">几何类型,枚举</param>
        /// <param name="gdbName">打开的地理数据库名</param>
        public static bool CreateXClass(string layerName, GeomType geomType, string gdbName, string[] fields)
        {
            //方法:指定类型、数据集ID,空间参考系,创建类
            Server      svr   = new Server();
            SFeatureCls sfcls = null;
            //连接数据源,打开数据库
            bool rtn = svr.Connect("MapGISLocal", "", "");

            if (rtn == true)
            {
                DataBase gdb = svr.OpenGDB(gdbName);
                //打开简单要素类
                sfcls = gdb.GetXClass(XClsType.SFCls) as SFeatureCls;
                //创建区类型的简单要素类
                int id = sfcls.Create(layerName, geomType, 0, 0, null);
                if (id <= 0)
                {
                    //关闭类、数据库、断开数据源
                    sfcls.Close();
                    gdb.Close();
                    svr.DisConnect();
                    return(false);
                }

                sfcls.Open(layerName, 0);
                Fields temp = sfcls.Fields;
                if (temp == null)
                {
                    temp = new Fields();
                }
                //Field adding = null;

                #region 添加属性

                //1: successful  0: failed
                int result = temp.AppendField(new Field
                {
                    FieldName   = "DataID",
                    FieldLength = 255,
                    FieldType   = FieldType.FldString,
                    Editable    = 1,
                    MskLength   = 15
                });

                result = temp.AppendField(new Field
                {
                    FieldName   = "BikeID",
                    FieldLength = 255,
                    FieldType   = FieldType.FldString,
                    Editable    = 1,
                    MskLength   = 15
                });

                result = temp.AppendField(new Field
                {
                    FieldName   = "ParkTime",
                    FieldType   = FieldType.FldTime,
                    Editable    = 1,
                    FieldLength = 10,
                    MskLength   = 10
                });

                result = temp.AppendField(new Field
                {
                    FieldName   = "Date",
                    FieldType   = FieldType.FldTime,
                    Editable    = 1,
                    FieldLength = 10,
                    MskLength   = 10
                });

                result = temp.AppendField(new Field
                {
                    FieldName   = "xAsis",
                    FieldLength = 255,
                    FieldType   = FieldType.FldDouble,
                    Editable    = 1,
                    MskLength   = 15
                });

                result = temp.AppendField(new Field
                {
                    FieldName   = "yAsis",
                    FieldLength = 255,
                    FieldType   = FieldType.FldDouble,
                    Editable    = 1,
                    MskLength   = 15
                });

                #endregion

                //foreach (var item in fields)
                //{
                //    adding = new Field
                //    {
                //        FieldName = item,
                //        FieldLength = 255,
                //        FieldType = FieldType.FldString,
                //        Editable = 1,
                //        MskLength = 15
                //    };
                //    int result = temp.AppendField(adding);  //1: successful  0: failed
                //}
                sfcls.Fields = temp;

                //关闭类、数据库、断开数据源
                sfcls.Close();
                gdb.Close();
                svr.DisConnect();

                if (id > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 12
0
        private void 闪烁ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.mapCtrl.EndFlash();
            IVectorCls VectorCls = new SFeatureCls();

            if (!VectorCls.Open("file:///c:\\users\\tangchao\\desktop\\ppp.wp"))
            {
                int i = 0;
            }
//             DataConvert dc = new DataConvert();
//             if (dc.OpenSource(VectorCls) > 0 && dc.OpenDestination("c:\\users\\tangchao\\desktop\\ppptrr.wp") > 0)
//             {
//                 dc.Convert();
//             }
            QueryDef def1 = new QueryDef();

            def1.Filter = "NAME='黑龙江省            'or ID > 3";
            SelectOption option = null;

            option = new SelectOption();
            //类型是点、线、区、注记的图层均属于查询范围
            option.DataType = SelectDataType.AnyVector;
            //当前地图中所有图层
            option.LayerCtrl = SelectLayerControl.Visible;
            //多选
            option.SelMode = SelectMode.Multiply;
            //结果数据累加
            option.UnMode = UnionMode.Add;
            //查询
            SelectSet set = this.mapCtrl.ActiveMap.Select(def1, true, null, option);

            this.mapCtrl.FlashSelectSet();
            return;

            RecordSet rst1 = VectorCls.Select(def1);

            Map      acMap    = this.mapCtrl.ActiveMap;
            MapLayer mapLayer = null;

            if (acMap.LayerCount > 0)
            {
                mapLayer = acMap.get_Layer(0);
            }
            SFeatureCls Sfcls    = mapLayer.GetData() as SFeatureCls;
            FileLayer6x file6x   = mapLayer as FileLayer6x;
            VectorLayer veclayer = file6x.get_Item(0) as VectorLayer;

            Sfcls = veclayer.GetData() as SFeatureCls;

            QueryDef def = new QueryDef();

            def.Filter = "ID>6";
            RecordSet rst = Sfcls.Select(def);

            if (rst == null || rst.Count == 0)
            {
                MessageBox.Show("未查询到数据");
                return;
            }
            this.attCtrl.SetXCls(Sfcls, rst);
            SelectSet sleset = this.mapCtrl.ActiveMap.GetSelectSet();

            sleset.Append(mapLayer, rst);
            this.mapCtrl.FlashSelectSet();
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 矩形查询
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void PUButton_Click_19(object sender, RoutedEventArgs e)
        {
            if (!(Regex.IsMatch(XMaxTextBox.Text, "^[\\d.]+$") && Regex.IsMatch(XMinTextBox.Text, "^[\\d.]+$") && Regex.IsMatch(YMaxTextBox.Text, "^[\\d.]+$") && Regex.IsMatch(YMinTextBox.Text, "^[\\d.]+$")))
            {
                PUMessageBox.ShowDialog("输入的内容不符合规范");
                return;
            }
            string sql          = "xAsis < " + XMaxTextBox.Text + " AND xAsis > " + XMinTextBox.Text + " AND yAsis < " + YMaxTextBox.Text + " AND yAsis > " + YMinTextBox.Text;
            bool   searchResult = DataHelper.SearchData("BikePnts", sql, "RectangleSearchResult");

            if (searchResult == true)
            {
                Fields Flds = null;
                Field  Fld  = null;
                long   ID   = 0;
                Record Rcd  = null;

                //变量初始化
                Rcd  = new Record();
                Flds = new Fields();

                Server svr = new Server();
                //连接数据源
                svr.Connect("MapGISLocal", "", "");
                DataBase    GDB   = svr.OpenGDB("Templates");
                SFeatureCls SFCls = new SFeatureCls(GDB);
                SFCls.Open("RectangleSearchResult", 0);
                //获取属性结构
                Flds = SFCls.Fields;
                if (Flds == null)
                {
                    SFCls.Close();
                    SearchTabControl.Visibility = Visibility.Collapsed;
                    SearchResultGrid.Visibility = Visibility.Collapsed;
                    NoResultGrid.Visibility     = Visibility.Visible;
                    return;
                }
                int num = Flds.Count;

                //目的类对象的个数
                int objnum = SFCls.Count;

                //获取所有对象的ID,思想是根据对象的个数进行循环,若OID不存在,则OID自加继续循环直到循环objnum次
                int n = 0;
                ID = 1;

                string[] listItem = new string[8];
                SearchListView.Items.Clear();
                while (n < objnum)
                {
                    //取得ID=ID.Int的简单要素的属性
                    Rcd = SFCls.GetAtt(ID);

                    //取得属性结构对象中的字段数目
                    if (Rcd != null)
                    {
                        Flds = Rcd.Fields;

                        listItem[0] = ID.ToString();

                        //获取对应属性字段的值
                        for (int i = 0; i < num; i++)
                        {
                            object val = null;
                            Fld = Flds.GetItem(i);
                            string name = Fld.FieldName;
                            val             = Rcd.get_FldVal(name);
                            listItem[i + 1] = ((val != null) ? val.ToString() : "");
                        }
                        n++;
                        SearchListView.Items.Add(new { BikeID = listItem[3], Time = listItem[4].Substring(9), XAsis = listItem[6].Substring(0, 8), YAsis = listItem[7].Substring(0, 8) });
                    }
                    ID++;
                }
                SFCls.Close();
                SearchTabControl.Visibility = Visibility.Collapsed;
                SearchResultGrid.Visibility = Visibility.Visible;
                NoResultGrid.Visibility     = Visibility.Collapsed;
            }
            else
            {
                SearchTabControl.Visibility = Visibility.Collapsed;
                SearchResultGrid.Visibility = Visibility.Collapsed;
                NoResultGrid.Visibility     = Visibility.Visible;
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// 获取单车的距离和时间统计
        /// </summary>
        /// <param name="bikes"></param>
        /// <returns></returns>
        public static List <BikeSearchViewModel> GetLengthNTimeData(string className, string bikeid)
        {
            List <BikeSearchViewModel> searchResult = new List <BikeSearchViewModel>();

            bool haveResult = DataHelper.SearchData("BikePnts", "BikeID = '" + bikeid + "'", bikeid + "Temp");

            if (haveResult == false)
            {
                return(null);
            }
            Fields Flds = null;
            Field  Fld  = null;
            long   ID   = 0;
            Record Rcd  = null;

            //变量初始化
            Rcd  = new Record();
            Flds = new Fields();

            Server svr = new Server();

            //连接数据源
            svr.Connect("MapGISLocal", "", "");
            DataBase    GDB      = svr.OpenGDB("Templates");
            SFeatureCls tmpSFCls = new SFeatureCls(GDB);

            tmpSFCls.Open(bikeid + "Temp", 0);
            //获取属性结构
            Flds = tmpSFCls.Fields;
            if (Flds == null)
            {
                tmpSFCls.Close();
                return(null);
            }
            int num = Flds.Count;

            //目的类对象的个数
            int objnum = tmpSFCls.Count;

            //获取所有对象的ID,思想是根据对象的个数进行循环,若OID不存在,则OID自加继续循环直到循环objnum次
            int n = 0;

            ID = 1;

            string[] listItem = new string[8];
            while (n < objnum)
            {
                //取得ID=ID.Int的简单要素的属性
                Rcd = tmpSFCls.GetAtt(ID);

                //取得属性结构对象中的字段数目
                if (Rcd != null)
                {
                    Flds = Rcd.Fields;

                    listItem[0] = ID.ToString();

                    //获取对应属性字段的值
                    for (int j = 0; j < num; j++)
                    {
                        object val = null;
                        Fld = Flds.GetItem(j);
                        string name = Fld.FieldName;
                        val             = Rcd.get_FldVal(name);
                        listItem[j + 1] = ((val != null) ? val.ToString() : "");
                    }
                    n++;
                    BikeSearchViewModel bike = new BikeSearchViewModel
                    {
                        BikeID = listItem[3],
                        Time   = Convert.ToDateTime(listItem[4].Substring(9)),
                        XAsis  = Convert.ToDouble(listItem[6].Substring(0, 8)),
                        YAsis  = Convert.ToDouble(listItem[7].Substring(0, 8))
                    };
                    searchResult.Add(bike);
                }
                ID++;
            }
            tmpSFCls.Close();
            return(searchResult);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// 搜索
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            SearchListView.Visibility       = Visibility.Collapsed;
            RideChart.Visibility            = Visibility.Collapsed;
            OnedayChart.Visibility          = Visibility.Collapsed;
            BackgroundStackPanel.Visibility = Visibility.Collapsed;
            NoResultStackPanel.Visibility   = Visibility.Collapsed;
            SearchListView.Items.Clear();
            bool searchResult = DataHelper.SearchData("BikePnts", "BikeID = '" + SearchTextBox.Text + "'", "SearchTemp");

            if (searchResult == true)
            {
                Fields Flds = null;
                Field  Fld  = null;
                long   ID   = 0;
                Record Rcd  = null;

                //变量初始化
                Rcd  = new Record();
                Flds = new Fields();

                Server svr = new Server();
                //连接数据源
                svr.Connect("MapGISLocal", "", "");
                DataBase    GDB   = svr.OpenGDB("Templates");
                SFeatureCls SFCls = new SFeatureCls(GDB);
                SFCls.Open("SearchTemp", 0);
                //获取属性结构
                Flds = SFCls.Fields;
                if (Flds == null)
                {
                    SFCls.Close();
                    OnedayChart.Visibility          = Visibility.Collapsed;
                    RideChart.Visibility            = Visibility.Collapsed;
                    SearchListView.Visibility       = Visibility.Collapsed;
                    BackgroundStackPanel.Visibility = Visibility.Collapsed;
                    NoResultStackPanel.Visibility   = Visibility.Visible;
                    return;
                }
                int num = Flds.Count;

                //目的类对象的个数
                int objnum = SFCls.Count;

                //获取所有对象的ID,思想是根据对象的个数进行循环,若OID不存在,则OID自加继续循环直到循环objnum次
                int n = 0;
                ID = 1;

                string[] listItem = new string[8];
                while (n < objnum)
                {
                    //取得ID=ID.Int的简单要素的属性
                    Rcd = SFCls.GetAtt(ID);

                    //取得属性结构对象中的字段数目
                    if (Rcd != null)
                    {
                        Flds = Rcd.Fields;

                        listItem[0] = ID.ToString();

                        //获取对应属性字段的值
                        for (int i = 0; i < num; i++)
                        {
                            object val = null;
                            Fld = Flds.GetItem(i);
                            string name = Fld.FieldName;
                            val             = Rcd.get_FldVal(name);
                            listItem[i + 1] = ((val != null) ? val.ToString() : "");
                        }
                        n++;
                        SearchListView.Items.Add(new { OID = listItem[0], BikeID = listItem[3], Time = listItem[4].Substring(9), XAsis = listItem[6].Substring(0, 8), YAsis = listItem[7].Substring(0, 8) });
                    }
                    ID++;
                }
                SFCls.Close();
                SearchListView.Visibility = Visibility.Visible;
            }
            else
            {
                OnedayChart.Visibility          = Visibility.Collapsed;
                RideChart.Visibility            = Visibility.Collapsed;
                SearchListView.Visibility       = Visibility.Collapsed;
                BackgroundStackPanel.Visibility = Visibility.Collapsed;
                NoResultStackPanel.Visibility   = Visibility.Visible;
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        /// 导入数据后显示地图
        /// </summary>
        private void ShowMaps()
        {
            MapGrid.Visibility        = Visibility.Visible;
            BackgroundGrid.Visibility = Visibility.Collapsed;
            MapGIS.UI.Controls.MapWorkSpaceTree _Tree = new MapGIS.UI.Controls.MapWorkSpaceTree();
            //地图文档
            Document doc = _Tree.Document;

            if (doc.Close(false))
            {
                OpenFileDialog mapxDialog = new OpenFileDialog();
                mapxDialog.Filter = ".mapx(地图文档)|*.mapx|.map(地图文档)|*.map|.mbag(地图包)|*.mbag";
                if (mapxDialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                string mapUrl = mapxDialog.FileName;
                //打开地图文档
                doc.Open(mapUrl);
            }

            Maps maps = doc.GetMaps();

            if (maps.Count > 0)
            {
                //获取当前第一个地图
                Map map = maps.GetMap(0);
                //设置地图的第一个图层为激活状态
                map.get_Layer(0).State         = LayerState.Active;
                this.WuhanMapControl.ActiveMap = map;
                this.WuhanMapControl.Restore();
            }
            else
            {
                return;
            }

            disp            = WuhanMapControl.Display;
            userDrawGeoInfo = disp.GetUserDrawGeoInfo();
            pntInfo         = userDrawGeoInfo.GetPntInfo();

            EditGeomInfoForm pntInfoForm = new EditGeomInfoForm((VectorLayer)null, pntInfo);

            if (pntInfoForm.ShowDialog() == DialogResult.OK)
            {
            }
            pntInfoForm.Dispose();
            //画点
            Fields Flds = null;
            Field  Fld  = null;
            long   ID   = 0;
            Record Rcd  = null;

            //变量初始化
            Rcd  = new Record();
            Flds = new Fields();

            Server svr = new Server();

            //连接数据源
            svr.Connect("MapGISLocal", "", "");
            DataBase    GDB   = svr.OpenGDB("Templates");
            SFeatureCls SFCls = new SFeatureCls(GDB);

            SFCls.Open("BikePnts", 0);
            //获取属性结构
            Flds = SFCls.Fields;
            if (Flds == null)
            {
                SFCls.Close();
                return;
            }
            int num = Flds.Count;

            //目的类对象的个数
            int objnum = SFCls.Count;

            //获取所有对象的ID,思想是根据对象的个数进行循环,若OID不存在,则OID自加继续循环直到循环objnum次
            int n = 0;

            ID = 1;

            string[] listItem = new string[8];
            while (n < objnum)
            {
                //取得ID=ID.Int的简单要素的属性
                Rcd = SFCls.GetAtt(ID);

                //取得属性结构对象中的字段数目
                if (Rcd != null)
                {
                    Flds = Rcd.Fields;

                    listItem[0] = ID.ToString();

                    //获取对应属性字段的值
                    for (int i = 0; i < num; i++)
                    {
                        object val = null;
                        Fld = Flds.GetItem(i);
                        string name = Fld.FieldName;
                        val             = Rcd.get_FldVal(name);
                        listItem[i + 1] = ((val != null) ? val.ToString() : "");
                    }
                    n++;
                    Dot dot = new Dot();
                    dot.X = Convert.ToDouble(listItem[6]);
                    dot.Y = Convert.ToDouble(listItem[7]);
                    DrawPoint(dot);
                }
                ID++;
            }
            SFCls.Close();
        }