-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #58 from RGPosadas/fix/set-groundwork-task-14-15
Set groundwork for TASK-14 and TASK-15
- Loading branch information
Showing
6 changed files
with
119 additions
and
31 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
@@ -1,39 +1,46 @@ | ||
import { FloorOverlay, BuildingId, Range } from "../types/main"; | ||
import { BuildingFloor, BuildingId, Range } from "../types/main"; | ||
|
||
export const floorOverlays: FloorOverlay[] = [ | ||
export const buildingFloors: BuildingFloor[] = [ | ||
{ | ||
id: 1, | ||
buildingId: BuildingId.H, | ||
level: 8, | ||
bounds: null, | ||
image: null, | ||
travelNodes: [] | ||
}, | ||
{ | ||
id: 2, | ||
buildingId: BuildingId.H, | ||
level: 9, | ||
bounds: null, | ||
image: null, | ||
travelNodes: [] | ||
}, | ||
{ | ||
id: 3, | ||
buildingId: BuildingId.MB, | ||
level: 1, | ||
bounds: [ | ||
[45.495778, -73.5797], | ||
[45.494802, -73.578297] | ||
], | ||
image: require("../../assets/floors/MB-1.png") | ||
image: require("../../assets/floors/MB-1.png"), | ||
travelNodes: [] | ||
}, | ||
{ | ||
id: 3, | ||
id: 4, | ||
buildingId: BuildingId.CC, | ||
level: 1, | ||
bounds: [ | ||
[45.458639, -73.640921], | ||
[45.457962, -73.639775] | ||
], | ||
image: require("../../assets/floors/CC1.png") | ||
image: require("../../assets/floors/CC1.png"), | ||
travelNodes: [] | ||
} | ||
]; | ||
|
||
export const indoorRange: Range = { | ||
min: 0, | ||
max: 0.0025 | ||
}; | ||
|
||
export const outdoorRange: Range = { | ||
min: 0.0025, | ||
max: 0.02 | ||
}; | ||
|
||
export const campusRange: Range = { | ||
min: 0.02, | ||
max: 0.09 | ||
const getTravelNodeById = (buildingFloor: BuildingFloor, id: number) => { | ||
return buildingFloor.travelNodes.filter(node => node.id === id)[0]; | ||
}; |
This file contains 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,16 @@ | ||
import { Range } from "../types/main"; | ||
|
||
export const indoorRange: Range = { | ||
min: 0, | ||
max: 0.0025 | ||
}; | ||
|
||
export const outdoorRange: Range = { | ||
min: 0.0025, | ||
max: 0.02 | ||
}; | ||
|
||
export const campusRange: Range = { | ||
min: 0.02, | ||
max: 0.09 | ||
}; |
This file contains 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 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 { Line } from "../types/main"; | ||
import { getDistanceFromLine } from "geolib"; | ||
|
||
/** | ||
* TASK-14 | ||
* A* implementation for indoor pathfinding | ||
* | ||
* TODO: | ||
* | ||
* 1. Use traverseNodes() to get a list of lines which correspond to connections between nodes. | ||
* @see Line | ||
* | ||
* 2. Go through each line and check distance between the line and the start location. The | ||
* line closest to the start location is made up of the travel nodes which are connect to the start location. | ||
* @see getDistanceFromLine() from geolib. | ||
* | ||
* 3. Go through each line and check distance between the line and the end location. The | ||
* line closest to the end location is made up of the travel nodes which are connect to the start location. | ||
* @see getDistanceFromLine() from geolib. | ||
* | ||
* 4. Make a copy of the floor's travel node list and update it with the new relation found in 2. and 3. | ||
* | ||
* 5. Now that the tree is set properly. Do A* (pref. someone who did COMP472 would do this): | ||
* | ||
* 1. Initialize the open list with the initial node so (top node) | ||
* 2. Initialize the closed list to empty | ||
* 3. Repeat | ||
* a) If the open list is empty, then exit with failure. | ||
* b) Else, take the first node s from the open list. | ||
* c) If s is a goal state, exit with success. Extract the solution path from s to so | ||
* d) Else, insert s in the closed list (s has been visited /expanded) | ||
* e) Insert the successors of s in the open list in a certain order if | ||
* they are not already in the closed and/or open lists (to avoid | ||
* cycles) | ||
*/ | ||
export const findPathOnFloor = ( | ||
floorId: number, | ||
start: Location, | ||
end: Location | ||
): Line[] => { | ||
return []; | ||
}; | ||
|
||
/** | ||
* TASK-15 | ||
* Function which traverses a floor's travel node and returns a set of lines. | ||
* | ||
* This function takes in a floorId, and will return all lines which correspond to | ||
* connections between nodes. Use a set to avoid duplicates. | ||
* @see buildingFloors from src/constants/floors.data.ts | ||
*/ | ||
export const traverseNodes = (floorId: number): Line[] => { | ||
return []; | ||
}; |
This file contains 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