vis-core 0.21.57 → 0.21.59

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -55,9 +55,9 @@ import CryptoJS from "crypto-js";
55
55
  import { makePromiseCreator, WorkerPool, generateUUID as generateUUID$1 } from "esus-lite";
56
56
  import { EventEmitter } from "events";
57
57
  import { throttle } from "lodash-es";
58
+ import { union, centroid, booleanPointInPolygon as booleanPointInPolygon$1, point, polygon, bbox, center, flatten as flatten$3, explode, inside, intersect as intersect$1, booleanContains, lineString, booleanCrosses } from "@turf/turf";
58
59
  import json100000 from "geojson-cn/extra/100000-lite-next.json";
59
60
  import countries from "geojson-cn/extra/countries-next.json";
60
- import { union, centroid, booleanPointInPolygon as booleanPointInPolygon$1, point, polygon, center, flatten as flatten$3, explode, inside, intersect as intersect$1, booleanContains, lineString, booleanCrosses, bbox } from "@turf/turf";
61
61
  import continents from "geojson-cn/extra/continents.json";
62
62
  import { adcodeMap, findLevelJsonItem, allArr } from "geojson-cn";
63
63
  import chinaJson from "geojson-cn/extra/100000-next.json";
@@ -89,7 +89,7 @@ const publicKeyPEM = "LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUlJQklqQU5CZ2txaGtpRz
89
89
  ).toString(CryptoJS.enc.Utf8), Jt = JSON.parse(Tt), $t = Date.now();
90
90
  return !Jt.s || Jt.s > $t ? (this.token = void 0, "") : Jt.e && Jt.e < $t ? (this.token = void 0, "") : (Jt.isValid = Yt, Jt);
91
91
  }
92
- }, version = "0.21.57";
92
+ }, version = "0.21.59";
93
93
  /**
94
94
  * @license
95
95
  * Copyright 2010-2024 Three.js Authors
@@ -49478,7 +49478,7 @@ const compareVersion = (c, e) => {
49478
49478
  }), compareVersion(c.c.version, "0.21.24") === -1 && c.h.u[0] && c.h.u[0].visType === "map" && (f = (r = c.v) == null ? void 0 : r.eo) != null && f.parentBgCurvatureResolution && (delete c.v.eo.parentBgCurvatureResolution, c.v.eo.parentBgTopSegments = 400), c;
49479
49479
  }, jsonFetch = (c, e, s = !1) => {
49480
49480
  const r = makePromiseCreator(!0), f = c.endsWith("gzip") || s;
49481
- return fetch(c).then((st) => {
49481
+ return window.fetch(c).then((st) => {
49482
49482
  let ct = st;
49483
49483
  if (ct.ok)
49484
49484
  return f ? ct.blob().then((Zt) => {
@@ -51836,16 +51836,23 @@ const objs$4 = Ui(hi({}, objs$5), {
51836
51836
  shadowMapDisabled() {
51837
51837
  this.pencil.scene.userData.shadowMapEnabled && (this.pencil.scene.userData.shadowMapEnabled = !1, this.shadowMapLight && (this.shadowMapLight.erase(), this.mList.delObject3d(this.shadowMapLight.object3d), this.shadowMapLight = void 0), this.planeShadow && (this.mList.delObject3d(this.planeShadow.object3d), this.planeShadow.erase(), this.planeShadow = void 0));
51838
51838
  }
51839
- getDepth(s) {
51840
- const r = this.getAdcodeShowLevel(s);
51841
- let f = this.options.mapDepth;
51842
- Array.isArray(f) || (f = new Array(3).fill(f));
51843
- let st;
51844
- if (r === "country" ? st = f[0] : r === "province" ? st = f[1] : st = f[2], this.options.depthReference && this.options.bboxMap[s]) {
51845
- const ct = this.options.depthReference, Zt = this.options.bboxMap[s], Wt = Math.abs(Zt[3] - Zt[1]) / Math.abs(ct[3] - ct[1]), Yt = Math.abs(Zt[2] - Zt[0]) / Math.abs(ct[2] - ct[0]);
51846
- st = st * Math.max(Wt, Yt);
51839
+ getDepth(s, r) {
51840
+ const f = this.getAdcodeShowLevel(s);
51841
+ let st = this.options.mapDepth;
51842
+ Array.isArray(st) || (st = new Array(3).fill(st));
51843
+ let ct;
51844
+ if (f === "country" ? ct = st[0] : f === "province" ? ct = st[1] : ct = st[2], this.options.depthReference && this.options.bboxMap[s]) {
51845
+ const Zt = this.options.depthReference, Wt = this.options.bboxMap[s];
51846
+ ct = ct * this.getReferenceScale(Zt, Wt);
51847
+ } else if (this.mapHistory.length && this.options.bboxMap[this.mapHistory[0].mapInfo.adcode]) {
51848
+ const Zt = this.options.bboxMap[this.mapHistory[0].mapInfo.adcode], Wt = bbox(r), Yt = this.getReferenceScale(Zt, Wt);
51849
+ ct = ct * Yt;
51847
51850
  }
51848
- return st;
51851
+ return ct;
51852
+ }
51853
+ getReferenceScale(s, r) {
51854
+ const f = Math.abs(r[3] - r[1]) / Math.abs(s[3] - s[1]), st = Math.abs(r[2] - r[0]) / Math.abs(s[2] - s[0]);
51855
+ return Math.max(f, st);
51849
51856
  }
51850
51857
  getAdcodeShowLevel(s) {
51851
51858
  var r;
@@ -51986,7 +51993,7 @@ const objs$4 = Ui(hi({}, objs$5), {
51986
51993
  }), this.eraseLabels(), this.map && (this.options.drillDownHideParent && this.parentBg.forEach((r0) => {
51987
51994
  r0.hide();
51988
51995
  }), this.options.showOneLevel ? this.map.hide() : this.map.deactive(), this.options.handleBackKeepCamvasState && this.saveBackCamvasState(-1));
51989
- const qe = this.mapHistory.length, t0 = qe - 1, e0 = this.getDepth(s), i0 = (Jt = this.mapHistory[t0]) == null ? void 0 : Jt.depth, n0 = qe === 0 ? 0 : this.mapHistory[t0].z + (this.options.showOneLevel ? 0 : i0), s0 = qe === 0 ? 0 : n0 - e0, a0 = center(Je).geometry.coordinates, [h0, m0] = this.projection(a0), V0 = yield this.drawPlaneMap({
51996
+ const qe = this.mapHistory.length, t0 = qe - 1, e0 = this.getDepth(s, de || Je), i0 = (Jt = this.mapHistory[t0]) == null ? void 0 : Jt.depth, n0 = qe === 0 ? 0 : this.mapHistory[t0].z + (this.options.showOneLevel ? 0 : i0), s0 = qe === 0 ? 0 : n0 - e0, a0 = center(Je).geometry.coordinates, [h0, m0] = this.projection(a0), V0 = yield this.drawPlaneMap({
51990
51997
  geojson: Je,
51991
51998
  extrudeLineGeojson: de,
51992
51999
  depth: e0,
@@ -52039,42 +52046,40 @@ const objs$4 = Ui(hi({}, objs$5), {
52039
52046
  azimuthAngle: f,
52040
52047
  enableTransition: st = !0
52041
52048
  } = {}) {
52042
- var Je, de, Ke;
52049
+ var Qe, Je, de;
52043
52050
  if (!(s != null && s.object3d)) return;
52044
- const Zt = (de = this.options.lookAtMap) == null ? void 0 : de[(Je = this.mapInfo) == null ? void 0 : Je.adcode];
52051
+ const Zt = (Je = this.options.lookAtMap) == null ? void 0 : Je[(Qe = this.mapInfo) == null ? void 0 : Qe.adcode];
52045
52052
  if (Zt) {
52046
- const [_e, $e, qe, t0, e0, i0] = Zt;
52047
- yield (Ke = this.pencil.controls) == null ? void 0 : Ke.setLookAt(
52053
+ const [Ke, _e, $e, qe, t0, e0] = Zt;
52054
+ yield (de = this.pencil.controls) == null ? void 0 : de.setLookAt(
52055
+ Ke,
52048
52056
  _e,
52049
52057
  $e,
52050
52058
  qe,
52051
52059
  t0,
52052
52060
  e0,
52053
- i0,
52054
52061
  st
52055
52062
  );
52056
52063
  return;
52057
52064
  }
52058
52065
  const Wt = this.options.mapPadding, { height: Yt, width: vt } = this.pencil.getSize();
52059
52066
  Yt < Wt[0] + Wt[2] + 100 && (Wt[0] = 0, Wt[2] = 0), vt < Wt[1] + Wt[3] + 100 && (Wt[1] = 0, Wt[3] = 0);
52060
- const Tt = r || this.options.polarAngle, Jt = f || this.options.azimuthAngle, $t = this.pencil.controls.azimuthAngle, Xe = this.pencil.controls.polarAngle, Qe = $t !== Jt || Xe !== Tt;
52061
- yield Promise.all(
52062
- [
52063
- this.paddingInCssPixel(
52064
- s,
52065
- Wt[0],
52066
- Wt[1],
52067
- Wt[2],
52068
- Wt[3],
52069
- st
52070
- ),
52071
- Qe && this.pencil.controls.rotateTo(
52072
- $t + this.absoluteAngle(Jt, $t),
52073
- Xe + this.absoluteAngle(Tt, Xe),
52074
- st
52075
- )
52076
- ].filter(Boolean)
52077
- );
52067
+ const Tt = r || this.options.polarAngle, Jt = f || this.options.azimuthAngle, $t = this.pencil.controls.azimuthAngle, Xe = this.pencil.controls.polarAngle;
52068
+ yield Promise.all([
52069
+ this.paddingInCssPixel(
52070
+ s,
52071
+ Wt[0],
52072
+ Wt[1],
52073
+ Wt[2],
52074
+ Wt[3],
52075
+ st
52076
+ ),
52077
+ this.pencil.controls.rotateTo(
52078
+ $t + this.absoluteAngle(Jt, $t),
52079
+ Xe + this.absoluteAngle(Tt, Xe),
52080
+ st
52081
+ )
52082
+ ]);
52078
52083
  });
52079
52084
  }
52080
52085
  paddingInCssPixel(s, r, f, st, ct, Zt) {
@@ -55476,9 +55481,7 @@ const getMapConfig = (r, ...f) => ti(void 0, [r, ...f], function* (c, e = b, s)
55476
55481
  }
55477
55482
  return hi({}, e);
55478
55483
  }), getCityConfig = (s, ...r) => ti(void 0, [s, ...r], function* (c, e = b) {
55479
- const f = adcodeMap[c], st = yield fetch(
55480
- e + `/geojson/json-lite/${c}.json`
55481
- ).then((Wt) => Wt.json()), ct = bbox(st), { name: Zt } = adcodeMap[c];
55484
+ const f = adcodeMap[c], st = yield window.fetch(e + `/geojson/json-lite/${c}.json`).then((Wt) => Wt.json()), ct = bbox(st), { name: Zt } = adcodeMap[c];
55482
55485
  return {
55483
55486
  center: [f.lng, f.lat],
55484
55487
  adcode: f.adcode,
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare const _default: "0.21.57";
1
+ declare const _default: "0.21.59";
2
2
  export default _default;
@@ -148,7 +148,8 @@ export default class extends Base {
148
148
  planeShadow?: BaseObject;
149
149
  shadowMapEnabled(): Promise<void>;
150
150
  shadowMapDisabled(): void;
151
- getDepth(adcode: number): number;
151
+ getDepth(adcode: number, geojson: GeoJSON): number;
152
+ getReferenceScale(bboxa: number[], bboxb: number[]): number;
152
153
  getAdcodeShowLevel(adcode: number): string;
153
154
  handleClick(e: MouseEvent): void;
154
155
  beforeClickArea(adcodes: number[]): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vis-core",
3
- "version": "0.21.57",
3
+ "version": "0.21.59",
4
4
  "scripts": {
5
5
  "start": "npm run version && PORT=5173 bundler-dev",
6
6
  "build:site": "npm run version &&PUBLIC_EXCLUDE=public/city bundler",