proximiio-js-library 1.11.21 → 1.11.23
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 +1 -0
- package/lib/common.js +34 -1
- package/lib/components/map/main.js +4 -1
- package/lib/controllers/geo.js +7 -7
- package/lib/proximiio.js +1 -1
- package/package.json +1 -1
package/lib/common.d.ts
CHANGED
|
@@ -6,3 +6,4 @@ export declare const getImageFromBase64: (encoded: string) => Promise<HTMLImageE
|
|
|
6
6
|
export declare const getBase64FromImage: (file: File) => Promise<string>;
|
|
7
7
|
export declare const uuidv4: () => any;
|
|
8
8
|
export declare const getNestedObjectValue: (nestedObject: any, dynamicKey: any) => any;
|
|
9
|
+
export declare const removeNonNumeric: (uuid: string) => string;
|
package/lib/common.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import Axios from 'axios';
|
|
2
2
|
export const axios = Axios.create({
|
|
3
3
|
baseURL: 'https://api.proximi.fi',
|
|
4
|
-
timeout: 60000,
|
|
5
4
|
});
|
|
6
5
|
export const camelToKebab = (input) => input.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
|
|
7
6
|
export const kebabToCamel = (input) => input.replace(/-([a-z])/g, (g) => g[1].toUpperCase());
|
|
@@ -58,3 +57,37 @@ export const getNestedObjectValue = (nestedObject, dynamicKey) => {
|
|
|
58
57
|
// Get the value of the remaining keys in the nested object.
|
|
59
58
|
return getNestedObjectValue(value, remainingKeys);
|
|
60
59
|
};
|
|
60
|
+
// Function to remove non-numeric characters
|
|
61
|
+
export const removeNonNumeric = (uuid) => {
|
|
62
|
+
// Remove hyphens from the UUID
|
|
63
|
+
uuid = uuid.replace(/[^0-9.]/g, '');
|
|
64
|
+
// Initialize the result string
|
|
65
|
+
let result = '';
|
|
66
|
+
// Variable to track whether we are capturing the first or last number
|
|
67
|
+
let captureFirst = true;
|
|
68
|
+
// Index for capturing the first number
|
|
69
|
+
let firstIndex = 0;
|
|
70
|
+
// Index for capturing the last number
|
|
71
|
+
let lastIndex = uuid.length - 1;
|
|
72
|
+
// Loop until we have enough digits or run out of digits in the UUID
|
|
73
|
+
while (result.length < 10 && firstIndex <= lastIndex) {
|
|
74
|
+
// If we're capturing the first number
|
|
75
|
+
if (captureFirst) {
|
|
76
|
+
// Add the first numerical digit to the result
|
|
77
|
+
result += uuid[firstIndex];
|
|
78
|
+
// Move to the next digit for the next iteration
|
|
79
|
+
firstIndex++;
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
// Add the last numerical digit to the result
|
|
83
|
+
result += uuid[lastIndex];
|
|
84
|
+
// Move to the previous digit for the next iteration
|
|
85
|
+
lastIndex--;
|
|
86
|
+
}
|
|
87
|
+
// Toggle between capturing first and last numbers
|
|
88
|
+
captureFirst = !captureFirst;
|
|
89
|
+
}
|
|
90
|
+
// Truncate the result to fit within 10 bytes
|
|
91
|
+
result = result.slice(0, 10);
|
|
92
|
+
return result;
|
|
93
|
+
};
|
|
@@ -635,7 +635,7 @@ export class Map {
|
|
|
635
635
|
});
|
|
636
636
|
const levelChangers = features.features.filter((f) => f.properties.type === 'elevator' || f.properties.type === 'escalator' || f.properties.type === 'staircase');
|
|
637
637
|
this.state = Object.assign(Object.assign({}, this.state), { features, allFeatures: new FeatureCollection(features), levelChangers: new FeatureCollection({ features: levelChangers }) });
|
|
638
|
-
this.geojsonSource.fetch(this.state.features);
|
|
638
|
+
// this.geojsonSource.fetch(this.state.features);
|
|
639
639
|
this.onFeaturesChange();
|
|
640
640
|
}
|
|
641
641
|
});
|
|
@@ -2220,7 +2220,10 @@ export class Map {
|
|
|
2220
2220
|
this.defaultOptions.kioskSettings.showLabel &&
|
|
2221
2221
|
this.map.getLayer('my-location-layer')) {
|
|
2222
2222
|
this.map.setLayoutProperty('my-location-layer', 'text-field', translations[this.defaultOptions.language].YOU_ARE_HERE);
|
|
2223
|
+
const styleLayer = this.state.style.layers.find((layer) => layer.id === 'my-location-layer');
|
|
2224
|
+
styleLayer.layout['text-field'] = translations[this.defaultOptions.language].YOU_ARE_HERE;
|
|
2223
2225
|
}
|
|
2226
|
+
this.state.style.setSource('main', this.geojsonSource);
|
|
2224
2227
|
}
|
|
2225
2228
|
getClosestFeature(amenityId, fromFeature) {
|
|
2226
2229
|
let sameLevelfeatures = this.state.allFeatures.features.filter((i) => i.properties.amenity === amenityId &&
|
package/lib/controllers/geo.js
CHANGED
|
@@ -7,7 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { axios, getNestedObjectValue } from '../common';
|
|
10
|
+
import { axios, getNestedObjectValue, removeNonNumeric } from '../common';
|
|
11
11
|
import Feature, { FeatureCollection } from '../models/feature';
|
|
12
12
|
import { AmenityModel } from '../models/amenity';
|
|
13
13
|
import { globalState } from '../components/map/main';
|
|
@@ -119,7 +119,7 @@ export const getFeatures = ({ initPolygons, polygonFeatureTypes, autoLabelLines,
|
|
|
119
119
|
connectedPolygon.properties._dynamic.poi_id = feature.properties.id;
|
|
120
120
|
connectedPolygon.properties._dynamic.amenity = feature.properties.amenity;
|
|
121
121
|
// id have to be changed to numeric type so feature state will work
|
|
122
|
-
connectedPolygon.id =
|
|
122
|
+
connectedPolygon.id = removeNonNumeric(connectedPolygon.id);
|
|
123
123
|
// check if feature is inside a polygon
|
|
124
124
|
labelLineFeatures.forEach((line) => {
|
|
125
125
|
var _a, _b;
|
|
@@ -131,7 +131,7 @@ export const getFeatures = ({ initPolygons, polygonFeatureTypes, autoLabelLines,
|
|
|
131
131
|
});
|
|
132
132
|
if (connectedLabelLine) {
|
|
133
133
|
// id have to be changed to numeric type so feature state will work
|
|
134
|
-
connectedLabelLine.id =
|
|
134
|
+
connectedLabelLine.id = removeNonNumeric(connectedLabelLine.id);
|
|
135
135
|
feature.properties._dynamic.label_id = connectedLabelLine.id;
|
|
136
136
|
connectedPolygon.properties._dynamic.label_id = connectedLabelLine.id;
|
|
137
137
|
connectedLabelLine.properties._dynamic = connectedLabelLine.properties._dynamic
|
|
@@ -162,8 +162,8 @@ export const getFeatures = ({ initPolygons, polygonFeatureTypes, autoLabelLines,
|
|
|
162
162
|
coordinates: parsedLabelLine,
|
|
163
163
|
type: 'LineString',
|
|
164
164
|
};
|
|
165
|
-
labelLineFeature.properties.id =
|
|
166
|
-
labelLineFeature.id =
|
|
165
|
+
labelLineFeature.properties.id = `${removeNonNumeric(connectedPolygon.id)}9999`;
|
|
166
|
+
labelLineFeature.id = `${removeNonNumeric(connectedPolygon.id)}9999`;
|
|
167
167
|
labelLineFeature.properties.type = `${featureType}-label`;
|
|
168
168
|
labelLineFeature.properties._dynamic.type = `${featureType}-label`;
|
|
169
169
|
labelLineFeature.properties._dynamic.length = Math.ceil(length(labelLineFeature) * 1000);
|
|
@@ -221,8 +221,8 @@ export const getFeatures = ({ initPolygons, polygonFeatureTypes, autoLabelLines,
|
|
|
221
221
|
console.error('No longest border found.');
|
|
222
222
|
}
|
|
223
223
|
// labelBorder.properties = { ...labelBorder.properties, ...feature.properties };
|
|
224
|
-
labelBorder.properties.id =
|
|
225
|
-
labelBorder.id =
|
|
224
|
+
labelBorder.properties.id = `${removeNonNumeric(connectedPolygon.id)}9999`;
|
|
225
|
+
labelBorder.id = `${removeNonNumeric(connectedPolygon.id)}9999`;
|
|
226
226
|
labelBorder.properties.type = `${featureType}-label`;
|
|
227
227
|
labelBorder.properties._dynamic.type = `${featureType}-label`;
|
|
228
228
|
connectedPolygon.properties._dynamic.label_id = labelBorder.properties.id;
|