From a4467394329463ffbdf27f6225f7068ea060ccdb Mon Sep 17 00:00:00 2001 From: swcho Date: Fri, 25 Jul 2025 00:21:07 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20-=20gis.select.js=20=ED=94=BC=EC=B2=98?= =?UTF-8?q?=20=EB=8B=A4=EC=A4=91=20=EC=85=80=EB=A0=89=ED=8A=B8=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EC=B6=94=EA=B0=80=20-=20Gis.js=20=EC=83=81?= =?UTF-8?q?=EB=A5=98=EA=B4=80=EB=A1=9C=20=EC=A1=B0=ED=9A=8C=20=EB=A9=94?= =?UTF-8?q?=EC=84=9C=EB=93=9C=20=EC=B6=94=EA=B0=80=20-=20GisLonLat=20?= =?UTF-8?q?=EC=A3=BC=EC=84=9D=20=EC=B2=98=EB=A6=AC(=EC=9C=84=EA=B2=BD?= =?UTF-8?q?=EB=8F=84=20=ED=91=9C=EC=8B=9CX)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business_components/src/ui/map/Gis.js | 58 ++++++++++++++++++- .../src/ui/map/lib/gis.select.js | 13 +++++ 2 files changed, 70 insertions(+), 1 deletion(-) diff --git a/packages/common/business_components/src/ui/map/Gis.js b/packages/common/business_components/src/ui/map/Gis.js index 5386207d8..fb0529828 100644 --- a/packages/common/business_components/src/ui/map/Gis.js +++ b/packages/common/business_components/src/ui/map/Gis.js @@ -20,6 +20,62 @@ import GisApp from './lib/gis.core'; export const GisContext = createContext({ gisCore: null, gisMap: null, treeData: null, checkedLayerIds: null }); export const useGisContext = () => useContext(GisContext); +export async function searchUpperPpls(fcltMngNo) { + const BASE_URL = process.env.NEXT_PUBLIC_SERVER_API_URL || ''; + + const res = await fetch(`${BASE_URL}/v1/fcltmhl/upperPpls/${fcltMngNo}`, { + method: "GET", + }); + if (res.ok) { + const data = await res.json(); + return data; + } + throw new Error('Failed to fetch data'); + console.log('상류관로 조회 결과:', res); + + const select = GisApp.Module.select; + if (!select || !Array.isArray(res)) return; + + const gisMap = GisApp.Module.core?.map; + if (!gisMap) return; + + let foundFeature = null; + + res.forEach(item => { + const pplMngNo = item.ppl_mng_no.trim(); + + gisMap.getLayers().getArray().filter(e => e.get("lyrTyNm") == 'tb_ms_swage_ppl').forEach(layer => { + const source = layer.getSource?.(); + if (source?.getFeatures) { + const features = source.getFeatures(); + for (const f of features) { + if (f.values_.fclt_mng_no.trim() === pplMngNo) { + foundFeature = f; + break; + } + } + } + }); + + if (foundFeature) select.selectMultiFeature(foundFeature, true); + }); + + console.log('찾은 피쳐:', foundFeature); + if (!foundFeature) alert(`해당 맨홀의 상류관로를 찾을 수 없습니다.`); + + let geometry = foundFeature?.getGeometry(); + if (geometry) { + let extent = geometry.getExtent(); + + gisMap.getView().fit(extent, { + duration: 300, + padding: [50, 50, 50, 50], + maxZoom: 14, + constrainResolution: true, + nearest: true, + }); + } +} function Gis({ isOpen, @@ -418,7 +474,7 @@ function Gis({ onFeatureSelect={handleFeatureSelect} /> )} - + {/* */} diff --git a/packages/common/business_components/src/ui/map/lib/gis.select.js b/packages/common/business_components/src/ui/map/lib/gis.select.js index 21ab39609..d0209a6ed 100644 --- a/packages/common/business_components/src/ui/map/lib/gis.select.js +++ b/packages/common/business_components/src/ui/map/lib/gis.select.js @@ -429,6 +429,19 @@ GisOlSelect.prototype = { auto: auto, }); }, + /** + * 피처 다중 셀렉트 + */ + selectMultiFeature: function (feature, auto) { + let me = this; + me.selectedFeatures.push(feature); + me.selectInteraction.dispatchEvent({ + type: 'select', + selected: me.selectedFeatures, + deselected: [], + auto: auto, + }); + }, }; export default GisOlSelect;