Browse Source

laanc 비행금지구역 알럿 롤백

pull/2/head
junh_eee(이준희) 1 year ago
parent
commit
9cc3a13843
  1. 41
      src/views/laanc/FlightArea.js

41
src/views/laanc/FlightArea.js

@ -1,6 +1,7 @@
import 'mapbox-gl/dist/mapbox-gl.css'; import 'mapbox-gl/dist/mapbox-gl.css';
import mapboxgl from 'mapbox-gl'; import mapboxgl from 'mapbox-gl';
import threebox from 'threebox-plugin'; import threebox from 'threebox-plugin';
import * as turf from '@turf/turf';
import MapboxLanguage from '@mapbox/mapbox-gl-language'; import MapboxLanguage from '@mapbox/mapbox-gl-language';
import { MAPBOX_TOKEN } from '../../configs/constants'; import { MAPBOX_TOKEN } from '../../configs/constants';
import { useEffect, useRef, useState } from 'react'; import { useEffect, useRef, useState } from 'react';
@ -144,20 +145,20 @@ export default function FlightArea({ centeredModal, setCenteredModal, page }) {
}; };
}); });
const { data } = await axios.post( // const { data } = await axios.post(
`api/bas/flight/airspace/contains`, // `api/bas/flight/airspace/contains`,
resultAreaDetail // resultAreaDetail
); // );
if (data.result) { // if (data.result) {
setAlertModal({ // setAlertModal({
isOpen: true, // isOpen: true,
title: '우회 여부 확인', // title: '우회 여부 확인',
desc: '경로상에 비행 금지된 구역이 있습니다.\n우회하여 경로 설정해주시기 바랍니다.' // desc: '경로상에 비행 금지된 구역이 있습니다.\n우회하여 경로 설정해주시기 바랍니다.'
}); // });
return false; // return false;
} // }
setCenteredModal(false); setCenteredModal(false);
dispatch(AREA_DETAIL_LIST_SAVE(resultAreaDetail)); dispatch(AREA_DETAIL_LIST_SAVE(resultAreaDetail));
@ -257,6 +258,8 @@ export default function FlightArea({ centeredModal, setCenteredModal, page }) {
circle.geometry.coordinates = circleCoords; circle.geometry.coordinates = circleCoords;
previewGeo.features.push(circle); previewGeo.features.push(circle);
mapObject.setCenter(circle.properties.center);
} else { } else {
const lineString = InitFeature('LineString', 'polyline'); const lineString = InitFeature('LineString', 'polyline');
const bufferPolyline = InitFeature('LineString', 'buffer'); const bufferPolyline = InitFeature('LineString', 'buffer');
@ -277,9 +280,23 @@ export default function FlightArea({ centeredModal, setCenteredModal, page }) {
bufferPolyline.geometry.coordinates = bufferPaths; bufferPolyline.geometry.coordinates = bufferPaths;
previewGeo.features.push(bufferPolyline); previewGeo.features.push(bufferPolyline);
} }
const lineCoord = lineString.geometry.coordinates.concat();
lineCoord.push(lineString.geometry.coordinates[0]);
const obj = turf.polygon([lineCoord]);
const centerOfMass = turf.centerOfMass(obj);
mapObject.setCenter(centerOfMass.geometry.coordinates);
} else if (areas.areaType === 'POLYGON') { } else if (areas.areaType === 'POLYGON') {
polygon.geometry.coordinates = [paths]; polygon.geometry.coordinates = [paths];
previewGeo.features.push(polygon); previewGeo.features.push(polygon);
const polygonCoord = polygon.geometry.coordinates[0].concat();
polygonCoord.push(polygon.geometry.coordinates[0][0]);
const obj = turf.polygon([polygonCoord]);
const centerOfMass = turf.centerOfMass(obj);
mapObject.setCenter(centerOfMass.geometry.coordinates);
} }
//포인트 생성 //포인트 생성

Loading…
Cancel
Save