@wikicasa-dev/utilities 1.1.15 → 1.1.17

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/dist/MapUtils.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("google-polyline");function i(t){if(!t)return;const n=t.match(/[-]?[\d]*[.]?[\d]+/g);if(!n)return;const e=[];for(let l=0;l<n.length;l++)e.push({lat:parseFloat(n[l+1]),lng:parseFloat(n[l])}),l++;return e}function c(t,n=!0){const e=[];t.forEach(o=>{e.push([o.lat,o.lng])});const l=r.encode(e);return n?encodeURIComponent(l):l}function g(t){const n={minY:t[0].lat,maxY:t[0].lat,minX:t[0].lng,maxX:t[0].lng};return t.forEach(e=>{n.minY=Math.min(n.minY,e.lat),n.maxY=Math.max(n.maxY,e.lat),n.minX=Math.min(n.minX,e.lng),n.maxX=Math.max(n.maxX,e.lng)}),n}function u(t){if(t.length<=0)return[];const n=new Set;return t.filter(l=>{const o=n.has(l.lat+l.lng),a=l.lat+l.lng;return n.add(a),!o})}function m(t){let n=0,e=0;for(let l=0;l<t.length;l++){const o=t[l];n+=o.lat,e+=o.lng}return{lat:n/t.length,lng:e/t.length}}function s(t){let n="POLYGON((";return t.forEach(e=>{n+=`${e.lng} ${e.lat}, `}),n+=`${t[0].lng} ${t[0].lat}))`,n}exports.calcPolygonCenter=m;exports.encodePolygon=c;exports.getMinMaxLatLng=g;exports.getPolygonString=s;exports.parsePoints=i;exports.removeDuplicatePoints=u;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("google-polyline");function i(t){if(!t)return;const n=t.match(/[-]?[\d]*[.]?[\d]+/g);if(!n)return;const e=[];for(let l=0;l<n.length;l++)e.push({lat:parseFloat(n[l+1]),lng:parseFloat(n[l])}),l++;return e}function c(t,n=!0){const e=[];t.forEach(r=>{Array.isArray(r)?e.push(r):e.push([r.lat,r.lng])});const l=o.encode(e);return n?encodeURIComponent(l):l}function g(t){const n={minY:t[0].lat,maxY:t[0].lat,minX:t[0].lng,maxX:t[0].lng};return t.forEach(e=>{n.minY=Math.min(n.minY,e.lat),n.maxY=Math.max(n.maxY,e.lat),n.minX=Math.min(n.minX,e.lng),n.maxX=Math.max(n.maxX,e.lng)}),n}function u(t){if(t.length<=0)return[];const n=new Set;return t.filter(l=>{const r=n.has(l.lat+l.lng),a=l.lat+l.lng;return n.add(a),!r})}function m(t){let n=0,e=0;for(let l=0;l<t.length;l++){const r=t[l];n+=r.lat,e+=r.lng}return{lat:n/t.length,lng:e/t.length}}function s(t){let n="POLYGON((";return t.forEach(e=>{n+=`${e.lng} ${e.lat}, `}),n+=`${t[0].lng} ${t[0].lat}))`,n}exports.calcPolygonCenter=m;exports.encodePolygon=c;exports.getMinMaxLatLng=g;exports.getPolygonString=s;exports.parsePoints=i;exports.removeDuplicatePoints=u;
package/dist/MapUtils.js CHANGED
@@ -4,20 +4,20 @@ function c(t) {
4
4
  const n = t.match(/[-]?[\d]*[.]?[\d]+/g);
5
5
  if (!n) return;
6
6
  const e = [];
7
- for (let l = 0; l < n.length; l++)
7
+ for (let r = 0; r < n.length; r++)
8
8
  e.push({
9
- lat: parseFloat(n[l + 1]),
10
- lng: parseFloat(n[l])
11
- }), l++;
9
+ lat: parseFloat(n[r + 1]),
10
+ lng: parseFloat(n[r])
11
+ }), r++;
12
12
  return e;
13
13
  }
14
14
  function u(t, n = !0) {
15
15
  const e = [];
16
- t.forEach((a) => {
17
- e.push([a.lat, a.lng]);
16
+ t.forEach((l) => {
17
+ Array.isArray(l) ? e.push(l) : e.push([l.lat, l.lng]);
18
18
  });
19
- const l = o(e);
20
- return n ? encodeURIComponent(l) : l;
19
+ const r = o(e);
20
+ return n ? encodeURIComponent(r) : r;
21
21
  }
22
22
  function g(t) {
23
23
  const n = {
@@ -33,20 +33,20 @@ function g(t) {
33
33
  function m(t) {
34
34
  if (t.length <= 0) return [];
35
35
  const n = /* @__PURE__ */ new Set();
36
- return t.filter((l) => {
37
- const a = n.has(l.lat + l.lng), r = l.lat + l.lng;
38
- return n.add(r), !a;
36
+ return t.filter((r) => {
37
+ const l = n.has(r.lat + r.lng), a = r.lat + r.lng;
38
+ return n.add(a), !l;
39
39
  });
40
40
  }
41
41
  function f(t) {
42
42
  let n = 0, e = 0;
43
- for (let l = 0; l < t.length; l++) {
44
- const a = t[l];
45
- n += a.lat, e += a.lng;
43
+ for (let r = 0; r < t.length; r++) {
44
+ const l = t[r];
45
+ n += l.lat, e += l.lng;
46
46
  }
47
47
  return { lat: n / t.length, lng: e / t.length };
48
48
  }
49
- function h(t) {
49
+ function s(t) {
50
50
  let n = "POLYGON((";
51
51
  return t.forEach((e) => {
52
52
  n += `${e.lng} ${e.lat}, `;
@@ -56,7 +56,7 @@ export {
56
56
  f as calcPolygonCenter,
57
57
  u as encodePolygon,
58
58
  g as getMinMaxLatLng,
59
- h as getPolygonString,
59
+ s as getPolygonString,
60
60
  c as parsePoints,
61
61
  m as removeDuplicatePoints
62
62
  };
@@ -2,10 +2,11 @@ import { LatLng } from 'leaflet';
2
2
 
3
3
  export declare function parsePoints(polygonFromMap: string): Array<LatLng> | undefined;
4
4
  /**
5
- * @param polygon An array of latitude and polygon that will be used to design an area in a map
6
- * @param forUrl If true, the output string will be encoded as a URI so respecting the UTF-8 encoding
7
- * */
8
- export declare function encodePolygon(polygon: Array<LatLng>, forUrl?: boolean): string;
5
+ * Parses a string representation of a polygon and converts it to an array of LatLng coordinates.
6
+ * @param polygonFromMap - String representation of polygon coordinates
7
+ * @returns Array of LatLng objects or undefined if input is invalid
8
+ */
9
+ export declare function encodePolygon(polygon: Array<LatLng | [number, number]>, forUrl?: boolean): string;
9
10
  export declare function getMinMaxLatLng(polygon: Array<LatLng>): {
10
11
  minY: number;
11
12
  maxY: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wikicasa-dev/utilities",
3
- "version": "1.1.15",
3
+ "version": "1.1.17",
4
4
  "description": "Wikicasa frontend utilities",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",