proximiio-js-library 1.12.49 → 1.12.52
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/lib/common.d.ts +2 -1
- package/lib/common.js +5 -3
- package/lib/controllers/geo.js +13 -10
- package/lib/proximiio.js +1 -1
- package/package.json +1 -1
package/lib/common.d.ts
CHANGED
|
@@ -23,5 +23,6 @@ declare const convertToRTL: (arabicString: any) => any;
|
|
|
23
23
|
declare const base64toBlob: (base64: any) => Blob;
|
|
24
24
|
declare function throttle<T extends (...args: any[]) => any>(func: T, delay: number): (...args: Parameters<T>) => void;
|
|
25
25
|
declare const filterByAmenity: (data: any, filterCriteria?: string | string[]) => any[];
|
|
26
|
-
declare const validateLabelLine: (labelLine: string
|
|
26
|
+
declare const validateLabelLine: (labelLine: string | [
|
|
27
|
+
][], polygon: any, feature: any) => boolean;
|
|
27
28
|
export { calculateDimensions, convertToRTL, base64toBlob, throttle, filterByAmenity, validateLabelLine };
|
package/lib/common.js
CHANGED
|
@@ -169,9 +169,9 @@ const filterByAmenity = (data, filterCriteria) => {
|
|
|
169
169
|
return amenityMatches || includedAmenitiesMatch;
|
|
170
170
|
});
|
|
171
171
|
};
|
|
172
|
-
const validateLabelLine = (labelLine, polygon) => {
|
|
172
|
+
const validateLabelLine = (labelLine, polygon, feature) => {
|
|
173
173
|
try {
|
|
174
|
-
const coordinates = JSON.parse(labelLine);
|
|
174
|
+
const coordinates = typeof labelLine === 'string' ? JSON.parse(labelLine) : labelLine;
|
|
175
175
|
// 1. Validate that it's a valid JSON array of arrays
|
|
176
176
|
if (!Array.isArray(coordinates) || coordinates.length === 0) {
|
|
177
177
|
console.log('Input is not a valid array.');
|
|
@@ -197,7 +197,9 @@ const validateLabelLine = (labelLine, polygon) => {
|
|
|
197
197
|
return isInside;
|
|
198
198
|
}
|
|
199
199
|
catch (error) {
|
|
200
|
-
console.
|
|
200
|
+
console.log('Invalid input:', error.message);
|
|
201
|
+
console.log('for feature:', feature);
|
|
202
|
+
console.log('for polygon:', polygon);
|
|
201
203
|
return false;
|
|
202
204
|
}
|
|
203
205
|
};
|
package/lib/controllers/geo.js
CHANGED
|
@@ -180,10 +180,11 @@ export const getFeatures = ({ initPolygons, polygonFeatureTypes, autoLabelLines,
|
|
|
180
180
|
// or if not check if the polygon is defined in metadata and use it instead
|
|
181
181
|
if (!connectedPolygon && feature.properties.metadata && feature.properties.metadata.polygon_id) {
|
|
182
182
|
connectedPolygon = res.data.features.find((f) => {
|
|
183
|
-
var _a, _b;
|
|
183
|
+
var _a, _b, _c, _d;
|
|
184
184
|
return f.properties.type === featureType &&
|
|
185
|
-
((_a = f.properties.id) === null || _a === void 0 ? void 0 : _a.replace(/\{|\}/g, '')) ===
|
|
186
|
-
((_b = feature.properties.metadata.polygon_id) === null || _b === void 0 ? void 0 : _b.replace(/\{|\}/g, ''))
|
|
185
|
+
(((_a = f.properties.id) === null || _a === void 0 ? void 0 : _a.replace(/\{|\}/g, '')) ===
|
|
186
|
+
((_b = feature.properties.metadata.polygon_id) === null || _b === void 0 ? void 0 : _b.replace(/\{|\}/g, '')) ||
|
|
187
|
+
((_c = f.id) === null || _c === void 0 ? void 0 : _c.replace(/\{|\}/g, '')) === ((_d = feature.properties.metadata.polygon_id) === null || _d === void 0 ? void 0 : _d.replace(/\{|\}/g, '')));
|
|
187
188
|
});
|
|
188
189
|
}
|
|
189
190
|
if (connectedPolygon) {
|
|
@@ -249,7 +250,7 @@ export const getFeatures = ({ initPolygons, polygonFeatureTypes, autoLabelLines,
|
|
|
249
250
|
if (labelLine &&
|
|
250
251
|
labelLine !== undefined &&
|
|
251
252
|
labelLine.length > 0 &&
|
|
252
|
-
validateLabelLine(labelLine, connectedPolygon)) {
|
|
253
|
+
validateLabelLine(labelLine, connectedPolygon, feature)) {
|
|
253
254
|
const parsedLabelLine = typeof labelLine === 'string' ? JSON.parse(labelLine) : labelLine;
|
|
254
255
|
if (parsedLabelLine[0] instanceof Array && parsedLabelLine[1] instanceof Array) {
|
|
255
256
|
const labelLineFeature = JSON.parse(JSON.stringify(feature));
|
|
@@ -403,11 +404,13 @@ export const getFeaturesBundle = ({ initPolygons, polygonFeatureTypes, autoLabel
|
|
|
403
404
|
// or if not check if the polygon is defined in metadata and use it instead
|
|
404
405
|
if (!connectedPolygon && feature.properties.metadata && feature.properties.metadata.polygon_id) {
|
|
405
406
|
const polygonId = feature.properties.metadata.polygon_id.replace(/\{|\}/g, '');
|
|
406
|
-
connectedPolygon = data.features.find((f) => {
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
407
|
+
connectedPolygon = data.features.find((f) => { var _a; return ((_a = f.properties.id) === null || _a === void 0 ? void 0 : _a.replace(/\{|\}/g, '')) === polygonId || f.id.replace(/\{|\}/g, '') === polygonId; });
|
|
408
|
+
connectedPolygon =
|
|
409
|
+
connectedPolygon &&
|
|
410
|
+
connectedPolygon.properties.type ===
|
|
411
|
+
polygonFeatureTypes.find((type) => type === connectedPolygon.properties.type)
|
|
412
|
+
? connectedPolygon
|
|
413
|
+
: undefined;
|
|
411
414
|
}
|
|
412
415
|
if (connectedPolygon) {
|
|
413
416
|
feature.properties._dynamic = feature.properties._dynamic ? feature.properties._dynamic : {};
|
|
@@ -471,7 +474,7 @@ export const getFeaturesBundle = ({ initPolygons, polygonFeatureTypes, autoLabel
|
|
|
471
474
|
if (labelLine &&
|
|
472
475
|
labelLine !== undefined &&
|
|
473
476
|
labelLine.length > 0 &&
|
|
474
|
-
validateLabelLine(labelLine, connectedPolygon)) {
|
|
477
|
+
validateLabelLine(labelLine, connectedPolygon, feature)) {
|
|
475
478
|
const parsedLabelLine = typeof labelLine === 'string' ? JSON.parse(labelLine) : labelLine;
|
|
476
479
|
if (parsedLabelLine[0] instanceof Array && parsedLabelLine[1] instanceof Array) {
|
|
477
480
|
const labelLineFeature = JSON.parse(JSON.stringify(feature));
|