gisviewer-vue3-arcgis
Version:
在应用中引入私服的包, 项目根目录下 新建文件 .npmrc 在 .npmrc 中对包源进行配置:
86 lines (85 loc) • 3.41 kB
JavaScript
import d from "pako";
import h from "../common-utils.mjs";
class c {
constructor(i, s) {
if (this.parentName = "", this.signals = [], this.subDistricts = [], this.areaColor = this.getDarkNonGrayColor(), this.signalCount = 0, this.subDistrictCount = 0, this.roadConnections = [], this.id = i.name, this.name = i.areaDesc, this.parentId = i.parentId, s === "alarm" && (this.areaColor = [255, 0, 0]), i.mapConnectList)
try {
const t = i.mapConnectList, o = new Uint8Array(
window.atob(t).split("").map((n) => n.charCodeAt(0))
), a = d.inflate(o, { to: "string" }), r = JSON.parse(a);
this.roadConnections.push(
...r.map((n) => ({
id: n.roadsectId,
coordinates: JSON.parse(n.geomData).coordinates,
districtId: this.parentId,
subDistrictId: this.id,
color: this.areaColor
}))
);
} catch (t) {
console.error("解压子区路段连接信息失败:", t);
}
for (const t of i.children)
if (t.children) {
const o = new c(t, s);
if (o.id = t.id, o.name = `SS ${t.name}`, o.parentId = this.id, o.parentName = this.name, o.areaColor = this.getDarkNonGrayColor(t.id), this.subDistricts.push(o), this.subDistrictCount++, this.signalCount += o.signalCount, t.mapConnectList)
try {
const a = t.mapConnectList, r = new Uint8Array(
window.atob(a).split("").map((e) => e.charCodeAt(0))
), n = d.inflate(r, { to: "string" }), l = JSON.parse(n);
o.roadConnections.push(
...l.map((e) => ({
id: e.roadsectId,
coordinates: JSON.parse(e.geomData).coordinates,
districtId: o.parentId,
subDistrictId: o.id
}))
);
} catch (a) {
console.error("解压子区路段连接信息失败:", a);
}
} else if (h.isCoordinateValid(t)) {
const o = {
id: t.id,
name: t.name,
parentId: t.parentId,
latitude: Number(t.latitude),
longitude: Number(t.longitude),
signalId: t.signalId,
nodeId: t.nodeId,
isKey: t.isKey === 1
};
this.signals.push(o), this.signalCount++;
}
}
/**
* 获取区控/子区下的所有信号机
* @returns
*/
getAllSignalCoordinates() {
const i = [];
for (const s of this.signals)
i.push([s.longitude, s.latitude]);
for (const s of this.subDistricts)
i.push(...s.getAllSignalCoordinates());
return i;
}
getDarkNonGrayColor(i) {
let s, t, o;
if (i) {
const a = this.cyrb53(i);
s = ((a & 16711680) >> 16) % 200, t = ((a & 65280) >> 8) % 200, o = (a & 255) % 200;
} else
s = Math.floor(Math.random() * 256), t = Math.floor(Math.random() * 256), o = Math.floor(Math.random() * 256);
return [s, t, o];
}
cyrb53(i, s = 0) {
let t = 3735928559 ^ s, o = 1103547991 ^ s;
for (let a = 0, r; a < i.length; a++)
r = i.charCodeAt(a), t = Math.imul(t ^ r, 2654435761), o = Math.imul(o ^ r, 1597334677);
return t = Math.imul(t ^ t >>> 16, 2246822507), t ^= Math.imul(o ^ o >>> 13, 3266489909), o = Math.imul(o ^ o >>> 16, 2246822507), o ^= Math.imul(t ^ t >>> 13, 3266489909), 4294967296 * (2097151 & o) + (t >>> 0);
}
}
export {
c as default
};