Skip to content

Commit

Permalink
Merge pull request #58 from RGPosadas/fix/set-groundwork-task-14-15
Browse files Browse the repository at this point in the history
Set groundwork for TASK-14 and TASK-15
  • Loading branch information
ys-lin committed Mar 20, 2020
2 parents 0958e9b + af55c76 commit 03c7e14
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 31 deletions.
18 changes: 10 additions & 8 deletions src/components/map-overlays/map-overlays.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { BuildingId, ZoomLevel, IndoorInformation } from "../../types/main";
import { StyleSheet } from "react-native";
import { CONCORDIA_RED, BUILDING_UNTAPPED } from "../../constants/style";
import { getAllCampuses } from "../../constants/campus.data";
import { floorOverlays } from "../../constants/floors.data";
import { buildingFloors } from "../../constants/floors.data";
import { getAllPOI } from "../../constants/poi.data";
import CustomMarker from "./custom-marker.component";
import CustomPolygon from "./custom-polygon.component";
Expand Down Expand Up @@ -107,13 +107,15 @@ const MapOverlays = ({
*/}
{zoomLevel === ZoomLevel.INDOOR ? (
<>
{floorOverlays.map(floorOverlay => (
<Overlay
key={floorOverlay.id}
bounds={floorOverlay.bounds}
image={floorOverlay.image}
/>
))}
{buildingFloors
.filter(floor => floor.bounds != null && floor.image != null)
.map(floor => (
<Overlay
key={floor.id}
bounds={floor.bounds}
image={floor.image}
/>
))}

{getAllPOI()
.filter(poi => {
Expand Down
43 changes: 25 additions & 18 deletions src/constants/floors.data.ts
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];
};
16 changes: 16 additions & 0 deletions src/constants/zoom-range.data.ts
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
};
4 changes: 2 additions & 2 deletions src/screens/map-screen/map-screen.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useState, useEffect, useRef } from "react";
import { StyleSheet, View } from "react-native";
import { RegionProvider } from "../../context/region.context";
import CampusToggle from "../../components/campus-toggle/campus-toggle.component";
import MapView, { PROVIDER_GOOGLE, Marker } from "react-native-maps";
import MapView, { PROVIDER_GOOGLE } from "react-native-maps";
import MapOverlays from "../../components/map-overlays/map-overlays.component";
import BuildingInformation from "../../components/building-information/building-information.component";
import { Buildings } from "../../constants/buildings.data";
Expand All @@ -26,7 +26,7 @@ import {
indoorRange,
outdoorRange,
campusRange
} from "../../constants/floors.data";
} from "../../constants/zoom-range.data";

/**
* Screen for the Map and its related buttons and components
Expand Down
54 changes: 54 additions & 0 deletions src/services/pathfinding.service.ts
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 [];
};
15 changes: 12 additions & 3 deletions src/types/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ export interface Region extends Location {
longitudeDelta: number;
}

export type Coordinate = [number, number];

export interface Building {
id: BuildingId;
campusId: CampusId;
Expand Down Expand Up @@ -60,12 +58,19 @@ export interface LinkItem {
link: string;
}

export interface FloorOverlay {
export interface BuildingFloor {
id: number;
buildingId: BuildingId;
level: number;
bounds: [Coordinate, Coordinate];
image: any;
travelNodes: TravelNode[];
}

export interface TravelNode {
id: number;
location: Location;
children: number[];
}

export interface IndoorInformation {
Expand All @@ -83,6 +88,10 @@ export interface Range {
max: number;
}

export type Line = [Location, Location];

export type Coordinate = [number, number];

export enum CampusId {
SGW = "SGW",
Loyola = "Loyola"
Expand Down

0 comments on commit 03c7e14

Please sign in to comment.