From 9e005e886208b83b49cb8f258add00a58d60bf07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?junh=5Feee=28=EC=9D=B4=EC=A4=80=ED=9D=AC=29?= Date: Mon, 2 Sep 2024 14:42:51 +0900 Subject: [PATCH] =?UTF-8?q?feat/=20=EA=B3=B5=EC=97=AD=EA=B4=80=EB=A0=A8=20?= =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=9C=A0=ED=8B=B8=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utility/airAreaUtil.js | 83 ++++++++++++++++++++++++++++++++++++++ test/coordTest.js | 57 -------------------------- 2 files changed, 83 insertions(+), 57 deletions(-) create mode 100644 src/utility/airAreaUtil.js delete mode 100644 test/coordTest.js diff --git a/src/utility/airAreaUtil.js b/src/utility/airAreaUtil.js new file mode 100644 index 00000000..4c6069ec --- /dev/null +++ b/src/utility/airAreaUtil.js @@ -0,0 +1,83 @@ +import * as turf from '@turf/turf'; +import axios from '@src/utility/customAxiosUtil'; + +// 공역 쪼개기 & 3등분 도우미 +const handlerCoordTest = () => { + const line = turf.lineString([ + [0, 0], + [0, 0] + ]); + + if (line.geometry.coordinates.length > 0) { + const coordList = []; + line.geometry.coordinates.map(coord => { + coordList.push({ + planAreacoordSno: 0, + planAreaSno: 0, + lat: coord[1], + lon: coord[0], + createUserId: '', + createDt: '' + }); + }); + const rq = { + planAreaSno: 0, + planSno: 0, + areaType: 'LINE', + fltMethod: '', + fltMothoeRm: '', + bufferZone: 367, + concatBufferZone: 0, + fltElev: 0, + createUserId: '', + createDt: '', + updateUserId: '', + updateDt: '', + coordList: coordList + }; + + // 3등분 분할시 사용 + // dispatch(AreaBufferList([rq])).then(res => { + // const buffer = res.payload[0].bufferCoordList; + // const bufferCoord = []; + + // buffer.map(bf => { + // bufferCoord.push([bf.lon, bf.lat]); + // }); + // }); + } + + const line1 = turf.lineString([ + [126.468766270098, 33.4984463563465, 296], + [126.426984195498, 33.4689808922696, 296] + ]); + + const line2 = turf.lineString([ + [126.434262804465, 33.4771238651376, 77.03], + [126.436041799461, 33.4753713462788, 77.03] + ]); + const intersect = turf.lineIntersect(line1, line2); + // console.log(intersect, '---intersect'); + + // 고도 재계산 + const data = [ + // 좌표 기입 + ]; + if (data.length > 0) { + const fetch = data.map(([lon, lat, alt]) => { + return axios.post('api/comn/elev/ground', [{ lat, lon }]).then(res => { + return [lon, lat, res.data[0].elev + alt]; + }); + }); + + Promise.all(fetch) + .then(result => { + console.log(result, '----result'); + }) + .catch(error => { + console.error('Error fetching data:', error); + }); + } +}; + +export { handlerCoordTest }; diff --git a/test/coordTest.js b/test/coordTest.js deleted file mode 100644 index 1e21703c..00000000 --- a/test/coordTest.js +++ /dev/null @@ -1,57 +0,0 @@ -import * as turf from '@turf/turf'; - -const handlerTest = () => { - const line = turf.lineString([ - [0, 0], - [0, 0] - ]); - - if (line.geometry.coordinates.length > 0) { - const coordList = []; - line.geometry.coordinates.map(coord => { - coordList.push({ - planAreacoordSno: 0, - planAreaSno: 0, - lat: coord[1], - lon: coord[0], - createUserId: '', - createDt: '' - }); - }); - const rq = { - planAreaSno: 0, - planSno: 0, - areaType: 'LINE', - fltMethod: '', - fltMothoeRm: '', - bufferZone: 367, - concatBufferZone: 0, - fltElev: 0, - createUserId: '', - createDt: '', - updateUserId: '', - updateDt: '', - coordList: coordList - }; - - // dispatch(AreaBufferList([rq])).then(res => { - // const buffer = res.payload[0].bufferCoordList; - // const bufferCoord = []; - - // buffer.map(bf => { - // bufferCoord.push([bf.lon, bf.lat]); - // }); - // }); - } - - const linee = turf.lineString([ - [126.773741386, 37.5677930496, 18.59], - [126.7461278299, 37.5840418952, 82.81], - [126.6355487467, 37.6489641997, 381.99] - ]); - const circle = turf.lineString([ - [126.70986209199998, 37.60272668099992], - [126.71112399499998, 37.604222307999976] - ]); - const intersect = turf.lineIntersect(linee, circle); -};