初始化地铁数据
This commit is contained in:
parent
5083ea100a
commit
1c3207adbe
|
|
@ -26,5 +26,8 @@ declare const _default: {
|
|||
coordinate: number[];
|
||||
};
|
||||
})[];
|
||||
subway: import("../general-app-domain/Subway/Schema").CreateOperationData[];
|
||||
station: import("../general-app-domain/Station/Schema").CreateOperationData[];
|
||||
subwayStation: import("../general-app-domain/SubwayStation/Schema").CreateOperationData[];
|
||||
};
|
||||
export default _default;
|
||||
|
|
|
|||
|
|
@ -2,10 +2,16 @@
|
|||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var userRole_1 = require("./userRole");
|
||||
var area_1 = require("./area");
|
||||
var subway_1 = require("./subway");
|
||||
var station_1 = require("./station");
|
||||
var subwayStation_1 = require("./subwayStation");
|
||||
exports.default = {
|
||||
user: userRole_1.users,
|
||||
role: userRole_1.roles,
|
||||
mobile: userRole_1.mobiles,
|
||||
token: userRole_1.tokens,
|
||||
area: area_1.area,
|
||||
subway: subway_1.subway,
|
||||
station: station_1.station,
|
||||
subwayStation: subwayStation_1.subwayStation,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
import { CreateOperationData as Station } from "../general-app-domain/Station/Schema";
|
||||
export declare const station: Station[];
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,2 @@
|
|||
import { CreateOperationData as Subway } from "../general-app-domain/Subway/Schema";
|
||||
export declare const subway: Subway[];
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.subway = void 0;
|
||||
exports.subway = [
|
||||
{
|
||||
id: "330100023133",
|
||||
name: "1号线",
|
||||
areaId: "330100",
|
||||
},
|
||||
{
|
||||
id: "330100023132",
|
||||
name: "1号线",
|
||||
areaId: "330100",
|
||||
},
|
||||
{
|
||||
id: "900000150789",
|
||||
name: "绍兴1号线",
|
||||
areaId: "330100",
|
||||
},
|
||||
{
|
||||
id: "330100020003",
|
||||
name: "2号线",
|
||||
areaId: "330100",
|
||||
},
|
||||
{
|
||||
id: "900000092651",
|
||||
name: "3号线",
|
||||
areaId: "330100",
|
||||
},
|
||||
{
|
||||
id: "900000096933",
|
||||
name: "3号线",
|
||||
areaId: "330100",
|
||||
},
|
||||
{
|
||||
id: "900000029624",
|
||||
name: "4号线",
|
||||
areaId: "330100",
|
||||
},
|
||||
{
|
||||
id: "900000065767",
|
||||
name: "5号线",
|
||||
areaId: "330100",
|
||||
},
|
||||
{
|
||||
id: "900000073754",
|
||||
name: "6号线",
|
||||
areaId: "330100",
|
||||
},
|
||||
{
|
||||
id: "900000062493",
|
||||
name: "6号线",
|
||||
areaId: "330100",
|
||||
},
|
||||
{
|
||||
id: "900000099060",
|
||||
name: "7号线",
|
||||
areaId: "330100",
|
||||
},
|
||||
{
|
||||
id: "900000099066",
|
||||
name: "8号线",
|
||||
areaId: "330100",
|
||||
},
|
||||
{
|
||||
id: "900000166808",
|
||||
name: "9号线",
|
||||
areaId: "330100",
|
||||
},
|
||||
{
|
||||
id: "900000122963",
|
||||
name: "10号线",
|
||||
areaId: "330100",
|
||||
},
|
||||
{
|
||||
id: "900000130963",
|
||||
name: "16号线",
|
||||
areaId: "330100",
|
||||
},
|
||||
{
|
||||
id: "900000101230",
|
||||
name: "19号线",
|
||||
areaId: "330100",
|
||||
},
|
||||
{
|
||||
id: "900000150702",
|
||||
name: "杭海城际",
|
||||
areaId: "330100",
|
||||
},
|
||||
{
|
||||
id: "900000109349",
|
||||
name: "S1线",
|
||||
areaId: "330300",
|
||||
},
|
||||
];
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
import { CreateOperationData as SubwayStation } from "../general-app-domain/SubwayStation/Schema";
|
||||
export declare const subwayStation: SubwayStation[];
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -84,6 +84,7 @@
|
|||
"copy-xml": "copyfiles -u 1 src/**/*.xml lib/ & copyfiles -u 1 src/**/*.wxml lib/",
|
||||
"build": "tsc && npm run copy-js && npm run copy-less && npm run copy-wxs && npm run copy-svg && npm run copy-xml",
|
||||
"gen:areaDebug": "ts-node ./scripts/generateAreaDebug.ts",
|
||||
"gen:subway": "ts-node ./scripts/local/getAmapSubway.ts",
|
||||
"clean:dir": "ts-node ./scripts/cleanDtsAndJs",
|
||||
"test": "ts-node ./test/test.ts",
|
||||
"prepare": "rimraf node_modules/react & rimraf node_modules/react-dom & rimraf node_modules/react-router",
|
||||
|
|
|
|||
|
|
@ -1,63 +1,60 @@
|
|||
/**
|
||||
* 用于更新高德数据库中的adCode信息到本地src/data/area.json中
|
||||
*/
|
||||
import 'isomorphic-fetch';
|
||||
import assert from 'assert';
|
||||
import { writeFileSync } from 'fs-extra';
|
||||
import { FormCreateData } from 'oak-domain/lib/types/Entity';
|
||||
import { OpSchema as Area } from '../src/general-app-domain/Area/Schema';
|
||||
|
||||
|
||||
const KEY = '4f3d4499850ba51429b9dece8cedd8d2';
|
||||
|
||||
async function acquireAmap(keyWords: string, subdistrict: number) {
|
||||
const url = `https://restapi.amap.com/v3/config/district?keywords=${encodeURIComponent(keyWords)}&subdistrict=${subdistrict}&key=${KEY}`;
|
||||
|
||||
const res = await fetch(url);
|
||||
return res.json();
|
||||
}
|
||||
|
||||
|
||||
function processRepeatedAdCode(districts: any[], parentAdCode: string) {
|
||||
// 高德的street的adCode和父亲相同,这里统一处理一下
|
||||
let jdCount = 0;
|
||||
let zCount = 100;
|
||||
let oCount = 400;
|
||||
let xCount = 200;
|
||||
const districts2 = districts.map(
|
||||
(ele) => {
|
||||
const { name, adcode } = ele;
|
||||
let ele2 = ele;
|
||||
if (adcode === parentAdCode) {
|
||||
if (name.endsWith('街道')) {
|
||||
ele2 = Object.assign(ele, { adcode: parseInt(adcode) * 1000 + jdCount });
|
||||
jdCount++;
|
||||
}
|
||||
else if (name.endsWith('镇')) {
|
||||
ele2 = Object.assign(ele, { adcode: parseInt(adcode) * 1000 + zCount });
|
||||
zCount++;
|
||||
}
|
||||
else if (name.endsWith('乡')) {
|
||||
ele2 = Object.assign(ele, { adcode: parseInt(adcode) * 1000 + xCount });
|
||||
xCount++;
|
||||
}
|
||||
else {
|
||||
ele2 = Object.assign(ele, { adcode: parseInt(adcode) * 1000 + oCount });
|
||||
oCount++;
|
||||
}
|
||||
}
|
||||
return ele2;
|
||||
}
|
||||
);
|
||||
return districts2;
|
||||
}
|
||||
|
||||
/**
|
||||
* 省份直接取到街道,然后存储
|
||||
* @param provinceName
|
||||
* @returns {*}
|
||||
*/
|
||||
/* function getProvince(provinceName) {
|
||||
import "isomorphic-fetch";
|
||||
import assert from "assert";
|
||||
import { writeFileSync } from "fs-extra";
|
||||
import { FormCreateData } from "oak-domain/lib/types/Entity";
|
||||
import { OpSchema as Area } from "../../src/general-app-domain/Area/Schema";
|
||||
|
||||
const KEY = "4f3d4499850ba51429b9dece8cedd8d2";
|
||||
|
||||
async function acquireAmap(keyWords: string, subdistrict: number) {
|
||||
const url = `https://restapi.amap.com/v3/config/district?keywords=${encodeURIComponent(
|
||||
keyWords
|
||||
)}&subdistrict=${subdistrict}&key=${KEY}`;
|
||||
|
||||
const res = await fetch(url);
|
||||
return res.json();
|
||||
}
|
||||
|
||||
function processRepeatedAdCode(districts: any[], parentAdCode: string) {
|
||||
// 高德的street的adCode和父亲相同,这里统一处理一下
|
||||
let jdCount = 0;
|
||||
let zCount = 100;
|
||||
let oCount = 400;
|
||||
let xCount = 200;
|
||||
const districts2 = districts.map((ele) => {
|
||||
const { name, adcode } = ele;
|
||||
let ele2 = ele;
|
||||
if (adcode === parentAdCode) {
|
||||
if (name.endsWith("街道")) {
|
||||
ele2 = Object.assign(ele, {
|
||||
adcode: parseInt(adcode) * 1000 + jdCount,
|
||||
});
|
||||
jdCount++;
|
||||
} else if (name.endsWith("镇")) {
|
||||
ele2 = Object.assign(ele, { adcode: parseInt(adcode) * 1000 + zCount });
|
||||
zCount++;
|
||||
} else if (name.endsWith("乡")) {
|
||||
ele2 = Object.assign(ele, { adcode: parseInt(adcode) * 1000 + xCount });
|
||||
xCount++;
|
||||
} else {
|
||||
ele2 = Object.assign(ele, { adcode: parseInt(adcode) * 1000 + oCount });
|
||||
oCount++;
|
||||
}
|
||||
}
|
||||
return ele2;
|
||||
});
|
||||
return districts2;
|
||||
}
|
||||
|
||||
/**
|
||||
* 省份直接取到街道,然后存储
|
||||
* @param provinceName
|
||||
* @returns {*}
|
||||
*/
|
||||
/* function getProvince(provinceName) {
|
||||
return acquireAmap(provinceName, 3)
|
||||
.then(
|
||||
(result) => {
|
||||
|
|
@ -79,66 +76,63 @@
|
|||
}
|
||||
);
|
||||
} */
|
||||
|
||||
|
||||
async function main() {
|
||||
const areaTotal: FormCreateData<Area>[] = [];
|
||||
function saveAreas(areas: any[], parentId: string | null, depth: 0 | 1 | 2 | 3 | 4, dest: FormCreateData<Area>[]) {
|
||||
areas.forEach(
|
||||
(ele) => {
|
||||
const { adcode, center, citycode, level, name } = ele;
|
||||
const coords = center.split(',');
|
||||
dest.push({
|
||||
code: adcode,
|
||||
level,
|
||||
parentId,
|
||||
name,
|
||||
depth,
|
||||
id: adcode,
|
||||
center: {
|
||||
type: 'point',
|
||||
coordinate: [parseFloat(coords[0]), parseFloat(coords[1])],
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
const result = await acquireAmap('中国', 1);
|
||||
const { districts } = result;
|
||||
const country = districts[0];
|
||||
saveAreas([country], null, 0, areaTotal);
|
||||
const { districts: provinces, adcode: countryCode } = country;
|
||||
|
||||
saveAreas(provinces, countryCode, 1, areaTotal);
|
||||
|
||||
// 完整的数据
|
||||
for (const dist of provinces) {
|
||||
const result2 = await acquireAmap(dist.name, 3);
|
||||
const { districts: cities, adcode: provinceCode } = result2.districts[0];
|
||||
saveAreas(cities, provinceCode, 2, areaTotal);
|
||||
for (const city of cities) {
|
||||
const { districts, adcode: cityCode } = city;
|
||||
const districts2 = processRepeatedAdCode(districts, cityCode);
|
||||
saveAreas(districts2, cityCode, 3, areaTotal);
|
||||
districts2.forEach(
|
||||
(district) => {
|
||||
const { districts: streets, adcode: districtCode } = district;
|
||||
const streets2 = processRepeatedAdCode(streets, districtCode);
|
||||
saveAreas(streets2, districtCode, 4, areaTotal);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
writeFileSync(`${__dirname}/../area.json`, JSON.stringify(areaTotal));
|
||||
}
|
||||
|
||||
|
||||
main().then(
|
||||
() => console.log('success')
|
||||
);
|
||||
/*
|
||||
|
||||
async function main() {
|
||||
const areaTotal: FormCreateData<Area>[] = [];
|
||||
function saveAreas(
|
||||
areas: any[],
|
||||
parentId: string | null,
|
||||
depth: 0 | 1 | 2 | 3 | 4,
|
||||
dest: FormCreateData<Area>[]
|
||||
) {
|
||||
areas.forEach((ele) => {
|
||||
const { adcode, center, citycode, level, name } = ele;
|
||||
const coords = center.split(",");
|
||||
dest.push({
|
||||
code: adcode,
|
||||
level,
|
||||
parentId,
|
||||
name,
|
||||
depth,
|
||||
id: adcode,
|
||||
center: {
|
||||
type: "point",
|
||||
coordinate: [parseFloat(coords[0]), parseFloat(coords[1])],
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
const result = await acquireAmap("中国", 1);
|
||||
const { districts } = result;
|
||||
const country = districts[0];
|
||||
saveAreas([country], null, 0, areaTotal);
|
||||
const { districts: provinces, adcode: countryCode } = country;
|
||||
|
||||
saveAreas(provinces, countryCode, 1, areaTotal);
|
||||
|
||||
// 完整的数据
|
||||
for (const dist of provinces) {
|
||||
const result2 = await acquireAmap(dist.name, 3);
|
||||
const { districts: cities, adcode: provinceCode } = result2.districts[0];
|
||||
saveAreas(cities, provinceCode, 2, areaTotal);
|
||||
for (const city of cities) {
|
||||
const { districts, adcode: cityCode } = city;
|
||||
const districts2 = processRepeatedAdCode(districts, cityCode);
|
||||
saveAreas(districts2, cityCode, 3, areaTotal);
|
||||
districts2.forEach((district) => {
|
||||
const { districts: streets, adcode: districtCode } = district;
|
||||
const streets2 = processRepeatedAdCode(streets, districtCode);
|
||||
saveAreas(streets2, districtCode, 4, areaTotal);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
writeFileSync(`${__dirname}/../area.json`, JSON.stringify(areaTotal));
|
||||
}
|
||||
|
||||
main().then(() => console.log("success"));
|
||||
/*
|
||||
acquireAmap('中国', 1)
|
||||
.then(
|
||||
(result) => {
|
||||
|
|
@ -169,4 +163,3 @@
|
|||
process.exit(-1);
|
||||
}
|
||||
); */
|
||||
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1 @@
|
|||
[{"id":"330100023133","name":"1号线","areaId":"330100"},{"id":"330100023132","name":"1号线","areaId":"330100"},{"id":"900000150789","name":"绍兴1号线","areaId":"330100"},{"id":"330100020003","name":"2号线","areaId":"330100"},{"id":"900000092651","name":"3号线","areaId":"330100"},{"id":"900000096933","name":"3号线","areaId":"330100"},{"id":"900000029624","name":"4号线","areaId":"330100"},{"id":"900000065767","name":"5号线","areaId":"330100"},{"id":"900000073754","name":"6号线","areaId":"330100"},{"id":"900000062493","name":"6号线","areaId":"330100"},{"id":"900000099060","name":"7号线","areaId":"330100"},{"id":"900000099066","name":"8号线","areaId":"330100"},{"id":"900000166808","name":"9号线","areaId":"330100"},{"id":"900000122963","name":"10号线","areaId":"330100"},{"id":"900000130963","name":"16号线","areaId":"330100"},{"id":"900000101230","name":"19号线","areaId":"330100"},{"id":"900000150702","name":"杭海城际","areaId":"330100"},{"id":"900000109349","name":"S1线","areaId":"330300"}]
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -1,10 +1,16 @@
|
|||
import { users, roles, mobiles, tokens } from './userRole';
|
||||
import { area } from './area';
|
||||
import { users, roles, mobiles, tokens } from "./userRole";
|
||||
import { area } from "./area";
|
||||
import { subway } from "./subway";
|
||||
import { station } from "./station";
|
||||
import { subwayStation } from "./subwayStation";
|
||||
|
||||
export default {
|
||||
user: users,
|
||||
role: roles,
|
||||
mobile: mobiles,
|
||||
token: tokens,
|
||||
area,
|
||||
};
|
||||
user: users,
|
||||
role: roles,
|
||||
mobile: mobiles,
|
||||
token: tokens,
|
||||
area,
|
||||
subway,
|
||||
station,
|
||||
subwayStation,
|
||||
};
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,93 @@
|
|||
import { CreateOperationData as Subway } from "../general-app-domain/Subway/Schema";
|
||||
export const subway: Subway[] = [
|
||||
{
|
||||
id: "330100023133",
|
||||
name: "1号线",
|
||||
areaId: "330100",
|
||||
},
|
||||
{
|
||||
id: "330100023132",
|
||||
name: "1号线",
|
||||
areaId: "330100",
|
||||
},
|
||||
{
|
||||
id: "900000150789",
|
||||
name: "绍兴1号线",
|
||||
areaId: "330100",
|
||||
},
|
||||
{
|
||||
id: "330100020003",
|
||||
name: "2号线",
|
||||
areaId: "330100",
|
||||
},
|
||||
{
|
||||
id: "900000092651",
|
||||
name: "3号线",
|
||||
areaId: "330100",
|
||||
},
|
||||
{
|
||||
id: "900000096933",
|
||||
name: "3号线",
|
||||
areaId: "330100",
|
||||
},
|
||||
{
|
||||
id: "900000029624",
|
||||
name: "4号线",
|
||||
areaId: "330100",
|
||||
},
|
||||
{
|
||||
id: "900000065767",
|
||||
name: "5号线",
|
||||
areaId: "330100",
|
||||
},
|
||||
{
|
||||
id: "900000073754",
|
||||
name: "6号线",
|
||||
areaId: "330100",
|
||||
},
|
||||
{
|
||||
id: "900000062493",
|
||||
name: "6号线",
|
||||
areaId: "330100",
|
||||
},
|
||||
{
|
||||
id: "900000099060",
|
||||
name: "7号线",
|
||||
areaId: "330100",
|
||||
},
|
||||
{
|
||||
id: "900000099066",
|
||||
name: "8号线",
|
||||
areaId: "330100",
|
||||
},
|
||||
{
|
||||
id: "900000166808",
|
||||
name: "9号线",
|
||||
areaId: "330100",
|
||||
},
|
||||
{
|
||||
id: "900000122963",
|
||||
name: "10号线",
|
||||
areaId: "330100",
|
||||
},
|
||||
{
|
||||
id: "900000130963",
|
||||
name: "16号线",
|
||||
areaId: "330100",
|
||||
},
|
||||
{
|
||||
id: "900000101230",
|
||||
name: "19号线",
|
||||
areaId: "330100",
|
||||
},
|
||||
{
|
||||
id: "900000150702",
|
||||
name: "杭海城际",
|
||||
areaId: "330100",
|
||||
},
|
||||
{
|
||||
id: "900000109349",
|
||||
name: "S1线",
|
||||
areaId: "330300",
|
||||
},
|
||||
];
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue