|
|
|
@ -27,6 +27,8 @@ export const LaancDrawControl = props => {
|
|
|
|
|
const [bufferId, setBufferId] = useState(); |
|
|
|
|
|
|
|
|
|
const [isDrawDone, setIsDrawDone] = useState(false); |
|
|
|
|
// const [inAirArea, setInAirArea] = useState(false);
|
|
|
|
|
let inAirArea = 'N'; |
|
|
|
|
|
|
|
|
|
const [alertModal, setAlertModal] = useState({ |
|
|
|
|
isOpen: false, |
|
|
|
@ -48,7 +50,6 @@ export const LaancDrawControl = props => {
|
|
|
|
|
const DrawLineStringMode = MapboxDraw.modes.draw_line_string; |
|
|
|
|
const DrawPolygonMode = MapboxDraw.modes.draw_polygon; |
|
|
|
|
const DrawCircleMode = CircleMode; |
|
|
|
|
console.log(DrawCircleMode, '>>>>>>'); |
|
|
|
|
const modeArr = [DrawLineStringMode, DrawPolygonMode, DrawCircleMode]; |
|
|
|
|
|
|
|
|
|
modeArr.forEach(m => { |
|
|
|
@ -75,6 +76,10 @@ export const LaancDrawControl = props => {
|
|
|
|
|
} |
|
|
|
|
}, [isDrawDone]); |
|
|
|
|
|
|
|
|
|
// useEffect(() => {
|
|
|
|
|
// console.log(inAirArea, '--1122');
|
|
|
|
|
// }, [inAirArea]);
|
|
|
|
|
|
|
|
|
|
// 클릭할 때마다 마커 찍어줌
|
|
|
|
|
const handlerCustomOnClick = (state, e) => { |
|
|
|
|
console.log('click'); |
|
|
|
@ -83,6 +88,8 @@ export const LaancDrawControl = props => {
|
|
|
|
|
layers: ['maine'] |
|
|
|
|
}); |
|
|
|
|
if (features.length > 0) { |
|
|
|
|
inAirArea = 'Y'; |
|
|
|
|
// setInAirArea(true);
|
|
|
|
|
// console.log(features, '>>>>>관제권?');
|
|
|
|
|
// areaCoordList 컬럼 새로 만든거에 TRUE 머시기... 가 아니라 여기가 아님 일단은!! 노트 참고해!!!
|
|
|
|
|
} |
|
|
|
@ -124,20 +131,23 @@ export const LaancDrawControl = props => {
|
|
|
|
|
const handlerDblClickFinish = state => { |
|
|
|
|
console.log('dblclick'); |
|
|
|
|
const mode = handlerReturnMode(drawObj.getMode()); |
|
|
|
|
console.log(state, '>>>>>state'); |
|
|
|
|
|
|
|
|
|
if (mode === 'CIRCLE') { |
|
|
|
|
const obj = state.polygon; |
|
|
|
|
const data = { |
|
|
|
|
coord: state.polygon.properties.center, |
|
|
|
|
radius: state.polygon.properties.radiusInKm * 1000, |
|
|
|
|
id: state.polygon.id |
|
|
|
|
coord: obj.properties.center, |
|
|
|
|
radius: obj.properties.radiusInKm * 1000, |
|
|
|
|
id: obj.id |
|
|
|
|
}; |
|
|
|
|
drawObj.setFeatureProperty(data.id, 'id', mode); |
|
|
|
|
handlerCreateOneMarker([0, -10], data.coord, data.radius, data.id); |
|
|
|
|
handlerAbnormalityCheck(data, mode); |
|
|
|
|
} else { |
|
|
|
|
const obj = state[mode.toLowerCase()]; |
|
|
|
|
console.log(obj, '>>>>>>obj'); |
|
|
|
|
const length = state.currentVertexPosition; |
|
|
|
|
drawObj.setFeatureProperty(obj.id, 'id', mode); |
|
|
|
|
drawObj.setFeatureProperty(obj.id, 'inAirArea', inAirArea); |
|
|
|
|
// console.log(inAirArea, '--------------------');
|
|
|
|
|
|
|
|
|
|
// dbl클릭이 click 두번으로 인식돼서, 마지막 값을 없애버리기로 함
|
|
|
|
|
if (mode === 'LINE') { |
|
|
|
@ -163,7 +173,8 @@ export const LaancDrawControl = props => {
|
|
|
|
|
} |
|
|
|
|
const data = { |
|
|
|
|
coord: obj.coordinates, |
|
|
|
|
id: obj.id |
|
|
|
|
id: obj.id, |
|
|
|
|
inAirArea: inAirArea |
|
|
|
|
}; |
|
|
|
|
handlerAbnormalityCheck(data, mode); |
|
|
|
|
} |
|
|
|
@ -178,15 +189,26 @@ export const LaancDrawControl = props => {
|
|
|
|
|
const mode = obj.properties.id; |
|
|
|
|
const initCoord = obj.geometry.coordinates; |
|
|
|
|
|
|
|
|
|
// 폴리곤은 중첩좌표 제거해서 서버에 넘겨야함
|
|
|
|
|
if (mode === 'POLYGON') { |
|
|
|
|
initCoord[0].splice(-1); |
|
|
|
|
if (mode === 'CIRCLE') { |
|
|
|
|
const data = { |
|
|
|
|
coord: obj.properties.center, |
|
|
|
|
radius: obj.properties.radiusInKm * 1000, |
|
|
|
|
id: obj.id |
|
|
|
|
}; |
|
|
|
|
handlerRemoveGroupMarker(obj.id); |
|
|
|
|
handlerCreateOneMarker([0, -10], data.coord, data.radius, data.id); |
|
|
|
|
handlerAbnormalityCheck(data, mode); |
|
|
|
|
} else { |
|
|
|
|
// 폴리곤은 중첩좌표 제거해서 서버에 넘겨야함
|
|
|
|
|
if (mode === 'POLYGON') initCoord[0].splice(-1); |
|
|
|
|
const data = { |
|
|
|
|
coord: initCoord, |
|
|
|
|
id: obj.id |
|
|
|
|
}; |
|
|
|
|
handlerRemoveGroupMarker(obj.id); |
|
|
|
|
handlerCreateGroupMarker(data.coord, obj.id); |
|
|
|
|
handlerAbnormalityCheck(data, mode); |
|
|
|
|
} |
|
|
|
|
const data = { |
|
|
|
|
coord: initCoord, |
|
|
|
|
id: obj.id |
|
|
|
|
}; |
|
|
|
|
handlerAbnormalityCheck(data, mode); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
@ -203,9 +225,10 @@ export const LaancDrawControl = props => {
|
|
|
|
|
: mode === 'CIRCLE' |
|
|
|
|
? data.coord |
|
|
|
|
: null; |
|
|
|
|
console.log(data, '>>>>>'); |
|
|
|
|
console.log(initCoord, mode, '>>>>check'); |
|
|
|
|
handlerSaveAreaInfo(initCoord, mode); |
|
|
|
|
|
|
|
|
|
const datas = { coord: initCoord, mode: mode, inAirArea: inAirArea }; |
|
|
|
|
// handlerSaveAreaInfo(initCoord, mode);
|
|
|
|
|
handlerSaveAreaInfo(datas); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// 현재 그려진 모든 도형에 대한 비가시권 검사
|
|
|
|
@ -245,8 +268,9 @@ export const LaancDrawControl = props => {
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// areaInfo 셋팅
|
|
|
|
|
const handlerSaveAreaInfo = (coord, mode) => { |
|
|
|
|
if (!coord || !mode) { |
|
|
|
|
// const handlerSaveAreaInfo = (coord, mode) => {
|
|
|
|
|
const handlerSaveAreaInfo = data => { |
|
|
|
|
if (!data.coord || !data.mode) { |
|
|
|
|
alert('에러 발생. 다시 시도해 주세요.'); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
@ -255,16 +279,17 @@ export const LaancDrawControl = props => {
|
|
|
|
|
const areaInfo = { |
|
|
|
|
coordinates: [], |
|
|
|
|
bufferZone: 0, |
|
|
|
|
areaType: '' |
|
|
|
|
areaType: '', |
|
|
|
|
inAirArea: 'N' |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const bufferZone = mode === 'POLYGON' ? 0 : 100; |
|
|
|
|
const bufferZone = data.mode === 'POLYGON' ? 0 : 100; |
|
|
|
|
const prePath = []; |
|
|
|
|
|
|
|
|
|
areaInfo.areaType = mode; |
|
|
|
|
areaInfo.areaType = data.mode; |
|
|
|
|
|
|
|
|
|
if (areaInfo.areaType !== 'CIRCLE') { |
|
|
|
|
coord.forEach(item => { |
|
|
|
|
data.coord.forEach(item => { |
|
|
|
|
const p = { |
|
|
|
|
lat: item[1], |
|
|
|
|
lon: item[0] |
|
|
|
@ -275,66 +300,56 @@ export const LaancDrawControl = props => {
|
|
|
|
|
|
|
|
|
|
areaInfo.coordinates = prePath; |
|
|
|
|
areaInfo.bufferZone = bufferZone; |
|
|
|
|
areaInfo.inAirArea = inAirArea; |
|
|
|
|
if (areaInfo.areaType === 'CIRCLE') { |
|
|
|
|
const obj = drawObj.getAll(); |
|
|
|
|
const feature = obj.features[0]; |
|
|
|
|
const obj = drawObj.getAll().features; |
|
|
|
|
const feature = obj.filter(o => o.properties.id === 'CIRCLE'); |
|
|
|
|
|
|
|
|
|
const point = { |
|
|
|
|
lat: coord[1], |
|
|
|
|
lon: coord[0] |
|
|
|
|
lat: data.coord[1], |
|
|
|
|
lon: data.coord[0] |
|
|
|
|
}; |
|
|
|
|
areaInfo.coordinates = [point]; |
|
|
|
|
areaInfo.bufferZone = feature.properties.radiusInKm * 1000; |
|
|
|
|
areaInfo.bufferZone = feature[0].properties.radiusInKm * 1000; |
|
|
|
|
} |
|
|
|
|
props.handlerCoordinates(areaInfo); |
|
|
|
|
setIsDrawDone(true); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// 버퍼 및 기존 도형 재생성
|
|
|
|
|
// 근데 areaCoordList[0]이.. 도형을 하나만 받아오는걸로 알고 있어서 그거 확인해야함
|
|
|
|
|
// 그리고 circle관련해서 create랑 update다시 작업해야함....
|
|
|
|
|
const handlerPastDraw = () => { |
|
|
|
|
if (props.areaCoordList) { |
|
|
|
|
const obj = drawObj.getAll().features; |
|
|
|
|
const areas = props.areaCoordList; |
|
|
|
|
if (areas.length > 0 && obj.length > 0) { |
|
|
|
|
// console.log(obj, '>>>');
|
|
|
|
|
// console.log(areas, '>>>>areas');
|
|
|
|
|
|
|
|
|
|
// areas -> 지도에 그려진 모든 구역 정보여야함
|
|
|
|
|
areas.forEach((area, idx) => { |
|
|
|
|
const paths = []; |
|
|
|
|
area.coordList.forEach(coord => paths.push([coord.lon, coord.lat])); |
|
|
|
|
if (area.areaType) { |
|
|
|
|
console.log('pastDraw', area); |
|
|
|
|
if (area.areaType === 'LINE') { |
|
|
|
|
// 버퍼 생성
|
|
|
|
|
if (area.bufferCoordList) { |
|
|
|
|
const bufferPaths = []; |
|
|
|
|
|
|
|
|
|
area.bufferCoordList.forEach(bfCoord => |
|
|
|
|
bufferPaths.push([bfCoord.lon, bfCoord.lat]) |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
handlerCreateDrawObj( |
|
|
|
|
bufferId, |
|
|
|
|
setBufferId, |
|
|
|
|
'LineString', |
|
|
|
|
{ path: bufferPaths }, |
|
|
|
|
'BUFFER' |
|
|
|
|
); |
|
|
|
|
if (area.areaType === 'CIRCLE') { |
|
|
|
|
} else { |
|
|
|
|
if (area.areaType === 'LINE') { |
|
|
|
|
// 버퍼 생성
|
|
|
|
|
if (area.bufferCoordList) { |
|
|
|
|
const bufferPaths = []; |
|
|
|
|
|
|
|
|
|
area.bufferCoordList.forEach(bfCoord => |
|
|
|
|
bufferPaths.push([bfCoord.lon, bfCoord.lat]) |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
handlerCreateDrawObj( |
|
|
|
|
bufferId, |
|
|
|
|
setBufferId, |
|
|
|
|
'LineString', |
|
|
|
|
{ path: bufferPaths }, |
|
|
|
|
'BUFFER' |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
} else if (area.areaType === 'POLYGON') { |
|
|
|
|
paths.push(paths[0]); |
|
|
|
|
} |
|
|
|
|
} else if (area.areaType === 'POLYGON') { |
|
|
|
|
paths.push(paths[0]); |
|
|
|
|
} |
|
|
|
|
const currentObj = obj.filter(o => o.properties.id !== 'BUFFER'); |
|
|
|
|
currentObj.forEach(obj => { |
|
|
|
|
handlerRemoveGroupMarker(obj.id); |
|
|
|
|
|
|
|
|
|
const initCoord = obj.geometry.coordinates; |
|
|
|
|
const coord = |
|
|
|
|
obj.properties.id === 'LINE' ? initCoord : initCoord[0]; |
|
|
|
|
handlerCreateGroupMarker(coord, obj.id); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
@ -417,6 +432,8 @@ export const LaancDrawControl = props => {
|
|
|
|
|
const drawInit = () => { |
|
|
|
|
// drawObj.deleteAll();
|
|
|
|
|
// handlerRemoveAllMarker();
|
|
|
|
|
// setInAirArea(false);
|
|
|
|
|
|
|
|
|
|
props.handlerSaveCheck(false); |
|
|
|
|
setDrawObjId(); |
|
|
|
|
|
|
|
|
|