-
Notifications
You must be signed in to change notification settings - Fork 0
[UNI-46] [FE] Mock Data 생성하기 (UNI-47, UNI-48) #10
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
05cea61
[UNI-42] feat: 데이터 구조 생성 및 mock data 생성 완료
jpark0506 140f3e3
[UNI-46] fix: vite build 수정
jpark0506 676bb38
[UNI-46] feat: marker mock data 생성
jpark0506 3e76591
[UNI-46] fix : Node List Converter 수정
jpark0506 3f4ecc4
[UNI-46] fix: routes -> route로 변경
jpark0506 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import type { CustomNode } from "../types/node"; | ||
| import type { Path } from "../types/path"; | ||
|
|
||
| export const convertToCoreNode = (data: { id: string; lat: number; lng: number }): CustomNode => { | ||
| return { | ||
| id: data.id, | ||
| lat: data.lat, | ||
| lng: data.lng, | ||
| isCore: true, | ||
| }; | ||
| }; | ||
|
|
||
| export const convertToSubNode = (data: { id: string; lat: number; lng: number }): CustomNode => { | ||
| return { | ||
| id: data.id, | ||
| lat: data.lat, | ||
| lng: data.lng, | ||
| isCore: false, | ||
| }; | ||
| }; | ||
|
|
||
| export const convertToPath = (pathKey: string, nodesData: { id: string; lat: number; lng: number }[]): Path => { | ||
| const nodeList = nodesData.map((node) => convertToSubNode(node)); | ||
| const startNode = convertToCoreNode(nodesData[0]); | ||
| const endNode = convertToCoreNode(nodesData[nodesData.length - 1]); | ||
|
|
||
| nodeList[0] = startNode; | ||
| nodeList[nodeList.length - 1] = endNode; | ||
|
|
||
| return { | ||
| id: pathKey, | ||
| startNode, | ||
| endNode, | ||
| nodeList, | ||
| }; | ||
| }; | ||
|
|
||
| export const convertToPaths = (pathData: { [key: string]: { id: string; lat: number; lng: number }[] }): Path[] => { | ||
| return Object.keys(pathData).map((pathKey) => convertToPath(pathKey, pathData[pathKey])); | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import { HazardEdge } from "../types/edge"; | ||
| import { CautionFactor, DangerFactor } from "../types/factor"; | ||
| import { CustomNode } from "../types/node"; | ||
|
|
||
| export const createHazardEdge = ( | ||
| id: string, | ||
| startNode: CustomNode, | ||
| endNode: CustomNode, | ||
| cautionFactors?: CautionFactor[], | ||
| dangerFactors?: DangerFactor[], | ||
| ): HazardEdge => ({ | ||
| id, | ||
| startNode, | ||
| endNode, | ||
| cautionFactors, | ||
| dangerFactors, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import { HazardEdge } from "../types/edge"; | ||
| import { NavigationRoute } from "../types/route"; | ||
|
|
||
| export const createNavigationRoute = (edges: HazardEdge[]): NavigationRoute => { | ||
| return { | ||
| route: edges, | ||
| hasCaution: edges.some((edge) => edge.cautionFactors !== undefined), | ||
| totalDistance: 1.5, | ||
| totalCost: 10, | ||
| }; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import type { CustomNode } from "../types/node"; | ||
|
|
||
| export const createNode = (id: string, lat: number, lng: number, isCore: boolean = false): CustomNode => ({ | ||
| id, | ||
| lat, | ||
| lng, | ||
| isCore, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| import { Building } from "../types/node"; | ||
|
|
||
| export const buildings: Building[] = [ | ||
| { | ||
| id: "101", | ||
| lng: 127.044755, | ||
| lat: 37.555994, | ||
| isCore: true, | ||
| buildingName: "역사관", | ||
| buildingImageUrl: "https://upload.wikimedia.org/wikipedia/commons/6/69/Hanyang_University_008.JPG", | ||
| phoneNumber: "02-2220-0114", | ||
| address: "서울특별시 성동구 왕십리로 222", | ||
| }, | ||
| { | ||
| id: "102", | ||
| lng: 127.0455, | ||
| lat: 37.5565, | ||
| isCore: true, | ||
| buildingName: "본관", | ||
| buildingImageUrl: "https://upload.wikimedia.org/wikipedia/commons/6/69/Hanyang_University_008.JPG", | ||
| phoneNumber: "02-2220-0114", | ||
| address: "서울특별시 성동구 왕십리로 222", | ||
| }, | ||
| { | ||
| id: "108", | ||
| lng: 127.0458, | ||
| lat: 37.557, | ||
| isCore: false, | ||
| buildingName: "국제관", | ||
| buildingImageUrl: "https://upload.wikimedia.org/wikipedia/commons/6/69/Hanyang_University_008.JPG", | ||
| phoneNumber: "02-2220-0114", | ||
| address: "서울특별시 성동구 왕십리로 222", | ||
| }, | ||
| { | ||
| id: "701", | ||
| lng: 127.0452, | ||
| lat: 37.5548, | ||
| isCore: false, | ||
| buildingName: "백남학술정보관", | ||
| buildingImageUrl: "https://upload.wikimedia.org/wikipedia/commons/6/69/Hanyang_University_008.JPG", | ||
| phoneNumber: "02-2220-1363", | ||
| address: "서울특별시 성동구 왕십리로 222", | ||
| }, | ||
| { | ||
| id: "201", | ||
| lng: 127.046, | ||
| lat: 37.5562, | ||
| isCore: false, | ||
| buildingName: "제1공학관", | ||
| buildingImageUrl: "https://upload.wikimedia.org/wikipedia/commons/6/69/Hanyang_University_008.JPG", | ||
| phoneNumber: "02-2220-0114", | ||
| address: "서울특별시 성동구 왕십리로 222", | ||
| }, | ||
| ]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import { createHazardEdge } from "../factory/edgeFactory"; | ||
| import { createNode } from "../factory/nodeFactory"; | ||
| import { HazardEdge } from "../types/edge"; | ||
| import { CustomNode } from "../types/node"; | ||
|
|
||
| const nodes: CustomNode[] = [ | ||
| createNode("4", 37.557669, 127.042007), | ||
| createNode("5", 37.557695, 127.042002), | ||
| createNode("9", 37.557956, 127.04228), | ||
| createNode("10", 37.557956, 127.042314), | ||
| createNode("14", 37.557659, 127.042548), | ||
| createNode("15", 37.557637, 127.04253), | ||
| createNode("20", 37.559317, 127.045131), | ||
| createNode("21", 37.559296, 127.045152), | ||
| createNode("30", 37.559275, 127.043711), | ||
| createNode("31", 37.559301, 127.043705), | ||
| ]; | ||
|
|
||
| const edges: HazardEdge[] = [ | ||
| createHazardEdge("path0", nodes[0], nodes[1], ["도로에 균열이 있어요"], []), | ||
| createHazardEdge("path1", nodes[2], nodes[3], [], ["계단이 있어요"]), | ||
| createHazardEdge("path2", nodes[4], nodes[5], ["낮은 턱이 있어요"], []), | ||
| createHazardEdge("path3", nodes[6], nodes[7], [], ["경사가 높아요"]), | ||
| createHazardEdge("path4", nodes[8], nodes[9], ["낮은 비탈길이 있어요"], []), | ||
| ]; | ||
|
|
||
| export const mockHazardEdges = edges; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Converter를 만들어서 타입을 명시하고 자동 변환 시켜주는 접근이 좋습니다!