Esempio n. 1
0
        /// <summary>
        /// 处理搜索的结果
        /// </summary>
        /// <param name="output"></param>
        /// <param name="exitCode"></param>
        private void handleOutput(string output, int exitCode)
        {
            retrievalBtn.Enabled = true;

            if (exitCode == 0)
            {
                String       jsonString = "";
                String       line;
                StreamReader sr = new StreamReader(Program.tempPath + "data", Encoding.Default);
                while ((line = sr.ReadLine()) != null)
                {
                    jsonString += line + "\n";
                }
                sr.Close();
                mSceneList = JsonConvert.DeserializeObject <List <SimilarScene> >(jsonString);
                //排序
                Util.sort(mSceneList);


                //删除datagridview中的数据
                removeData();
                //将结果显示在dataGridView中
                DataGridViewRow row;
                for (int i = 0; i < mSceneList.Count; i++)
                {
                    SimilarScene  scene    = mSceneList[i];
                    List <String> polygons = scene.polygonList;

                    row = new DataGridViewRow();
                    int index = dataView.Rows.Add(row);
                    dataView.Rows[index].Cells[0].Value = polygons[0].Split('_')[0];
                    dataView.Rows[index].Cells[1].Value = scene.md;
                }

                mMessageForm.Close();
            }
            else
            {
                mMessageForm.Close();
                MessageBox.Show("检索失败!!");
            }

            Console.WriteLine(output);
        }
Esempio n. 2
0
        /// <summary>
        /// 将选择的相似场景高亮
        /// </summary>
        /// <param name="scene"></param>
        private void showScene(SimilarScene scene)
        {
            String        LayerName = scene.polygonList[0].Split('_')[0];
            IFeatureLayer layer     = Util.getLayerByName(axMap.Map, LayerName) as IFeatureLayer;

            axMap.Map.ClearSelection();
            //查询
            IFeatureSelection featureSelection = layer as IFeatureSelection;

            for (int i = 0; i < scene.polygonList.Count; i++)
            {
                int id = Convert.ToInt32(scene.polygonList[i].Split('_')[1]);

                //新建IQueryFilter接口,添加where语句
                IQueryFilter queryFilter = new QueryFilterClass();

                //设置where语句内容
                queryFilter.WhereClause = "\"FID\" = " + id;

                //选择,并将其添加到选择集中
                featureSelection.SelectFeatures(queryFilter, esriSelectionResultEnum.esriSelectionResultAdd, false);
            }
            //高亮
            IActiveView activeView  = axMap.Map as IActiveView;
            IEnvelope   extent      = activeView.Extent;
            double      sceenWidth  = extent.Width;
            double      sceenHeight = extent.Height;
            double      sceenMin    = sceenWidth > sceenHeight ? sceenHeight : sceenWidth;
            double      sceenMax    = sceenWidth < sceenHeight ? sceenHeight : sceenWidth;
            double      sceenScale  = sceenMax / sceenMin;


            model.Point gravity = scene.gravity;

            float scale = 4.0f;

            model.Envelope envelope = scene.envelope;
            double         width    = envelope.Width;
            double         height   = envelope.Height;
            double         max      = width > height ? width : height;

            if (sceenHeight == sceenMin)
            {
                ESRI.ArcGIS.Geometry.Point rt = new ESRI.ArcGIS.Geometry.Point();
                rt.X = gravity.x + max * sceenScale * scale / 2;
                rt.Y = gravity.y + max * scale / 2;

                ESRI.ArcGIS.Geometry.Point lb = new ESRI.ArcGIS.Geometry.Point();
                lb.X = gravity.x - max * sceenScale * scale / 2;
                lb.Y = gravity.y - max * scale / 2;

                ESRI.ArcGIS.Geometry.Point rb = new ESRI.ArcGIS.Geometry.Point();
                rb.X = gravity.x + max * sceenScale * scale / 2;
                rb.Y = gravity.y - max * scale / 2;

                ESRI.ArcGIS.Geometry.Point lt = new ESRI.ArcGIS.Geometry.Point();
                lt.X = gravity.x - max * sceenScale * scale / 2;
                lt.Y = gravity.y + max * scale / 2;

                extent.LowerLeft  = lb;
                extent.UpperRight = rt;
                extent.UpperLeft  = lt;
                extent.LowerRight = rb;
            }
            else
            {
                ESRI.ArcGIS.Geometry.Point rt = new ESRI.ArcGIS.Geometry.Point();
                rt.X = gravity.x + max / 2;
                rt.Y = gravity.y + max * sceenScale / 2;

                ESRI.ArcGIS.Geometry.Point lb = new ESRI.ArcGIS.Geometry.Point();
                lb.X = gravity.x - max / 2;
                lb.Y = gravity.y - max * sceenScale / 2;

                ESRI.ArcGIS.Geometry.Point rb = new ESRI.ArcGIS.Geometry.Point();
                rb.X = gravity.x + max * scale / 2;
                rb.Y = gravity.y - max * sceenScale * scale / 2;

                ESRI.ArcGIS.Geometry.Point lt = new ESRI.ArcGIS.Geometry.Point();
                lt.X = gravity.x - max * scale / 2;
                lt.Y = gravity.y + max * sceenScale * scale / 2;

                extent.LowerLeft  = lb;
                extent.UpperRight = rt;
                extent.UpperLeft  = lt;
                extent.LowerRight = rb;
            }

            activeView.Extent = extent;
            //刷新
            activeView.Refresh();
        }