const wrLayerList = [ { text: "tb_il_swage_prcs_fclt", val: "bscFctCd" }, { text: "tb_wr_bdst_ruse_fclt", val: "pbnstRuseFcltId" }, { text: "tb_wr_rnwtr_utztn_fclt", val: "rainyObj" }, { text: "tb_wr_rswtr_fclt", val: "rswtrObj" }, { text: "tb_wr_htdfl_fclt", val: "htdflObj" }, { text: "tb_wr_ruse_fclt_dmd_co", val: "dmdInfoId" }, { text: "tb_wr_tmpr_dmd_co", val: "fctryMngSn" }, ]; const wrFeaturePK = [ { text: "bscFctCd", val: "tb_il_swage_prcs_fclt" }, { text: "searchPk", val: "tb_wr_bdst_ruse_fclt" }, { text: "bdstInfoSn", val: "tb_wr_rnwtr_utztn_fclt" }, { text: "bdstInfoSn", val: "tb_wr_rswtr_fclt" }, { text: "bdstInfoSn", val: "tb_wr_htdfl_fclt" }, { text: "dmdInfoId", val: "tb_wr_ruse_fclt_dmd_co" }, { text: "fctryMngSn", val: "tb_wr_tmpr_dmd_co" }, ]; // { text: "하수처리시설", val: "tb_il_swage_prcs_fclt" }, // { text: "하수재이용시설", val: "tb_wr_bdst_ruse_fclt" }, // { text: "빗물이용시설", val: "tb_wr_rnwtr_utztn_fclt" }, // { text: "중수도시설", val: "tb_wr_rswtr_fclt" }, // { text: "온배수시설", val: "tb_wr_htdfl_fclt" }, // { text: "수요처", val: "tb_wr_ruse_fclt_dmd_co" }, // { text: "잠재수요처", val: "tb_wr_tmpr_dmd_co" }, export const getFeatureCd = (featurePropertise: any, layerNm: string) => { console.log('featurePropertise ', featurePropertise) const featureCd = layerNm === "tb_wr_bdst_ruse_fclt" ? featurePropertise?.swtrmt_fclt_cd : [ "tb_wr_rswtr_fclt", "tb_wr_htdfl_fclt", "tb_wr_rnwtr_utztn_fclt", "tb_wr_tmpr_dmd_co", ].includes(layerNm) ? featurePropertise?.bdst_nm : layerNm === "tb_il_swage_prcs_fclt" ? featurePropertise?.swtrmt_fclt_nm : layerNm === "tb_wr_ruse_fclt_dmd_co"? featurePropertise?.bdst_info_sn : null; return featureCd; }; export const getWrLayerNm = (featurePropertise: any) => { const result = wrLayerList .filter(item => item.val in featurePropertise) // 키 존재 여부 체크 .map(item => item.text); return result[0]; }; export const getWrFeaturePk = (layerName :string) => { const result = wrFeaturePK .filter(item => item.val === layerName) // 키 존재 여부 체크 .map(item => item.text); return result[0]; }; export const getSelectedLayers = (isFeature: any, gisMaps:any) => { const map = gisMaps.current; if (!map) { console.warn("지도가 초기화되지 않았습니다."); return; } let result = null; const layers = map ? map .getLayers() .getArray() .filter((l: any) => l.getVisible()) : []; // gisMap이 null인지 확인 후 레이어 가져오기 let featureLayer: { get: (key: string) => any } = { get: () => null }; layers.forEach((layer: any) => { const source = layer.getSource(); if ( source && source.hasFeature && isFeature && typeof isFeature.getId === "function" && source.hasFeature(isFeature) ) { featureLayer = layer; // 피처가 속한 레이어 찾기) } }); result = featureLayer.get("lyrTyNm"); return result; }; export const getClickFeatureId = (data: any) => { let featureId ='' const layerName = data.layerNm; if (layerName === "하수재이용시설") { // 재이용시설 featureId = `${layerName}.${data.searchPk}`; } else if ( //빗물이용시설, 중수도시설 layerName === "빗물이용시설" || layerName == "중수도시설" ) { featureId = `${layerName}.${data.bdstInfoSn}`; } else if (layerName === "하수처리시설") { //하수처리시설 featureId = `${layerName}.${data.bscFctCd}`; } else if (layerName === "온배수시설") { //온배수시설 featureId = `${layerName}.${data.bdstRuseFcltSn}`; } else if (layerName == "수요처") { //수요처 featureId = `${layerName}.${data.dmdInfoId.replaceAll("-", "")}`; } else { featureId = `${layerName}.${data.fid || data.id || data.ftrIdn}`; } return featureId; }; export function featurePopUpOpen(layerNm:string,featureCd:string,popupDetailRef){ const url = `/mapFeaturePopup?layerNm=${encodeURIComponent(String(layerNm))}&featureCd=${encodeURIComponent(featureCd)} `; const width = String(layerNm) === "tb_wr_bdst_ruse_fclt" ? Math.floor(window.innerWidth * 0.6) : Math.floor(window.innerWidth * 0.4); // 화면 폭의 40% const height = String(layerNm) === "tb_wr_bdst_ruse_fclt" ? Math.floor(window.innerHeight - 100) : String(layerNm) === "tb_wr_ruse_fclt_dmd_co" ?Math.floor(window.innerHeight - 430) : Math.floor(window.innerHeight - 300); // 150px 여백 확보; // calc(100% - 70px) const left = (window.screen.availWidth - width) / 2; const top = (window.screen.availHeight - height) / 2; const popupOptions = `width=${width},height=${height},left=${left},top=${top},resizable=yes,scrollbars=yes `; popupDetailRef.current = window.open( url, "지도 시설 상세정보 팝업", popupOptions ); }