Compare commits
10 Commits
b8a18029ef
...
ca8c24c058
| Author | SHA1 | Date | |
|---|---|---|---|
| ca8c24c058 | |||
| 0cdfee2f2e | |||
| ae6f297292 | |||
| 78c39e3780 | |||
| 00d45b0ee3 | |||
| f1c8e2ea24 | |||
| a36b1dafd6 | |||
| 763a4832b4 | |||
| b2576e5c06 | |||
| 5cbb188146 |
9
.gitignore
vendored
9
.gitignore
vendored
@@ -1,8 +1,5 @@
|
||||
node_modules
|
||||
.DS_Store
|
||||
dist
|
||||
dist-ssr
|
||||
*.local
|
||||
|
||||
.vscode
|
||||
.idea
|
||||
|
||||
node_modules
|
||||
dist
|
||||
|
||||
2
index.js
2
index.js
@@ -1,4 +1,4 @@
|
||||
require('ts-node').register({
|
||||
project:'./tsconfig.electron.json'
|
||||
});
|
||||
require('./src/main/app.ts')
|
||||
require('./src/main/app.ts');
|
||||
56
oneShow.html
Normal file
56
oneShow.html
Normal file
@@ -0,0 +1,56 @@
|
||||
<!DOCTYPE html>
|
||||
<html class="w-h-full">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<style>
|
||||
/* 当屏幕宽度大于或等于3840px时 */
|
||||
@media (min-width: 3840px) {
|
||||
html {
|
||||
font-size: 40px;
|
||||
}
|
||||
}
|
||||
|
||||
/* 当屏幕宽度在2560px到3839px之间时 */
|
||||
@media (min-width: 2560px) and (max-width: 3839px) {
|
||||
html {
|
||||
font-size: 26px;
|
||||
}
|
||||
}
|
||||
|
||||
/* 当屏幕宽度在1920px到2559px之间时 */
|
||||
@media (min-width: 1920px) and (max-width: 2559px) {
|
||||
html {
|
||||
font-size: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
/* 当屏幕宽度在750px到1919px之间时 */
|
||||
@media (min-width: 750px) and (max-width: 1919px) {
|
||||
html {
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
/* 当屏幕宽度在600px到749px之间时 */
|
||||
@media (min-width: 600px) and (max-width: 749px) {
|
||||
html {
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
/* 当屏幕宽度小于600px时 */
|
||||
@media (max-width: 599px) {
|
||||
html {
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<title>卫星数据监控平台</title>
|
||||
</head>
|
||||
<body class="w-h-full">
|
||||
<div id="app" class="w-h-full text-white"></div>
|
||||
<script type="module" src="/src/render/oneShow.ts"></script>
|
||||
</body>
|
||||
</html>
|
||||
56
oneShowAll.html
Normal file
56
oneShowAll.html
Normal file
@@ -0,0 +1,56 @@
|
||||
<!DOCTYPE html>
|
||||
<html class="w-h-full">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<style>
|
||||
/* 当屏幕宽度大于或等于3840px时 */
|
||||
@media (min-width: 3840px) {
|
||||
html {
|
||||
font-size: 40px;
|
||||
}
|
||||
}
|
||||
|
||||
/* 当屏幕宽度在2560px到3839px之间时 */
|
||||
@media (min-width: 2560px) and (max-width: 3839px) {
|
||||
html {
|
||||
font-size: 26px;
|
||||
}
|
||||
}
|
||||
|
||||
/* 当屏幕宽度在1920px到2559px之间时 */
|
||||
@media (min-width: 1920px) and (max-width: 2559px) {
|
||||
html {
|
||||
font-size: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
/* 当屏幕宽度在750px到1919px之间时 */
|
||||
@media (min-width: 750px) and (max-width: 1919px) {
|
||||
html {
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
/* 当屏幕宽度在600px到749px之间时 */
|
||||
@media (min-width: 600px) and (max-width: 749px) {
|
||||
html {
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
/* 当屏幕宽度小于600px时 */
|
||||
@media (max-width: 599px) {
|
||||
html {
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<title>卫星数据监控平台</title>
|
||||
</head>
|
||||
<body class="w-h-full">
|
||||
<div id="app" class="w-h-full text-white"></div>
|
||||
<script type="module" src="/src/render/oneShowAll.ts"></script>
|
||||
</body>
|
||||
</html>
|
||||
56
oneShowSwitch.html
Normal file
56
oneShowSwitch.html
Normal file
@@ -0,0 +1,56 @@
|
||||
<!DOCTYPE html>
|
||||
<html class="w-h-full">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<style>
|
||||
/* 当屏幕宽度大于或等于3840px时 */
|
||||
@media (min-width: 3840px) {
|
||||
html {
|
||||
font-size: 40px;
|
||||
}
|
||||
}
|
||||
|
||||
/* 当屏幕宽度在2560px到3839px之间时 */
|
||||
@media (min-width: 2560px) and (max-width: 3839px) {
|
||||
html {
|
||||
font-size: 26px;
|
||||
}
|
||||
}
|
||||
|
||||
/* 当屏幕宽度在1920px到2559px之间时 */
|
||||
@media (min-width: 1920px) and (max-width: 2559px) {
|
||||
html {
|
||||
font-size: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
/* 当屏幕宽度在750px到1919px之间时 */
|
||||
@media (min-width: 750px) and (max-width: 1919px) {
|
||||
html {
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
/* 当屏幕宽度在600px到749px之间时 */
|
||||
@media (min-width: 600px) and (max-width: 749px) {
|
||||
html {
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
/* 当屏幕宽度小于600px时 */
|
||||
@media (max-width: 599px) {
|
||||
html {
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<title>卫星数据监控平台</title>
|
||||
</head>
|
||||
<body class="w-h-full">
|
||||
<div id="app" class="w-h-full text-white"></div>
|
||||
<script type="module" src="/src/render/oneShowSwitch.ts"></script>
|
||||
</body>
|
||||
</html>
|
||||
14
package.json
14
package.json
@@ -9,16 +9,18 @@
|
||||
"build": "vite build",
|
||||
"serve": "vite preview",
|
||||
"electron:dev": "cross-env NODE_ENV=development electron index.js",
|
||||
"electron:build": "rimraf dist && vite build && tsc -p tsconfig.electron.json && electron-builder"
|
||||
"electron:build": "rimraf dist && vite build && tsc -p tsconfig.electron.json && electron-builder",
|
||||
"fix-memory-limit": "cross-env LIMIT=10000 increase-memory-limit"
|
||||
},
|
||||
"dependencies": {
|
||||
"echarts": "^5.2.2",
|
||||
"echarts": "^5.4.1",
|
||||
"echarts-gl": "^2.0.9",
|
||||
"echarts-liquidfill": "^3.1.0",
|
||||
"electron-store": "^8.0.1",
|
||||
"nmea": "git+https://e.coding.net/hwasmart/beidou-satellite-data-monitor/node-nmea.git",
|
||||
"serialport": "9.2.4",
|
||||
"nmea": "http://git.hwasmart.com/bd_group/node-nmea.git",
|
||||
"serialport": "10.5.0",
|
||||
"vue": "^3.0.5",
|
||||
"vue-echarts": "^6.0.0"
|
||||
"vue-echarts": "^6.6.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue": "^1.1.5",
|
||||
@@ -27,7 +29,7 @@
|
||||
"cross-env": "^7.0.3",
|
||||
"electron": "13.5.2",
|
||||
"electron-builder": "^22.10.5",
|
||||
"electron-rebuild": "2.3.5",
|
||||
"electron-rebuild": "^3.2.9",
|
||||
"postcss": "^8.2.10",
|
||||
"rimraf": "^3.0.2",
|
||||
"tailwindcss": "^2.1.1",
|
||||
|
||||
@@ -4,6 +4,49 @@
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<style>
|
||||
/* 当屏幕宽度大于或等于3840px时 */
|
||||
@media (min-width: 3840px) {
|
||||
html {
|
||||
font-size: 40px;
|
||||
}
|
||||
}
|
||||
|
||||
/* 当屏幕宽度在2560px到3839px之间时 */
|
||||
@media (min-width: 2560px) and (max-width: 3839px) {
|
||||
html {
|
||||
font-size: 26px;
|
||||
}
|
||||
}
|
||||
|
||||
/* 当屏幕宽度在1920px到2559px之间时 */
|
||||
@media (min-width: 1920px) and (max-width: 2559px) {
|
||||
html {
|
||||
font-size: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
/* 当屏幕宽度在750px到1919px之间时 */
|
||||
@media (min-width: 750px) and (max-width: 1919px) {
|
||||
html {
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
/* 当屏幕宽度在600px到749px之间时 */
|
||||
@media (min-width: 600px) and (max-width: 749px) {
|
||||
html {
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
/* 当屏幕宽度小于600px时 */
|
||||
@media (max-width: 599px) {
|
||||
html {
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<title>卫星数据监控平台</title>
|
||||
</head>
|
||||
<body class="w-h-full">
|
||||
|
||||
@@ -4,6 +4,49 @@
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<style>
|
||||
/* 当屏幕宽度大于或等于3840px时 */
|
||||
@media (min-width: 3840px) {
|
||||
html {
|
||||
font-size: 40px;
|
||||
}
|
||||
}
|
||||
|
||||
/* 当屏幕宽度在2560px到3839px之间时 */
|
||||
@media (min-width: 2560px) and (max-width: 3839px) {
|
||||
html {
|
||||
font-size: 26px;
|
||||
}
|
||||
}
|
||||
|
||||
/* 当屏幕宽度在1920px到2559px之间时 */
|
||||
@media (min-width: 1920px) and (max-width: 2559px) {
|
||||
html {
|
||||
font-size: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
/* 当屏幕宽度在750px到1919px之间时 */
|
||||
@media (min-width: 750px) and (max-width: 1919px) {
|
||||
html {
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
/* 当屏幕宽度在600px到749px之间时 */
|
||||
@media (min-width: 600px) and (max-width: 749px) {
|
||||
html {
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
/* 当屏幕宽度小于600px时 */
|
||||
@media (max-width: 599px) {
|
||||
html {
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<title>卫星信息监控平台</title>
|
||||
</head>
|
||||
<body class="w-h-full">
|
||||
|
||||
@@ -4,6 +4,49 @@
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<style>
|
||||
/* 当屏幕宽度大于或等于3840px时 */
|
||||
@media (min-width: 3840px) {
|
||||
html {
|
||||
font-size: 40px;
|
||||
}
|
||||
}
|
||||
|
||||
/* 当屏幕宽度在2560px到3839px之间时 */
|
||||
@media (min-width: 2560px) and (max-width: 3839px) {
|
||||
html {
|
||||
font-size: 26px;
|
||||
}
|
||||
}
|
||||
|
||||
/* 当屏幕宽度在1920px到2559px之间时 */
|
||||
@media (min-width: 1920px) and (max-width: 2559px) {
|
||||
html {
|
||||
font-size: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
/* 当屏幕宽度在750px到1919px之间时 */
|
||||
@media (min-width: 750px) and (max-width: 1919px) {
|
||||
html {
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
/* 当屏幕宽度在600px到749px之间时 */
|
||||
@media (min-width: 600px) and (max-width: 749px) {
|
||||
html {
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
/* 当屏幕宽度小于600px时 */
|
||||
@media (max-width: 599px) {
|
||||
html {
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<title>卫星信号监控平台</title>
|
||||
</head>
|
||||
<body class="w-h-full">
|
||||
|
||||
@@ -4,6 +4,49 @@
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<style>
|
||||
/* 当屏幕宽度大于或等于3840px时 */
|
||||
@media (min-width: 3840px) {
|
||||
html {
|
||||
font-size: 40px;
|
||||
}
|
||||
}
|
||||
|
||||
/* 当屏幕宽度在2560px到3839px之间时 */
|
||||
@media (min-width: 2560px) and (max-width: 3839px) {
|
||||
html {
|
||||
font-size: 26px;
|
||||
}
|
||||
}
|
||||
|
||||
/* 当屏幕宽度在1920px到2559px之间时 */
|
||||
@media (min-width: 1920px) and (max-width: 2559px) {
|
||||
html {
|
||||
font-size: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
/* 当屏幕宽度在750px到1919px之间时 */
|
||||
@media (min-width: 750px) and (max-width: 1919px) {
|
||||
html {
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
/* 当屏幕宽度在600px到749px之间时 */
|
||||
@media (min-width: 600px) and (max-width: 749px) {
|
||||
html {
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
/* 当屏幕宽度小于600px时 */
|
||||
@media (max-width: 599px) {
|
||||
html {
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<title>卫星状态监控平台</title>
|
||||
</head>
|
||||
<body class="w-h-full">
|
||||
|
||||
3
src/main/KeyWord.js
Normal file
3
src/main/KeyWord.js
Normal file
@@ -0,0 +1,3 @@
|
||||
// 加密关键字
|
||||
const keyword = 'BD';
|
||||
export { keyword };
|
||||
@@ -1,47 +1,77 @@
|
||||
import nmea from 'nmea'
|
||||
import nmea from 'nmea';
|
||||
|
||||
let events = {}
|
||||
let events = {};
|
||||
const on = (eventName, callback) => {
|
||||
if (!(eventName in events)) {
|
||||
events[eventName] = []
|
||||
events[eventName] = [];
|
||||
}
|
||||
|
||||
events[eventName].push(callback)
|
||||
}
|
||||
events[eventName].push(callback);
|
||||
};
|
||||
|
||||
const emit = (eventName, ...args) => {
|
||||
if (!(eventName in events)) {
|
||||
return
|
||||
return;
|
||||
}
|
||||
|
||||
const cbs = events[eventName]
|
||||
const cbs = events[eventName];
|
||||
|
||||
cbs.forEach(cb => {
|
||||
cb.call(this, ...args)
|
||||
cb.call(this, ...args);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const includes = (arr1, arr2) => {
|
||||
return arr2.every(val => arr1.includes(val));
|
||||
};
|
||||
|
||||
const handle = (value) => {
|
||||
if (value.length <= 0) return
|
||||
if (value.length <= 0) return;
|
||||
|
||||
emit('received', value)
|
||||
emit('received', value);
|
||||
|
||||
const strArr = value.split('\r\n')
|
||||
const strArr = value.split('\r\n');
|
||||
for (let i = 0; i < strArr.length; i++) {
|
||||
const element = strArr[i];
|
||||
doHandle(element)
|
||||
doHandle(element);
|
||||
}
|
||||
|
||||
nmeaObj.GSA.forEach(element => {
|
||||
let nmeaCache = {
|
||||
GB:{talker_id:'GB',satellites:[]},
|
||||
GP:{talker_id:'GP',satellites:[]},
|
||||
GL:{talker_id:'GL',satellites:[]},
|
||||
GA:{talker_id:'GA',satellites:[]},
|
||||
GQ:{talker_id:'GQ',satellites:[]},
|
||||
GI:{talker_id:'GI',satellites:[]},
|
||||
GN:{talker_id:'GN',satellites:[]}
|
||||
};
|
||||
nmeaObj.GSV.forEach(item => {
|
||||
if(item.talker_id == nmeaCache[item.talker_id].talker_id){
|
||||
item.satellites.forEach(index => {
|
||||
nmeaCache[item.talker_id].satellites.push(Number(index.id));
|
||||
});
|
||||
}
|
||||
});
|
||||
for (const key in nmeaCache) {
|
||||
const nmeaValue = nmeaCache[key];
|
||||
if(includes(nmeaValue.satellites,element.satellites)){
|
||||
element.talker_id = nmeaValue.talker_id;
|
||||
}
|
||||
}
|
||||
nmeaCache = null;
|
||||
});
|
||||
|
||||
emit('handled', nmeaObj)
|
||||
nmeaObj = resetNMEAObj()
|
||||
}
|
||||
emit('handled', nmeaObj);
|
||||
nmeaObj = resetNMEAObj();
|
||||
};
|
||||
|
||||
const doHandle = (value) => {
|
||||
if (!verify(value)) {
|
||||
return
|
||||
return;
|
||||
}
|
||||
|
||||
const result = nmea.parse(value)
|
||||
const result = nmea.parse(value);
|
||||
switch (result.sentence) {
|
||||
case 'RMC':
|
||||
nmeaObj.RMC = result
|
||||
@@ -56,22 +86,22 @@ const doHandle = (value) => {
|
||||
nmeaObj.GSV.push(result)
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const verify = (value) => {
|
||||
if (!value) {
|
||||
return false
|
||||
return false;
|
||||
}
|
||||
|
||||
const dollar_index = value.indexOf('$')
|
||||
const star_index = value.indexOf('*')
|
||||
const dollar_index = value.indexOf('$');
|
||||
const star_index = value.indexOf('*');
|
||||
if (value.indexOf('$') !== 0 || star_index <= dollar_index) {
|
||||
return false
|
||||
return false;
|
||||
}
|
||||
|
||||
const [sentence, checksum, ] = value.split('*')
|
||||
return nmea.Helpers.verifyChecksum(sentence, checksum)
|
||||
}
|
||||
const [sentence, checksum, ] = value.split('*');
|
||||
return nmea.Helpers.verifyChecksum(sentence, checksum);
|
||||
};
|
||||
|
||||
const resetNMEAObj = () => {
|
||||
return {
|
||||
@@ -79,9 +109,9 @@ const resetNMEAObj = () => {
|
||||
'GGA': null,
|
||||
'GSA': [],
|
||||
'GSV': []
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
let nmeaObj = resetNMEAObj()
|
||||
let nmeaObj = resetNMEAObj();
|
||||
|
||||
module.exports = { on, handle }
|
||||
module.exports = { on, handle };
|
||||
282
src/main/app.ts
282
src/main/app.ts
@@ -1,6 +1,91 @@
|
||||
import { app, screen, globalShortcut, BrowserWindow } from 'electron'
|
||||
import {join} from "path";
|
||||
import './load-serialport'
|
||||
import { ipcMain, app, screen, globalShortcut, BrowserWindow, dialog, crashReporter } from 'electron';
|
||||
import { join } from "path";
|
||||
const config = require('./config');
|
||||
import './load-serialport';
|
||||
import { keyword } from './KeyWord';
|
||||
|
||||
const child_process = require('child_process');
|
||||
const crypto = require('crypto');
|
||||
const fs = require('fs');
|
||||
|
||||
function queryPass(passPath: string, passValue: string) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
try {
|
||||
child_process.exec(`reg query ${passPath} /v ${passValue}`, (error: Error, stdout: string, stderr: string) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
resolve({stdout, stderr});
|
||||
});
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
function queryKey(keyPath: string, keyValue: string) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
try {
|
||||
child_process.exec(`reg query ${keyPath} /v ${keyValue}`, (error: Error, stdout: string, stderr: string) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
resolve({stdout, stderr});
|
||||
})
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
function cryptMD5(GUID: string) {
|
||||
let md5 = crypto.createHash('md5');
|
||||
let ciphertext = md5.update(GUID).digest('hex');
|
||||
return ciphertext.slice(0,8)+'-'+ciphertext.slice(8,12)+'-'+ciphertext.slice(12,16)+'-'+ciphertext.slice(16,20)+'-'+ciphertext.slice(20,32);
|
||||
};
|
||||
|
||||
const passPath = 'HKEY_CURRENT_USER\\SOFTWARE\\HwaSmart';
|
||||
const passValue = 'BDAuthorization';
|
||||
const keyPath = 'HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography';
|
||||
const keyValue = 'MachineGuid';
|
||||
|
||||
async function checkLaunchEnv() {
|
||||
try {
|
||||
const passResult: any = await queryPass(passPath, passValue);
|
||||
const keyResult: any = await queryKey(keyPath, keyValue);
|
||||
if(cryptMD5(keyResult.stdout.slice(83,119) + keyword) == passResult.stdout.slice(72,108)){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
// 成功
|
||||
// 查询到 有这个app启动项
|
||||
} catch (error) {
|
||||
// 没有查询到该app启动项目
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
// 记录崩溃信息
|
||||
function recordCrash() {
|
||||
return new Promise<void>(resolve => {
|
||||
// 崩溃日志请求成功....
|
||||
resolve();
|
||||
});
|
||||
};
|
||||
|
||||
function abnormalLog(txtName: string, txtLog: string) {
|
||||
fs.writeFile(txtName, txtLog, (ero:any) => {
|
||||
if(ero){
|
||||
console.log(`创建失败:${ero}`);
|
||||
}
|
||||
console.log(`创建成功!`);
|
||||
});
|
||||
};
|
||||
|
||||
var windows:Array<BrowserWindow> = [];
|
||||
|
||||
function createWindow(page: string, display: any) {
|
||||
const win = new BrowserWindow({
|
||||
@@ -10,47 +95,188 @@ function createWindow(page: string, display: any) {
|
||||
y: display.bounds.y,
|
||||
webPreferences: {
|
||||
nodeIntegration: true,
|
||||
preload: join(__dirname, 'preload.js')
|
||||
preload: join(__dirname, 'preload.js'),
|
||||
webgl: true
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
ipcMain.on("APP_MOUNTED", (event) => {
|
||||
const { sender } = event;
|
||||
if (page == 'satellite-data-monitor-platform' || page == 'oneShow' || page == 'oneShowAll' || page == 'oneShowSwitch') {
|
||||
const depth = config.get('depth');
|
||||
const secondary = config.get('secondary');
|
||||
sender.send('deep', [depth, secondary]);
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.on("webglcontextlost", (event) => {
|
||||
abnormalLog(`./resources/webglcontextlost${new Date().getTime()}.txt`, `webglcontextlost: ${new Date()}`);
|
||||
});
|
||||
|
||||
ipcMain.on("refresh", (event) => {
|
||||
abnormalLog(`./resources/refresh${new Date().getTime()}.txt`, `refresh: ${new Date()}`);
|
||||
});
|
||||
|
||||
// 监听到软件奔溃时执行
|
||||
win.webContents.on('crashed', () => {
|
||||
console.log('crash');
|
||||
// const options = dialog.showMessageBox({
|
||||
// type: 'error',
|
||||
// title: '进程崩溃了',
|
||||
// message: '这个进程已经崩溃.',
|
||||
// buttons: ['重载', '退出'],
|
||||
// });
|
||||
recordCrash().then(() => {
|
||||
abnormalLog(`./resources/crash${new Date().getTime()}.txt`, `crash: ${new Date()}`);
|
||||
// options.then((index) => {
|
||||
// if (index.response === 0) {
|
||||
// if (win.isDestroyed()) {
|
||||
// app.relaunch();
|
||||
// app.exit(0);
|
||||
// } else {
|
||||
// BrowserWindow.getAllWindows().forEach((w) => {
|
||||
// if (w.id !== win.id) w.destroy();
|
||||
// });
|
||||
// win.reload();
|
||||
// }
|
||||
// }
|
||||
// else app.quit();
|
||||
// });
|
||||
}).catch((e) => {
|
||||
console.log('err', e);
|
||||
abnormalLog(`./resources/crash${new Date().getTime()}.txt`, `crash: ${new Date()}, err: ${e}`);
|
||||
});
|
||||
});
|
||||
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
win.loadURL(`http://localhost:3000/${page}.html`)
|
||||
win.webContents.openDevTools()
|
||||
win.loadURL(`http://localhost:3000/${page}.html`);
|
||||
// win.webContents.openDevTools();
|
||||
} else {
|
||||
win.loadFile(`dist/render/${page}.html`)
|
||||
win.loadFile(`dist/render/${page}.html`);
|
||||
// win.webContents.openDevTools();
|
||||
}
|
||||
}
|
||||
|
||||
function launch() {
|
||||
const displays = screen.getAllDisplays()
|
||||
windows.push(win);
|
||||
return win;
|
||||
};
|
||||
|
||||
const sleep = (timeout:number) => {
|
||||
return new Promise((resolve?:any)=>{
|
||||
setTimeout(()=>{
|
||||
resolve();
|
||||
}, timeout);
|
||||
});
|
||||
};
|
||||
|
||||
async function launch() {
|
||||
const showMode = config.get('showMode');
|
||||
const displays = screen.getAllDisplays();
|
||||
if (displays.length !== 4) {
|
||||
createWindow('satellite-data-monitor-platform', displays[0])
|
||||
createWindow('satellite-info-monitor-platform', displays[0])
|
||||
createWindow('satellite-signal-monitor-platform', displays[0])
|
||||
createWindow('satellite-state-monitor-platform', displays[0])
|
||||
switch (showMode) {
|
||||
case "oneShow":
|
||||
createWindow('oneShow', displays[0]);
|
||||
break;
|
||||
case "oneShowSwitch":
|
||||
createWindow('oneShowSwitch', displays[0]);
|
||||
break;
|
||||
case "oneShowAll":
|
||||
createWindow('oneShowAll', displays[0]);
|
||||
break;
|
||||
case "twoShow":
|
||||
if (displays.length == 2) {
|
||||
createWindow('oneShowSwitch', displays[0]);
|
||||
await sleep(200);
|
||||
createWindow('oneShowAll', displays[1]);
|
||||
} else {
|
||||
createWindow('oneShowSwitch', displays[0]);
|
||||
await sleep(200);
|
||||
createWindow('oneShowAll', displays[0]);
|
||||
}
|
||||
break;
|
||||
case "fourShow":
|
||||
createWindow('satellite-data-monitor-platform', displays[0]);
|
||||
await sleep(200);
|
||||
createWindow('satellite-info-monitor-platform', displays[0]);
|
||||
await sleep(400);
|
||||
createWindow('satellite-signal-monitor-platform', displays[0]);
|
||||
await sleep(600);
|
||||
createWindow('satellite-state-monitor-platform', displays[0]);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
createWindow('satellite-data-monitor-platform', displays[0])
|
||||
createWindow('satellite-info-monitor-platform', displays[1])
|
||||
createWindow('satellite-signal-monitor-platform', displays[2])
|
||||
createWindow('satellite-state-monitor-platform', displays[3])
|
||||
createWindow('satellite-data-monitor-platform', displays[0]);
|
||||
await sleep(200);
|
||||
createWindow('satellite-info-monitor-platform', displays[1]);
|
||||
await sleep(400);
|
||||
createWindow('satellite-signal-monitor-platform', displays[2]);
|
||||
await sleep(600);
|
||||
createWindow('satellite-state-monitor-platform', displays[3]);
|
||||
}
|
||||
|
||||
// 屏蔽 F11 进入/退出全屏功能
|
||||
globalShortcut.register('F11', () => {return})
|
||||
}
|
||||
|
||||
app.whenReady().then(launch)
|
||||
// 屏蔽 F11 进入/退出全屏功能
|
||||
globalShortcut.register('F11', () => { return });
|
||||
};
|
||||
|
||||
ipcMain.on('CLOSE', (event) => {
|
||||
const res = dialog.showMessageBox({
|
||||
type: 'warning',
|
||||
title: '警告',
|
||||
message: '确定要关闭软件吗?',
|
||||
detail: '关闭软件',
|
||||
cancelId: 1, // 按esc默认点击索引按钮
|
||||
defaultId: 0, // 默认高亮的按钮下标
|
||||
buttons: ['确认', '取消'], // 按钮按索引从右往左排序
|
||||
})
|
||||
|
||||
res.then((data)=>{
|
||||
if(data.response == 0){
|
||||
windows.forEach((key:BrowserWindow) => {
|
||||
key.close();
|
||||
});
|
||||
windows = [];
|
||||
}else{
|
||||
console.log('not close software');
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
async function main() {
|
||||
// 异步代码
|
||||
const checkReault: any = await checkLaunchEnv();
|
||||
console.log('env right:', checkReault);
|
||||
|
||||
// 异步代码执行完毕后执行的代码
|
||||
if (checkReault) {
|
||||
launch();
|
||||
// 模拟软件崩溃
|
||||
// setTimeout(() => {
|
||||
// process.crash();
|
||||
// }, 10000);
|
||||
} else {
|
||||
dialog.showErrorBox('系统提示', '软件启动出错,请联系售后技术支持人员');
|
||||
process.exit(1);
|
||||
}
|
||||
};
|
||||
|
||||
crashReporter.start({uploadToServer: false});
|
||||
|
||||
app.commandLine.appendSwitch('ignore-gpu-blacklist');
|
||||
|
||||
app.disableDomainBlockingFor3DAPIs();
|
||||
|
||||
// 禁用GPU加速,此模式下何时刷新canvas不能通过判断webgl上下文丢失实现
|
||||
// app.disableHardwareAcceleration()
|
||||
|
||||
app.whenReady().then(main);
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
if (process.platform !== 'darwin') {
|
||||
app.quit()
|
||||
app.quit();
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
app.on('activate', () => {
|
||||
if (BrowserWindow.getAllWindows().length === 0) {
|
||||
launch()
|
||||
launch();
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
const Store = require('electron-store')
|
||||
const Store = require('electron-store');
|
||||
|
||||
const store = new Store()
|
||||
const set = (key, val) => store.set(key, val)
|
||||
const store = new Store();
|
||||
const set = (key, val) => store.set(key, val);
|
||||
|
||||
const get = (key) => store.get(key)
|
||||
const get = (key) => store.get(key);
|
||||
|
||||
module.exports = { set, get }
|
||||
module.exports = { set, get };
|
||||
|
||||
@@ -1,69 +1,72 @@
|
||||
const { ipcMain } = require('electron')
|
||||
const SerialPort = require('serialport')
|
||||
const InterByteTimeout = require('@serialport/parser-inter-byte-timeout')
|
||||
const config = require('./config')
|
||||
const { ipcMain } = require('electron');
|
||||
const { SerialPort } = require("serialport");
|
||||
const { InterByteTimeoutParser } = require('@serialport/parser-inter-byte-timeout');
|
||||
const config = require('./config');
|
||||
|
||||
const NMEAHandler = require('./api/NMEAHandler')
|
||||
const NMEAHandler = require('./api/NMEAHandler');
|
||||
|
||||
const DEFAULT_BAUDRATE = 9600
|
||||
const DEFAULT_BAUDRATE = 115200;
|
||||
const getSerialPortConstructorArguments = (ports) => {
|
||||
let serialport = config.get('serialport')
|
||||
const path = ( serialport && serialport.path ) ? serialport.path : ports[0].path
|
||||
const baudRate = ( serialport && serialport.baudRate ) ? serialport.baudRate : DEFAULT_BAUDRATE
|
||||
return { path, baudRate }
|
||||
}
|
||||
let serialport = config.get('serialport');
|
||||
const path = ( serialport && serialport.path ) ? serialport.path : ports[0].path;
|
||||
const baudRate = ( serialport && serialport.baudRate ) ? serialport.baudRate : DEFAULT_BAUDRATE;
|
||||
return { path, baudRate };
|
||||
};
|
||||
|
||||
const senders = []
|
||||
const senders = [];
|
||||
ipcMain.on("APP_MOUNTED", (event) => {
|
||||
const { sender } = event
|
||||
senders.push(sender)
|
||||
const { sender } = event;
|
||||
senders.push(sender);
|
||||
|
||||
sender.once('destroyed', () => {
|
||||
const index = senders.indexOf(sender)
|
||||
if (index >= 0) senders.splice(index, 1)
|
||||
const index = senders.indexOf(sender);
|
||||
if (index >= 0) senders.splice(index, 1);
|
||||
})
|
||||
})
|
||||
|
||||
const sendMsg = (channel, msg) => {
|
||||
if (senders.length <= 0) return
|
||||
if (senders.length <= 0) return;
|
||||
|
||||
try {
|
||||
senders.forEach((sender) => {
|
||||
sender.send(channel, msg)
|
||||
sender.send(channel, msg);
|
||||
})
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
|
||||
SerialPort.list().then((ports, err) => {
|
||||
if (err) {
|
||||
console.log(err)
|
||||
return
|
||||
console.log(err);
|
||||
return;
|
||||
}
|
||||
|
||||
// console.log(ports, '=====================')
|
||||
|
||||
// 过滤掉COM1口,很多电脑自带COM1接口
|
||||
ports = ports.filter((port) => port.path != 'COM1')
|
||||
ports = ports.filter((port) => port.path != 'COM1');
|
||||
if (ports.length == 0) {
|
||||
console.error('设备为连接')
|
||||
return
|
||||
console.error('设备未连接');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const { path, baudRate } = getSerialPortConstructorArguments(ports)
|
||||
console.log(path, baudRate, '=====================')
|
||||
const serialPort = new SerialPort(path, { baudRate })
|
||||
const { path, baudRate } = getSerialPortConstructorArguments(ports);
|
||||
console.log(path, baudRate, '=====================');
|
||||
const serialPort = new SerialPort({ path, baudRate });
|
||||
|
||||
const parser = serialPort.pipe(new InterByteTimeout({interval: 30}))
|
||||
const parser = serialPort.pipe(new InterByteTimeoutParser({interval: 30}));
|
||||
|
||||
NMEAHandler.on('received' , (nmeaStr) => {
|
||||
sendMsg('NMEA_RECEIVED', nmeaStr);
|
||||
});
|
||||
|
||||
NMEAHandler.on('handled' , (nmeaObj) => {
|
||||
sendMsg('nmea', JSON.stringify(nmeaObj))
|
||||
})
|
||||
sendMsg('nmea', JSON.stringify(nmeaObj));
|
||||
});
|
||||
|
||||
parser.on('data', (data) => NMEAHandler.handle(data.toString()));
|
||||
|
||||
parser.on('data', (data) => NMEAHandler.handle(data.toString()))
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
const {ipcRenderer, contextBridge} = require('electron')
|
||||
const {ipcRenderer, contextBridge} = require('electron');
|
||||
|
||||
contextBridge.exposeInMainWorld('ipcRenderer', {
|
||||
send: (channel, data) => {
|
||||
// whitelist channels
|
||||
let validChannels = ['toMain']
|
||||
let validChannels = ['toMain'];
|
||||
if (validChannels.includes(channel)) {
|
||||
ipcRenderer.send(channel, data)
|
||||
ipcRenderer.send(channel, data);
|
||||
}
|
||||
ipcRenderer.send(channel, data)
|
||||
ipcRenderer.send(channel, data);
|
||||
},
|
||||
receive: (channel, func) => {
|
||||
let validChannels = ['fromMain']
|
||||
console.log(func());
|
||||
let validChannels = ['fromMain'];
|
||||
if (validChannels.includes(channel)) {
|
||||
// Deliberately strip event as it includes `sender`
|
||||
ipcRenderer.on(channel, (event, ...args) => func(...args))
|
||||
ipcRenderer.on(channel, (event, ...args) => func(...args));
|
||||
}
|
||||
ipcRenderer.on(channel, (event, ...args) => func(...args))
|
||||
ipcRenderer.on(channel, (event, ...args) => func(...args));
|
||||
}
|
||||
})
|
||||
});
|
||||
@@ -1,64 +1,65 @@
|
||||
export function filterNonNumber (array) {
|
||||
return array.filter(n => typeof n === 'number')
|
||||
}
|
||||
return array.filter(n => typeof n === 'number');
|
||||
};
|
||||
|
||||
export function mulAdd (nums) {
|
||||
nums = filterNonNumber(nums)
|
||||
nums = filterNonNumber(nums);
|
||||
|
||||
return nums.reduce((all, num) => all + num, 0)
|
||||
}
|
||||
return nums.reduce((all, num) => all + num, 0);
|
||||
};
|
||||
|
||||
export function getTwoPointDistance (pointOne, pointTwo) {
|
||||
const minusX = Math.abs(pointOne[0] - pointTwo[0])
|
||||
const minusX = Math.abs(pointOne[0] - pointTwo[0]);
|
||||
|
||||
const minusY = Math.abs(pointOne[1] - pointTwo[1])
|
||||
const minusY = Math.abs(pointOne[1] - pointTwo[1]);
|
||||
|
||||
return Math.sqrt(minusX * minusX + minusY * minusY)
|
||||
}
|
||||
return Math.sqrt(minusX * minusX + minusY * minusY);
|
||||
};
|
||||
|
||||
export function getPolylineLength(points) {
|
||||
const lineSegments = new Array(points.length - 1)
|
||||
.fill(0)
|
||||
.map((foo, i) => [points[i], points[i + 1]])
|
||||
.map((foo, i) => [points[i], points[i + 1]]);
|
||||
|
||||
const lengths = lineSegments.map(item => getTwoPointDistance(...item))
|
||||
const lengths = lineSegments.map(item => getTwoPointDistance(...item));
|
||||
|
||||
return mulAdd(lengths)
|
||||
}
|
||||
return mulAdd(lengths);
|
||||
};
|
||||
|
||||
export function get_in_positioning_id(GSAArr) {
|
||||
let in_positioning_id = []
|
||||
let in_positioning_id = [];
|
||||
GSAArr.forEach(({ satellites }) => {
|
||||
in_positioning_id.push(...satellites)
|
||||
in_positioning_id.push(...satellites);
|
||||
});
|
||||
|
||||
return in_positioning_id
|
||||
}
|
||||
return in_positioning_id;
|
||||
};
|
||||
|
||||
export function getNMEAObj(nmeaStr) {
|
||||
if (!nmeaStr) return
|
||||
if (!nmeaStr) return;
|
||||
|
||||
return JSON.parse(nmeaStr)
|
||||
}
|
||||
return JSON.parse(nmeaStr);
|
||||
};
|
||||
|
||||
export function getGSV (nmeaStr) {
|
||||
const nmeaObj = getNMEAObj(nmeaStr)
|
||||
console.log(nmeaObj, '================')
|
||||
if (!nmeaObj || !nmeaObj.GSV) return null
|
||||
const nmeaObj = getNMEAObj(nmeaStr);
|
||||
// console.log(nmeaObj, '================');
|
||||
if (!nmeaObj || !nmeaObj.GSV) return null;
|
||||
|
||||
const { GSV } = nmeaObj
|
||||
const { GSV } = nmeaObj;
|
||||
const bd = {
|
||||
GSVArr: GSV.filter((gsv) => gsv.talker_id === 'BD')
|
||||
}
|
||||
// GSVArr: GSV.filter((gsv) => gsv.talker_id === 'BD')
|
||||
GSVArr: GSV.filter((gsv) => gsv.talker_id === 'GB')
|
||||
};
|
||||
const gp = {
|
||||
GSVArr: GSV.filter((gsv) => gsv.talker_id === 'GP')
|
||||
}
|
||||
};
|
||||
const gl = {
|
||||
GSVArr: GSV.filter((gsv) => gsv.talker_id === 'GL')
|
||||
}
|
||||
};
|
||||
const ga = {
|
||||
GSVArr: GSV.filter((gsv) => gsv.talker_id === 'GA')
|
||||
}
|
||||
};
|
||||
|
||||
return { bd, gp, gl, ga }
|
||||
}
|
||||
return { bd, gp, gl, ga };
|
||||
};
|
||||
|
||||
1
src/render/assets/geojson/100000_full.json
Normal file
1
src/render/assets/geojson/100000_full.json
Normal file
File diff suppressed because one or more lines are too long
1
src/render/assets/geojson/city/710000.json
Normal file
1
src/render/assets/geojson/city/710000.json
Normal file
@@ -0,0 +1 @@
|
||||
{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"adcode":710000,"name":"台湾省","center":[121.509062,25.044332],"centroid":[120.971485,23.749452],"childrenNum":0,"level":"province","acroutes":[100000],"parent":{"adcode":100000}},"geometry":{"type":"MultiPolygon","coordinates":[[[[120.443558,22.441245],[120.517584,22.408536],[120.569903,22.361728],[120.640505,22.241347],[120.659209,22.15432],[120.662001,22.066983],[120.651464,22.033165],[120.667691,21.983168],[120.70157,21.927065],[120.743246,21.915569],[120.78155,21.923957],[120.85468,21.883333],[120.87291,21.897387],[120.866482,21.98436],[120.907315,22.033208],[120.904154,22.119757],[120.914955,22.302718],[120.981658,22.528305],[121.015009,22.584168],[121.033292,22.650725],[121.078498,22.669656],[121.170544,22.723133],[121.210481,22.770665],[121.237931,22.836327],[121.324708,22.945666],[121.354687,23.01006],[121.370388,23.084347],[121.409535,23.102669],[121.430294,23.137196],[121.415015,23.195973],[121.440358,23.272096],[121.479558,23.3223],[121.497788,23.419789],[121.521497,23.483198],[121.523078,23.538708],[121.587778,23.76102],[121.621604,23.92075],[121.659381,24.006893],[121.639992,24.064276],[121.643838,24.097713],[121.678085,24.133906],[121.689044,24.174401],[121.809172,24.339055],[121.826717,24.423579],[121.867498,24.478978],[121.885464,24.529677],[121.892524,24.617912],[121.862598,24.671515],[121.837993,24.76015],[121.845053,24.836269],[121.932883,24.938645],[122.012178,25.001469],[121.980776,25.03079],[121.947425,25.031955],[121.917077,25.137908],[121.842155,25.135332],[121.782407,25.160425],[121.750531,25.160716],[121.707327,25.191493],[121.700319,25.226913],[121.655324,25.241859],[121.623026,25.294694],[121.584986,25.308926],[121.535038,25.307515],[121.444415,25.270624],[121.413487,25.238912],[121.371864,25.159885],[121.319281,25.140691],[121.209322,25.127104],[121.133135,25.078728],[121.102102,25.075153],[121.024704,25.040479],[121.009688,24.993649],[120.960899,24.940227],[120.908475,24.852012],[120.892299,24.767526],[120.823753,24.688321],[120.762371,24.658335],[120.688661,24.600678],[120.64277,24.490172],[120.589187,24.432354],[120.546299,24.370413],[120.521009,24.312038],[120.470534,24.24259],[120.451461,24.182691],[120.392029,24.11824],[120.316158,23.984881],[120.278276,23.927798],[120.245768,23.840553],[120.175377,23.807385],[120.102773,23.700981],[120.094817,23.587466],[120.121741,23.504664],[120.107831,23.341264],[120.081434,23.29191],[120.018947,23.073115],[120.029537,23.048623],[120.131382,23.002118],[120.149138,22.896715],[120.200403,22.721101],[120.274272,22.560181],[120.297191,22.531315],[120.443558,22.441245]]],[[[124.542984,25.903911],[124.586346,25.913777],[124.572805,25.93974],[124.541825,25.931031],[124.542984,25.903911]]],[[[123.445286,25.725966],[123.472104,25.713024],[123.508933,25.723237],[123.514834,25.751226],[123.483063,25.768587],[123.444496,25.746514],[123.445286,25.725966]]],[[[119.64597,23.55091],[119.701081,23.550657],[119.678057,23.600041],[119.610089,23.603953],[119.594388,23.577245],[119.566306,23.584732],[119.562565,23.530377],[119.573788,23.505885],[119.609141,23.503864],[119.64597,23.55091]]],[[[123.667207,25.914066],[123.707092,25.916873],[123.678008,25.938667],[123.667207,25.914066]]],[[[119.506031,23.625567],[119.505241,23.575814],[119.472416,23.557136],[119.523207,23.563699],[119.525578,23.624895],[119.506031,23.625567]]],[[[119.49739,23.386683],[119.495125,23.350156],[119.516885,23.349903],[119.49739,23.386683]]],[[[119.557454,23.666474],[119.604083,23.616989],[119.615516,23.660925],[119.586485,23.675974],[119.557454,23.666474]]],[[[121.46823,22.676644],[121.476502,22.64166],[121.513541,22.631833],[121.5147,22.67639],[121.46823,22.676644]]],[[[121.510538,22.087185],[121.507693,22.048523],[121.534089,22.022146],[121.594522,21.995382],[121.604586,22.022699],[121.575028,22.037122],[121.575607,22.084421],[121.510538,22.087185]]],[[[122.097533,25.500168],[122.093581,25.47183],[122.124825,25.475932],[122.097533,25.500168]]],[[[119.421467,23.216684],[119.421309,23.18935],[119.453396,23.217697],[119.421467,23.216684]]],[[[120.355042,22.327259],[120.395454,22.342287],[120.383072,22.355573],[120.355042,22.327259]]]]}}]}
|
||||
20
src/render/assets/geojson/city/citygeo.js
Normal file
20
src/render/assets/geojson/city/citygeo.js
Normal file
@@ -0,0 +1,20 @@
|
||||
import jbjMap from "./total/110000.json"
|
||||
import jtjMap from "./total/120000.json"
|
||||
import hshMap from "./total/310000.json"
|
||||
import ycqMap from "./total/500000.json"
|
||||
import gxgMap from "./total/810000.json"
|
||||
import aamMap from "./total/820000.json"
|
||||
import ttwMap from "./710000.json"
|
||||
|
||||
const city = {
|
||||
"北京市":jbjMap,
|
||||
"天津市":jtjMap,
|
||||
"上海市":hshMap,
|
||||
"重庆市":ycqMap,
|
||||
"香港特别行政区":gxgMap,
|
||||
"澳门特别行政区":aamMap,
|
||||
"台湾省":ttwMap
|
||||
}
|
||||
|
||||
|
||||
export { city }
|
||||
20
src/render/assets/geojson/city/citygeo_full.js
Normal file
20
src/render/assets/geojson/city/citygeo_full.js
Normal file
@@ -0,0 +1,20 @@
|
||||
import jbjMap from "./full/110000_full.json"
|
||||
import jtjMap from "./full/120000_full.json"
|
||||
import hshMap from "./full/310000_full.json"
|
||||
import ycqMap from "./full/500000_full.json"
|
||||
import gxgMap from "./full/810000_full.json"
|
||||
import aamMap from "./full/820000_full.json"
|
||||
import ttwMap from "./710000.json"
|
||||
|
||||
const city = {
|
||||
"北京市":jbjMap,
|
||||
"天津市":jtjMap,
|
||||
"上海市":hshMap,
|
||||
"重庆市":ycqMap,
|
||||
"香港特别行政区":gxgMap,
|
||||
"澳门特别行政区":aamMap,
|
||||
"台湾省":ttwMap
|
||||
}
|
||||
|
||||
|
||||
export { city }
|
||||
1
src/render/assets/geojson/city/full/110000_full.json
Normal file
1
src/render/assets/geojson/city/full/110000_full.json
Normal file
File diff suppressed because one or more lines are too long
1
src/render/assets/geojson/city/full/120000_full.json
Normal file
1
src/render/assets/geojson/city/full/120000_full.json
Normal file
File diff suppressed because one or more lines are too long
1
src/render/assets/geojson/city/full/310000_full.json
Normal file
1
src/render/assets/geojson/city/full/310000_full.json
Normal file
File diff suppressed because one or more lines are too long
1
src/render/assets/geojson/city/full/500000_full.json
Normal file
1
src/render/assets/geojson/city/full/500000_full.json
Normal file
File diff suppressed because one or more lines are too long
1
src/render/assets/geojson/city/full/810000_full.json
Normal file
1
src/render/assets/geojson/city/full/810000_full.json
Normal file
File diff suppressed because one or more lines are too long
1
src/render/assets/geojson/city/full/820000_full.json
Normal file
1
src/render/assets/geojson/city/full/820000_full.json
Normal file
File diff suppressed because one or more lines are too long
1
src/render/assets/geojson/city/total/110000.json
Normal file
1
src/render/assets/geojson/city/total/110000.json
Normal file
File diff suppressed because one or more lines are too long
1
src/render/assets/geojson/city/total/120000.json
Normal file
1
src/render/assets/geojson/city/total/120000.json
Normal file
File diff suppressed because one or more lines are too long
1
src/render/assets/geojson/city/total/310000.json
Normal file
1
src/render/assets/geojson/city/total/310000.json
Normal file
File diff suppressed because one or more lines are too long
1
src/render/assets/geojson/city/total/500000.json
Normal file
1
src/render/assets/geojson/city/total/500000.json
Normal file
File diff suppressed because one or more lines are too long
1
src/render/assets/geojson/city/total/810000.json
Normal file
1
src/render/assets/geojson/city/total/810000.json
Normal file
File diff suppressed because one or more lines are too long
1
src/render/assets/geojson/city/total/820000.json
Normal file
1
src/render/assets/geojson/city/total/820000.json
Normal file
@@ -0,0 +1 @@
|
||||
{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"adcode":820000,"name":"澳门特别行政区","center":[113.54909,22.198951],"centroid":[113.566988,22.159307],"childrenNum":8,"level":"province","acroutes":[100000],"parent":{"adcode":100000}},"geometry":{"type":"MultiPolygon","coordinates":[[[[113.553916,22.125215],[113.553389,22.112664],[113.554447,22.107312],[113.559643,22.106216],[113.561045,22.106214],[113.576328,22.108147],[113.578953,22.108929],[113.580194,22.109694],[113.597564,22.125115],[113.603681,22.132371],[113.603873,22.132864],[113.601946,22.138113],[113.593091,22.162285],[113.586631,22.174165],[113.582019,22.182646],[113.575698,22.194265],[113.575472,22.199781],[113.573697,22.205587],[113.567629,22.209102],[113.567336,22.209241],[113.55711,22.213036],[113.556008,22.212463],[113.555864,22.212561],[113.555807,22.212703],[113.555932,22.214074],[113.555089,22.213974],[113.55474,22.213773],[113.554289,22.213656],[113.553843,22.213659],[113.553427,22.213776],[113.552808,22.213703],[113.552722,22.213604],[113.552132,22.213827],[113.550576,22.213861],[113.550287,22.213973],[113.549457,22.214005],[113.548496,22.213368],[113.54757,22.211492],[113.547515,22.211343],[113.547122,22.210753],[113.547063,22.210731],[113.546825,22.210294],[113.546644,22.210384],[113.54644,22.210146],[113.546291,22.210083],[113.546011,22.210094],[113.543261,22.210709],[113.541458,22.210708],[113.540832,22.210632],[113.540566,22.210549],[113.540073,22.210601],[113.538217,22.209386],[113.5391,22.206724],[113.539782,22.204445],[113.540515,22.203771],[113.540624,22.201871],[113.540764,22.199383],[113.53954,22.194664],[113.538742,22.191586],[113.534366,22.185627],[113.535335,22.185013],[113.534311,22.183656],[113.533508,22.181603],[113.533314,22.179271],[113.53456,22.174104],[113.535723,22.172545],[113.537107,22.170402],[113.537273,22.16918],[113.540985,22.161571],[113.544638,22.154083],[113.549079,22.149234],[113.550344,22.14785],[113.554638,22.142429],[113.553916,22.125215]]],[[[113.586501,22.201059],[113.576151,22.201038],[113.576045,22.20007],[113.576045,22.194495],[113.57635,22.193843],[113.577001,22.193432],[113.583971,22.193289],[113.586193,22.194792],[113.586499,22.195613],[113.586501,22.201059]]]]}}]}
|
||||
86
src/render/assets/geojson/geo.js
Normal file
86
src/render/assets/geojson/geo.js
Normal file
@@ -0,0 +1,86 @@
|
||||
// 通过打包配置文件来决定引入那些地图文件
|
||||
|
||||
// 以下文件为包含省内地级市区域内容细节的地图文件
|
||||
import { provice as provice_incity } from "./provice/provice_incity"
|
||||
|
||||
// 以下文件为只包含省级地图轮廓信息的地图文件
|
||||
import { provice as provice_nocity } from "./provice/provice_nocity"
|
||||
|
||||
// 以下_full文件为包含地级市市内区域内容细节的地图文件
|
||||
import { provice as provice_full } from "./provice/provicegeo_full"
|
||||
|
||||
// 以下文件为只包含地级市地图轮廓信息的地图文件
|
||||
import { provice as provice_geo } from "./provice/provicegeo"
|
||||
|
||||
// 以下_full文件为包含直辖市市内区域内容细节的地图文件
|
||||
import { city as city_full } from "./city/citygeo_full"
|
||||
|
||||
// 以下文件为只包含直辖市市级地图轮廓信息的地图文件
|
||||
import { city as city_geo } from "./city/citygeo"
|
||||
|
||||
export function intersect(checkPoint, polygonPoints) {
|
||||
for (let j = 0; j < polygonPoints.features.length-1; j++) {
|
||||
var counter = 0;
|
||||
var i;
|
||||
var xinters;
|
||||
var p1, p2;
|
||||
var pointCount = polygonPoints.features[j].properties.name == "内蒙古自治区" ? polygonPoints.features[j].geometry.coordinates[0].length : polygonPoints.features[j].geometry.coordinates[0][0].length;
|
||||
p1 = polygonPoints.features[j].properties.name == "内蒙古自治区" ? polygonPoints.features[j].geometry.coordinates[0][0] : polygonPoints.features[j].geometry.coordinates[0][0][0];
|
||||
for (i = 1; i <= pointCount; i++) {
|
||||
p2 = polygonPoints.features[j].properties.name == "内蒙古自治区" ? polygonPoints.features[j].geometry.coordinates[0][i % pointCount] : polygonPoints.features[j].geometry.coordinates[0][0][i % pointCount];
|
||||
if (
|
||||
checkPoint[0] > Math.min(p1[0], p2[0]) &&
|
||||
checkPoint[0] <= Math.max(p1[0], p2[0])
|
||||
) {
|
||||
if (checkPoint[1] <= Math.max(p1[1], p2[1])) {
|
||||
if (p1[0] != p2[0]) {
|
||||
xinters =
|
||||
(checkPoint[0] - p1[0]) *
|
||||
(p2[1] - p1[1]) /
|
||||
(p2[0] - p1[0]) +
|
||||
p1[1];
|
||||
if (p1[1] == p2[1] || checkPoint[1] <= xinters) {
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
p1 = p2;
|
||||
}
|
||||
if (counter % 2 == 0) {
|
||||
console.log(counter)
|
||||
} else {
|
||||
return polygonPoints.features[j].properties.name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function findMap(nowPoint, name, deepset) {
|
||||
let provice
|
||||
let city
|
||||
if (deepset[0]) {
|
||||
if(deepset[1]){
|
||||
provice = provice_full
|
||||
city = city_full
|
||||
}else{
|
||||
provice = provice_geo
|
||||
city = city_geo
|
||||
}
|
||||
} else {
|
||||
if(deepset[1]){
|
||||
provice = provice_incity
|
||||
city = city_full
|
||||
}else{
|
||||
provice = provice_nocity
|
||||
city = city_geo
|
||||
}
|
||||
}
|
||||
if (provice[name]) {
|
||||
if (provice[name][name]) {
|
||||
let cityname = intersect(nowPoint, provice[name][name])
|
||||
return provice[name].city[cityname]
|
||||
}
|
||||
return provice[name]
|
||||
}
|
||||
return city[name]
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,50 @@
|
||||
import cscMap from "../../provice_incity/510000_full.json"
|
||||
import cdMap from "./provice_city/510100_full.json"
|
||||
import zgMap from "./provice_city/510300_full.json"
|
||||
import pzhMap from "./provice_city/510400_full.json"
|
||||
import lzMap from "./provice_city/510500_full.json"
|
||||
import dyMap from "./provice_city/510600_full.json"
|
||||
import myMap from "./provice_city/510700_full.json"
|
||||
import gyMap from "./provice_city/510800_full.json"
|
||||
import snMap from "./provice_city/510900_full.json"
|
||||
import njMap from "./provice_city/511000_full.json"
|
||||
import lsMap from "./provice_city/511100_full.json"
|
||||
import ncMap from "./provice_city/511300_full.json"
|
||||
import msMap from "./provice_city/511400_full.json"
|
||||
import ybMap from "./provice_city/511500_full.json"
|
||||
import gaMap from "./provice_city/511600_full.json"
|
||||
import dzMap from "./provice_city/511700_full.json"
|
||||
import yaMap from "./provice_city/511800_full.json"
|
||||
import bzMap from "./provice_city/511900_full.json"
|
||||
import zyMap from "./provice_city/512000_full.json"
|
||||
import abzqMap from "./provice_city/513200_full.json"
|
||||
import gzzMap from "./provice_city/513300_full.json"
|
||||
import lsyMap from "./provice_city/513400_full.json"
|
||||
|
||||
const provice_csc = {
|
||||
"四川省":cscMap,
|
||||
city:{
|
||||
"成都市":cdMap,
|
||||
"自贡市":zgMap,
|
||||
"攀枝花市":pzhMap,
|
||||
"泸州市":lzMap,
|
||||
"德阳市":dyMap,
|
||||
"绵阳市":myMap,
|
||||
"广元市":gyMap,
|
||||
"遂宁市":snMap,
|
||||
"内江市":njMap,
|
||||
"乐山市":lsMap,
|
||||
"南充市":ncMap,
|
||||
"眉山市":msMap,
|
||||
"宜宾市":ybMap,
|
||||
"广安市":gaMap,
|
||||
"达州市":dzMap,
|
||||
"雅安市":yaMap,
|
||||
"巴中市":bzMap,
|
||||
"资阳市":zyMap,
|
||||
"阿坝藏族羌族自治州":abzqMap,
|
||||
"甘孜藏族自治州":gzzMap,
|
||||
"凉山彝族自治州":lsyMap,
|
||||
}
|
||||
}
|
||||
export { provice_csc }
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,42 @@
|
||||
import ehbMap from "../../provice_incity/420000_full.json"
|
||||
import whMap from "./provice_city/420100_full.json"
|
||||
import hsMap from "./provice_city/420200_full.json"
|
||||
import syMap from "./provice_city/420300_full.json"
|
||||
import ycMap from "./provice_city/420500_full.json"
|
||||
import xyMap from "./provice_city/420600_full.json"
|
||||
import ezMap from "./provice_city/420700_full.json"
|
||||
import jmMap from "./provice_city/420800_full.json"
|
||||
import xgMap from "./provice_city/420900_full.json"
|
||||
import jzMap from "./provice_city/421000_full.json"
|
||||
import hgMap from "./provice_city/421100_full.json"
|
||||
import xnMap from "./provice_city/421200_full.json"
|
||||
import szMap from "./provice_city/421300_full.json"
|
||||
import setjmMap from "./provice_city/422800_full.json"
|
||||
import xtMap from "../../just_total/ehb/429004.json"
|
||||
import qjMap from "../../just_total/ehb/429005.json"
|
||||
import tmMap from "../../just_total/ehb/429006.json"
|
||||
import snjMap from "../../just_total/ehb/429021.json"
|
||||
|
||||
const provice_ehb = {
|
||||
"湖北省":ehbMap,
|
||||
city:{
|
||||
"武汉市":whMap,
|
||||
"黄石市":hsMap,
|
||||
"十堰市":syMap,
|
||||
"宜昌市":ycMap,
|
||||
"襄阳市":xyMap,
|
||||
"鄂州市":ezMap,
|
||||
"荆门市":jmMap,
|
||||
"孝感市":xgMap,
|
||||
"荆州市":jzMap,
|
||||
"黄冈市":hgMap,
|
||||
"咸宁市":xnMap,
|
||||
"随州市":szMap,
|
||||
"恩施土家族苗族自治州":setjmMap,
|
||||
"仙桃市":xtMap,
|
||||
"潜江市":qjMap,
|
||||
"天门市":tmMap,
|
||||
"神农架林区":snjMap,
|
||||
}
|
||||
}
|
||||
export { provice_ehb }
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,36 @@
|
||||
import ggsMap from "../../provice_incity/620000_full.json"
|
||||
import lzMap from "./provice_city/620100_full.json"
|
||||
import jcMap from "./provice_city/620300_full.json"
|
||||
import byMap from "./provice_city/620400_full.json"
|
||||
import tsMap from "./provice_city/620500_full.json"
|
||||
import wwMap from "./provice_city/620600_full.json"
|
||||
import zyMap from "./provice_city/620700_full.json"
|
||||
import plMap from "./provice_city/620800_full.json"
|
||||
import jqMap from "./provice_city/620900_full.json"
|
||||
import qyMap from "./provice_city/621000_full.json"
|
||||
import dxMap from "./provice_city/621100_full.json"
|
||||
import lnMap from "./provice_city/621200_full.json"
|
||||
import lxhMap from "./provice_city/622900_full.json"
|
||||
import gnzMap from "./provice_city/623000_full.json"
|
||||
import jygMap from "../../just_total/ggs/620200.json"
|
||||
|
||||
const provice_ggs = {
|
||||
"甘肃省":ggsMap,
|
||||
city:{
|
||||
"兰州市":lzMap,
|
||||
"金昌市":jcMap,
|
||||
"白银市":byMap,
|
||||
"天水市":tsMap,
|
||||
"武威市":wwMap,
|
||||
"张掖市":zyMap,
|
||||
"平凉市":plMap,
|
||||
"酒泉市":jqMap,
|
||||
"庆阳市":qyMap,
|
||||
"定西市":dxMap,
|
||||
"陇南市":lnMap,
|
||||
"临夏回族自治州":lxhMap,
|
||||
"甘南藏族自治州":gnzMap,
|
||||
"嘉峪关市":jygMap,
|
||||
}
|
||||
}
|
||||
export { provice_ggs }
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,36 @@
|
||||
import ggxMap from "../../provice_incity/450000_full.json"
|
||||
import nnMap from "./provice_city/450100_full.json"
|
||||
import lzMap from "./provice_city/450200_full.json"
|
||||
import glMap from "./provice_city/450300_full.json"
|
||||
import wzMap from "./provice_city/450400_full.json"
|
||||
import bhMap from "./provice_city/450500_full.json"
|
||||
import fcgMap from "./provice_city/450600_full.json"
|
||||
import qzMap from "./provice_city/450700_full.json"
|
||||
import ggMap from "./provice_city/450800_full.json"
|
||||
import ylMap from "./provice_city/450900_full.json"
|
||||
import czMap from "./provice_city/451000_full.json"
|
||||
import hzMap from "./provice_city/451100_full.json"
|
||||
import rpMap from "./provice_city/451200_full.json"
|
||||
import lbMap from "./provice_city/451300_full.json"
|
||||
import czuoMap from "./provice_city/451400_full.json"
|
||||
|
||||
const provice_ggx = {
|
||||
"广西壮族自治区":ggxMap,
|
||||
city:{
|
||||
"南宁市":nnMap,
|
||||
"柳州市":lzMap,
|
||||
"桂林市":glMap,
|
||||
"梧州市":wzMap,
|
||||
"北海市":bhMap,
|
||||
"防城港市":fcgMap,
|
||||
"钦州市":qzMap,
|
||||
"贵港市":ggMap,
|
||||
"玉林市":ylMap,
|
||||
"潮州市":czMap,
|
||||
"贺州市":hzMap,
|
||||
"饶平市":rpMap,
|
||||
"来宾市":lbMap,
|
||||
"崇左市":czuoMap,
|
||||
}
|
||||
}
|
||||
export { provice_ggx }
|
||||
File diff suppressed because one or more lines are too long
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user