Exemplo 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);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
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();
        }