@arenarium/maps 1.0.186 → 1.0.188

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.
package/README.md CHANGED
@@ -293,7 +293,7 @@ const mapManager = new MapManager(mapProvider, {
293
293
  });
294
294
  ```
295
295
 
296
- ## API (WIP)
296
+ ## API
297
297
 
298
298
  While the library works out of the box, it is recommended to use the API for calculating the marker states. The calculations can be compute intensive and api could offer a more standerdized performance, and benefits from caching.
299
299
 
package/dist/api.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";var E=Object.defineProperty;var v=(l,o,n)=>o in l?E(l,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):l[o]=n;var h=(l,o,n)=>v(l,typeof o!="symbol"?o+"":o,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("./states-D6BEdwDG.cjs");class B{constructor(o,n,i){h(this,"x");h(this,"y");h(this,"width");h(this,"height");h(this,"zoom");h(this,"angles");h(this,"expanded");h(this,"angle");h(this,"bounds");const c=f.Mercator.project(n.lat,n.lng,o.mapSize);this.x=c.x,this.y=c.y,this.width=n.width+2*n.margin,this.height=n.height+2*n.margin,this.zoom=i[0],this.angles=i[1].map(g=>[g[0],f.Angles.DEGREES[g[1]]]),this.expanded=!1,this.angle=0,this.bounds=void 0}getBounds(o,n){let{offsetX:i,offsetY:c}=f.Rectangle.getOffsets(this.width,this.height,n),g=-i,u=this.width-g,b=-c,e=this.height-b;return{x:this.x,y:this.y,left:g/o,right:u/o,top:b/o,bottom:e/o}}}function M(l,o,n){var b;if(o.length!=n.length)throw new Error("Data and states length must be the same");const i=new Array(o.length);for(let e=0;e<o.length;e++){const a=n[e];if(isNaN(a[0]))throw new Error("State zoom is not a number");if(a[1]==null||a[1].length==0)throw new Error("State angles is empty");if(a[0]!=a[1][0][0])throw new Error("State expand zoom and start angles zoom are not the same");const d=new B(l,o[e],n[e]);i[e]=d}const c=l.zoomMin,g=l.zoomMax,u=1/l.zoomScale;for(let e=c;e<=g;e+=u){const a=Math.pow(2,e);for(let d=0;d<i.length;d++){const t=i[d];if(t.expanded=t.zoom<e,t.expanded==!1)continue;const r=(b=t.angles.findLast(s=>s[0]<e))==null?void 0:b[1];if(r==null)throw new Error("Angle not found");t.angle=r,t.bounds=t.getBounds(a,r)}for(let d=0;d<i.length;d++){const t=i[d];if(t.bounds!=null)for(let r=d+1;r<i.length;r++){const s=i[r];if(s.bounds!=null&&f.Bounds.areOverlaping(t.bounds,s.bounds)){console.log("OVERLAP",e,o[d],o[r],t.angle,s.angle);const m=t.bounds.x-t.bounds.left,w=t.bounds.y-t.bounds.top,x=t.bounds.x+t.bounds.right,y=t.bounds.y+t.bounds.bottom;console.log(`B1: (${m}, ${w}), (${m}, ${y}), (${x}, ${w}), (${x}, ${y})`);const z=s.bounds.x-s.bounds.left,S=s.bounds.y-s.bounds.top,$=s.bounds.x+s.bounds.right,p=s.bounds.y+s.bounds.bottom;throw console.log(`B2: (${z}, ${S}), (${z}, ${p}), (${$}, ${S}), (${$}, ${p})`),new Error("Bounds overlaping")}}}}}exports.getStates=f.getStates;exports.testStates=M;
1
+ "use strict";var E=Object.defineProperty;var v=(d,o,n)=>o in d?E(d,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):d[o]=n;var a=(d,o,n)=>v(d,typeof o!="symbol"?o+"":o,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("./states-Dr9TQeEe.cjs");class B{constructor(o,n,s){a(this,"x");a(this,"y");a(this,"width");a(this,"height");a(this,"zoom");a(this,"angles");a(this,"expanded");a(this,"angle");a(this,"bounds");const r=b.Mercator.project(n.lat,n.lng,o.mapSize);this.x=r.x,this.y=r.y,this.width=n.width+2*n.margin,this.height=n.height+2*n.margin,this.zoom=s[0],this.angles=s[1].map(c=>[c[0],b.Angles.DEGREES[c[1]]]),this.expanded=!1,this.angle=0,this.bounds=void 0}getBounds(o,n){let s=b.Rectangle.getOffsets(this.width,this.height,n),r=-s.x,c=this.width-r,u=-s.y,f=this.height-u;return{x:this.x,y:this.y,distances:{left:r/o,right:c/o,top:u/o,bottom:f/o}}}}function M(d,o,n){var f;if(o.length!=n.length)throw new Error("Data and states length must be the same");const s=new Array(o.length);for(let i=0;i<o.length;i++){const g=n[i];if(isNaN(g[0]))throw new Error("State zoom is not a number");if(g[1]==null||g[1].length==0)throw new Error("State angles is empty");if(g[0]!=g[1][0][0])throw new Error("State expand zoom and start angles zoom are not the same");const l=new B(d,o[i],n[i]);s[i]=l}const r=d.zoomMin,c=d.zoomMax,u=1/d.zoomScale;for(let i=r;i<=c;i+=u){const g=Math.pow(2,i);for(let l=0;l<s.length;l++){const t=s[l];if(t.expanded=t.zoom<i,t.expanded==!1)continue;const h=(f=t.angles.findLast(e=>e[0]<i))==null?void 0:f[1];if(h==null)throw new Error("Angle not found");t.angle=h,t.bounds=t.getBounds(g,h)}for(let l=0;l<s.length;l++){const t=s[l];if(t.bounds!=null)for(let h=l+1;h<s.length;h++){const e=s[h];if(e.bounds!=null&&b.Bounds.areOverlaping(t.bounds,e.bounds)){console.log("OVERLAP",i,t,o[l],e,o[h]);const m=t.bounds.x-t.bounds.distances.left,x=t.bounds.x+t.bounds.distances.right,w=t.bounds.y-t.bounds.distances.top,y=t.bounds.y+t.bounds.distances.bottom;console.log(`B1: (${m}, ${w}), (${m}, ${y}), (${x}, ${w}), (${x}, ${y}), (${t.bounds.x}, ${t.bounds.y})`,t.angle);const $=e.bounds.x-e.bounds.distances.left,z=e.bounds.x+e.bounds.distances.right,S=e.bounds.y-e.bounds.distances.top,p=e.bounds.y+e.bounds.distances.bottom;throw console.log(`B2: (${$}, ${S}), (${$}, ${p}), (${z}, ${S}), (${z}, ${p}), (${e.bounds.x}, ${e.bounds.y})`,e.angle),new Error("Bounds overlaping")}}}}}exports.getStates=b.getStates;exports.testStates=M;
package/dist/api.d.ts CHANGED
@@ -1,8 +1,6 @@
1
1
  import { z } from 'zod';
2
2
 
3
- export declare function getStates(parameters: MapProviderParameters, data: Array<MapTooltipStateInput>): MapTooltipState[];
4
-
5
- declare type MapProviderParameters = z.infer<typeof mapProviderParametersSchema>;
3
+ export declare function getStates(parameters: MapTooltipStatesParameters, data: Array<MapTooltipStateInput>): MapTooltipState[];
6
4
 
7
5
  declare const mapProviderParametersSchema: z.ZodObject<{
8
6
  mapSize: z.ZodNumber;
@@ -53,6 +51,8 @@ declare const mapTooltipStateInputSchema: z.ZodObject<{
53
51
 
54
52
  declare const mapTooltipStateSchema: z.ZodTuple<[z.ZodNumber, z.ZodArray<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>, "many">], null>;
55
53
 
54
+ export declare type MapTooltipStatesParameters = z.infer<typeof mapProviderParametersSchema>;
55
+
56
56
  export declare type MapTooltipStatesRequest = z.infer<typeof mapTooltipStatesRequestSchema>;
57
57
 
58
58
  declare const mapTooltipStatesRequestSchema: z.ZodObject<{
@@ -134,6 +134,6 @@ declare const mapTooltipStatesRequestSchema: z.ZodObject<{
134
134
  }[];
135
135
  }>;
136
136
 
137
- export declare function testStates(parameters: MapProviderParameters, inputs: MapTooltipStateInput[], states: MapTooltipState[]): void;
137
+ export declare function testStates(parameters: MapTooltipStatesParameters, inputs: MapTooltipStateInput[], states: MapTooltipState[]): void;
138
138
 
139
139
  export { }
package/dist/api.es.js CHANGED
@@ -1,67 +1,75 @@
1
1
  var E = Object.defineProperty;
2
- var S = (l, o, n) => o in l ? E(l, o, { enumerable: !0, configurable: !0, writable: !0, value: n }) : l[o] = n;
3
- var d = (l, o, n) => S(l, typeof o != "symbol" ? o + "" : o, n);
4
- import { B as v, M as B, A, R as M } from "./states-CqXqpk4z.js";
5
- import { g as G } from "./states-CqXqpk4z.js";
2
+ var S = (d, t, n) => t in d ? E(d, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : d[t] = n;
3
+ var l = (d, t, n) => S(d, typeof t != "symbol" ? t + "" : t, n);
4
+ import { B as v, M as B, A, R as M } from "./states-BVsyCOND.js";
5
+ import { g as G } from "./states-BVsyCOND.js";
6
6
  class R {
7
- constructor(o, n, i) {
8
- d(this, "x");
9
- d(this, "y");
10
- d(this, "width");
11
- d(this, "height");
12
- d(this, "zoom");
13
- d(this, "angles");
14
- d(this, "expanded");
15
- d(this, "angle");
16
- d(this, "bounds");
17
- const c = B.project(n.lat, n.lng, o.mapSize);
18
- this.x = c.x, this.y = c.y, this.width = n.width + 2 * n.margin, this.height = n.height + 2 * n.margin, this.zoom = i[0], this.angles = i[1].map((a) => [a[0], A.DEGREES[a[1]]]), this.expanded = !1, this.angle = 0, this.bounds = void 0;
7
+ constructor(t, n, e) {
8
+ l(this, "x");
9
+ l(this, "y");
10
+ l(this, "width");
11
+ l(this, "height");
12
+ l(this, "zoom");
13
+ l(this, "angles");
14
+ l(this, "expanded");
15
+ l(this, "angle");
16
+ l(this, "bounds");
17
+ const r = B.project(n.lat, n.lng, t.mapSize);
18
+ this.x = r.x, this.y = r.y, this.width = n.width + 2 * n.margin, this.height = n.height + 2 * n.margin, this.zoom = e[0], this.angles = e[1].map((c) => [c[0], A.DEGREES[c[1]]]), this.expanded = !1, this.angle = 0, this.bounds = void 0;
19
19
  }
20
- getBounds(o, n) {
21
- let { offsetX: i, offsetY: c } = M.getOffsets(this.width, this.height, n), a = -i, b = this.width - a, f = -c, e = this.height - f;
20
+ getBounds(t, n) {
21
+ let e = M.getOffsets(this.width, this.height, n), r = -e.x, c = this.width - r, b = -e.y, u = this.height - b;
22
22
  return {
23
23
  x: this.x,
24
24
  y: this.y,
25
- left: a / o,
26
- right: b / o,
27
- top: f / o,
28
- bottom: e / o
25
+ distances: {
26
+ left: r / t,
27
+ right: c / t,
28
+ top: b / t,
29
+ bottom: u / t
30
+ }
29
31
  };
30
32
  }
31
33
  }
32
- function D(l, o, n) {
33
- var f;
34
- if (o.length != n.length) throw new Error("Data and states length must be the same");
35
- const i = new Array(o.length);
36
- for (let e = 0; e < o.length; e++) {
37
- const g = n[e];
34
+ function D(d, t, n) {
35
+ var u;
36
+ if (t.length != n.length) throw new Error("Data and states length must be the same");
37
+ const e = new Array(t.length);
38
+ for (let i = 0; i < t.length; i++) {
39
+ const g = n[i];
38
40
  if (isNaN(g[0])) throw new Error("State zoom is not a number");
39
41
  if (g[1] == null || g[1].length == 0) throw new Error("State angles is empty");
40
42
  if (g[0] != g[1][0][0]) throw new Error("State expand zoom and start angles zoom are not the same");
41
- const h = new R(l, o[e], n[e]);
42
- i[e] = h;
43
+ const a = new R(d, t[i], n[i]);
44
+ e[i] = a;
43
45
  }
44
- const c = l.zoomMin, a = l.zoomMax, b = 1 / l.zoomScale;
45
- for (let e = c; e <= a; e += b) {
46
- const g = Math.pow(2, e);
47
- for (let h = 0; h < i.length; h++) {
48
- const t = i[h];
49
- if (t.expanded = t.zoom < e, t.expanded == !1) continue;
50
- const r = (f = t.angles.findLast((s) => s[0] < e)) == null ? void 0 : f[1];
51
- if (r == null) throw new Error("Angle not found");
52
- t.angle = r, t.bounds = t.getBounds(g, r);
46
+ const r = d.zoomMin, c = d.zoomMax, b = 1 / d.zoomScale;
47
+ for (let i = r; i <= c; i += b) {
48
+ const g = Math.pow(2, i);
49
+ for (let a = 0; a < e.length; a++) {
50
+ const o = e[a];
51
+ if (o.expanded = o.zoom < i, o.expanded == !1) continue;
52
+ const h = (u = o.angles.findLast((s) => s[0] < i)) == null ? void 0 : u[1];
53
+ if (h == null) throw new Error("Angle not found");
54
+ o.angle = h, o.bounds = o.getBounds(g, h);
53
55
  }
54
- for (let h = 0; h < i.length; h++) {
55
- const t = i[h];
56
- if (t.bounds != null)
57
- for (let r = h + 1; r < i.length; r++) {
58
- const s = i[r];
59
- if (s.bounds != null && v.areOverlaping(t.bounds, s.bounds)) {
60
- console.log("OVERLAP", e, o[h], o[r], t.angle, s.angle);
61
- const m = t.bounds.x - t.bounds.left, u = t.bounds.y - t.bounds.top, x = t.bounds.x + t.bounds.right, w = t.bounds.y + t.bounds.bottom;
62
- console.log(`B1: (${m}, ${u}), (${m}, ${w}), (${x}, ${u}), (${x}, ${w})`);
63
- const $ = s.bounds.x - s.bounds.left, y = s.bounds.y - s.bounds.top, p = s.bounds.x + s.bounds.right, z = s.bounds.y + s.bounds.bottom;
64
- throw console.log(`B2: (${$}, ${y}), (${$}, ${z}), (${p}, ${y}), (${p}, ${z})`), new Error("Bounds overlaping");
56
+ for (let a = 0; a < e.length; a++) {
57
+ const o = e[a];
58
+ if (o.bounds != null)
59
+ for (let h = a + 1; h < e.length; h++) {
60
+ const s = e[h];
61
+ if (s.bounds != null && v.areOverlaping(o.bounds, s.bounds)) {
62
+ console.log("OVERLAP", i, o, t[a], s, t[h]);
63
+ const f = o.bounds.x - o.bounds.distances.left, m = o.bounds.x + o.bounds.distances.right, x = o.bounds.y - o.bounds.distances.top, w = o.bounds.y + o.bounds.distances.bottom;
64
+ console.log(
65
+ `B1: (${f}, ${x}), (${f}, ${w}), (${m}, ${x}), (${m}, ${w}), (${o.bounds.x}, ${o.bounds.y})`,
66
+ o.angle
67
+ );
68
+ const $ = s.bounds.x - s.bounds.distances.left, y = s.bounds.x + s.bounds.distances.right, p = s.bounds.y - s.bounds.distances.top, z = s.bounds.y + s.bounds.distances.bottom;
69
+ throw console.log(
70
+ `B2: (${$}, ${p}), (${$}, ${z}), (${y}, ${p}), (${y}, ${z}), (${s.bounds.x}, ${s.bounds.y})`,
71
+ s.angle
72
+ ), new Error("Bounds overlaping");
65
73
  }
66
74
  }
67
75
  }
package/dist/index.d.ts CHANGED
@@ -344,7 +344,7 @@ declare const mapProviderSchema: z.ZodObject<{
344
344
  export type MapBounds = z.infer<typeof mapBoundsSchema>;
345
345
  export type MapProvider = z.infer<typeof mapProviderSchema>;
346
346
  export type MapProviderMarker = z.infer<typeof mapProviderMarkerSchema>;
347
- export type MapProviderParameters = z.infer<typeof mapProviderParametersSchema>;
347
+ type MapProviderParameters = z.infer<typeof mapProviderParametersSchema>;
348
348
  declare const mapMarkerSchema: z.ZodObject<{
349
349
  id: z.ZodString;
350
350
  rank: z.ZodNumber;
@@ -785,6 +785,10 @@ export declare const GoogleMapDarkStyle: ({
785
785
  export declare function getStates(parameters: MapProviderParameters, data: Array<MapTooltipStateInput>): MapTooltipState[];
786
786
  export declare function testStates(parameters: MapProviderParameters, inputs: MapTooltipStateInput[], states: MapTooltipState[]): void;
787
787
 
788
+ export {
789
+ MapProviderParameters as MapTooltipStatesParameters,
790
+ };
791
+
788
792
  export as namespace arenarium;
789
793
 
790
794
  export {};