Commit d0ccf743 authored by KangMin An's avatar KangMin An
Browse files

Update : Data 명세서 & Controller.

parent efe07467
......@@ -8,16 +8,26 @@
∟ Local Code (Do/도)
∟ Local Code (SGG/시군구)
∟ Local Code (EMD/읍면동)
∟ Year (연)
∟ YYYYMMDD (연/월/일)
∟ Outside
∟ weather.csv
∟ Users
∟ ID (사용자 개인 ID)
∟ Outside
∟ YYYY (연)
∟ YYYYMM (연/월)
∟ YYYYMMDD (연/월/일)
∟ weather.csv
∟ weights.csv
∟ Users
∟ ID (사용자 개인 ID)
∟ YYYY (연)
∟ YYYYMM (연/월)
∟ YYYYMMDD (연/월/일)
∟ weather.csv
∟ weights.csv
데이터가 저장되는 경로의 구조입니다.<br><br>
데이터가 저장되는 경로의 구조입니다.
- 1차 : 지역별 대분류
- 2차 : 사용자와 외부 정보 분류
- 3차 : 연 / 월 / 일 분류
<br><br>
# 2. Data Format
......@@ -37,9 +47,9 @@
사용자가 설정한 장소의 데이터는 다음과 같은 형식으로 저장됩니다.
| Month | Date | Hour | Minute | Temperature | Humidity | Lights | Future Temperature |
| :---: | :--: | :--: | :----: | :---------: | :------: | :----: | :------------------: |
| 월 | 일 | 시 | 분 | 온도(℃) | 습도(%) | 광도 | 단위 시간 후 온도(℃) |
| Month | Date | Hour | Minute | Temperature | Humidity | Lights |
| :---: | :--: | :--: | :----: | :---------: | :------: | :----: |
| 월 | 일 | 시 | 분 | 온도(℃) | 습도(%) | 광도 |
<br><br>
......@@ -58,15 +68,15 @@ EUE가 제일 중요하게 수행해야할 부분입니다. 데이터를 학습
- 외부 데이터
- 온도
- 습도
- 기압
- 풍속
- 온도 ( Out Temperature )
- 습도 ( Out Humidity )
- 기압 ( Out Pressure )
- 풍속 ( Out Wind Speed )
- 사용자 데이터
- 온도
- 습도
- 광도
- 온도 ( Temperature )
- 습도 ( Humidity )
- 광도 ( Lights )
<br>
......
......@@ -4,6 +4,9 @@ import fetch from "node-fetch";
const OUT = "Out";
const IN = "In";
const OUTSIDE = "Outside";
const USERS = "Users";
// 데이터 수집 기로 부터 받아온 지역 코드 세분화
const locCodeSep = (code = "") => {
const DO = code.slice(0, 2);
......@@ -40,12 +43,20 @@ const getTimeInfo = () => {
return time;
};
const getDataDIR = (loc, time) => {
const repoDIR = `./data/${loc.DO}/${loc.SGG}/${loc.EMD}/${time.year}/${
time.year
}${time.month < 10 ? "0" + time.month : time.month}${
time.date < 10 ? "0" + time.date : time.date
}`;
const getDataDIR = (loc, time, id) => {
const year = time.year;
const month = time.month < 10 ? `0${time.month}` : time.month;
const date = time.date < 10 ? `0${time.date}` : time.date;
const repoDIR =
"./data" +
`/${loc.DO}` +
`/${loc.SGG}` +
`/${loc.EMD}` +
`/${id}` +
`/${year}` +
`/${year}${month}` +
`/${year}${month}${date}`;
return repoDIR;
};
......@@ -65,11 +76,6 @@ const storeData = (type, time, loc, fdir, data) => {
});
console.log("Create directory.");
if (type === IN) {
data = data.split("\n")[1];
console.log("Split the user Data.");
}
}
// 그 외의 에러는 출력
else console.log(err);
......@@ -81,7 +87,7 @@ const storeData = (type, time, loc, fdir, data) => {
console.log(
`${time.year}/${time.month}/${time.date} ${time.hour}:${
time.minute
} - ${loc.EMD} ${type === OUT ? "Outside" : "User"} data append.`
} - ${loc.EMD} ${type === OUT ? OUTSIDE : USERS} data append.`
);
});
});
......@@ -104,8 +110,8 @@ const handleOutData = (locCode, lat, lng) => {
const loc = locCodeSep(locCode);
const time = getTimeInfo();
const fdir = getDataDIR(loc, time) + "/Outside";
// 데이터 형식 - 월 | 일 | 시 | 분 | 온도 | 습도 | 기압 | 풍속
const fdir = getDataDIR(loc, time, OUTSIDE);
// 데이터 형식 - [ 월 | 일 | 시 | 분 | 온도 | 습도 | 기압 | 풍속 ]
const data = `${time.month},${time.date},${time.hour},${time.minute},${temp},${humi},${press},${wind_speed}\n`;
storeData(OUT, time, loc, fdir, data);
......@@ -118,9 +124,9 @@ const handleInData = (id, locCode, temp, humi, lights) => {
const loc = locCodeSep(locCode);
const time = getTimeInfo();
const fdir = getDataDIR(loc, time) + `/Users/${id}`;
// 데이터 형식 - [이전 줄 : 현재 온도 ( 이전 기록 기준 단위 시간 후 온도)] , [ 현재 줄 : 월 | 일 | 시 | 분 | 온도 | 습도 | 광도 ]
const data = `${temp}\n${time.month},${time.date},${time.hour},${time.minute},${temp},${humi},${lights}`;
const fdir = getDataDIR(loc, time, `${USERS}/${id}`);
// 데이터 형식 - [ 월 | 일 | 시 | 분 | 온도 | 습도 | 광도 ]
const data = `${time.month},${time.date},${time.hour},${time.minute},${temp},${humi},${lights}\n`;
storeData(IN, time, loc, fdir, data);
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment