@wikicasa-dev/utilities 1.1.15 → 1.1.18
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 +1 -1
- package/dist/MapUtils.js +16 -16
- package/dist/utils/MapUtils.d.ts +5 -4
- package/package.json +1 -8
package/dist/MapUtils.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
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
|
|
7
|
+
for (let r = 0; r < n.length; r++)
|
|
8
8
|
e.push({
|
|
9
|
-
lat: parseFloat(n[
|
|
10
|
-
lng: parseFloat(n[
|
|
11
|
-
}),
|
|
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((
|
|
17
|
-
e.push([
|
|
16
|
+
t.forEach((l) => {
|
|
17
|
+
Array.isArray(l) ? e.push(l) : e.push([l.lat, l.lng]);
|
|
18
18
|
});
|
|
19
|
-
const
|
|
20
|
-
return n ? encodeURIComponent(
|
|
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((
|
|
37
|
-
const
|
|
38
|
-
return n.add(
|
|
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
|
|
44
|
-
const
|
|
45
|
-
n +=
|
|
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
|
|
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
|
-
|
|
59
|
+
s as getPolygonString,
|
|
60
60
|
c as parsePoints,
|
|
61
61
|
m as removeDuplicatePoints
|
|
62
62
|
};
|
package/dist/utils/MapUtils.d.ts
CHANGED
|
@@ -2,10 +2,11 @@ import { LatLng } from 'leaflet';
|
|
|
2
2
|
|
|
3
3
|
export declare function parsePoints(polygonFromMap: string): Array<LatLng> | undefined;
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
* @param
|
|
7
|
-
*
|
|
8
|
-
|
|
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.
|
|
3
|
+
"version": "1.1.18",
|
|
4
4
|
"description": "Wikicasa frontend utilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -30,9 +30,6 @@
|
|
|
30
30
|
"@types/jquery": "^3.5.16",
|
|
31
31
|
"@types/js-cookie": "^3.0.6",
|
|
32
32
|
"@types/leaflet": "^1.9.3",
|
|
33
|
-
"@types/leaflet-draw": "^1.0.7",
|
|
34
|
-
"@types/leaflet-freedraw": "^2.13.3",
|
|
35
|
-
"@types/leaflet.markercluster": "^1.5.1",
|
|
36
33
|
"@types/node": "^20.5.0",
|
|
37
34
|
"@types/uuid": "^9.0.2",
|
|
38
35
|
"@wikicasa-dev/types": "^1.14.6",
|
|
@@ -49,10 +46,6 @@
|
|
|
49
46
|
"google-polyline": "^1.0.3",
|
|
50
47
|
"jest": "^29.7.0",
|
|
51
48
|
"js-cookie": "^3.0.5",
|
|
52
|
-
"leaflet": "^1.9.4",
|
|
53
|
-
"leaflet-control-geocoder": "^2.4.0",
|
|
54
|
-
"leaflet-draw": "^1.0.4",
|
|
55
|
-
"leaflet-freedraw": "^2.13.3",
|
|
56
49
|
"uuid": "^9.0.0"
|
|
57
50
|
},
|
|
58
51
|
"scripts": {
|