-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Started tmp.ts for algorithm
- Loading branch information
Dave Palay
committed
Sep 11, 2019
1 parent
decc20b
commit be1e6f3
Showing
10 changed files
with
454 additions
and
90 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules/ | ||
package-lock.json |
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,27 @@ | ||
{ | ||
// See https://go.microsoft.com/fwlink/?LinkId=733558 | ||
// for the documentation about the tasks.json format | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"type": "typescript", | ||
"tsconfig": "tsconfig.json", | ||
"problemMatcher": [ | ||
"$tsc" | ||
], | ||
"group": "build" | ||
}, | ||
{ | ||
"type": "typescript", | ||
"tsconfig": "tsconfig.json", | ||
"option": "watch", | ||
"problemMatcher": [ | ||
"$tsc-watch" | ||
], | ||
"group": { | ||
"kind": "build", | ||
"isDefault": true | ||
} | ||
} | ||
] | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
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,32 @@ | ||
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
exports.__esModule = true; | ||
var data_1 = __importDefault(require("./data")); | ||
var slope = function (anchor, point) { | ||
return (point.lat - anchor.lat) / (point.lng - anchor.lng); | ||
}; | ||
var sortedList = data_1["default"].sort(function (a, b) { return Math.abs(b.coordinates.lng) - Math.abs(a.coordinates.lng); }); | ||
var anchor = sortedList.shift(); // removes the Anchor from the list of portals to check | ||
console.log("Using " + anchor.title + " as the Anchor!"); | ||
console.log(sortedList | ||
// calculates the slope and adds it to the portal | ||
.map(function (portal) { | ||
return __assign(__assign({}, portal), { slopeFromAnchor: slope(anchor.coordinates, portal.coordinates) }); | ||
}) | ||
// sorts based on the slope | ||
.sort(function (a, b) { return a.slopeFromAnchor - b.slopeFromAnchor; }) | ||
// extracts just the bits we want to see | ||
.map(function (portal) { return "from " + portal.title; })); |
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,24 @@ | ||
{ | ||
"name": "portaldisplay", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"dependencies": { | ||
"tsc": "^1.20150623.0", | ||
"typescript": "^3.6.3" | ||
}, | ||
"devDependencies": {}, | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/dpalay/PortalDisplay.git" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"bugs": { | ||
"url": "https://github.com/dpalay/PortalDisplay/issues" | ||
}, | ||
"homepage": "https://github.com/dpalay/PortalDisplay#readme" | ||
} |
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,22 @@ | ||
import data from './data' | ||
|
||
|
||
const slope = (anchor: {lat: number, lng: number}, point: {lat: number, lng: number}): number => | ||
(point.lat - anchor.lat)/(point.lng - anchor.lng) | ||
|
||
let sortedList = data.sort((a,b) => Math.abs(b.coordinates.lng) - Math.abs(a.coordinates.lng)) | ||
let anchor = sortedList.shift() // removes the Anchor from the list of portals to check | ||
console.log(`Using ${anchor.title} as the Anchor!`) | ||
console.log( | ||
|
||
sortedList | ||
// calculates the slope and adds it to the portal | ||
.map((portal) => { | ||
return {...portal, slopeFromAnchor: slope(anchor.coordinates, portal.coordinates)} | ||
}) | ||
// sorts based on the slope | ||
.sort((a,b) => a.slopeFromAnchor - b.slopeFromAnchor) | ||
|
||
// extracts just the bits we want to see | ||
.map(portal => `from ${portal.title}`) | ||
); |
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,8 @@ | ||
{ | ||
"compileOnSave": true, | ||
"compilerOptions": { | ||
"resolveJsonModule": true, | ||
"esModuleInterop": true, | ||
"outDir": "./bin" | ||
} | ||
} |