This repository has been archived by the owner on Oct 18, 2024. It is now read-only.
-
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.
AME now takes one JSON/GEOJSON file and throws it into the map (#10)
- Loading branch information
Showing
16 changed files
with
45,695 additions
and
1,763 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,21 @@ | ||
module.exports = { | ||
env: { | ||
browser: true, | ||
es2021: true, | ||
}, | ||
extends: [ | ||
"eslint:recommended", | ||
"plugin:react/recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
], | ||
parser: "@typescript-eslint/parser", | ||
parserOptions: { | ||
ecmaFeatures: { | ||
jsx: true, | ||
}, | ||
ecmaVersion: 12, | ||
sourceType: "module", | ||
}, | ||
plugins: ["react", "@typescript-eslint"], | ||
rules: {}, | ||
}; |
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,10 @@ | ||
{ | ||
"bracketSpacing": true, | ||
"jsxSingleQuote": true, | ||
"printWidth": 80, | ||
"semi": true, | ||
"singleQuote": true, | ||
"tabWidth": 2, | ||
"trailingComma": "none", | ||
"useTabs": false | ||
} |
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,176 @@ | ||
{ | ||
"type": "FeatureCollection", | ||
"features": [ | ||
{ | ||
"type": "Feature", | ||
"properties": { | ||
"fid": 1, | ||
"type": "room", | ||
"roomType": "classroom", | ||
"roomId": "2200", | ||
"building": "RB", | ||
"roomName": "Big Theatre", | ||
"searchTagProps": ["building", "roomId", "roomName"], | ||
"floor": "1" | ||
}, | ||
"geometry": { | ||
"type": "Polygon", | ||
"coordinates": [ | ||
[ | ||
[ | ||
-75.69827377796173, | ||
45.39140195535068 | ||
], | ||
[ | ||
-75.69802701473236, | ||
45.39140195535068 | ||
], | ||
[ | ||
-75.69802701473236, | ||
45.392049912726584 | ||
], | ||
[ | ||
-75.69827377796173, | ||
45.392049912726584 | ||
], | ||
[ | ||
-75.69827377796173, | ||
45.39140195535068 | ||
] | ||
] | ||
] | ||
} | ||
}, | ||
{ | ||
"type": "Feature", | ||
"properties": { | ||
"fid": 2, | ||
"type": "room", | ||
"roomType": "hallway", | ||
"roomId": "2402", | ||
"building": "RB", | ||
"search": false, | ||
"searchTagProps": ["building", "roomId"], | ||
"floor": "1" | ||
}, | ||
"geometry": { | ||
"type": "Polygon", | ||
"coordinates": [ | ||
[ | ||
[ | ||
-75.69746375083923, | ||
45.39141325699649 | ||
], | ||
[ | ||
-75.69719552993774, | ||
45.39141325699649 | ||
], | ||
[ | ||
-75.69719552993774, | ||
45.392049912726584 | ||
], | ||
[ | ||
-75.69746375083923, | ||
45.392049912726584 | ||
], | ||
[ | ||
-75.69746375083923, | ||
45.39141325699649 | ||
] | ||
] | ||
] | ||
} | ||
}, | ||
{ | ||
"type": "Feature", | ||
"properties": { | ||
"fid": 3, | ||
"type": "room", | ||
"roomType": "office", | ||
"roomId": "2222", | ||
"building": "RB", | ||
"searchTagProps": ["building", "roomId"], | ||
"floor": "2" | ||
}, | ||
"geometry": { | ||
"type": "Polygon", | ||
"coordinates": [ | ||
[ | ||
[ | ||
-75.69878876209258, | ||
45.39117215472943 | ||
], | ||
[ | ||
-75.69864392280579, | ||
45.390949887665876 | ||
], | ||
[ | ||
-75.69835960865021, | ||
45.39088584445143 | ||
], | ||
[ | ||
-75.69794118404388, | ||
45.390870775449265 | ||
], | ||
[ | ||
-75.69744229316711, | ||
45.39085947369498 | ||
], | ||
[ | ||
-75.69701850414276, | ||
45.39089337895103 | ||
], | ||
[ | ||
-75.69679319858551, | ||
45.390953654911506 | ||
], | ||
[ | ||
-75.69669127464294, | ||
45.39110434453151 | ||
], | ||
[ | ||
-75.69677174091339, | ||
45.39119852533998 | ||
], | ||
[ | ||
-75.69687902927399, | ||
45.39109681006006 | ||
], | ||
[ | ||
-75.6971150636673, | ||
45.39102146529023 | ||
], | ||
[ | ||
-75.69743692874908, | ||
45.39101016356611 | ||
], | ||
[ | ||
-75.69775879383087, | ||
45.39099886183969 | ||
], | ||
[ | ||
-75.69805383682251, | ||
45.391044068731716 | ||
], | ||
[ | ||
-75.69833815097809, | ||
45.39113824964064 | ||
], | ||
[ | ||
-75.69861173629761, | ||
45.39125503374973 | ||
], | ||
[ | ||
-75.69878876209258, | ||
45.39126256820012 | ||
], | ||
[ | ||
-75.69878876209258, | ||
45.39117215472943 | ||
] | ||
] | ||
] | ||
} | ||
} | ||
] | ||
} |
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,67 +1,122 @@ | ||
import { app, BrowserWindow } from "electron"; | ||
import * as path from "path"; | ||
import * as isDev from "electron-is-dev"; | ||
import { | ||
app, | ||
BrowserWindow, | ||
dialog, | ||
Menu, | ||
MenuItemConstructorOptions | ||
} from 'electron'; | ||
import * as path from 'path'; | ||
import * as isDev from 'electron-is-dev'; | ||
import installExtension, { | ||
REACT_DEVELOPER_TOOLS, | ||
} from "electron-devtools-installer"; | ||
REACT_DEVELOPER_TOOLS | ||
} from 'electron-devtools-installer'; | ||
import * as fs from 'fs'; | ||
|
||
let win: BrowserWindow | null = null; | ||
|
||
const template: MenuItemConstructorOptions[] = [ | ||
{ | ||
label: 'File', | ||
submenu: [ | ||
{ | ||
label: 'Open File', | ||
accelerator: 'CmdOrCtrl+O', | ||
click: openFile | ||
} | ||
] | ||
}, | ||
{ | ||
label: 'Edit', | ||
submenu: [ | ||
{ | ||
role: 'undo' | ||
}, | ||
{ | ||
role: 'redo' | ||
} | ||
] | ||
} | ||
]; | ||
|
||
function createWindow() { | ||
win = new BrowserWindow({ | ||
width: 800, | ||
height: 600, | ||
webPreferences: { | ||
nodeIntegration: true, | ||
}, | ||
enableRemoteModule: true | ||
} | ||
}); | ||
|
||
if (isDev) { | ||
win.loadURL("http://localhost:3000/index.html"); | ||
win.loadURL('http://localhost:3000/index.html'); | ||
} else { | ||
// 'build/index.html' | ||
win.loadURL(`file://${__dirname}/../index.html`); | ||
} | ||
|
||
win.on("closed", () => (win = null)); | ||
win.on('closed', () => (win = null)); | ||
|
||
// Hot Reloading | ||
if (isDev) { | ||
// 'node_modules/.bin/electronPath' | ||
require("electron-reload")(__dirname, { | ||
require('electron-reload')(__dirname, { | ||
electron: path.join( | ||
__dirname, | ||
"..", | ||
"..", | ||
"node_modules", | ||
".bin", | ||
"electron" | ||
'..', | ||
'..', | ||
'node_modules', | ||
'.bin', | ||
'electron' | ||
), | ||
forceHardReset: true, | ||
hardResetMethod: "exit", | ||
hardResetMethod: 'exit' | ||
}); | ||
} | ||
|
||
// DevTools | ||
installExtension(REACT_DEVELOPER_TOOLS) | ||
.then((name) => console.log(`Added Extension: ${name}`)) | ||
.catch((err) => console.log("An error occurred: ", err)); | ||
.catch((err) => console.log('An error occurred: ', err)); | ||
|
||
if (isDev) { | ||
win.webContents.openDevTools(); | ||
} | ||
} | ||
|
||
app.on("ready", createWindow); | ||
const menu = Menu.buildFromTemplate(template); | ||
Menu.setApplicationMenu(menu); | ||
app.on('ready', createWindow); | ||
|
||
app.on("window-all-closed", () => { | ||
if (process.platform !== "darwin") { | ||
app.on('window-all-closed', () => { | ||
if (process.platform !== 'darwin') { | ||
app.quit(); | ||
} | ||
}); | ||
|
||
app.on("activate", () => { | ||
app.on('activate', () => { | ||
if (win === null) { | ||
createWindow(); | ||
} | ||
}); | ||
|
||
function openFile() { | ||
dialog | ||
.showOpenDialog({ | ||
properties: ['openFile', 'multiSelections'], | ||
filters: [{ name: 'Maps', extensions: ['json', 'geojson'] }] | ||
}) | ||
.then((data) => { | ||
if (!data) return; | ||
|
||
const { filePaths } = data; | ||
// TODO: Change the fact that implementation currently only supports opening one file at a time. | ||
|
||
fs.readFile(filePaths[0], 'utf-8', (err, data) => { | ||
// We could also probably just send an alert/dialogue saying something went wrong | ||
if (err) return; | ||
|
||
win?.webContents.send('file-content', JSON.parse(data.toString())); | ||
}); | ||
}); | ||
} |
Oops, something went wrong.