Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

검색 기능 변경 #37

Merged
merged 20 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
18fc271
feat: 단어의 첫 번째와 일치하는 경우에만 검색
presentKey Aug 26, 2024
0130423
refactor: SearchHeader 컴포넌트 분리
presentKey Aug 26, 2024
45eb0d4
feat: 현재 위치로 설정하기 버튼 마크업
presentKey Aug 26, 2024
9efe718
feat: 최근 검색어 마크업
presentKey Aug 26, 2024
3e6e11b
remove: 사용되지 않는 코드 및 파일 삭제
presentKey Aug 26, 2024
511aed1
feat: 홈 헤더에 검색 페이지 링크 추가
presentKey Aug 26, 2024
8ff0b40
feat: redux로 사용자 현재 지역 상태 관리
presentKey Aug 26, 2024
e5c3fc8
feat: 검색 페이지의 현재 위치로 설정 기능 구현
presentKey Aug 26, 2024
c36a3aa
feat: 검색 아이템 클릭 시, 해당 지역으로 위치 변경
presentKey Aug 26, 2024
af3d2c3
fix: 지역 아이콘 렌더링 조건 변경
presentKey Aug 26, 2024
79ad94d
feat: 사용자가 선택한 지역을 현재 지역으로 유지
presentKey Aug 26, 2024
fca0487
rename: useGeolocation을 공통 hook 폴더로 이동
presentKey Aug 26, 2024
abe64fd
feat: 현재 위치 설정하기 버튼의 disabled 조건 추가
presentKey Aug 26, 2024
e5fb847
Merge branch 'develop' of https://github.com/FashionForecast/FashionF…
presentKey Aug 26, 2024
adef3a0
feat: 현재 지역으로 날씨 정보 가져오기
presentKey Aug 26, 2024
40a785f
refactor: WeatherCard 리팩토링
presentKey Aug 26, 2024
d9870aa
remove: 불필요한 파일 및 코드 제거
presentKey Aug 26, 2024
c78be20
design: LocationIcon disabled 색상 조건 추가
presentKey Aug 27, 2024
1467257
feat: 기상청의 지역 좌표로 날씨 요청
presentKey Aug 27, 2024
f39bf0a
feat: 엑셀파일 추가
presentKey Aug 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,4 @@ dist-ssr
*.sln
*.sw?

# etc
*.xlsx

63 changes: 57 additions & 6 deletions script/region.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,89 @@ const fs = require('fs');
* 위경도 엑셀 파일은 아래 링크의 참고 문서에서 가져왔습니다.
* script 폴더에 '위경도.xlsx' 파일을 넣어주세요.
* @link https://www.data.go.kr/data/15084084/openapi.do
*
* 기상청 좌표 파일은 아래 링크의 csv파일을 변환했습니다.
* scrirpt 폴더에 '기상청좌표.xlsx' 파일을 넣어주세요.
* @link https://github.com/FashionForecast/FashionForecast-server/blob/develop/src/main/resources/national_forecast_regions.csv
*/

const workbook = xlsx.readFile('./script/위경도.xlsx');
const sheetName = workbook.SheetNames[0];
const sheet = workbook.Sheets[sheetName];

console.log('엑셀 데이터 변환중...');
console.log('지역 실제 좌표 엑셀 데이터 변환중...');

const data = xlsx.utils.sheet_to_json(sheet);
const regions = [];
const localCoordinates = [];

for (const v of data) {
if (!v['2단계'] || v['3단계']) continue;

const obj = {
const region = {
region: `${v['1단계']} ${v['2단계']}`,
nx: Number(v['위도(초/100)']),
ny: Number(v['경도(초/100)']),
};

regions.push(obj);
localCoordinates.push(region);
}

console.log('region.json 파일 생성중...');

const json = JSON.stringify(regions, null, 2);
const regionJson = JSON.stringify(localCoordinates, null, 2);

fs.writeFile('./src/assets/region.json', json, 'utf-8', (err) => {
fs.writeFile('./src/assets/region.json', regionJson, 'utf-8', (err) => {
if (err) {
console.error('파일 생성 중 오류 발생: ', err);
return;
}

console.log('region.json 파일이 생성되었습니다.');
});

console.log('기상청 지역 좌표 엑셀 데이터 변환중...');

const weatherWorkbook = xlsx.readFile('./script/기상청좌표.xlsx');
const weatherSheetName = weatherWorkbook.SheetNames[0];
const weathersheet = weatherWorkbook.Sheets[weatherSheetName];

const weatherData = xlsx.utils.sheet_to_json(weathersheet);

const weatherCoordinateList = {};

for (const v of weatherData) {
if (!v['district'] || v['neighborhood']) continue;

weatherCoordinateList[`${v['city']} ${v['district']}`] = {
weatherNx: v['nx'],
weatherNy: v['ny'],
};
}

localCoordinates.forEach((v) => {
if (!weatherCoordinateList[v.region]) {
throw Error(`${v.region}이 존재하지 않습니다. 확인해주세요.`);
}
});

console.log('weatherRegionCoordinates.ts 파일 생성중...');

const listJson = JSON.stringify(weatherCoordinateList, null, 2);
const listContent = `const weatherCoordinateList: Record<
string,
{ weatherNx: number; weatherNy: number }
> = ${listJson}\n export default weatherCoordinateList`;

fs.writeFile(
'./src/assets/weatherRegionCoordinates.ts',
listContent,
'utf-8',
(err) => {
if (err) {
console.error('파일 생성 중 오류 발생: ', err);
return;
}

console.log('weatherRegionCoordinates.ts 파일이 생성되었습니다.');
}
);
Binary file added script/기상청좌표.xlsx
Binary file not shown.
Binary file added script/위경도.xlsx
Binary file not shown.
Loading