/// <summary> /// 해당시설물의 지도상위치 찾아가기(업무화면에서 호출됨) /// </summary> /// <param name="FTR_CDE"></param> /// <param name="FTR_IDN"></param> /// <returns></returns> public async Task findFtrAsync(string FTR_CDE, string FTR_IDN) { string layerNm = ""; try { layerNm = GisCmm.GetLayerNm(FTR_CDE); if ("".Equals(layerNm)) { MessageBox.Show("잘못된 레이어입니다."); return; } } catch (Exception) { MessageBox.Show("잘못된 레이어입니다."); return; } //0.해당레이어표시 - 내부에서자동으로 로딩여부 체크함 ///ShowShapeLayer(mapView, GisCmm.GetLayerNm(FTR_CDE), true); //1.해당레이어 가져오기 FeatureLayer layer = CmmRun.layers[GisCmm.GetLayerNm(FTR_CDE)]; // Remove any previous feature selections that may have been made. layer.ClearSelection(); // Begin query process. await QueryStateFeature(FTR_CDE, FTR_IDN, layer); }
//강제로 체크박스레이어 클릭 private async Task <FeatureLayer> ClickLayer(string FTR_CDE) { foreach (Button btn in FmsUtil.FindVisualChildren <Button>(mapArcObjView)) { try { if (btn.Tag.ToString() == GisCmm.GetLayerNm(FTR_CDE)) { CheckBox chkbox = btn.Template.FindName("chkLayer", btn) as CheckBox; chkbox.IsChecked = true; btn.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));//강제클릭 break; } } catch (Exception) { } } await Task.Delay(1000); return(CmmObj.layers[GisCmm.GetLayerNm(FTR_CDE)].FL); }
/// <summary> /// 해당시설물의 지도상위치 찾아가기(업무화면에서 호출됨) /// </summary> /// <param name="FTR_CDE"></param> /// <param name="FTR_IDN"></param> /// <returns></returns> public async void findFtr(string FTR_CDE, string FTR_IDN) { string layerNm = ""; try { layerNm = GisCmm.GetLayerNm(FTR_CDE); if ("".Equals(layerNm)) { MessageBox.Show("잘못된 레이어입니다."); return; } } catch (Exception) { MessageBox.Show("잘못된 레이어입니다."); return; } //지도리셋 string stat = await resetAction(null); //0.해당레이어표시 - 내부에서자동으로 로딩여부 체크함 //FeatureLayer layer = ShowShapeLayer(GisCmm.GetLayerNm(FTR_CDE), true); //체크박스UI를 클릭시키는 방식으로 변경 FeatureLayer layer = await ClickLayer(FTR_CDE); //1.해당레이어 가져오기 //FeatureLayer layer = CmmObj.layers[GisCmm.GetLayerNm(FTR_CDE)]; //1.셀렉트처리 필터링 IQueryFilter qfltr = new QueryFilter(); qfltr.WhereClause = " FTR_CDE = '" + FTR_CDE + "' AND FTR_IDN = " + FTR_IDN + " "; IFeatureSelection fsel = layer as IFeatureSelection; fsel.SelectFeatures(qfltr, esriSelectionResultEnum.esriSelectionResultAdd, true); await Task.Delay(1000); //2.피처객체 필터링 IFeatureCursor cursor = layer.Search(qfltr, true); IFeature feature = cursor.NextFeature(); if (feature is null) { MessageBox.Show("해당시설물 위치가 없습니다."); return; } ESRI.ArcGIS.Geometry.IPoint point = mapControl.ToMapPoint(Convert.ToInt32(GisCmm.fmsCoords.X), Convert.ToInt32(GisCmm.fmsCoords.Y)); if (FTR_CDE == "SA001" || FTR_CDE == "SA002") //상수관로,급수관로 { ESRI.ArcGIS.Geometry.IPolyline line = (ESRI.ArcGIS.Geometry.IPolyline)feature.ShapeCopy; point = line.FromPoint; //point = mapControl.ToMapPoint(Convert.ToInt32((line.ToPoint.X + line.FromPoint.X) / 2), Convert.ToInt32((line.ToPoint.Y + line.FromPoint.Y) / 2)); } else if (FTR_CDE == "SA113" || FTR_CDE == "BZ001" || FTR_CDE == "BZ002" || FTR_CDE == "BZ003") //정수장, 블록 { IArea area = (ESRI.ArcGIS.Geometry.IArea)feature.ShapeCopy; point = area.Centroid; } else //나머지 포이트 시설물 { point = (ESRI.ArcGIS.Geometry.IPoint)feature.ShapeCopy; } //3. - 타겟으로 지도중심이동 //IEnumFeature pFsel = (IEnumFeature)mapControl.Map.FeatureSelection; //pFsel.Reset(); // make sure it starts from the first feature //IFeature pFeat = pFsel.Next(); //do //{ // ESRI.ArcGIS.Geometry.IGeometry pGeom = pFeat.ShapeCopy; // if (pGeom.GeometryType == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint) // { // point = (ESRI.ArcGIS.Geometry.IPoint)pGeom; // double x, y; // point.QueryCoords(out x, out y); // use the coordinates from here // } // else if (pGeom.GeometryType == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline) // { // ESRI.ArcGIS.Geometry.IPolyline line = (ESRI.ArcGIS.Geometry.IPolyline)pGeom; // point = line.FromPoint; // } // else if (pGeom.GeometryType == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon) // { // ESRI.ArcGIS.Geometry.IPolygon polygon = (ESRI.ArcGIS.Geometry.IPolygon)pGeom; // point = polygon.FromPoint; // } // pFeat = pFsel.Next(); //} while (pFeat != null); /* */ IEnvelope envelope = mapControl.ActiveView.Extent; envelope.CenterAt(point); //int x = Convert.ToInt32(point.X); //int y = Convert.ToInt32(point.Y); //mapControl.ToMapPoint(x, y); //mapControl.ActiveView.ScreenDisplay.UpdateWindow(); mapControl.ActiveView.Extent = envelope; mapControl.Refresh(); mapControl.MapScale = 36112; // 18056; // 9028; }