Merge branch 'iipbs/common/main' into iipbs/sn/ii

This commit is contained in:
swcho
2025-07-25 00:50:40 +09:00
@@ -20,28 +20,39 @@ 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 || '';
export const searchUpperPpls = async (fcltMngNo) => {
const BASE_URL = process.env.NEXT_PUBLIC_SEWERAGE_API_URL || '';
const res = await fetch(`${BASE_URL}/v1/fcltmhl/upperPpls/${fcltMngNo}`, {
method: "GET",
});
let data = null;
if (res.ok) {
const data = await res.json();
return data;
try {
// 응답이 비어있는지 확인
const contentLength = res.headers.get('content-length');
if (contentLength === '0') alert(`해당 맨홀의 상류관로를 찾을 수 없습니다.`);
// 응답 텍스트를 먼저 가져와서 빈 문자열인지 확인
const text = await res.text();
if (!text || text.trim() === '') alert(`해당 맨홀의 상류관로를 찾을 수 없습니다.`);
// JSON 파싱 시도
data = JSON.parse(text);
} catch (error) {
console.error('JSON parsing error:', error);
alert(`해당 맨홀의 상류관로를 찾을 수 없습니다.`);
}
}
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 => {
data.forEach(item => {
const pplMngNo = item.ppl_mng_no.trim();
gisMap.getLayers().getArray().filter(e => e.get("lyrTyNm") == 'tb_ms_swage_ppl').forEach(layer => {
@@ -60,7 +71,6 @@ export async function searchUpperPpls(fcltMngNo) {
if (foundFeature) select.selectMultiFeature(foundFeature, true);
});
console.log('찾은 피쳐:', foundFeature);
if (!foundFeature) alert(`해당 맨홀의 상류관로를 찾을 수 없습니다.`);
let geometry = foundFeature?.getGeometry();
@@ -75,7 +85,8 @@ export async function searchUpperPpls(fcltMngNo) {
nearest: true,
});
}
}
};
function Gis({
isOpen,