venue-js 1.4.0-next.17 → 1.4.0-next.19
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/data/index.d.mts +3 -941
- package/dist/data/index.d.ts +3 -941
- package/dist/data/index.js +1618 -1300
- package/dist/data/index.js.map +1 -1
- package/dist/data/index.mjs +1608 -1300
- package/dist/data/index.mjs.map +1 -1
- package/dist/index-C1nZyY-F.d.mts +1002 -0
- package/dist/index-C1nZyY-F.d.ts +1002 -0
- package/dist/index.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1820 -1721
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1806 -1707
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -1
package/dist/index.js
CHANGED
|
@@ -495,6 +495,19 @@ var findContainingUnit = (poi, units) => {
|
|
|
495
495
|
);
|
|
496
496
|
return unit;
|
|
497
497
|
};
|
|
498
|
+
var findContainingUnitAtPoint = (point2, levelId, units) => {
|
|
499
|
+
const unit = units.find(
|
|
500
|
+
(unit2) => {
|
|
501
|
+
try {
|
|
502
|
+
return unit2.properties.level_id === levelId && (0, import_boolean_point_in_polygon.booleanPointInPolygon)(point2, unit2);
|
|
503
|
+
} catch (e) {
|
|
504
|
+
console.log(`Cannot find containing unit of (point: ${point2}, levelId: ${levelId}):`, e.message);
|
|
505
|
+
return false;
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
);
|
|
509
|
+
return unit;
|
|
510
|
+
};
|
|
498
511
|
|
|
499
512
|
// src/data/populator/index.ts
|
|
500
513
|
var createPopulator = ({
|
|
@@ -667,6 +680,19 @@ var createPopulator = ({
|
|
|
667
680
|
}
|
|
668
681
|
};
|
|
669
682
|
};
|
|
683
|
+
const populateSection = async (section) => {
|
|
684
|
+
const venue = await internalFindById(section.properties.venue_id);
|
|
685
|
+
const level = await internalFindById(section.properties.level_id);
|
|
686
|
+
return {
|
|
687
|
+
...section,
|
|
688
|
+
properties: {
|
|
689
|
+
...section.properties,
|
|
690
|
+
venue,
|
|
691
|
+
level: await populateLevel(level),
|
|
692
|
+
ordinal: level.properties.ordinal
|
|
693
|
+
}
|
|
694
|
+
};
|
|
695
|
+
};
|
|
670
696
|
const populateRelationship = async (relationship) => {
|
|
671
697
|
const originId = relationship.properties.origin?.id;
|
|
672
698
|
const destinationId = relationship.properties.destination?.id;
|
|
@@ -684,19 +710,6 @@ var createPopulator = ({
|
|
|
684
710
|
}
|
|
685
711
|
};
|
|
686
712
|
};
|
|
687
|
-
const populateSection = async (section) => {
|
|
688
|
-
const venue = await internalFindById(section.properties.venue_id);
|
|
689
|
-
const level = await internalFindById(section.properties.level_id);
|
|
690
|
-
return {
|
|
691
|
-
...section,
|
|
692
|
-
properties: {
|
|
693
|
-
...section.properties,
|
|
694
|
-
venue,
|
|
695
|
-
level: await populateLevel(level),
|
|
696
|
-
ordinal: level.properties.ordinal
|
|
697
|
-
}
|
|
698
|
-
};
|
|
699
|
-
};
|
|
700
713
|
const populateUnit = async (unit) => {
|
|
701
714
|
const venue = await internalFindById(unit.properties.venue_id);
|
|
702
715
|
const level = await internalFindById(unit.properties.level_id);
|
|
@@ -773,1366 +786,1649 @@ var createPopulator = ({
|
|
|
773
786
|
};
|
|
774
787
|
};
|
|
775
788
|
|
|
776
|
-
//
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
var
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
}
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
}
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
}
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
}
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
}
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
}
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
}
|
|
815
|
-
var INCORRECT_INDEX_TYPE = "Incorrect 'index' type";
|
|
816
|
-
var LOGICAL_SEARCH_INVALID_QUERY_FOR_KEY = (key) => `Invalid value for key ${key}`;
|
|
817
|
-
var PATTERN_LENGTH_TOO_LARGE = (max2) => `Pattern length exceeds max of ${max2}.`;
|
|
818
|
-
var MISSING_KEY_PROPERTY = (name) => `Missing ${name} property in key`;
|
|
819
|
-
var INVALID_KEY_WEIGHT_VALUE = (key) => `Property 'weight' in key '${key}' must be a positive integer`;
|
|
820
|
-
var hasOwn = Object.prototype.hasOwnProperty;
|
|
821
|
-
var KeyStore = class {
|
|
822
|
-
constructor(keys) {
|
|
823
|
-
this._keys = [];
|
|
824
|
-
this._keyMap = {};
|
|
825
|
-
let totalWeight = 0;
|
|
826
|
-
keys.forEach((key) => {
|
|
827
|
-
let obj = createKey(key);
|
|
828
|
-
this._keys.push(obj);
|
|
829
|
-
this._keyMap[obj.id] = obj;
|
|
830
|
-
totalWeight += obj.weight;
|
|
831
|
-
});
|
|
832
|
-
this._keys.forEach((key) => {
|
|
833
|
-
key.weight /= totalWeight;
|
|
834
|
-
});
|
|
835
|
-
}
|
|
836
|
-
get(keyId) {
|
|
837
|
-
return this._keyMap[keyId];
|
|
838
|
-
}
|
|
839
|
-
keys() {
|
|
840
|
-
return this._keys;
|
|
841
|
-
}
|
|
842
|
-
toJSON() {
|
|
843
|
-
return JSON.stringify(this._keys);
|
|
844
|
-
}
|
|
789
|
+
// src/data/search/getSearchClient.ts
|
|
790
|
+
var import_fuse = __toESM(require("fuse.js"));
|
|
791
|
+
|
|
792
|
+
// src/data/search/utils/sanitizeInput.ts
|
|
793
|
+
var sanitizeInput = (str) => str.replace(/[\u200E\u200F\u202A-\u202E\u2066-\u2069]/g, "").replace(/[\-–—_./()]+/g, "").normalize("NFC").trim();
|
|
794
|
+
|
|
795
|
+
// src/data/search/getSearchClient.ts
|
|
796
|
+
var getSearchClient = ({ occupants, amenities }) => {
|
|
797
|
+
const fuseAmenities = new import_fuse.default(amenities, {
|
|
798
|
+
threshold: 0.2,
|
|
799
|
+
keys: [
|
|
800
|
+
{ name: "properties.name", "weight": 1, getFn: (obj) => Object.values(obj.properties.name || {}) },
|
|
801
|
+
{ name: "properties.category", "weight": 1 }
|
|
802
|
+
]
|
|
803
|
+
});
|
|
804
|
+
const fuseOccupants = new import_fuse.default(occupants, {
|
|
805
|
+
threshold: 0.25,
|
|
806
|
+
// 0.2 is too strict (can't find Mo-Mo Paradise with "momo" search string)
|
|
807
|
+
includeScore: true,
|
|
808
|
+
shouldSort: true,
|
|
809
|
+
keys: [
|
|
810
|
+
{ name: "properties.name", "weight": 4, getFn: (obj) => Object.values(obj.properties.name || {}) },
|
|
811
|
+
{ name: "properties.keywords", "weight": 0.5 },
|
|
812
|
+
{ name: "properties.category", "weight": 0.25 },
|
|
813
|
+
{ name: "properties.local_category_names", "weight": 0.25 },
|
|
814
|
+
{ name: "properties.description", "weight": 0.25, getFn: (occ) => Object.values(occ.properties.description || {}) },
|
|
815
|
+
{ name: "properties.unit_name", "weight": 0.25 },
|
|
816
|
+
{ name: "properties.kiosk_name", "weight": 0.25 }
|
|
817
|
+
]
|
|
818
|
+
});
|
|
819
|
+
const search = (value) => {
|
|
820
|
+
const sanitizedValue = sanitizeInput(value);
|
|
821
|
+
const matchedAmenities = fuseAmenities.search(sanitizedValue);
|
|
822
|
+
const matchedOccupants = fuseOccupants.search(sanitizedValue);
|
|
823
|
+
return [...matchedAmenities, ...matchedOccupants];
|
|
824
|
+
};
|
|
825
|
+
return {
|
|
826
|
+
search
|
|
827
|
+
};
|
|
845
828
|
};
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
829
|
+
|
|
830
|
+
// src/data/navigate/getNavigateClient.ts
|
|
831
|
+
var import_boolean_point_in_polygon4 = require("@turf/boolean-point-in-polygon");
|
|
832
|
+
|
|
833
|
+
// src/data/navigate/graph/prepare.ts
|
|
834
|
+
var import_lodash10 = __toESM(require("lodash"));
|
|
835
|
+
var import_node_dijkstra = __toESM(require("node-dijkstra"));
|
|
836
|
+
var import_distance3 = require("@turf/distance");
|
|
837
|
+
var import_center5 = require("@turf/center");
|
|
838
|
+
|
|
839
|
+
// src/data/navigate/graph/nodemap/createTraversalNodeMap.ts
|
|
840
|
+
var import_distance = require("@turf/distance");
|
|
841
|
+
var import_center3 = require("@turf/center");
|
|
842
|
+
var import_lodash3 = __toESM(require("lodash"));
|
|
843
|
+
|
|
844
|
+
// src/data/navigate/graph/constants.ts
|
|
845
|
+
var ROOM_BASEDISTANCE = 1e3;
|
|
846
|
+
var TERRACE_BASEDISTANCE = 1e3;
|
|
847
|
+
var ESCALATOR_BASEDISTANCE = 200;
|
|
848
|
+
var RAMP_BASEDISTANCE = 200;
|
|
849
|
+
var ELEVATOR_BASEDISTANCE = 500;
|
|
850
|
+
var STAIR_BASEDISTANCE = 1e5;
|
|
851
|
+
var BASE_POI_BASEDISTANCE = 9999999;
|
|
852
|
+
var DEFAULT_UNIT_BASEDISTANCE_OPTIONS = {
|
|
853
|
+
default: { baseDistance: 0 },
|
|
854
|
+
byCategory: {
|
|
855
|
+
room: { baseDistance: ROOM_BASEDISTANCE },
|
|
856
|
+
terrace: { baseDistance: TERRACE_BASEDISTANCE },
|
|
857
|
+
escalator: { baseDistance: ESCALATOR_BASEDISTANCE, scaleDistanceByLevel: false },
|
|
858
|
+
ramp: { baseDistance: RAMP_BASEDISTANCE, scaleDistanceByLevel: false },
|
|
859
|
+
elevator: { baseDistance: ELEVATOR_BASEDISTANCE, scaleDistanceByLevel: false },
|
|
860
|
+
stairs: {
|
|
861
|
+
baseDistance: STAIR_BASEDISTANCE,
|
|
862
|
+
scaleDistanceByLevel: true
|
|
863
|
+
},
|
|
864
|
+
"stairs.emergencyexit": {
|
|
865
|
+
baseDistance: STAIR_BASEDISTANCE,
|
|
866
|
+
scaleDistanceByLevel: true
|
|
867
867
|
}
|
|
868
|
-
path = createKeyPath(name);
|
|
869
|
-
id = createKeyId(name);
|
|
870
|
-
getFn = key.getFn;
|
|
871
868
|
}
|
|
872
|
-
return { path, id, weight, src, getFn };
|
|
873
|
-
}
|
|
874
|
-
function createKeyPath(key) {
|
|
875
|
-
return isArray(key) ? key : key.split(".");
|
|
876
|
-
}
|
|
877
|
-
function createKeyId(key) {
|
|
878
|
-
return isArray(key) ? key.join(".") : key;
|
|
879
|
-
}
|
|
880
|
-
function get(obj, path) {
|
|
881
|
-
let list = [];
|
|
882
|
-
let arr = false;
|
|
883
|
-
const deepGet = (obj2, path2, index) => {
|
|
884
|
-
if (!isDefined(obj2)) {
|
|
885
|
-
return;
|
|
886
|
-
}
|
|
887
|
-
if (!path2[index]) {
|
|
888
|
-
list.push(obj2);
|
|
889
|
-
} else {
|
|
890
|
-
let key = path2[index];
|
|
891
|
-
const value = obj2[key];
|
|
892
|
-
if (!isDefined(value)) {
|
|
893
|
-
return;
|
|
894
|
-
}
|
|
895
|
-
if (index === path2.length - 1 && (isString(value) || isNumber(value) || isBoolean(value))) {
|
|
896
|
-
list.push(toString(value));
|
|
897
|
-
} else if (isArray(value)) {
|
|
898
|
-
arr = true;
|
|
899
|
-
for (let i = 0, len = value.length; i < len; i += 1) {
|
|
900
|
-
deepGet(value[i], path2, index + 1);
|
|
901
|
-
}
|
|
902
|
-
} else if (path2.length) {
|
|
903
|
-
deepGet(value, path2, index + 1);
|
|
904
|
-
}
|
|
905
|
-
}
|
|
906
|
-
};
|
|
907
|
-
deepGet(obj, isString(path) ? path.split(".") : path, 0);
|
|
908
|
-
return arr ? list : list[0];
|
|
909
|
-
}
|
|
910
|
-
var MatchOptions = {
|
|
911
|
-
// Whether the matches should be included in the result set. When `true`, each record in the result
|
|
912
|
-
// set will include the indices of the matched characters.
|
|
913
|
-
// These can consequently be used for highlighting purposes.
|
|
914
|
-
includeMatches: false,
|
|
915
|
-
// When `true`, the matching function will continue to the end of a search pattern even if
|
|
916
|
-
// a perfect match has already been located in the string.
|
|
917
|
-
findAllMatches: false,
|
|
918
|
-
// Minimum number of characters that must be matched before a result is considered a match
|
|
919
|
-
minMatchCharLength: 1
|
|
920
869
|
};
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
ignoreDiacritics: false,
|
|
927
|
-
// When true, the matching function will continue to the end of a search pattern even if
|
|
928
|
-
includeScore: false,
|
|
929
|
-
// List of properties that will be searched. This also supports nested properties.
|
|
930
|
-
keys: [],
|
|
931
|
-
// Whether to sort the result list, by score
|
|
932
|
-
shouldSort: true,
|
|
933
|
-
// Default sort function: sort by ascending score, ascending index
|
|
934
|
-
sortFn: (a, b) => a.score === b.score ? a.idx < b.idx ? -1 : 1 : a.score < b.score ? -1 : 1
|
|
935
|
-
};
|
|
936
|
-
var FuzzyOptions = {
|
|
937
|
-
// Approximately where in the text is the pattern expected to be found?
|
|
938
|
-
location: 0,
|
|
939
|
-
// At what point does the match algorithm give up. A threshold of '0.0' requires a perfect match
|
|
940
|
-
// (of both letters and location), a threshold of '1.0' would match anything.
|
|
941
|
-
threshold: 0.6,
|
|
942
|
-
// Determines how close the match must be to the fuzzy location (specified above).
|
|
943
|
-
// An exact letter match which is 'distance' characters away from the fuzzy location
|
|
944
|
-
// would score as a complete mismatch. A distance of '0' requires the match be at
|
|
945
|
-
// the exact location specified, a threshold of '1000' would require a perfect match
|
|
946
|
-
// to be within 800 characters of the fuzzy location to be found using a 0.8 threshold.
|
|
947
|
-
distance: 100
|
|
948
|
-
};
|
|
949
|
-
var AdvancedOptions = {
|
|
950
|
-
// When `true`, it enables the use of unix-like search commands
|
|
951
|
-
useExtendedSearch: false,
|
|
952
|
-
// The get function to use when fetching an object's properties.
|
|
953
|
-
// The default will search nested paths *ie foo.bar.baz*
|
|
954
|
-
getFn: get,
|
|
955
|
-
// When `true`, search will ignore `location` and `distance`, so it won't matter
|
|
956
|
-
// where in the string the pattern appears.
|
|
957
|
-
// More info: https://fusejs.io/concepts/scoring-theory.html#fuzziness-score
|
|
958
|
-
ignoreLocation: false,
|
|
959
|
-
// When `true`, the calculation for the relevance score (used for sorting) will
|
|
960
|
-
// ignore the field-length norm.
|
|
961
|
-
// More info: https://fusejs.io/concepts/scoring-theory.html#field-length-norm
|
|
962
|
-
ignoreFieldNorm: false,
|
|
963
|
-
// The weight to determine how much field length norm effects scoring.
|
|
964
|
-
fieldNormWeight: 1
|
|
870
|
+
|
|
871
|
+
// src/data/navigate/graph/utils/getDistanceOption.ts
|
|
872
|
+
var getDistanceOptions = (options, category) => {
|
|
873
|
+
if (!options) return DEFAULT_UNIT_BASEDISTANCE_OPTIONS.byCategory[category];
|
|
874
|
+
return (category && options.byCategory?.[category]) ?? DEFAULT_UNIT_BASEDISTANCE_OPTIONS.byCategory[category] ?? options?.default ?? DEFAULT_UNIT_BASEDISTANCE_OPTIONS.default;
|
|
965
875
|
};
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
...AdvancedOptions
|
|
876
|
+
|
|
877
|
+
// src/data/utils/trace.ts
|
|
878
|
+
var trace = (namespace, text, ms, color) => {
|
|
879
|
+
console.log(`[${namespace}] %c${text.padEnd(90)} ${ms !== void 0 ? `${ms.toFixed(1).padStart(6)} ms` : ``}`, color ? `color: ${color}` : void 0);
|
|
971
880
|
};
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
const
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
881
|
+
|
|
882
|
+
// src/data/navigate/graph/nodemap/createTraversalNodeMap.ts
|
|
883
|
+
var createTraversalNodeMap = (unitOpenings, options) => {
|
|
884
|
+
const { units } = options.data;
|
|
885
|
+
let counter = 0;
|
|
886
|
+
const calculateFeatureDistanceWithinUnit = (features, distanceOptions) => {
|
|
887
|
+
let relationshipGraph = {};
|
|
888
|
+
for (let currentIndex = 0; currentIndex < features.length; currentIndex++) {
|
|
889
|
+
const isLastItem = currentIndex + 1 === features.length;
|
|
890
|
+
if (isLastItem) break;
|
|
891
|
+
for (let j = currentIndex + 1; j < features.length; j++) {
|
|
892
|
+
const opening = features[currentIndex];
|
|
893
|
+
const feature2 = features[j];
|
|
894
|
+
try {
|
|
895
|
+
const distance5 = (0, import_distance.distance)(
|
|
896
|
+
(0, import_center3.center)(opening.geometry),
|
|
897
|
+
(0, import_center3.center)(feature2.geometry),
|
|
898
|
+
{ units: "meters" }
|
|
899
|
+
) + (distanceOptions?.baseDistance ?? 0);
|
|
900
|
+
if (opening.id === feature2.id) continue;
|
|
901
|
+
import_lodash3.default.set(relationshipGraph, `${opening.id}.${feature2.id}`, distance5);
|
|
902
|
+
import_lodash3.default.set(relationshipGraph, `${feature2.id}.${opening.id}`, distance5);
|
|
903
|
+
counter++;
|
|
904
|
+
} catch (error) {
|
|
905
|
+
continue;
|
|
906
|
+
}
|
|
981
907
|
}
|
|
982
|
-
const norm2 = 1 / Math.pow(numTokens, 0.5 * weight);
|
|
983
|
-
const n = parseFloat(Math.round(norm2 * m) / m);
|
|
984
|
-
cache.set(numTokens, n);
|
|
985
|
-
return n;
|
|
986
|
-
},
|
|
987
|
-
clear() {
|
|
988
|
-
cache.clear();
|
|
989
908
|
}
|
|
909
|
+
return relationshipGraph;
|
|
990
910
|
};
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
911
|
+
const t0 = performance.now();
|
|
912
|
+
const nodeMap = import_lodash3.default.reduce(
|
|
913
|
+
unitOpenings,
|
|
914
|
+
(acc, openings, unitId) => {
|
|
915
|
+
const unit = units.find((unit2) => unit2.id === unitId);
|
|
916
|
+
const unitDistanceOption = getDistanceOptions(options.unitDistanceOptions, unit.properties.category);
|
|
917
|
+
return import_lodash3.default.merge(
|
|
918
|
+
acc,
|
|
919
|
+
calculateFeatureDistanceWithinUnit(openings, unitDistanceOption)
|
|
920
|
+
);
|
|
921
|
+
},
|
|
922
|
+
{}
|
|
923
|
+
);
|
|
924
|
+
const t1 = performance.now();
|
|
925
|
+
trace("nav", ` \u2502 \u251C\u2500 add ${counter} traversal relationships`, t1 - t0);
|
|
926
|
+
return nodeMap;
|
|
927
|
+
};
|
|
928
|
+
|
|
929
|
+
// src/data/navigate/graph/nodemap/createElevatorNodeMap.ts
|
|
930
|
+
var import_lodash4 = __toESM(require("lodash"));
|
|
931
|
+
var createElevatorNodeMap = (elevatorLikeRelationships, unitOpenings, options) => {
|
|
932
|
+
const t0 = performance.now();
|
|
933
|
+
const { levels, units } = options.data;
|
|
934
|
+
const distanceOptions = getDistanceOptions(options.unitDistanceOptions, "elevator");
|
|
935
|
+
const {
|
|
936
|
+
baseDistance = ELEVATOR_BASEDISTANCE,
|
|
937
|
+
scaleDistanceByLevel = false
|
|
938
|
+
} = distanceOptions;
|
|
939
|
+
let elevatorNodeMap = {};
|
|
940
|
+
let counter = 0;
|
|
941
|
+
for (const relationship of elevatorLikeRelationships) {
|
|
942
|
+
try {
|
|
943
|
+
const {
|
|
944
|
+
origin: originTypeAndId,
|
|
945
|
+
intermediary,
|
|
946
|
+
destination: destinationTypeAndId
|
|
947
|
+
} = relationship.properties;
|
|
948
|
+
const origin = units.find((unit) => unit.id === originTypeAndId.id);
|
|
949
|
+
if (!origin) return;
|
|
950
|
+
const originOpenings = compact(unitOpenings[origin.id]);
|
|
951
|
+
const originLevel = levels.find((level) => level.id === origin.properties.level_id);
|
|
952
|
+
const destination = units.find((unit) => unit.id === destinationTypeAndId.id);
|
|
953
|
+
const destinationOpenings = unitOpenings[destination.id];
|
|
954
|
+
const destinationOpeningAndLevels = destinationOpenings.map((opening) => {
|
|
955
|
+
const level = levels.find((level2) => level2.id === destination.properties.level_id);
|
|
956
|
+
return { opening, level };
|
|
1027
957
|
});
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
}
|
|
1046
|
-
}
|
|
1047
|
-
getValueForItemAtKeyId(item, keyId) {
|
|
1048
|
-
return item[this._keysMap[keyId]];
|
|
1049
|
-
}
|
|
1050
|
-
size() {
|
|
1051
|
-
return this.records.length;
|
|
1052
|
-
}
|
|
1053
|
-
_addString(doc, docIndex) {
|
|
1054
|
-
if (!isDefined(doc) || isBlank(doc)) {
|
|
1055
|
-
return;
|
|
1056
|
-
}
|
|
1057
|
-
let record = {
|
|
1058
|
-
v: doc,
|
|
1059
|
-
i: docIndex,
|
|
1060
|
-
n: this.norm.get(doc)
|
|
1061
|
-
};
|
|
1062
|
-
this.records.push(record);
|
|
1063
|
-
}
|
|
1064
|
-
_addObject(doc, docIndex) {
|
|
1065
|
-
let record = { i: docIndex, $: {} };
|
|
1066
|
-
this.keys.forEach((key, keyIndex) => {
|
|
1067
|
-
let value = key.getFn ? key.getFn(doc) : this.getFn(doc, key.path);
|
|
1068
|
-
if (!isDefined(value)) {
|
|
1069
|
-
return;
|
|
1070
|
-
}
|
|
1071
|
-
if (isArray(value)) {
|
|
1072
|
-
let subRecords = [];
|
|
1073
|
-
const stack = [{ nestedArrIndex: -1, value }];
|
|
1074
|
-
while (stack.length) {
|
|
1075
|
-
const { nestedArrIndex, value: value2 } = stack.pop();
|
|
1076
|
-
if (!isDefined(value2)) {
|
|
1077
|
-
continue;
|
|
958
|
+
const intermediaryOpeningAndLevels = intermediary.map((unitTypeAndId) => {
|
|
959
|
+
const openings = unitOpenings[unitTypeAndId.id];
|
|
960
|
+
const unit = units.find((unit2) => unit2.id === unitTypeAndId.id);
|
|
961
|
+
const level = levels.find((level2) => level2.id === unit.properties.level_id);
|
|
962
|
+
return openings.map((opening) => ({ opening, level }));
|
|
963
|
+
}).flat();
|
|
964
|
+
const connections = compact([...intermediaryOpeningAndLevels, ...destinationOpeningAndLevels]);
|
|
965
|
+
if (!originOpenings || originOpenings.length === 0) return;
|
|
966
|
+
for (const originOpening of originOpenings) {
|
|
967
|
+
for (const connection of connections) {
|
|
968
|
+
const { opening, level } = connection;
|
|
969
|
+
let distance5 = baseDistance;
|
|
970
|
+
if (scaleDistanceByLevel) {
|
|
971
|
+
const originOrdinal = originLevel.properties.ordinal;
|
|
972
|
+
const connectionOrdinal = level.properties.ordinal;
|
|
973
|
+
const levelDifference = Math.abs(originOrdinal - connectionOrdinal);
|
|
974
|
+
if (levelDifference > 0) distance5 *= levelDifference;
|
|
1078
975
|
}
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
i: nestedArrIndex,
|
|
1083
|
-
n: this.norm.get(value2)
|
|
1084
|
-
};
|
|
1085
|
-
subRecords.push(subRecord);
|
|
1086
|
-
} else if (isArray(value2)) {
|
|
1087
|
-
value2.forEach((item, k) => {
|
|
1088
|
-
stack.push({
|
|
1089
|
-
nestedArrIndex: k,
|
|
1090
|
-
value: item
|
|
1091
|
-
});
|
|
1092
|
-
});
|
|
1093
|
-
} else ;
|
|
976
|
+
import_lodash4.default.set(elevatorNodeMap, `${originOpening.id}.${opening.id}`, distance5);
|
|
977
|
+
import_lodash4.default.set(elevatorNodeMap, `${opening.id}.${originOpening.id}`, distance5);
|
|
978
|
+
counter++;
|
|
1094
979
|
}
|
|
1095
|
-
record.$[keyIndex] = subRecords;
|
|
1096
|
-
} else if (isString(value) && !isBlank(value)) {
|
|
1097
|
-
let subRecord = {
|
|
1098
|
-
v: value,
|
|
1099
|
-
n: this.norm.get(value)
|
|
1100
|
-
};
|
|
1101
|
-
record.$[keyIndex] = subRecord;
|
|
1102
980
|
}
|
|
1103
|
-
})
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
return {
|
|
1108
|
-
keys: this.keys,
|
|
1109
|
-
records: this.records
|
|
1110
|
-
};
|
|
981
|
+
} catch (err) {
|
|
982
|
+
console.log(err);
|
|
983
|
+
console.log("cannot create elevatorNodeMap for ", { relationship });
|
|
984
|
+
}
|
|
1111
985
|
}
|
|
986
|
+
const t1 = performance.now();
|
|
987
|
+
trace("nav", ` \u2502 \u251C\u2500 add ${counter} escalator relationships`, t1 - t0);
|
|
988
|
+
return elevatorNodeMap;
|
|
1112
989
|
};
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
const
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
errors = 0,
|
|
1129
|
-
currentLocation = 0,
|
|
1130
|
-
expectedLocation = 0,
|
|
1131
|
-
distance = Config.distance,
|
|
1132
|
-
ignoreLocation = Config.ignoreLocation
|
|
1133
|
-
} = {}) {
|
|
1134
|
-
const accuracy = errors / pattern.length;
|
|
1135
|
-
if (ignoreLocation) {
|
|
1136
|
-
return accuracy;
|
|
1137
|
-
}
|
|
1138
|
-
const proximity = Math.abs(expectedLocation - currentLocation);
|
|
1139
|
-
if (!distance) {
|
|
1140
|
-
return proximity ? 1 : accuracy;
|
|
1141
|
-
}
|
|
1142
|
-
return accuracy + proximity / distance;
|
|
1143
|
-
}
|
|
1144
|
-
function convertMaskToIndices(matchmask = [], minMatchCharLength = Config.minMatchCharLength) {
|
|
1145
|
-
let indices = [];
|
|
1146
|
-
let start = -1;
|
|
1147
|
-
let end = -1;
|
|
1148
|
-
let i = 0;
|
|
1149
|
-
for (let len = matchmask.length; i < len; i += 1) {
|
|
1150
|
-
let match = matchmask[i];
|
|
1151
|
-
if (match && start === -1) {
|
|
1152
|
-
start = i;
|
|
1153
|
-
} else if (!match && start !== -1) {
|
|
1154
|
-
end = i - 1;
|
|
1155
|
-
if (end - start + 1 >= minMatchCharLength) {
|
|
1156
|
-
indices.push([start, end]);
|
|
1157
|
-
}
|
|
1158
|
-
start = -1;
|
|
990
|
+
|
|
991
|
+
// src/data/navigate/graph/nodemap/createEscalatorNodeMap.ts
|
|
992
|
+
var import_set = __toESM(require("lodash/set"));
|
|
993
|
+
var createEscalatorNodeMap = (relationships, options) => {
|
|
994
|
+
const t0 = performance.now();
|
|
995
|
+
const distanceOptions = getDistanceOptions(options.unitDistanceOptions, "escalator");
|
|
996
|
+
let counter = 0;
|
|
997
|
+
let nodeMap = {};
|
|
998
|
+
for (const relationship of relationships) {
|
|
999
|
+
const {
|
|
1000
|
+
properties: { direction, origin, destination }
|
|
1001
|
+
} = relationship;
|
|
1002
|
+
(0, import_set.default)(nodeMap, `${origin.id}.${destination.id}`, distanceOptions.baseDistance);
|
|
1003
|
+
if (direction === "undirected") {
|
|
1004
|
+
(0, import_set.default)(nodeMap, `${destination.id}.${origin.id}`, distanceOptions.baseDistance);
|
|
1159
1005
|
}
|
|
1006
|
+
counter++;
|
|
1160
1007
|
}
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
const
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1008
|
+
const t1 = performance.now();
|
|
1009
|
+
trace("nav", ` \u2502 \u251C\u2500 add ${counter} escalator relationships`, t1 - t0);
|
|
1010
|
+
return nodeMap;
|
|
1011
|
+
};
|
|
1012
|
+
|
|
1013
|
+
// src/data/navigate/graph/nodemap/createRampNodeMap.ts
|
|
1014
|
+
var import_set2 = __toESM(require("lodash/set"));
|
|
1015
|
+
var createRampNodeMap = (relationships, options) => {
|
|
1016
|
+
const t0 = performance.now();
|
|
1017
|
+
const distanceOptions = getDistanceOptions(options.unitDistanceOptions, "ramp");
|
|
1018
|
+
let counter = 0;
|
|
1019
|
+
let nodeMap = {};
|
|
1020
|
+
relationships.forEach((relationship) => {
|
|
1021
|
+
const {
|
|
1022
|
+
properties: { origin, destination }
|
|
1023
|
+
} = relationship;
|
|
1024
|
+
(0, import_set2.default)(nodeMap, `${origin.id}.${destination.id}`, distanceOptions.baseDistance);
|
|
1025
|
+
(0, import_set2.default)(nodeMap, `${destination.id}.${origin.id}`, distanceOptions.baseDistance);
|
|
1026
|
+
counter++;
|
|
1027
|
+
});
|
|
1028
|
+
const t1 = performance.now();
|
|
1029
|
+
trace("nav", ` \u2502 \u251C\u2500 add ${counter} ramp relationships`, t1 - t0);
|
|
1030
|
+
return nodeMap;
|
|
1031
|
+
};
|
|
1032
|
+
|
|
1033
|
+
// src/data/navigate/graph/nodemap/createStairNodeMap.ts
|
|
1034
|
+
var import_lodash6 = __toESM(require("lodash"));
|
|
1035
|
+
var createStairNodeMap = (elevatorLikeRelationships, unitOpenings, options) => {
|
|
1036
|
+
const t0 = performance.now();
|
|
1037
|
+
const { levels = [], openings = [], units = [] } = options.data;
|
|
1038
|
+
const { baseDistance, scaleDistanceByLevel } = getDistanceOptions(options.unitDistanceOptions, "stairs");
|
|
1039
|
+
let elevatorNodeMap = {};
|
|
1040
|
+
let counter = 0;
|
|
1041
|
+
for (const relationship of elevatorLikeRelationships) {
|
|
1042
|
+
try {
|
|
1043
|
+
const {
|
|
1044
|
+
origin: { id: originId },
|
|
1045
|
+
intermediary,
|
|
1046
|
+
destination: { id: destinationId }
|
|
1047
|
+
} = relationship.properties;
|
|
1048
|
+
const origin = openings.find((opening) => opening.id === originId);
|
|
1049
|
+
if (!origin) return;
|
|
1050
|
+
const originLevel = levels.find((level) => level.id === origin.properties.level_id);
|
|
1051
|
+
const destination = openings.find((opening) => opening.id === destinationId);
|
|
1052
|
+
const destinationOpeningAndLevel = {
|
|
1053
|
+
opening: destination,
|
|
1054
|
+
level: levels.find((level) => level.id === destination.properties.level_id)
|
|
1055
|
+
};
|
|
1056
|
+
const intermediaryOpeningAndLevels = intermediary.map((unitTypeAndId) => {
|
|
1057
|
+
const openings2 = unitOpenings[unitTypeAndId.id];
|
|
1058
|
+
const unit = units.find((unit2) => unit2.id === unitTypeAndId.id);
|
|
1059
|
+
const level = levels.find((level2) => level2.id === unit.properties.level_id);
|
|
1060
|
+
return openings2.map((opening) => ({ opening, level }));
|
|
1061
|
+
}).flat();
|
|
1062
|
+
const connections = [...intermediaryOpeningAndLevels, destinationOpeningAndLevel];
|
|
1063
|
+
if (!origin) return;
|
|
1064
|
+
for (const connection of connections) {
|
|
1065
|
+
const { opening, level } = connection;
|
|
1066
|
+
let distance5 = baseDistance;
|
|
1067
|
+
if (scaleDistanceByLevel) {
|
|
1068
|
+
const originOrdinal = originLevel.properties.ordinal;
|
|
1069
|
+
const connectionOrdinal = level.properties.ordinal;
|
|
1070
|
+
const levelDifference = Math.abs(originOrdinal - connectionOrdinal);
|
|
1071
|
+
if (levelDifference > 0) distance5 *= levelDifference;
|
|
1072
|
+
}
|
|
1073
|
+
import_lodash6.default.set(elevatorNodeMap, `${origin.id}.${opening.id}`, distance5);
|
|
1074
|
+
import_lodash6.default.set(elevatorNodeMap, `${opening.id}.${origin.id}`, distance5);
|
|
1075
|
+
counter++;
|
|
1201
1076
|
}
|
|
1077
|
+
} catch (err) {
|
|
1078
|
+
console.warn(
|
|
1079
|
+
"Failed to create stairNodeMap",
|
|
1080
|
+
{
|
|
1081
|
+
relationshipId: relationship.id,
|
|
1082
|
+
featureType: relationship.feature_type,
|
|
1083
|
+
error: err instanceof Error ? err.message : err,
|
|
1084
|
+
stack: err instanceof Error ? err.stack : void 0
|
|
1085
|
+
}
|
|
1086
|
+
);
|
|
1202
1087
|
}
|
|
1203
1088
|
}
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
binMax = binMid;
|
|
1224
|
-
}
|
|
1225
|
-
binMid = Math.floor((binMax - binMin) / 2 + binMin);
|
|
1089
|
+
const t1 = performance.now();
|
|
1090
|
+
trace("nav", ` \u2502 \u251C\u2500 add ${counter} stairs relationships`, t1 - t0);
|
|
1091
|
+
return elevatorNodeMap;
|
|
1092
|
+
};
|
|
1093
|
+
|
|
1094
|
+
// src/data/navigate/graph/nodemap/createOccupantNodeMap.ts
|
|
1095
|
+
var import_lodash7 = __toESM(require("lodash"));
|
|
1096
|
+
var createOccupantNodeMap = (occupants) => {
|
|
1097
|
+
const t0 = performance.now();
|
|
1098
|
+
let nodeMap = {};
|
|
1099
|
+
let counter = 0;
|
|
1100
|
+
occupants.forEach((occupant) => {
|
|
1101
|
+
const { unit_id, unit_ids = [], kiosk_id, kiosk_ids = [] } = occupant.properties;
|
|
1102
|
+
const occupantRoomIds = compact([unit_id, ...unit_ids]);
|
|
1103
|
+
const occupantKioskIds = compact([kiosk_id, ...kiosk_ids]);
|
|
1104
|
+
for (const roomId of occupantRoomIds) {
|
|
1105
|
+
import_lodash7.default.set(nodeMap, `${roomId}.${occupant.id}`, 1e-3);
|
|
1106
|
+
import_lodash7.default.set(nodeMap, `${occupant.id}.${roomId}`, 1e-3);
|
|
1107
|
+
counter++;
|
|
1226
1108
|
}
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
}
|
|
1256
|
-
|
|
1109
|
+
for (const kioskId of occupantKioskIds) {
|
|
1110
|
+
import_lodash7.default.set(nodeMap, `${kioskId}.${occupant.id}`, 1e-3);
|
|
1111
|
+
import_lodash7.default.set(nodeMap, `${occupant.id}.${kioskId}`, 1e-3);
|
|
1112
|
+
counter++;
|
|
1113
|
+
}
|
|
1114
|
+
});
|
|
1115
|
+
const t1 = performance.now();
|
|
1116
|
+
trace("nav", ` \u2502 \u251C\u2500 add ${counter} occupants relationships`, t1 - t0);
|
|
1117
|
+
return nodeMap;
|
|
1118
|
+
};
|
|
1119
|
+
|
|
1120
|
+
// src/data/navigate/graph/nodemap/createPOINodeMaps.ts
|
|
1121
|
+
var import_center4 = require("@turf/center");
|
|
1122
|
+
var import_distance2 = require("@turf/distance");
|
|
1123
|
+
var import_lodash9 = __toESM(require("lodash"));
|
|
1124
|
+
var createPOINodeMap = (features, getFeatureUnit, unitOpenings) => {
|
|
1125
|
+
const t0 = performance.now();
|
|
1126
|
+
let nodeMap = {};
|
|
1127
|
+
let counter = 0;
|
|
1128
|
+
features.forEach((feat) => {
|
|
1129
|
+
try {
|
|
1130
|
+
const locatedOnUnitId = getFeatureUnit(feat);
|
|
1131
|
+
const openings = unitOpenings[locatedOnUnitId];
|
|
1132
|
+
const center8 = (0, import_center4.center)(feat);
|
|
1133
|
+
for (const opening of openings) {
|
|
1134
|
+
try {
|
|
1135
|
+
const openingCenter = (0, import_center4.center)(opening);
|
|
1136
|
+
const dis = (0, import_distance2.distance)(center8, openingCenter, { units: "meters" }) + BASE_POI_BASEDISTANCE;
|
|
1137
|
+
import_lodash9.default.set(nodeMap, `${opening.id}.${feat.id}`, dis);
|
|
1138
|
+
import_lodash9.default.set(nodeMap, `${feat.id}.${opening.id}`, dis);
|
|
1139
|
+
counter++;
|
|
1140
|
+
} catch (err) {
|
|
1141
|
+
console.log(err, opening);
|
|
1257
1142
|
}
|
|
1258
1143
|
}
|
|
1144
|
+
} catch (err) {
|
|
1145
|
+
console.log(err);
|
|
1146
|
+
console.log(`cannot connect poi to openings`, err.message, { feat });
|
|
1259
1147
|
}
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
};
|
|
1277
|
-
if (computeMatches) {
|
|
1278
|
-
const indices = convertMaskToIndices(matchMask, minMatchCharLength);
|
|
1279
|
-
if (!indices.length) {
|
|
1280
|
-
result.isMatch = false;
|
|
1281
|
-
} else if (includeMatches) {
|
|
1282
|
-
result.indices = indices;
|
|
1148
|
+
});
|
|
1149
|
+
const type = features.length > 0 ? features[0].feature_type : "-";
|
|
1150
|
+
const t1 = performance.now();
|
|
1151
|
+
trace("nav", ` \u2502 \u251C\u2500 add ${counter} ${type} relationships`, t1 - t0);
|
|
1152
|
+
return nodeMap;
|
|
1153
|
+
};
|
|
1154
|
+
|
|
1155
|
+
// src/data/navigate/graph/utils/mergeNodeMap.ts
|
|
1156
|
+
var mergeNodeMap = (nodeMaps) => {
|
|
1157
|
+
const out = {};
|
|
1158
|
+
for (const nodeMap of nodeMaps) {
|
|
1159
|
+
for (const from in nodeMap) {
|
|
1160
|
+
out[from] = {
|
|
1161
|
+
...out[from] ?? {},
|
|
1162
|
+
...nodeMap[from]
|
|
1163
|
+
};
|
|
1283
1164
|
}
|
|
1284
1165
|
}
|
|
1285
|
-
return
|
|
1286
|
-
}
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
location = Config.location,
|
|
1299
|
-
threshold = Config.threshold,
|
|
1300
|
-
distance = Config.distance,
|
|
1301
|
-
includeMatches = Config.includeMatches,
|
|
1302
|
-
findAllMatches = Config.findAllMatches,
|
|
1303
|
-
minMatchCharLength = Config.minMatchCharLength,
|
|
1304
|
-
isCaseSensitive = Config.isCaseSensitive,
|
|
1305
|
-
ignoreDiacritics = Config.ignoreDiacritics,
|
|
1306
|
-
ignoreLocation = Config.ignoreLocation
|
|
1307
|
-
} = {}) {
|
|
1308
|
-
this.options = {
|
|
1309
|
-
location,
|
|
1310
|
-
threshold,
|
|
1311
|
-
distance,
|
|
1312
|
-
includeMatches,
|
|
1313
|
-
findAllMatches,
|
|
1314
|
-
minMatchCharLength,
|
|
1315
|
-
isCaseSensitive,
|
|
1316
|
-
ignoreDiacritics,
|
|
1317
|
-
ignoreLocation
|
|
1318
|
-
};
|
|
1319
|
-
pattern = isCaseSensitive ? pattern : pattern.toLowerCase();
|
|
1320
|
-
pattern = ignoreDiacritics ? stripDiacritics(pattern) : pattern;
|
|
1321
|
-
this.pattern = pattern;
|
|
1322
|
-
this.chunks = [];
|
|
1323
|
-
if (!this.pattern.length) {
|
|
1324
|
-
return;
|
|
1166
|
+
return out;
|
|
1167
|
+
};
|
|
1168
|
+
|
|
1169
|
+
// src/data/navigate/graph/utils/createUnitOpenings.ts
|
|
1170
|
+
var import_uniqBy = __toESM(require("lodash/uniqBy"));
|
|
1171
|
+
var createUnitOpenings = (relationships, units, openings) => {
|
|
1172
|
+
const openingConnections = {};
|
|
1173
|
+
const relationshipMap = /* @__PURE__ */ new Map();
|
|
1174
|
+
relationships.forEach((relationship) => {
|
|
1175
|
+
const originId = relationship.properties.origin?.id || null;
|
|
1176
|
+
const destinationId = relationship.properties.destination?.id || null;
|
|
1177
|
+
if (!relationshipMap.has(originId)) {
|
|
1178
|
+
relationshipMap.set(originId, []);
|
|
1325
1179
|
}
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
pattern: pattern2,
|
|
1329
|
-
alphabet: createPatternAlphabet(pattern2),
|
|
1330
|
-
startIndex
|
|
1331
|
-
});
|
|
1332
|
-
};
|
|
1333
|
-
const len = this.pattern.length;
|
|
1334
|
-
if (len > MAX_BITS) {
|
|
1335
|
-
let i = 0;
|
|
1336
|
-
const remainder = len % MAX_BITS;
|
|
1337
|
-
const end = len - remainder;
|
|
1338
|
-
while (i < end) {
|
|
1339
|
-
addChunk(this.pattern.substr(i, MAX_BITS), i);
|
|
1340
|
-
i += MAX_BITS;
|
|
1341
|
-
}
|
|
1342
|
-
if (remainder) {
|
|
1343
|
-
const startIndex = len - MAX_BITS;
|
|
1344
|
-
addChunk(this.pattern.substr(startIndex), startIndex);
|
|
1345
|
-
}
|
|
1346
|
-
} else {
|
|
1347
|
-
addChunk(this.pattern, 0);
|
|
1180
|
+
if (!relationshipMap.has(destinationId)) {
|
|
1181
|
+
relationshipMap.set(destinationId, []);
|
|
1348
1182
|
}
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1183
|
+
relationshipMap.get(originId).push(relationship);
|
|
1184
|
+
relationshipMap.get(destinationId).push(relationship);
|
|
1185
|
+
});
|
|
1186
|
+
units.forEach((unit) => {
|
|
1187
|
+
const unitId = unit.id;
|
|
1188
|
+
const connectedRelationshop = relationshipMap.get(unitId) || [];
|
|
1189
|
+
const relationshipIntermediaryTypeAndId = connectedRelationshop.map(
|
|
1190
|
+
(relationship) => relationship.properties.intermediary[0]
|
|
1191
|
+
// Assuming intermediary is always an array
|
|
1192
|
+
);
|
|
1193
|
+
const relationshipIntermediary = relationshipIntermediaryTypeAndId.map(({ id }) => {
|
|
1194
|
+
return openings.find((opening) => opening.id === id);
|
|
1195
|
+
});
|
|
1196
|
+
openingConnections[unitId] = (0, import_uniqBy.default)(
|
|
1197
|
+
[...openingConnections[unitId] || [], ...relationshipIntermediary],
|
|
1198
|
+
"id"
|
|
1199
|
+
);
|
|
1200
|
+
});
|
|
1201
|
+
return openingConnections;
|
|
1202
|
+
};
|
|
1203
|
+
|
|
1204
|
+
// src/data/navigate/parsers.ts
|
|
1205
|
+
var parseOrdinalCoordinate = (id) => {
|
|
1206
|
+
return id.slice(0, -1).split(",").map(Number);
|
|
1207
|
+
};
|
|
1208
|
+
|
|
1209
|
+
// src/data/navigate/graph/prepare.ts
|
|
1210
|
+
var prepareGraph = (options) => {
|
|
1211
|
+
const {
|
|
1212
|
+
data: {
|
|
1213
|
+
amenities = [],
|
|
1214
|
+
anchors = [],
|
|
1215
|
+
occupants = [],
|
|
1216
|
+
relationships = [],
|
|
1217
|
+
openings = [],
|
|
1218
|
+
units = [],
|
|
1219
|
+
kiosks = [],
|
|
1220
|
+
levels = []
|
|
1363
1221
|
}
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1222
|
+
} = options;
|
|
1223
|
+
const {
|
|
1224
|
+
traversal: traversalRelationships = [],
|
|
1225
|
+
escalator: escalatorRelationships = [],
|
|
1226
|
+
ramp: rampRelationships = [],
|
|
1227
|
+
elevator: elevatorRelationships = [],
|
|
1228
|
+
stairs: stairsRelationships = []
|
|
1229
|
+
} = import_lodash10.default.groupBy(relationships, "properties.category");
|
|
1230
|
+
const unitOpenings = createUnitOpenings(traversalRelationships, units, openings);
|
|
1231
|
+
const traversalNodeMap = createTraversalNodeMap(unitOpenings, options);
|
|
1232
|
+
const escalatorNodeMap = createEscalatorNodeMap(escalatorRelationships, options);
|
|
1233
|
+
const rampNodeMap = createRampNodeMap(rampRelationships, options);
|
|
1234
|
+
const elevatorNodeMap = createElevatorNodeMap(
|
|
1235
|
+
elevatorRelationships,
|
|
1236
|
+
unitOpenings,
|
|
1237
|
+
options
|
|
1238
|
+
);
|
|
1239
|
+
const stairNodeMap = createStairNodeMap(
|
|
1240
|
+
stairsRelationships,
|
|
1241
|
+
unitOpenings,
|
|
1242
|
+
options
|
|
1243
|
+
);
|
|
1244
|
+
const amenityNodeMap = createPOINodeMap(amenities, (amenity) => amenity.properties.unit_ids[0], unitOpenings);
|
|
1245
|
+
const anchorsNodeMap = createPOINodeMap(anchors, (anchor) => anchor.properties.unit_id, unitOpenings);
|
|
1246
|
+
const walkwayUnits = units.filter((unit) => unit.properties.category === "walkway");
|
|
1247
|
+
const kioskNodeMap = createPOINodeMap(kiosks, (kiosk) => findContainingUnit(kiosk, walkwayUnits)?.id, unitOpenings);
|
|
1248
|
+
const unitNodeMap = createPOINodeMap(units, (unit) => unit.id, unitOpenings);
|
|
1249
|
+
const occupantNodeMap = createOccupantNodeMap(occupants);
|
|
1250
|
+
const defaultGraph = new import_node_dijkstra.default(mergeNodeMap([
|
|
1251
|
+
traversalNodeMap,
|
|
1252
|
+
escalatorNodeMap,
|
|
1253
|
+
rampNodeMap,
|
|
1254
|
+
elevatorNodeMap,
|
|
1255
|
+
stairNodeMap,
|
|
1256
|
+
amenityNodeMap,
|
|
1257
|
+
anchorsNodeMap,
|
|
1258
|
+
kioskNodeMap,
|
|
1259
|
+
unitNodeMap,
|
|
1260
|
+
occupantNodeMap
|
|
1261
|
+
]));
|
|
1262
|
+
const accessibleGraph = new import_node_dijkstra.default(mergeNodeMap([
|
|
1263
|
+
traversalNodeMap,
|
|
1264
|
+
rampNodeMap,
|
|
1265
|
+
elevatorNodeMap,
|
|
1266
|
+
amenityNodeMap,
|
|
1267
|
+
anchorsNodeMap,
|
|
1268
|
+
kioskNodeMap,
|
|
1269
|
+
unitNodeMap,
|
|
1270
|
+
occupantNodeMap
|
|
1271
|
+
]));
|
|
1272
|
+
const addCoordinateOrdinalNode = (params, locatedOnUnit) => {
|
|
1273
|
+
const [lat, lng, ordinal] = parseOrdinalCoordinate(params);
|
|
1274
|
+
if (locatedOnUnit) {
|
|
1275
|
+
const openings2 = unitOpenings[locatedOnUnit.id];
|
|
1276
|
+
for (const opening of openings2) {
|
|
1277
|
+
const openingCenter = (0, import_center5.center)(opening);
|
|
1278
|
+
const dis = (0, import_distance3.distance)([lat, lng], openingCenter, { units: "meters" });
|
|
1279
|
+
defaultGraph.addNode(params, { [opening.id]: dis }).addNode(opening.id, { [params]: dis });
|
|
1280
|
+
accessibleGraph.addNode(params, { [opening.id]: dis }).addNode(opening.id, { [params]: dis });
|
|
1391
1281
|
}
|
|
1392
|
-
});
|
|
1393
|
-
let result = {
|
|
1394
|
-
isMatch: hasMatches,
|
|
1395
|
-
score: hasMatches ? totalScore / this.chunks.length : 1
|
|
1396
|
-
};
|
|
1397
|
-
if (hasMatches && includeMatches) {
|
|
1398
|
-
result.indices = allIndices;
|
|
1399
1282
|
}
|
|
1400
|
-
|
|
1401
|
-
}
|
|
1283
|
+
};
|
|
1284
|
+
return { defaultGraph, accessibleGraph, unitOpenings, addCoordinateOrdinalNode };
|
|
1402
1285
|
};
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
}
|
|
1413
|
-
search() {
|
|
1414
|
-
}
|
|
1415
|
-
};
|
|
1416
|
-
function getMatch(pattern, exp) {
|
|
1417
|
-
const matches = pattern.match(exp);
|
|
1418
|
-
return matches ? matches[1] : null;
|
|
1419
|
-
}
|
|
1420
|
-
var ExactMatch = class extends BaseMatch {
|
|
1421
|
-
constructor(pattern) {
|
|
1422
|
-
super(pattern);
|
|
1423
|
-
}
|
|
1424
|
-
static get type() {
|
|
1425
|
-
return "exact";
|
|
1426
|
-
}
|
|
1427
|
-
static get multiRegex() {
|
|
1428
|
-
return /^="(.*)"$/;
|
|
1429
|
-
}
|
|
1430
|
-
static get singleRegex() {
|
|
1431
|
-
return /^=(.*)$/;
|
|
1432
|
-
}
|
|
1433
|
-
search(text) {
|
|
1434
|
-
const isMatch = text === this.pattern;
|
|
1435
|
-
return {
|
|
1436
|
-
isMatch,
|
|
1437
|
-
score: isMatch ? 0 : 1,
|
|
1438
|
-
indices: [0, this.pattern.length - 1]
|
|
1439
|
-
};
|
|
1440
|
-
}
|
|
1286
|
+
|
|
1287
|
+
// src/data/navigate/steps/createStepUtils.ts
|
|
1288
|
+
var import_lodash12 = require("lodash");
|
|
1289
|
+
var import_intersectionBy = __toESM(require("lodash/intersectionBy"));
|
|
1290
|
+
var import_center9 = require("@turf/center");
|
|
1291
|
+
|
|
1292
|
+
// src/data/navigate/description/describe.ts
|
|
1293
|
+
var t = (template, locale, options) => {
|
|
1294
|
+
return template.replace(`{{intermediary}}`, options.intermediary ?? "").replace(`{{toward}}`, options.toward?.[locale] ?? "").replace(`{{landmark}}`, options.landmark?.[locale] ?? "");
|
|
1441
1295
|
};
|
|
1442
|
-
var
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
}
|
|
1449
|
-
static get multiRegex() {
|
|
1450
|
-
return /^!"(.*)"$/;
|
|
1451
|
-
}
|
|
1452
|
-
static get singleRegex() {
|
|
1453
|
-
return /^!(.*)$/;
|
|
1454
|
-
}
|
|
1455
|
-
search(text) {
|
|
1456
|
-
const index = text.indexOf(this.pattern);
|
|
1457
|
-
const isMatch = index === -1;
|
|
1458
|
-
return {
|
|
1459
|
-
isMatch,
|
|
1460
|
-
score: isMatch ? 0 : 1,
|
|
1461
|
-
indices: [0, text.length - 1]
|
|
1462
|
-
};
|
|
1463
|
-
}
|
|
1296
|
+
var describeVerticalStep = (fromLevel, toLevel, intermediary) => {
|
|
1297
|
+
const dir = fromLevel.properties.ordinal < toLevel.properties.ordinal ? "up" : "down";
|
|
1298
|
+
const template = `Take the {{intermediary}} ${dir} to {{toward}}`;
|
|
1299
|
+
return {
|
|
1300
|
+
template,
|
|
1301
|
+
text: t(template, "en", { intermediary, toward: toLevel.properties.name })
|
|
1302
|
+
};
|
|
1464
1303
|
};
|
|
1465
|
-
var
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
}
|
|
1472
|
-
static get multiRegex() {
|
|
1473
|
-
return /^\^"(.*)"$/;
|
|
1474
|
-
}
|
|
1475
|
-
static get singleRegex() {
|
|
1476
|
-
return /^\^(.*)$/;
|
|
1477
|
-
}
|
|
1478
|
-
search(text) {
|
|
1479
|
-
const isMatch = text.startsWith(this.pattern);
|
|
1480
|
-
return {
|
|
1481
|
-
isMatch,
|
|
1482
|
-
score: isMatch ? 0 : 1,
|
|
1483
|
-
indices: [0, this.pattern.length - 1]
|
|
1484
|
-
};
|
|
1485
|
-
}
|
|
1304
|
+
var describeHorizontalStep = (intermediary, toward, landmark) => {
|
|
1305
|
+
const template = `Follow the path ${intermediary === "walkway" ? `along the walkway` : `through {{intermediary}}`} ${toward ? `toward {{toward}}` : ``} ${landmark ? `near {{landmark}}` : ``}`.trim();
|
|
1306
|
+
return {
|
|
1307
|
+
text: t(template, "en", { intermediary, toward, landmark }),
|
|
1308
|
+
template
|
|
1309
|
+
};
|
|
1486
1310
|
};
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1311
|
+
|
|
1312
|
+
// src/data/navigate/steps/path/index.ts
|
|
1313
|
+
var import_lodash11 = __toESM(require("lodash"));
|
|
1314
|
+
|
|
1315
|
+
// src/data/navigate/constants.ts
|
|
1316
|
+
var OBSTACLE_FEATURE_TYPES = [
|
|
1317
|
+
"kiosk"
|
|
1318
|
+
/* , "fixture" */
|
|
1319
|
+
];
|
|
1320
|
+
var OBSTACLE_CATEGORIES = [
|
|
1321
|
+
"fixture.water",
|
|
1322
|
+
"fixture.stage",
|
|
1323
|
+
"nonpublic",
|
|
1324
|
+
"opentobelow",
|
|
1325
|
+
"elevator",
|
|
1326
|
+
"escalator",
|
|
1327
|
+
"stairs",
|
|
1328
|
+
"stairs.emergencyexit",
|
|
1329
|
+
"room",
|
|
1330
|
+
"unspecified",
|
|
1331
|
+
"structure",
|
|
1332
|
+
"brick",
|
|
1333
|
+
"concrete",
|
|
1334
|
+
"drywall",
|
|
1335
|
+
"glass",
|
|
1336
|
+
"wood",
|
|
1337
|
+
"column"
|
|
1338
|
+
];
|
|
1339
|
+
var WALKABLE_CATEGORY = [
|
|
1340
|
+
"walkway",
|
|
1341
|
+
"parking",
|
|
1342
|
+
"room",
|
|
1343
|
+
"terrace",
|
|
1344
|
+
"unenclosedarea",
|
|
1345
|
+
"vegetation",
|
|
1346
|
+
"unspecified"
|
|
1347
|
+
];
|
|
1348
|
+
|
|
1349
|
+
// node_modules/@turf/helpers/dist/esm/index.js
|
|
1350
|
+
var earthRadius = 63710088e-1;
|
|
1351
|
+
var factors = {
|
|
1352
|
+
centimeters: earthRadius * 100,
|
|
1353
|
+
centimetres: earthRadius * 100,
|
|
1354
|
+
degrees: 360 / (2 * Math.PI),
|
|
1355
|
+
feet: earthRadius * 3.28084,
|
|
1356
|
+
inches: earthRadius * 39.37,
|
|
1357
|
+
kilometers: earthRadius / 1e3,
|
|
1358
|
+
kilometres: earthRadius / 1e3,
|
|
1359
|
+
meters: earthRadius,
|
|
1360
|
+
metres: earthRadius,
|
|
1361
|
+
miles: earthRadius / 1609.344,
|
|
1362
|
+
millimeters: earthRadius * 1e3,
|
|
1363
|
+
millimetres: earthRadius * 1e3,
|
|
1364
|
+
nauticalmiles: earthRadius / 1852,
|
|
1365
|
+
radians: 1,
|
|
1366
|
+
yards: earthRadius * 1.0936
|
|
1508
1367
|
};
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1368
|
+
function feature(geom, properties, options = {}) {
|
|
1369
|
+
const feat = { type: "Feature" };
|
|
1370
|
+
if (options.id === 0 || options.id) {
|
|
1371
|
+
feat.id = options.id;
|
|
1512
1372
|
}
|
|
1513
|
-
|
|
1514
|
-
|
|
1373
|
+
if (options.bbox) {
|
|
1374
|
+
feat.bbox = options.bbox;
|
|
1515
1375
|
}
|
|
1516
|
-
|
|
1517
|
-
|
|
1376
|
+
feat.properties = properties || {};
|
|
1377
|
+
feat.geometry = geom;
|
|
1378
|
+
return feat;
|
|
1379
|
+
}
|
|
1380
|
+
function point(coordinates, properties, options = {}) {
|
|
1381
|
+
if (!coordinates) {
|
|
1382
|
+
throw new Error("coordinates is required");
|
|
1518
1383
|
}
|
|
1519
|
-
|
|
1520
|
-
|
|
1384
|
+
if (!Array.isArray(coordinates)) {
|
|
1385
|
+
throw new Error("coordinates must be an Array");
|
|
1521
1386
|
}
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
return {
|
|
1525
|
-
isMatch,
|
|
1526
|
-
score: isMatch ? 0 : 1,
|
|
1527
|
-
indices: [text.length - this.pattern.length, text.length - 1]
|
|
1528
|
-
};
|
|
1387
|
+
if (coordinates.length < 2) {
|
|
1388
|
+
throw new Error("coordinates must be at least 2 numbers long");
|
|
1529
1389
|
}
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
constructor(pattern) {
|
|
1533
|
-
super(pattern);
|
|
1390
|
+
if (!isNumber(coordinates[0]) || !isNumber(coordinates[1])) {
|
|
1391
|
+
throw new Error("coordinates must contain numbers");
|
|
1534
1392
|
}
|
|
1535
|
-
|
|
1536
|
-
|
|
1393
|
+
const geom = {
|
|
1394
|
+
type: "Point",
|
|
1395
|
+
coordinates
|
|
1396
|
+
};
|
|
1397
|
+
return feature(geom, properties, options);
|
|
1398
|
+
}
|
|
1399
|
+
function polygon(coordinates, properties, options = {}) {
|
|
1400
|
+
for (const ring of coordinates) {
|
|
1401
|
+
if (ring.length < 4) {
|
|
1402
|
+
throw new Error(
|
|
1403
|
+
"Each LinearRing of a Polygon must have 4 or more Positions."
|
|
1404
|
+
);
|
|
1405
|
+
}
|
|
1406
|
+
if (ring[ring.length - 1].length !== ring[0].length) {
|
|
1407
|
+
throw new Error("First and last Position are not equivalent.");
|
|
1408
|
+
}
|
|
1409
|
+
for (let j = 0; j < ring[ring.length - 1].length; j++) {
|
|
1410
|
+
if (ring[ring.length - 1][j] !== ring[0][j]) {
|
|
1411
|
+
throw new Error("First and last Position are not equivalent.");
|
|
1412
|
+
}
|
|
1413
|
+
}
|
|
1537
1414
|
}
|
|
1538
|
-
|
|
1539
|
-
|
|
1415
|
+
const geom = {
|
|
1416
|
+
type: "Polygon",
|
|
1417
|
+
coordinates
|
|
1418
|
+
};
|
|
1419
|
+
return feature(geom, properties, options);
|
|
1420
|
+
}
|
|
1421
|
+
function lineString(coordinates, properties, options = {}) {
|
|
1422
|
+
if (coordinates.length < 2) {
|
|
1423
|
+
throw new Error("coordinates must be an array of two or more positions");
|
|
1540
1424
|
}
|
|
1541
|
-
|
|
1542
|
-
|
|
1425
|
+
const geom = {
|
|
1426
|
+
type: "LineString",
|
|
1427
|
+
coordinates
|
|
1428
|
+
};
|
|
1429
|
+
return feature(geom, properties, options);
|
|
1430
|
+
}
|
|
1431
|
+
function featureCollection(features, options = {}) {
|
|
1432
|
+
const fc = { type: "FeatureCollection" };
|
|
1433
|
+
if (options.id) {
|
|
1434
|
+
fc.id = options.id;
|
|
1543
1435
|
}
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
return {
|
|
1547
|
-
isMatch,
|
|
1548
|
-
score: isMatch ? 0 : 1,
|
|
1549
|
-
indices: [0, text.length - 1]
|
|
1550
|
-
};
|
|
1436
|
+
if (options.bbox) {
|
|
1437
|
+
fc.bbox = options.bbox;
|
|
1551
1438
|
}
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1439
|
+
fc.features = features;
|
|
1440
|
+
return fc;
|
|
1441
|
+
}
|
|
1442
|
+
function multiPoint(coordinates, properties, options = {}) {
|
|
1443
|
+
const geom = {
|
|
1444
|
+
type: "MultiPoint",
|
|
1445
|
+
coordinates
|
|
1446
|
+
};
|
|
1447
|
+
return feature(geom, properties, options);
|
|
1448
|
+
}
|
|
1449
|
+
function isNumber(num) {
|
|
1450
|
+
return !isNaN(num) && num !== null && !Array.isArray(num);
|
|
1451
|
+
}
|
|
1452
|
+
function isObject(input) {
|
|
1453
|
+
return input !== null && typeof input === "object" && !Array.isArray(input);
|
|
1454
|
+
}
|
|
1455
|
+
|
|
1456
|
+
// node_modules/@turf/invariant/dist/esm/index.js
|
|
1457
|
+
function getCoord(coord) {
|
|
1458
|
+
if (!coord) {
|
|
1459
|
+
throw new Error("coord is required");
|
|
1460
|
+
}
|
|
1461
|
+
if (!Array.isArray(coord)) {
|
|
1462
|
+
if (coord.type === "Feature" && coord.geometry !== null && coord.geometry.type === "Point") {
|
|
1463
|
+
return [...coord.geometry.coordinates];
|
|
1464
|
+
}
|
|
1465
|
+
if (coord.type === "Point") {
|
|
1466
|
+
return [...coord.coordinates];
|
|
1467
|
+
}
|
|
1577
1468
|
}
|
|
1578
|
-
|
|
1579
|
-
return
|
|
1469
|
+
if (Array.isArray(coord) && coord.length >= 2 && !Array.isArray(coord[0]) && !Array.isArray(coord[1])) {
|
|
1470
|
+
return [...coord];
|
|
1580
1471
|
}
|
|
1581
|
-
|
|
1582
|
-
|
|
1472
|
+
throw new Error("coord must be GeoJSON Point or an Array of numbers");
|
|
1473
|
+
}
|
|
1474
|
+
function getGeom(geojson) {
|
|
1475
|
+
if (geojson.type === "Feature") {
|
|
1476
|
+
return geojson.geometry;
|
|
1583
1477
|
}
|
|
1584
|
-
|
|
1585
|
-
|
|
1478
|
+
return geojson;
|
|
1479
|
+
}
|
|
1480
|
+
function getType(geojson, _name) {
|
|
1481
|
+
if (geojson.type === "FeatureCollection") {
|
|
1482
|
+
return "FeatureCollection";
|
|
1586
1483
|
}
|
|
1587
|
-
|
|
1588
|
-
return
|
|
1484
|
+
if (geojson.type === "GeometryCollection") {
|
|
1485
|
+
return "GeometryCollection";
|
|
1589
1486
|
}
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
constructor(pattern) {
|
|
1593
|
-
super(pattern);
|
|
1594
|
-
}
|
|
1595
|
-
static get type() {
|
|
1596
|
-
return "include";
|
|
1597
|
-
}
|
|
1598
|
-
static get multiRegex() {
|
|
1599
|
-
return /^'"(.*)"$/;
|
|
1600
|
-
}
|
|
1601
|
-
static get singleRegex() {
|
|
1602
|
-
return /^'(.*)$/;
|
|
1603
|
-
}
|
|
1604
|
-
search(text) {
|
|
1605
|
-
let location = 0;
|
|
1606
|
-
let index;
|
|
1607
|
-
const indices = [];
|
|
1608
|
-
const patternLen = this.pattern.length;
|
|
1609
|
-
while ((index = text.indexOf(this.pattern, location)) > -1) {
|
|
1610
|
-
location = index + patternLen;
|
|
1611
|
-
indices.push([index, location - 1]);
|
|
1612
|
-
}
|
|
1613
|
-
const isMatch = !!indices.length;
|
|
1614
|
-
return {
|
|
1615
|
-
isMatch,
|
|
1616
|
-
score: isMatch ? 0 : 1,
|
|
1617
|
-
indices
|
|
1618
|
-
};
|
|
1487
|
+
if (geojson.type === "Feature" && geojson.geometry !== null) {
|
|
1488
|
+
return geojson.geometry.type;
|
|
1619
1489
|
}
|
|
1620
|
-
|
|
1621
|
-
var searchers = [
|
|
1622
|
-
ExactMatch,
|
|
1623
|
-
IncludeMatch,
|
|
1624
|
-
PrefixExactMatch,
|
|
1625
|
-
InversePrefixExactMatch,
|
|
1626
|
-
InverseSuffixExactMatch,
|
|
1627
|
-
SuffixExactMatch,
|
|
1628
|
-
InverseExactMatch,
|
|
1629
|
-
FuzzyMatch
|
|
1630
|
-
];
|
|
1631
|
-
var searchersLen = searchers.length;
|
|
1632
|
-
var SPACE_RE = / +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/;
|
|
1633
|
-
var OR_TOKEN = "|";
|
|
1634
|
-
function parseQuery(pattern, options = {}) {
|
|
1635
|
-
return pattern.split(OR_TOKEN).map((item) => {
|
|
1636
|
-
let query = item.trim().split(SPACE_RE).filter((item2) => item2 && !!item2.trim());
|
|
1637
|
-
let results = [];
|
|
1638
|
-
for (let i = 0, len = query.length; i < len; i += 1) {
|
|
1639
|
-
const queryItem = query[i];
|
|
1640
|
-
let found = false;
|
|
1641
|
-
let idx = -1;
|
|
1642
|
-
while (!found && ++idx < searchersLen) {
|
|
1643
|
-
const searcher = searchers[idx];
|
|
1644
|
-
let token = searcher.isMultiMatch(queryItem);
|
|
1645
|
-
if (token) {
|
|
1646
|
-
results.push(new searcher(token, options));
|
|
1647
|
-
found = true;
|
|
1648
|
-
}
|
|
1649
|
-
}
|
|
1650
|
-
if (found) {
|
|
1651
|
-
continue;
|
|
1652
|
-
}
|
|
1653
|
-
idx = -1;
|
|
1654
|
-
while (++idx < searchersLen) {
|
|
1655
|
-
const searcher = searchers[idx];
|
|
1656
|
-
let token = searcher.isSingleMatch(queryItem);
|
|
1657
|
-
if (token) {
|
|
1658
|
-
results.push(new searcher(token, options));
|
|
1659
|
-
break;
|
|
1660
|
-
}
|
|
1661
|
-
}
|
|
1662
|
-
}
|
|
1663
|
-
return results;
|
|
1664
|
-
});
|
|
1490
|
+
return geojson.type;
|
|
1665
1491
|
}
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1492
|
+
|
|
1493
|
+
// src/data/navigate/steps/path/index.ts
|
|
1494
|
+
var import_difference = __toESM(require("@turf/difference"));
|
|
1495
|
+
var import_envelope = __toESM(require("@turf/envelope"));
|
|
1496
|
+
var import_boolean_overlap = __toESM(require("@turf/boolean-overlap"));
|
|
1497
|
+
var import_boolean_intersects = __toESM(require("@turf/boolean-intersects"));
|
|
1498
|
+
|
|
1499
|
+
// ../../node_modules/@turf/meta/dist/esm/index.js
|
|
1500
|
+
function coordEach(geojson, callback, excludeWrapCoord) {
|
|
1501
|
+
if (geojson === null) return;
|
|
1502
|
+
var j, k, l, geometry, stopG, coords, geometryMaybeCollection, wrapShrink = 0, coordIndex = 0, isGeometryCollection, type = geojson.type, isFeatureCollection = type === "FeatureCollection", isFeature = type === "Feature", stop = isFeatureCollection ? geojson.features.length : 1;
|
|
1503
|
+
for (var featureIndex = 0; featureIndex < stop; featureIndex++) {
|
|
1504
|
+
geometryMaybeCollection = isFeatureCollection ? geojson.features[featureIndex].geometry : isFeature ? geojson.geometry : geojson;
|
|
1505
|
+
isGeometryCollection = geometryMaybeCollection ? geometryMaybeCollection.type === "GeometryCollection" : false;
|
|
1506
|
+
stopG = isGeometryCollection ? geometryMaybeCollection.geometries.length : 1;
|
|
1507
|
+
for (var geomIndex = 0; geomIndex < stopG; geomIndex++) {
|
|
1508
|
+
var multiFeatureIndex = 0;
|
|
1509
|
+
var geometryIndex = 0;
|
|
1510
|
+
geometry = isGeometryCollection ? geometryMaybeCollection.geometries[geomIndex] : geometryMaybeCollection;
|
|
1511
|
+
if (geometry === null) continue;
|
|
1512
|
+
coords = geometry.coordinates;
|
|
1513
|
+
var geomType = geometry.type;
|
|
1514
|
+
wrapShrink = excludeWrapCoord && (geomType === "Polygon" || geomType === "MultiPolygon") ? 1 : 0;
|
|
1515
|
+
switch (geomType) {
|
|
1516
|
+
case null:
|
|
1517
|
+
break;
|
|
1518
|
+
case "Point":
|
|
1519
|
+
if (callback(
|
|
1520
|
+
coords,
|
|
1521
|
+
coordIndex,
|
|
1522
|
+
featureIndex,
|
|
1523
|
+
multiFeatureIndex,
|
|
1524
|
+
geometryIndex
|
|
1525
|
+
) === false)
|
|
1526
|
+
return false;
|
|
1527
|
+
coordIndex++;
|
|
1528
|
+
multiFeatureIndex++;
|
|
1529
|
+
break;
|
|
1530
|
+
case "LineString":
|
|
1531
|
+
case "MultiPoint":
|
|
1532
|
+
for (j = 0; j < coords.length; j++) {
|
|
1533
|
+
if (callback(
|
|
1534
|
+
coords[j],
|
|
1535
|
+
coordIndex,
|
|
1536
|
+
featureIndex,
|
|
1537
|
+
multiFeatureIndex,
|
|
1538
|
+
geometryIndex
|
|
1539
|
+
) === false)
|
|
1540
|
+
return false;
|
|
1541
|
+
coordIndex++;
|
|
1542
|
+
if (geomType === "MultiPoint") multiFeatureIndex++;
|
|
1543
|
+
}
|
|
1544
|
+
if (geomType === "LineString") multiFeatureIndex++;
|
|
1545
|
+
break;
|
|
1546
|
+
case "Polygon":
|
|
1547
|
+
case "MultiLineString":
|
|
1548
|
+
for (j = 0; j < coords.length; j++) {
|
|
1549
|
+
for (k = 0; k < coords[j].length - wrapShrink; k++) {
|
|
1550
|
+
if (callback(
|
|
1551
|
+
coords[j][k],
|
|
1552
|
+
coordIndex,
|
|
1553
|
+
featureIndex,
|
|
1554
|
+
multiFeatureIndex,
|
|
1555
|
+
geometryIndex
|
|
1556
|
+
) === false)
|
|
1557
|
+
return false;
|
|
1558
|
+
coordIndex++;
|
|
1559
|
+
}
|
|
1560
|
+
if (geomType === "MultiLineString") multiFeatureIndex++;
|
|
1561
|
+
if (geomType === "Polygon") geometryIndex++;
|
|
1562
|
+
}
|
|
1563
|
+
if (geomType === "Polygon") multiFeatureIndex++;
|
|
1564
|
+
break;
|
|
1565
|
+
case "MultiPolygon":
|
|
1566
|
+
for (j = 0; j < coords.length; j++) {
|
|
1567
|
+
geometryIndex = 0;
|
|
1568
|
+
for (k = 0; k < coords[j].length; k++) {
|
|
1569
|
+
for (l = 0; l < coords[j][k].length - wrapShrink; l++) {
|
|
1570
|
+
if (callback(
|
|
1571
|
+
coords[j][k][l],
|
|
1572
|
+
coordIndex,
|
|
1573
|
+
featureIndex,
|
|
1574
|
+
multiFeatureIndex,
|
|
1575
|
+
geometryIndex
|
|
1576
|
+
) === false)
|
|
1577
|
+
return false;
|
|
1578
|
+
coordIndex++;
|
|
1579
|
+
}
|
|
1580
|
+
geometryIndex++;
|
|
1729
1581
|
}
|
|
1582
|
+
multiFeatureIndex++;
|
|
1730
1583
|
}
|
|
1731
|
-
} else {
|
|
1732
|
-
totalScore = 0;
|
|
1733
|
-
numMatches = 0;
|
|
1734
|
-
allIndices.length = 0;
|
|
1735
1584
|
break;
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
if (includeMatches) {
|
|
1744
|
-
result.indices = allIndices;
|
|
1745
|
-
}
|
|
1746
|
-
return result;
|
|
1585
|
+
case "GeometryCollection":
|
|
1586
|
+
for (j = 0; j < geometry.geometries.length; j++)
|
|
1587
|
+
if (coordEach(geometry.geometries[j], callback, excludeWrapCoord) === false)
|
|
1588
|
+
return false;
|
|
1589
|
+
break;
|
|
1590
|
+
default:
|
|
1591
|
+
throw new Error("Unknown Geometry Type");
|
|
1747
1592
|
}
|
|
1748
1593
|
}
|
|
1749
|
-
return {
|
|
1750
|
-
isMatch: false,
|
|
1751
|
-
score: 1
|
|
1752
|
-
};
|
|
1753
1594
|
}
|
|
1754
|
-
};
|
|
1755
|
-
var registeredSearchers = [];
|
|
1756
|
-
function register(...args) {
|
|
1757
|
-
registeredSearchers.push(...args);
|
|
1758
1595
|
}
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
}
|
|
1596
|
+
|
|
1597
|
+
// ../../node_modules/@turf/bbox/dist/esm/index.js
|
|
1598
|
+
function bbox(geojson, options = {}) {
|
|
1599
|
+
if (geojson.bbox != null && true !== options.recompute) {
|
|
1600
|
+
return geojson.bbox;
|
|
1765
1601
|
}
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
OR: "$or"
|
|
1771
|
-
};
|
|
1772
|
-
var KeyType = {
|
|
1773
|
-
PATH: "$path",
|
|
1774
|
-
PATTERN: "$val"
|
|
1775
|
-
};
|
|
1776
|
-
var isExpression = (query) => !!(query[LogicalOperator.AND] || query[LogicalOperator.OR]);
|
|
1777
|
-
var isPath = (query) => !!query[KeyType.PATH];
|
|
1778
|
-
var isLeaf = (query) => !isArray(query) && isObject(query) && !isExpression(query);
|
|
1779
|
-
var convertToExplicit = (query) => ({
|
|
1780
|
-
[LogicalOperator.AND]: Object.keys(query).map((key) => ({
|
|
1781
|
-
[key]: query[key]
|
|
1782
|
-
}))
|
|
1783
|
-
});
|
|
1784
|
-
function parse(query, options, { auto = true } = {}) {
|
|
1785
|
-
const next = (query2) => {
|
|
1786
|
-
let keys = Object.keys(query2);
|
|
1787
|
-
const isQueryPath = isPath(query2);
|
|
1788
|
-
if (!isQueryPath && keys.length > 1 && !isExpression(query2)) {
|
|
1789
|
-
return next(convertToExplicit(query2));
|
|
1602
|
+
const result = [Infinity, Infinity, -Infinity, -Infinity];
|
|
1603
|
+
coordEach(geojson, (coord) => {
|
|
1604
|
+
if (result[0] > coord[0]) {
|
|
1605
|
+
result[0] = coord[0];
|
|
1790
1606
|
}
|
|
1791
|
-
if (
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
pattern
|
|
1800
|
-
};
|
|
1801
|
-
if (auto) {
|
|
1802
|
-
obj.searcher = createSearcher(pattern, options);
|
|
1803
|
-
}
|
|
1804
|
-
return obj;
|
|
1607
|
+
if (result[1] > coord[1]) {
|
|
1608
|
+
result[1] = coord[1];
|
|
1609
|
+
}
|
|
1610
|
+
if (result[2] < coord[0]) {
|
|
1611
|
+
result[2] = coord[0];
|
|
1612
|
+
}
|
|
1613
|
+
if (result[3] < coord[1]) {
|
|
1614
|
+
result[3] = coord[1];
|
|
1805
1615
|
}
|
|
1806
|
-
let node = {
|
|
1807
|
-
children: [],
|
|
1808
|
-
operator: keys[0]
|
|
1809
|
-
};
|
|
1810
|
-
keys.forEach((key) => {
|
|
1811
|
-
const value = query2[key];
|
|
1812
|
-
if (isArray(value)) {
|
|
1813
|
-
value.forEach((item) => {
|
|
1814
|
-
node.children.push(next(item));
|
|
1815
|
-
});
|
|
1816
|
-
}
|
|
1817
|
-
});
|
|
1818
|
-
return node;
|
|
1819
|
-
};
|
|
1820
|
-
if (!isExpression(query)) {
|
|
1821
|
-
query = convertToExplicit(query);
|
|
1822
|
-
}
|
|
1823
|
-
return next(query);
|
|
1824
|
-
}
|
|
1825
|
-
function computeScore(results, { ignoreFieldNorm = Config.ignoreFieldNorm }) {
|
|
1826
|
-
results.forEach((result) => {
|
|
1827
|
-
let totalScore = 1;
|
|
1828
|
-
result.matches.forEach(({ key, norm: norm2, score }) => {
|
|
1829
|
-
const weight = key ? key.weight : null;
|
|
1830
|
-
totalScore *= Math.pow(
|
|
1831
|
-
score === 0 && weight ? Number.EPSILON : score,
|
|
1832
|
-
(weight || 1) * (ignoreFieldNorm ? 1 : norm2)
|
|
1833
|
-
);
|
|
1834
|
-
});
|
|
1835
|
-
result.score = totalScore;
|
|
1836
1616
|
});
|
|
1617
|
+
return result;
|
|
1837
1618
|
}
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1619
|
+
var index_default = bbox;
|
|
1620
|
+
|
|
1621
|
+
// src/data/navigate/steps/path/turf/shortestPath.ts
|
|
1622
|
+
var import_boolean_point_in_polygon3 = __toESM(require("@turf/boolean-point-in-polygon"));
|
|
1623
|
+
var import_distance4 = __toESM(require("@turf/distance"));
|
|
1624
|
+
var import_transform_scale = __toESM(require("@turf/transform-scale"));
|
|
1625
|
+
var import_union = __toESM(require("@turf/union"));
|
|
1626
|
+
var import_bbox_polygon = __toESM(require("@turf/bbox-polygon"));
|
|
1627
|
+
var import_clean_coords = require("@turf/clean-coords");
|
|
1628
|
+
var import_pathfinding = __toESM(require("pathfinding"));
|
|
1629
|
+
var import_set3 = __toESM(require("lodash/set"));
|
|
1630
|
+
|
|
1631
|
+
// src/data/navigate/steps/path/turf/stringPull.ts
|
|
1632
|
+
function stringPull(grid, path) {
|
|
1633
|
+
const isWalkable = (x, y) => grid.isInside(x, y) && grid.isWalkableAt(x, y);
|
|
1634
|
+
function hasLOS(a, b) {
|
|
1635
|
+
let x0 = a[0], y0 = a[1];
|
|
1636
|
+
const x1 = b[0], y1 = b[1];
|
|
1637
|
+
if (!isWalkable(x0, y0) || !isWalkable(x1, y1)) return false;
|
|
1638
|
+
const dx = Math.abs(x1 - x0);
|
|
1639
|
+
const dy = Math.abs(y1 - y0);
|
|
1640
|
+
const sx = x0 < x1 ? 1 : -1;
|
|
1641
|
+
const sy = y0 < y1 ? 1 : -1;
|
|
1642
|
+
let err = dx - dy;
|
|
1643
|
+
while (true) {
|
|
1644
|
+
if (!isWalkable(x0, y0)) return false;
|
|
1645
|
+
if (x0 === x1 && y0 === y1) break;
|
|
1646
|
+
const e2 = err * 2;
|
|
1647
|
+
let nx = x0;
|
|
1648
|
+
let ny = y0;
|
|
1649
|
+
let movedX = false;
|
|
1650
|
+
let movedY = false;
|
|
1651
|
+
if (e2 > -dy) {
|
|
1652
|
+
err -= dy;
|
|
1653
|
+
nx += sx;
|
|
1654
|
+
movedX = true;
|
|
1655
|
+
}
|
|
1656
|
+
if (e2 < dx) {
|
|
1657
|
+
err += dx;
|
|
1658
|
+
ny += sy;
|
|
1659
|
+
movedY = true;
|
|
1660
|
+
}
|
|
1661
|
+
if (movedX && movedY) {
|
|
1662
|
+
if (!isWalkable(nx, y0) || !isWalkable(x0, ny)) return false;
|
|
1663
|
+
}
|
|
1664
|
+
x0 = nx;
|
|
1665
|
+
y0 = ny;
|
|
1855
1666
|
}
|
|
1856
|
-
|
|
1857
|
-
|
|
1667
|
+
return true;
|
|
1668
|
+
}
|
|
1669
|
+
if (path.length <= 2) return path;
|
|
1670
|
+
const out = [path[0]];
|
|
1671
|
+
let i = 0;
|
|
1672
|
+
while (i < path.length - 1) {
|
|
1673
|
+
let best = i + 1;
|
|
1674
|
+
for (let j = i + 2; j < path.length; j++) {
|
|
1675
|
+
if (hasLOS(path[i], path[j])) best = j;
|
|
1676
|
+
else break;
|
|
1858
1677
|
}
|
|
1859
|
-
|
|
1860
|
-
|
|
1678
|
+
out.push(path[best]);
|
|
1679
|
+
i = best;
|
|
1680
|
+
}
|
|
1681
|
+
return out;
|
|
1861
1682
|
}
|
|
1862
|
-
|
|
1863
|
-
|
|
1683
|
+
|
|
1684
|
+
// src/data/navigate/steps/path/turf/pruneSmallAngle.ts
|
|
1685
|
+
function pruneSmallAngles(path, minDeg = 10) {
|
|
1686
|
+
if (path.length <= 2) return path;
|
|
1687
|
+
const out = [path[0]];
|
|
1688
|
+
for (let i = 1; i < path.length - 1; i++) {
|
|
1689
|
+
const a = out[out.length - 1];
|
|
1690
|
+
const b = path[i];
|
|
1691
|
+
const c = path[i + 1];
|
|
1692
|
+
const abx = b[0] - a[0], aby = b[1] - a[1];
|
|
1693
|
+
const bcx = c[0] - b[0], bcy = c[1] - b[1];
|
|
1694
|
+
const dot = abx * bcx + aby * bcy;
|
|
1695
|
+
const ab = Math.hypot(abx, aby);
|
|
1696
|
+
const bc = Math.hypot(bcx, bcy);
|
|
1697
|
+
const angle = Math.acos(dot / (ab * bc)) * 180 / Math.PI;
|
|
1698
|
+
if (angle > minDeg) out.push(b);
|
|
1699
|
+
}
|
|
1700
|
+
out.push(path[path.length - 1]);
|
|
1701
|
+
return out;
|
|
1864
1702
|
}
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
const data = {
|
|
1875
|
-
item: docs[idx],
|
|
1876
|
-
refIndex: idx
|
|
1877
|
-
};
|
|
1878
|
-
if (transformers.length) {
|
|
1879
|
-
transformers.forEach((transformer) => {
|
|
1880
|
-
transformer(result, data);
|
|
1881
|
-
});
|
|
1703
|
+
|
|
1704
|
+
// src/data/navigate/steps/path/turf/pruneShortSegments.ts
|
|
1705
|
+
function pruneShortSegments(path, minLen = 5) {
|
|
1706
|
+
const out = [path[0]];
|
|
1707
|
+
for (let i = 1; i < path.length; i++) {
|
|
1708
|
+
const [x0, y0] = out[out.length - 1];
|
|
1709
|
+
const [x1, y1] = path[i];
|
|
1710
|
+
if (Math.hypot(x1 - x0, y1 - y0) >= minLen) {
|
|
1711
|
+
out.push(path[i]);
|
|
1882
1712
|
}
|
|
1883
|
-
|
|
1884
|
-
|
|
1713
|
+
}
|
|
1714
|
+
return out;
|
|
1885
1715
|
}
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1716
|
+
|
|
1717
|
+
// src/data/navigate/steps/path/turf/clearance.ts
|
|
1718
|
+
function buildClearanceGrid(matrix) {
|
|
1719
|
+
const h = matrix.length;
|
|
1720
|
+
const w = matrix[0].length;
|
|
1721
|
+
const INF = 1e9;
|
|
1722
|
+
const dist = Array.from({ length: h }, () => Array(w).fill(INF));
|
|
1723
|
+
const q = [];
|
|
1724
|
+
for (let y = 0; y < h; y++) {
|
|
1725
|
+
for (let x = 0; x < w; x++) {
|
|
1726
|
+
if (matrix[y][x] === 1) {
|
|
1727
|
+
dist[y][x] = 0;
|
|
1728
|
+
q.push([x, y]);
|
|
1729
|
+
}
|
|
1891
1730
|
}
|
|
1892
|
-
this._keyStore = new KeyStore(this.options.keys);
|
|
1893
|
-
this.setCollection(docs, index);
|
|
1894
1731
|
}
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1732
|
+
const dirs = [
|
|
1733
|
+
[1, 0],
|
|
1734
|
+
[-1, 0],
|
|
1735
|
+
[0, 1],
|
|
1736
|
+
[0, -1],
|
|
1737
|
+
[1, 1],
|
|
1738
|
+
[1, -1],
|
|
1739
|
+
[-1, 1],
|
|
1740
|
+
[-1, -1]
|
|
1741
|
+
];
|
|
1742
|
+
let qi = 0;
|
|
1743
|
+
while (qi < q.length) {
|
|
1744
|
+
const [x, y] = q[qi++];
|
|
1745
|
+
const d0 = dist[y][x];
|
|
1746
|
+
for (const [dx, dy] of dirs) {
|
|
1747
|
+
const nx = x + dx, ny = y + dy;
|
|
1748
|
+
if (nx < 0 || ny < 0 || nx >= w || ny >= h) continue;
|
|
1749
|
+
const nd = d0 + 1;
|
|
1750
|
+
if (nd < dist[ny][nx]) {
|
|
1751
|
+
dist[ny][nx] = nd;
|
|
1752
|
+
q.push([nx, ny]);
|
|
1753
|
+
}
|
|
1899
1754
|
}
|
|
1900
|
-
this._myIndex = index || createIndex(this.options.keys, this._docs, {
|
|
1901
|
-
getFn: this.options.getFn,
|
|
1902
|
-
fieldNormWeight: this.options.fieldNormWeight
|
|
1903
|
-
});
|
|
1904
1755
|
}
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1756
|
+
return dist;
|
|
1757
|
+
}
|
|
1758
|
+
function snapPointToClearancePeak(p, clearance, isWalkableCell, radius = 4) {
|
|
1759
|
+
const [px, py] = p;
|
|
1760
|
+
let best = p;
|
|
1761
|
+
let bestScore = clearance[py]?.[px] ?? -Infinity;
|
|
1762
|
+
for (let dy = -radius; dy <= radius; dy++) {
|
|
1763
|
+
for (let dx = -radius; dx <= radius; dx++) {
|
|
1764
|
+
const x = px + dx;
|
|
1765
|
+
const y = py + dy;
|
|
1766
|
+
if (!isWalkableCell(x, y)) continue;
|
|
1767
|
+
const score = clearance[y][x];
|
|
1768
|
+
const penalty = Math.hypot(dx, dy) * 5e-3;
|
|
1769
|
+
const finalScore = score - penalty;
|
|
1770
|
+
if (finalScore > bestScore) {
|
|
1771
|
+
bestScore = finalScore;
|
|
1772
|
+
best = [x, y];
|
|
1921
1773
|
}
|
|
1922
1774
|
}
|
|
1923
|
-
return results;
|
|
1924
1775
|
}
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1776
|
+
return best;
|
|
1777
|
+
}
|
|
1778
|
+
function centerlineSnapPath(path, clearance, isWalkableCell, radius = 4) {
|
|
1779
|
+
const snapped = path.map((p) => snapPointToClearancePeak(p, clearance, isWalkableCell, radius));
|
|
1780
|
+
return snapped;
|
|
1781
|
+
}
|
|
1782
|
+
|
|
1783
|
+
// src/data/navigate/steps/path/turf/shortestPath.ts
|
|
1784
|
+
function shortestPath(start, end, options) {
|
|
1785
|
+
options = options || {};
|
|
1786
|
+
if (!isObject(options)) throw new Error("options is invalid");
|
|
1787
|
+
let resolution = options.resolution;
|
|
1788
|
+
const smoothenPath = options.smoothenPath;
|
|
1789
|
+
let obstacles = options.obstacles || featureCollection([]);
|
|
1790
|
+
if (!start) throw new Error("start is required");
|
|
1791
|
+
if (!end) throw new Error("end is required");
|
|
1792
|
+
if (resolution && !isNumber(resolution) || resolution <= 0)
|
|
1793
|
+
throw new Error("options.resolution must be a number, greater than 0");
|
|
1794
|
+
const startCoord = getCoord(start);
|
|
1795
|
+
const endCoord = getCoord(end);
|
|
1796
|
+
start = point(startCoord);
|
|
1797
|
+
end = point(endCoord);
|
|
1798
|
+
switch (getType(obstacles)) {
|
|
1799
|
+
case "FeatureCollection":
|
|
1800
|
+
if (obstacles.features.length === 0)
|
|
1801
|
+
return lineString([startCoord, endCoord]);
|
|
1802
|
+
break;
|
|
1803
|
+
case "Polygon":
|
|
1804
|
+
obstacles = featureCollection([feature(getGeom(obstacles))]);
|
|
1805
|
+
break;
|
|
1806
|
+
default:
|
|
1807
|
+
throw new Error("invalid obstacles");
|
|
1808
|
+
}
|
|
1809
|
+
const collection = obstacles;
|
|
1810
|
+
collection.features.push(start, end);
|
|
1811
|
+
const box = index_default((0, import_transform_scale.default)((0, import_bbox_polygon.default)(index_default(collection)), 1.15));
|
|
1812
|
+
if (!resolution) {
|
|
1813
|
+
const width = (0, import_distance4.default)([box[0], box[1]], [box[2], box[1]], options);
|
|
1814
|
+
resolution = width / 100;
|
|
1815
|
+
}
|
|
1816
|
+
collection.features.pop();
|
|
1817
|
+
collection.features.pop();
|
|
1818
|
+
const [west, south, east, north] = box;
|
|
1819
|
+
const xFraction = resolution / (0, import_distance4.default)([west, south], [east, south], options);
|
|
1820
|
+
const cellWidth = xFraction * (east - west);
|
|
1821
|
+
const yFraction = resolution / (0, import_distance4.default)([west, south], [west, north], options);
|
|
1822
|
+
const cellHeight = yFraction * (north - south);
|
|
1823
|
+
const bboxHorizontalSide = east - west;
|
|
1824
|
+
const bboxVerticalSide = north - south;
|
|
1825
|
+
const columns = Math.floor(bboxHorizontalSide / cellWidth);
|
|
1826
|
+
const rows = Math.floor(bboxVerticalSide / cellHeight);
|
|
1827
|
+
const deltaX = (bboxHorizontalSide - columns * cellWidth) / 2;
|
|
1828
|
+
const deltaY = (bboxVerticalSide - rows * cellHeight) / 2;
|
|
1829
|
+
let closestToStart = null, closestToEnd = null, minDistStart = Infinity, minDistEnd = Infinity, currentY = north - deltaY, currentX = west + deltaX, row = 0, column = 0, distStart, distEnd, pt, isInsideObstacle;
|
|
1830
|
+
const roundLoopY = Math.ceil((currentY - south) / cellHeight);
|
|
1831
|
+
const roundLoopX = Math.ceil((east - currentX) / cellWidth);
|
|
1832
|
+
let totalRounds = roundLoopX * roundLoopY;
|
|
1833
|
+
const pointMatrix = [];
|
|
1834
|
+
const matrix = [];
|
|
1835
|
+
const obstacleTotal = collection.features.length;
|
|
1836
|
+
const obstacleFeatures = collection.features;
|
|
1837
|
+
let combinedObstacle = obstacleFeatures[0];
|
|
1838
|
+
let obstacleIndex = 0;
|
|
1839
|
+
for (obstacleIndex = 0; obstacleIndex < obstacleTotal; obstacleIndex++) {
|
|
1840
|
+
const nextObstacleFeature = obstacleFeatures[obstacleIndex + 1];
|
|
1841
|
+
if (!nextObstacleFeature) continue;
|
|
1842
|
+
try {
|
|
1843
|
+
combinedObstacle = (0, import_union.default)(
|
|
1844
|
+
featureCollection([combinedObstacle, nextObstacleFeature])
|
|
1845
|
+
);
|
|
1846
|
+
} catch (e) {
|
|
1847
|
+
console.log(e);
|
|
1848
|
+
}
|
|
1931
1849
|
}
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
computeScore(results, { ignoreFieldNorm });
|
|
1942
|
-
if (shouldSort) {
|
|
1943
|
-
results.sort(sortFn);
|
|
1850
|
+
while (totalRounds--) {
|
|
1851
|
+
pt = point([currentX, currentY]);
|
|
1852
|
+
isInsideObstacle = (0, import_boolean_point_in_polygon3.default)(pt, combinedObstacle);
|
|
1853
|
+
(0, import_set3.default)(matrix, `[${row}][${column}]`, isInsideObstacle ? 1 : 0);
|
|
1854
|
+
(0, import_set3.default)(pointMatrix, `[${row}][${column}]`, `${currentX}|${currentY}`);
|
|
1855
|
+
distStart = (0, import_distance4.default)(pt, start);
|
|
1856
|
+
if (!isInsideObstacle && distStart < minDistStart) {
|
|
1857
|
+
minDistStart = distStart;
|
|
1858
|
+
closestToStart = { x: column, y: row };
|
|
1944
1859
|
}
|
|
1945
|
-
|
|
1946
|
-
|
|
1860
|
+
distEnd = (0, import_distance4.default)(pt, end);
|
|
1861
|
+
if (!isInsideObstacle && distEnd < minDistEnd) {
|
|
1862
|
+
minDistEnd = distEnd;
|
|
1863
|
+
closestToEnd = { x: column, y: row };
|
|
1864
|
+
}
|
|
1865
|
+
if (column < roundLoopX) {
|
|
1866
|
+
currentX += cellWidth;
|
|
1867
|
+
column++;
|
|
1868
|
+
continue;
|
|
1869
|
+
}
|
|
1870
|
+
if (row < roundLoopY) {
|
|
1871
|
+
currentY -= cellHeight;
|
|
1872
|
+
currentX = west + deltaX;
|
|
1873
|
+
column = 0;
|
|
1874
|
+
row++;
|
|
1947
1875
|
}
|
|
1948
|
-
return format(results, this._docs, {
|
|
1949
|
-
includeMatches,
|
|
1950
|
-
includeScore
|
|
1951
|
-
});
|
|
1952
1876
|
}
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1877
|
+
const finder = new import_pathfinding.default.AStarFinder({
|
|
1878
|
+
allowDiagonal: true,
|
|
1879
|
+
dontCrossCorners: true,
|
|
1880
|
+
heuristic: import_pathfinding.default.Heuristic.euclidean
|
|
1881
|
+
});
|
|
1882
|
+
const grid = new import_pathfinding.default.Grid(matrix);
|
|
1883
|
+
const startOnMatrix = [closestToStart.x, closestToStart.y];
|
|
1884
|
+
const endOnMatrix = [closestToEnd.x, closestToEnd.y];
|
|
1885
|
+
let result = finder.findPath(...startOnMatrix, ...endOnMatrix, grid);
|
|
1886
|
+
if (result.length > 0) {
|
|
1887
|
+
result = stringPull(grid, result);
|
|
1888
|
+
const clearanceGrid = buildClearanceGrid(matrix);
|
|
1889
|
+
const isWalkable = (x, y) => grid.isInside(x, y) && grid.isWalkableAt(x, y);
|
|
1890
|
+
result = centerlineSnapPath(result, clearanceGrid, isWalkable);
|
|
1891
|
+
result = stringPull(grid, result);
|
|
1892
|
+
result = pruneSmallAngles(result);
|
|
1893
|
+
result = pruneShortSegments(result);
|
|
1894
|
+
}
|
|
1895
|
+
result.pop();
|
|
1896
|
+
result.shift();
|
|
1897
|
+
const path = [startCoord];
|
|
1898
|
+
result.forEach((coord) => {
|
|
1899
|
+
const coords = pointMatrix[coord[1]][coord[0]].split("|");
|
|
1900
|
+
path.push([+coords[0], +coords[1]]);
|
|
1901
|
+
});
|
|
1902
|
+
path.push(endCoord);
|
|
1903
|
+
return (0, import_clean_coords.cleanCoords)(lineString(path));
|
|
1904
|
+
}
|
|
1905
|
+
var shortestPath_default = shortestPath;
|
|
1906
|
+
|
|
1907
|
+
// src/data/navigate/steps/path/index.ts
|
|
1908
|
+
var createStepPathUtils = (options) => {
|
|
1909
|
+
const resolution = options.resolution ?? 88e-5;
|
|
1910
|
+
const { units, kiosks, fixtures } = options.data;
|
|
1911
|
+
const possibleObstacleFeatures = [...units, ...kiosks, ...fixtures];
|
|
1912
|
+
const filterObstaclesByOrdinal = (levelId) => {
|
|
1913
|
+
return possibleObstacleFeatures.filter(({ feature_type, properties, geometry }) => {
|
|
1914
|
+
return properties.level_id === levelId && ["Polygon", "MultiPolygon"].includes(geometry.type) && (OBSTACLE_FEATURE_TYPES.includes(feature_type) || "category" in properties && OBSTACLE_CATEGORIES.includes(properties.category));
|
|
1969
1915
|
});
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
const
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
matches
|
|
1988
|
-
}
|
|
1989
|
-
];
|
|
1990
|
-
}
|
|
1991
|
-
return [];
|
|
1992
|
-
}
|
|
1993
|
-
const res = [];
|
|
1994
|
-
for (let i = 0, len = node.children.length; i < len; i += 1) {
|
|
1995
|
-
const child = node.children[i];
|
|
1996
|
-
const result = evaluate(child, item, idx);
|
|
1997
|
-
if (result.length) {
|
|
1998
|
-
res.push(...result);
|
|
1999
|
-
} else if (node.operator === LogicalOperator.AND) {
|
|
2000
|
-
return [];
|
|
2001
|
-
}
|
|
2002
|
-
}
|
|
2003
|
-
return res;
|
|
2004
|
-
};
|
|
2005
|
-
const records = this._myIndex.records;
|
|
2006
|
-
const resultMap = {};
|
|
2007
|
-
const results = [];
|
|
2008
|
-
records.forEach(({ $: item, i: idx }) => {
|
|
2009
|
-
if (isDefined(item)) {
|
|
2010
|
-
let expResults = evaluate(expression, item, idx);
|
|
2011
|
-
if (expResults.length) {
|
|
2012
|
-
if (!resultMap[idx]) {
|
|
2013
|
-
resultMap[idx] = { idx, item, matches: [] };
|
|
2014
|
-
results.push(resultMap[idx]);
|
|
2015
|
-
}
|
|
2016
|
-
expResults.forEach(({ matches }) => {
|
|
2017
|
-
resultMap[idx].matches.push(...matches);
|
|
2018
|
-
});
|
|
1916
|
+
};
|
|
1917
|
+
const findObstaclesFromWalkway = (intermediaryUnit, exceptionIds = []) => {
|
|
1918
|
+
const result = featureCollection([]);
|
|
1919
|
+
if (!intermediaryUnit) return result;
|
|
1920
|
+
const walkwayLevelId = intermediaryUnit.properties.level_id;
|
|
1921
|
+
const obstacleOnLevel = filterObstaclesByOrdinal(walkwayLevelId).filter(
|
|
1922
|
+
(obstacle) => !exceptionIds.includes(obstacle.id)
|
|
1923
|
+
);
|
|
1924
|
+
const relatedObstacleWithIntermediary = obstacleOnLevel.reduce(
|
|
1925
|
+
(obstacles, feature2) => {
|
|
1926
|
+
if (
|
|
1927
|
+
// Prevent detecting itself as an obstacle
|
|
1928
|
+
// Ex. Unable to draw a line to amenity located with in a room as room is also consider as obstacle
|
|
1929
|
+
feature2.id !== intermediaryUnit.id && ((0, import_boolean_overlap.default)(intermediaryUnit, feature2) || (0, import_boolean_intersects.default)(intermediaryUnit, feature2))
|
|
1930
|
+
) {
|
|
1931
|
+
const polygons = getType(feature2) === "Polygon" ? [polygon(feature2.geometry.coordinates, { id: feature2.id })] : feature2.geometry.coordinates.map((ring) => polygon(ring, { id: feature2.id }));
|
|
1932
|
+
obstacles.push(...polygons);
|
|
2019
1933
|
}
|
|
2020
|
-
|
|
1934
|
+
return obstacles;
|
|
1935
|
+
},
|
|
1936
|
+
[]
|
|
1937
|
+
);
|
|
1938
|
+
const intermediaryExtends = (0, import_envelope.default)(intermediaryUnit);
|
|
1939
|
+
const walkwayPerimeter = (0, import_difference.default)(
|
|
1940
|
+
featureCollection([intermediaryExtends, intermediaryUnit])
|
|
1941
|
+
);
|
|
1942
|
+
result.features.push(...relatedObstacleWithIntermediary, walkwayPerimeter);
|
|
1943
|
+
return result;
|
|
1944
|
+
};
|
|
1945
|
+
const findPathOnArea = (originPoint, destinationPoint, options2) => {
|
|
1946
|
+
const { obstacles = featureCollection([]), resolution: resolution2, properties } = options2 || {};
|
|
1947
|
+
const stepPath = shortestPath_default(originPoint, destinationPoint, {
|
|
1948
|
+
obstacles,
|
|
1949
|
+
smoothenPath: false,
|
|
1950
|
+
resolution: resolution2
|
|
2021
1951
|
});
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
const
|
|
2027
|
-
const
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
searcher
|
|
2039
|
-
})
|
|
2040
|
-
);
|
|
2041
|
-
});
|
|
2042
|
-
if (matches.length) {
|
|
2043
|
-
results.push({
|
|
2044
|
-
idx,
|
|
2045
|
-
item,
|
|
2046
|
-
matches
|
|
2047
|
-
});
|
|
2048
|
-
}
|
|
1952
|
+
stepPath.properties = properties;
|
|
1953
|
+
return stepPath;
|
|
1954
|
+
};
|
|
1955
|
+
const findStepPath = (from, to, intermediaries) => {
|
|
1956
|
+
const t0 = performance.now();
|
|
1957
|
+
const relatedWalkablePlatform = intermediaries.find(
|
|
1958
|
+
(feature2) => WALKABLE_CATEGORY.includes(feature2.properties.category)
|
|
1959
|
+
);
|
|
1960
|
+
const exceptionFeatureIds = [];
|
|
1961
|
+
const obstacles = findObstaclesFromWalkway(
|
|
1962
|
+
relatedWalkablePlatform,
|
|
1963
|
+
import_lodash11.default.compact(exceptionFeatureIds)
|
|
1964
|
+
);
|
|
1965
|
+
const line = findPathOnArea(from, to, {
|
|
1966
|
+
resolution,
|
|
1967
|
+
obstacles
|
|
2049
1968
|
});
|
|
2050
|
-
return
|
|
1969
|
+
return line.geometry.coordinates;
|
|
1970
|
+
};
|
|
1971
|
+
return {
|
|
1972
|
+
findStepPath
|
|
1973
|
+
};
|
|
1974
|
+
};
|
|
1975
|
+
|
|
1976
|
+
// src/data/navigate/landmark/createLandmarkUtils.ts
|
|
1977
|
+
var import_center6 = require("@turf/center");
|
|
1978
|
+
var import_distance5 = __toESM(require("@turf/distance"));
|
|
1979
|
+
var NEARBY_DISTANCE = 30;
|
|
1980
|
+
var createLandmarkUtils = (options) => {
|
|
1981
|
+
const { data, findByIdSync } = options;
|
|
1982
|
+
const { occupants } = data;
|
|
1983
|
+
const occupantToLandmark = (occupant) => {
|
|
1984
|
+
const locationType = occupant.properties.unit_id ? "unit" : "kiosk";
|
|
1985
|
+
const locationId = locationType === "unit" ? occupant.properties.unit_id : occupant.properties.kiosk_id;
|
|
1986
|
+
const location = locationType === "unit" ? findByIdSync(locationId) : findByIdSync(locationId);
|
|
1987
|
+
const level = findByIdSync(location.properties.level_id);
|
|
1988
|
+
return {
|
|
1989
|
+
name: occupant.properties.name,
|
|
1990
|
+
point: (0, import_center6.center)(location.geometry).geometry.coordinates,
|
|
1991
|
+
level_id: location.properties.level_id,
|
|
1992
|
+
is_priority: occupant.properties.is_landmark,
|
|
1993
|
+
ordinal: level.properties.ordinal
|
|
1994
|
+
};
|
|
1995
|
+
};
|
|
1996
|
+
const landmarks = [
|
|
1997
|
+
...occupants.map(occupantToLandmark)
|
|
1998
|
+
];
|
|
1999
|
+
const findNearbyLandmarks = (point2, levelId) => {
|
|
2000
|
+
if (point2 === null || levelId === null) return [];
|
|
2001
|
+
return landmarks.map((landmark) => {
|
|
2002
|
+
const landmarkAndDistance = {
|
|
2003
|
+
landmark,
|
|
2004
|
+
d: (0, import_distance5.default)(point2, landmark.point, { units: "meters" })
|
|
2005
|
+
};
|
|
2006
|
+
return landmarkAndDistance;
|
|
2007
|
+
}).filter(({ landmark, d }) => d <= NEARBY_DISTANCE && landmark.level_id === levelId).sort((a, b) => {
|
|
2008
|
+
const aPriority = a.landmark.is_priority ? 0 : 1;
|
|
2009
|
+
const bPriority = b.landmark.is_priority ? 0 : 1;
|
|
2010
|
+
if (aPriority !== bPriority) return aPriority - bPriority;
|
|
2011
|
+
return a.d - b.d;
|
|
2012
|
+
}).map(({ landmark }) => landmark);
|
|
2013
|
+
};
|
|
2014
|
+
const findNearestLandmark = (point2, levelId) => {
|
|
2015
|
+
const nearbyLandmarks = findNearbyLandmarks(point2, levelId);
|
|
2016
|
+
const nearestLandmark = nearbyLandmarks.length > 0 ? nearbyLandmarks[0] : null;
|
|
2017
|
+
return nearestLandmark;
|
|
2018
|
+
};
|
|
2019
|
+
return { findNearbyLandmarks, findNearestLandmark };
|
|
2020
|
+
};
|
|
2021
|
+
|
|
2022
|
+
// src/data/navigate/steps/utils/extractStartPoint.ts
|
|
2023
|
+
var import_center7 = require("@turf/center");
|
|
2024
|
+
|
|
2025
|
+
// src/data/navigate/steps/utils/featureIdGuard.ts
|
|
2026
|
+
var isOccupant = (id) => !!id && id.startsWith("occupant-");
|
|
2027
|
+
var isUnit = (id) => !!id && id.startsWith("unit-");
|
|
2028
|
+
var isKiosk = (id) => !!id && id.startsWith("kiosk-");
|
|
2029
|
+
var isOpening = (id) => !!id && id.startsWith("opening-");
|
|
2030
|
+
|
|
2031
|
+
// src/data/navigate/type-guard.ts
|
|
2032
|
+
function isCoordinateOrdinalString(id) {
|
|
2033
|
+
return /^-?\d+(\.\d+)?,-?\d+(\.\d+)?,-?\d+(\.\d+)?o$/.test(id);
|
|
2034
|
+
}
|
|
2035
|
+
|
|
2036
|
+
// src/data/navigate/steps/utils/extractStartPoint.ts
|
|
2037
|
+
var extractStartPoint = (path, options) => {
|
|
2038
|
+
const { findByIdSync } = options;
|
|
2039
|
+
const [a, b, c] = path;
|
|
2040
|
+
if (isOccupant(a) && isUnit(b) && isOpening(c)) {
|
|
2041
|
+
const occ = findByIdSync(a);
|
|
2042
|
+
const opening = findByIdSync(c);
|
|
2043
|
+
const level = findByIdSync(opening.properties.level_id);
|
|
2044
|
+
return [
|
|
2045
|
+
{
|
|
2046
|
+
id: occ.id,
|
|
2047
|
+
type: "start",
|
|
2048
|
+
name: occ.properties.name,
|
|
2049
|
+
point: (0, import_center7.center)(opening).geometry.coordinates,
|
|
2050
|
+
levelId: opening.properties.level_id,
|
|
2051
|
+
ordinal: level.properties.ordinal,
|
|
2052
|
+
source: { type: "opening", id: opening.id }
|
|
2053
|
+
},
|
|
2054
|
+
path.slice(3)
|
|
2055
|
+
];
|
|
2051
2056
|
}
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2057
|
+
if (isOccupant(a) && isKiosk(b)) {
|
|
2058
|
+
const occ = findByIdSync(a);
|
|
2059
|
+
const kiosk = findByIdSync(c);
|
|
2060
|
+
const level = findByIdSync(kiosk.properties.level_id);
|
|
2061
|
+
return [
|
|
2062
|
+
{
|
|
2063
|
+
id: occ.id,
|
|
2064
|
+
type: "start",
|
|
2065
|
+
name: occ.properties.name,
|
|
2066
|
+
point: (0, import_center7.center)(kiosk).geometry.coordinates,
|
|
2067
|
+
levelId: kiosk.properties.level_id,
|
|
2068
|
+
ordinal: level.properties.ordinal,
|
|
2069
|
+
source: { type: "kiosk", id: kiosk.id }
|
|
2070
|
+
},
|
|
2071
|
+
path.slice(2)
|
|
2072
|
+
];
|
|
2073
|
+
}
|
|
2074
|
+
if (isCoordinateOrdinalString(a) && isOpening(b)) {
|
|
2075
|
+
const [lat, lng, ordinal] = parseOrdinalCoordinate(a);
|
|
2076
|
+
const opening = findByIdSync(b);
|
|
2077
|
+
return [
|
|
2078
|
+
{
|
|
2079
|
+
id: a,
|
|
2080
|
+
type: "start",
|
|
2081
|
+
name: { en: `Your location` },
|
|
2082
|
+
point: [lng, lat],
|
|
2083
|
+
levelId: opening.properties.level_id,
|
|
2084
|
+
ordinal,
|
|
2085
|
+
source: { type: "opening", id: opening.id }
|
|
2086
|
+
},
|
|
2087
|
+
path.slice(1)
|
|
2088
|
+
];
|
|
2089
|
+
}
|
|
2090
|
+
return [null, path];
|
|
2091
|
+
};
|
|
2092
|
+
|
|
2093
|
+
// src/data/navigate/steps/utils/extractEndPint.ts
|
|
2094
|
+
var import_center8 = require("@turf/center");
|
|
2095
|
+
var extractEndPoint = (path, options) => {
|
|
2096
|
+
const { findByIdSync } = options;
|
|
2097
|
+
const [c, b, a] = path.slice(-3);
|
|
2098
|
+
if (isOccupant(a) && isUnit(b) && isOpening(c)) {
|
|
2099
|
+
const occ = findByIdSync(a);
|
|
2100
|
+
const opening = findByIdSync(c);
|
|
2101
|
+
const level = findByIdSync(opening.properties.level_id);
|
|
2102
|
+
return [
|
|
2103
|
+
{
|
|
2104
|
+
id: occ.id,
|
|
2105
|
+
type: "end",
|
|
2106
|
+
name: occ.properties.name,
|
|
2107
|
+
point: (0, import_center8.center)(opening).geometry.coordinates,
|
|
2108
|
+
levelId: opening.properties.level_id,
|
|
2109
|
+
ordinal: level.properties.ordinal,
|
|
2110
|
+
source: { type: "opening", id: opening.id }
|
|
2111
|
+
},
|
|
2112
|
+
path.slice(0, -3)
|
|
2113
|
+
];
|
|
2114
|
+
}
|
|
2115
|
+
if (isOccupant(a) && isKiosk(b)) {
|
|
2116
|
+
const occ = findByIdSync(a);
|
|
2117
|
+
const kiosk = findByIdSync(c);
|
|
2118
|
+
const level = findByIdSync(kiosk.properties.level_id);
|
|
2119
|
+
return [
|
|
2120
|
+
{
|
|
2121
|
+
id: occ.id,
|
|
2122
|
+
type: "end",
|
|
2123
|
+
name: occ.properties.name,
|
|
2124
|
+
point: (0, import_center8.center)(kiosk).geometry.coordinates,
|
|
2125
|
+
levelId: kiosk.properties.level_id,
|
|
2126
|
+
ordinal: level.properties.ordinal,
|
|
2127
|
+
source: { type: "kiosk", id: kiosk.id }
|
|
2128
|
+
},
|
|
2129
|
+
path.slice(0, -2)
|
|
2130
|
+
];
|
|
2131
|
+
}
|
|
2132
|
+
if (isCoordinateOrdinalString(a)) {
|
|
2133
|
+
const [lat, lng, ordinal] = parseOrdinalCoordinate(a);
|
|
2134
|
+
const opening = findByIdSync(b);
|
|
2135
|
+
return [
|
|
2136
|
+
{
|
|
2137
|
+
id: a,
|
|
2138
|
+
type: "end",
|
|
2139
|
+
name: { en: `Your location` },
|
|
2140
|
+
point: [lng, lat],
|
|
2141
|
+
levelId: opening.properties.level_id,
|
|
2142
|
+
ordinal,
|
|
2143
|
+
source: { type: "opening", id: opening.id }
|
|
2144
|
+
},
|
|
2145
|
+
path.slice(0, -2)
|
|
2146
|
+
];
|
|
2147
|
+
}
|
|
2148
|
+
return [null, path];
|
|
2149
|
+
};
|
|
2150
|
+
|
|
2151
|
+
// src/data/navigate/steps/utils/combineWalkwaySteps.ts
|
|
2152
|
+
var import_uniq = __toESM(require("lodash/uniq"));
|
|
2153
|
+
var combineWalkwaySteps = (steps) => {
|
|
2154
|
+
let result = [];
|
|
2155
|
+
for (let i = 0; i < steps.length; i++) {
|
|
2156
|
+
const thisStep = steps[i];
|
|
2157
|
+
if (i === steps.length - 1) {
|
|
2158
|
+
result.push(thisStep);
|
|
2159
|
+
continue;
|
|
2055
2160
|
}
|
|
2056
|
-
|
|
2057
|
-
if (
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
indices
|
|
2071
|
-
});
|
|
2072
|
-
}
|
|
2161
|
+
const nextStep = steps[i + 1];
|
|
2162
|
+
if (thisStep.intermediaryCategory === "walkway" && nextStep.intermediaryCategory === "walkway" && thisStep.from.source.type === "opening" && nextStep.from.source.type === "opening") {
|
|
2163
|
+
console.log({ i, len: steps.length, thisStep, nextStep });
|
|
2164
|
+
result.push({
|
|
2165
|
+
from: thisStep.from,
|
|
2166
|
+
to: nextStep.to,
|
|
2167
|
+
levelIds: (0, import_uniq.default)([...thisStep.levelIds, ...nextStep.levelIds]),
|
|
2168
|
+
ordinals: (0, import_uniq.default)([...thisStep.ordinals, ...nextStep.ordinals]),
|
|
2169
|
+
intermediaryCategory: "walkway",
|
|
2170
|
+
description: nextStep.description,
|
|
2171
|
+
path: [
|
|
2172
|
+
...thisStep.path,
|
|
2173
|
+
...nextStep.path
|
|
2174
|
+
]
|
|
2073
2175
|
});
|
|
2176
|
+
i++;
|
|
2074
2177
|
} else {
|
|
2075
|
-
|
|
2076
|
-
const { isMatch, score, indices } = searcher.searchIn(text);
|
|
2077
|
-
if (isMatch) {
|
|
2078
|
-
matches.push({ score, key, value: text, norm: norm2, indices });
|
|
2079
|
-
}
|
|
2178
|
+
result.push(thisStep);
|
|
2080
2179
|
}
|
|
2081
|
-
return matches;
|
|
2082
2180
|
}
|
|
2181
|
+
return result;
|
|
2083
2182
|
};
|
|
2084
|
-
Fuse.version = "7.1.0";
|
|
2085
|
-
Fuse.createIndex = createIndex;
|
|
2086
|
-
Fuse.parseIndex = parseIndex;
|
|
2087
|
-
Fuse.config = Config;
|
|
2088
|
-
{
|
|
2089
|
-
Fuse.parseQuery = parse;
|
|
2090
|
-
}
|
|
2091
|
-
{
|
|
2092
|
-
register(ExtendedSearch);
|
|
2093
|
-
}
|
|
2094
2183
|
|
|
2095
|
-
// src/data/
|
|
2096
|
-
var
|
|
2184
|
+
// src/data/navigate/steps/createStepUtils.ts
|
|
2185
|
+
var createStepUtils = (options) => {
|
|
2186
|
+
const { data: { units, relationships }, findByIdSync } = options;
|
|
2187
|
+
const landmarkUtils = createLandmarkUtils(options);
|
|
2188
|
+
const stepPathUtils = createStepPathUtils({ ...options, resolution: 88e-5 });
|
|
2189
|
+
const findUnitBetweenOpenings = (originId, destinationId) => {
|
|
2190
|
+
const origin = findByIdSync(originId);
|
|
2191
|
+
const destination = findByIdSync(destinationId);
|
|
2192
|
+
const matchedOne = relationships.find((rel) => rel.properties.intermediary.map((int) => int.id).includes(origin.id));
|
|
2193
|
+
const matchOneUnits = [matchedOne.properties.origin, matchedOne.properties.destination];
|
|
2194
|
+
const matchedTwo = relationships.find((rel) => rel.properties.intermediary.map((int) => int.id).includes(destination.id));
|
|
2195
|
+
const matchTwoUnits = [matchedTwo.properties.origin, matchedTwo.properties.destination];
|
|
2196
|
+
const unitIds = (0, import_intersectionBy.default)(matchOneUnits, matchTwoUnits, "id");
|
|
2197
|
+
return unitIds.map(({ id }) => findByIdSync(id));
|
|
2198
|
+
};
|
|
2199
|
+
const findHorizontalIntermediary = (from, to) => {
|
|
2200
|
+
if (from.source.type !== "opening") {
|
|
2201
|
+
const unit = findContainingUnitAtPoint(from.point, from.levelId, units);
|
|
2202
|
+
return unit ? [unit] : [];
|
|
2203
|
+
}
|
|
2204
|
+
if (to.source.type !== "opening") {
|
|
2205
|
+
const unit = findContainingUnitAtPoint(to.point, to.levelId, units);
|
|
2206
|
+
return unit ? [unit] : [];
|
|
2207
|
+
}
|
|
2208
|
+
return findUnitBetweenOpenings(from.source.id, to.source.id);
|
|
2209
|
+
};
|
|
2210
|
+
const findVerticalIntermediary = (from, to) => {
|
|
2211
|
+
const firstOpeningId = from.source.id;
|
|
2212
|
+
const secondOpeningId = to.source.id;
|
|
2213
|
+
const relationship = relationships.find((rel) => {
|
|
2214
|
+
return rel.properties.origin?.id === firstOpeningId && rel.properties.destination?.id === secondOpeningId || rel.properties.origin?.id === secondOpeningId && rel.properties.destination?.id === firstOpeningId;
|
|
2215
|
+
});
|
|
2216
|
+
const intermediaryTypeAndId = relationship.properties.intermediary;
|
|
2217
|
+
return intermediaryTypeAndId.map(({ id }) => findByIdSync(id));
|
|
2218
|
+
};
|
|
2219
|
+
const formatCategoryLabel = (category) => {
|
|
2220
|
+
return (0, import_lodash12.capitalize)(category);
|
|
2221
|
+
};
|
|
2222
|
+
const getToward = (from, to, intermediary) => {
|
|
2223
|
+
if (to.type === "end") return to.name;
|
|
2224
|
+
const intermediaryIds = intermediary.map((int) => int.id);
|
|
2225
|
+
const relationship = relationships.find((rel) => rel.properties.intermediary.map((int) => int.id).includes(to.source.id));
|
|
2226
|
+
if (!relationship) return to.name;
|
|
2227
|
+
const candidates = [relationship.properties.origin.id, relationship.properties.destination.id];
|
|
2228
|
+
const nextUnitId = candidates.filter((id) => !intermediaryIds.includes(id))[0];
|
|
2229
|
+
if (!nextUnitId) return to.name;
|
|
2230
|
+
const nextUnit = findByIdSync(nextUnitId);
|
|
2231
|
+
return { en: formatCategoryLabel(`${nextUnit.properties.category}`) };
|
|
2232
|
+
};
|
|
2233
|
+
const toWaypoints = (path) => {
|
|
2234
|
+
const [startPoint, middleAndEndPoints] = extractStartPoint(path, options);
|
|
2235
|
+
const [endPoint, middlePoints] = extractEndPoint(middleAndEndPoints, options);
|
|
2236
|
+
const waypoints = middlePoints.map((openingId) => {
|
|
2237
|
+
const opening = findByIdSync(openingId);
|
|
2238
|
+
const level = findByIdSync(opening.properties.level_id);
|
|
2239
|
+
const coordinates = (0, import_center9.center)(opening).geometry.coordinates;
|
|
2240
|
+
const landmark = landmarkUtils.findNearestLandmark(coordinates, opening.properties.level_id);
|
|
2241
|
+
return {
|
|
2242
|
+
id: `${opening.properties.level_id}:${openingId}`,
|
|
2243
|
+
type: "between",
|
|
2244
|
+
point: coordinates,
|
|
2245
|
+
name: null,
|
|
2246
|
+
levelId: opening.properties.level_id,
|
|
2247
|
+
ordinal: level.properties.ordinal,
|
|
2248
|
+
hint: landmark ? { kind: "landmark", name: landmark.name } : void 0,
|
|
2249
|
+
source: { type: "opening", id: opening.id }
|
|
2250
|
+
};
|
|
2251
|
+
});
|
|
2252
|
+
return [startPoint, ...waypoints, endPoint];
|
|
2253
|
+
};
|
|
2254
|
+
const createHorizontalStep = (from, to) => {
|
|
2255
|
+
const intermediary = findHorizontalIntermediary(from, to);
|
|
2256
|
+
const intermediaryCategories = intermediary.map((unit) => unit.properties.category);
|
|
2257
|
+
const intermediaryCategory = intermediaryCategories.length > 0 ? intermediaryCategories[0] : "unspecified";
|
|
2258
|
+
const toward = getToward(from, to, intermediary);
|
|
2259
|
+
const landmark = to.hint?.kind === "landmark" ? to.hint.name : null;
|
|
2260
|
+
const path = stepPathUtils.findStepPath(from.point, to.point, intermediary);
|
|
2261
|
+
const step = {
|
|
2262
|
+
from,
|
|
2263
|
+
to,
|
|
2264
|
+
levelIds: [from.levelId],
|
|
2265
|
+
ordinals: [from.ordinal],
|
|
2266
|
+
intermediaryCategory,
|
|
2267
|
+
description: describeHorizontalStep(intermediaryCategory, toward, landmark),
|
|
2268
|
+
path: path.map((coord) => [...coord, from.ordinal * 9])
|
|
2269
|
+
};
|
|
2270
|
+
return step;
|
|
2271
|
+
};
|
|
2272
|
+
const createVerticalStep = (from, to) => {
|
|
2273
|
+
const intermediary = findVerticalIntermediary(from, to);
|
|
2274
|
+
const intermediaryCategories = intermediary.map((unit) => unit.properties.category);
|
|
2275
|
+
const intermediaryCategory = intermediaryCategories.length > 0 ? intermediaryCategories[0] : "unspecified";
|
|
2276
|
+
const fromLevel = findByIdSync(from.levelId);
|
|
2277
|
+
const toLevel = findByIdSync(to.levelId);
|
|
2278
|
+
return {
|
|
2279
|
+
from,
|
|
2280
|
+
to,
|
|
2281
|
+
levelIds: [from.levelId, to.levelId],
|
|
2282
|
+
ordinals: [from.ordinal, to.ordinal],
|
|
2283
|
+
intermediaryCategory,
|
|
2284
|
+
description: describeVerticalStep(fromLevel, toLevel, intermediaryCategory),
|
|
2285
|
+
path: [
|
|
2286
|
+
[...from.point, from.ordinal * 9],
|
|
2287
|
+
[...to.point, to.ordinal * 9]
|
|
2288
|
+
]
|
|
2289
|
+
};
|
|
2290
|
+
};
|
|
2291
|
+
const isVertical = (from, to) => {
|
|
2292
|
+
const fromLevel = findByIdSync(from.levelId);
|
|
2293
|
+
const toLevel = findByIdSync(to.levelId);
|
|
2294
|
+
return !!fromLevel && !!toLevel && fromLevel.properties.ordinal !== toLevel.properties.ordinal;
|
|
2295
|
+
};
|
|
2296
|
+
const toSteps = (waypoints) => {
|
|
2297
|
+
let steps = [];
|
|
2298
|
+
const t0_allSteps = performance.now();
|
|
2299
|
+
for (let i = 0; i < waypoints.length - 1; i++) {
|
|
2300
|
+
const from = waypoints[i];
|
|
2301
|
+
const to = waypoints[i + 1];
|
|
2302
|
+
const t0 = performance.now();
|
|
2303
|
+
const step = isVertical(from, to) ? createVerticalStep(from, to) : createHorizontalStep(from, to);
|
|
2304
|
+
steps.push(step);
|
|
2305
|
+
const t1 = performance.now();
|
|
2306
|
+
trace("nav", ` \u2502 \u251C\u2500 #${i} ${from.id.padEnd(25)} \u2192 ${`(${step.intermediaryCategory})`.padEnd(12)} \u2192 ${to.id}`, t1 - t0);
|
|
2307
|
+
trace("nav", ` \u2502 \u2502 ${step.description.text}`, void 0, "#bada55");
|
|
2308
|
+
}
|
|
2309
|
+
const simplifySteps = combineWalkwaySteps(steps);
|
|
2310
|
+
const t1_allSteps = performance.now();
|
|
2311
|
+
trace("nav", " \u2502 \u2514\u2500 Total ", t1_allSteps - t0_allSteps);
|
|
2312
|
+
return simplifySteps;
|
|
2313
|
+
};
|
|
2314
|
+
return {
|
|
2315
|
+
// createSteps,
|
|
2316
|
+
toWaypoints,
|
|
2317
|
+
toSteps
|
|
2318
|
+
};
|
|
2319
|
+
};
|
|
2097
2320
|
|
|
2098
|
-
// src/data/
|
|
2099
|
-
var
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2321
|
+
// src/data/navigate/utils/timeDistance.ts
|
|
2322
|
+
var import_length = __toESM(require("@turf/length"));
|
|
2323
|
+
var WALKING_SPEED = 1.4;
|
|
2324
|
+
var calculatePathLength = (feature2) => (0, import_length.default)(feature2, { units: "kilometers" }) * 1e3;
|
|
2325
|
+
var calculateTravelingDuration = (distance5) => {
|
|
2326
|
+
const duration = distance5 / WALKING_SPEED;
|
|
2327
|
+
const minutes = Math.round(duration / 60);
|
|
2328
|
+
return minutes > 0 ? minutes : 1;
|
|
2329
|
+
};
|
|
2330
|
+
var calculateTotalDistance = (steps = []) => {
|
|
2331
|
+
return steps.reduce((acc, { path }) => acc + calculatePathLength(lineString(path)), 0);
|
|
2332
|
+
};
|
|
2333
|
+
var calculateRoundedDistance = (distance5) => {
|
|
2334
|
+
return Math.round(distance5 - distance5 % 25);
|
|
2335
|
+
};
|
|
2336
|
+
|
|
2337
|
+
// src/data/navigate/utils/createFindByIdSync.ts
|
|
2338
|
+
var createFindByIdSync = (data) => {
|
|
2339
|
+
const { amenities = [], anchors = [], fixtures = [], levels = [], kiosks = [], relationships = [], occupants = [], openings = [], units } = data;
|
|
2340
|
+
const featureById = /* @__PURE__ */ new Map();
|
|
2341
|
+
const entries = [
|
|
2342
|
+
...amenities,
|
|
2343
|
+
...anchors,
|
|
2344
|
+
...fixtures,
|
|
2345
|
+
...levels,
|
|
2346
|
+
...kiosks,
|
|
2347
|
+
...relationships,
|
|
2348
|
+
...occupants,
|
|
2349
|
+
...openings,
|
|
2350
|
+
...units
|
|
2351
|
+
];
|
|
2352
|
+
for (const f of entries) featureById.set(f.id, f);
|
|
2353
|
+
const findByIdSync = (id) => {
|
|
2354
|
+
return featureById.get(id);
|
|
2355
|
+
};
|
|
2356
|
+
return { findByIdSync };
|
|
2357
|
+
};
|
|
2358
|
+
|
|
2359
|
+
// src/data/navigate/getNavigateClient.ts
|
|
2360
|
+
var getNavigateClient = (options) => {
|
|
2361
|
+
const { data } = options;
|
|
2362
|
+
const { levels, units } = data;
|
|
2363
|
+
trace("nav", "\u2713 prepare");
|
|
2364
|
+
const t0 = performance.now();
|
|
2365
|
+
trace("nav", " \u251C\u2500 createGraph (dijkstra)");
|
|
2366
|
+
const { defaultGraph, accessibleGraph, addCoordinateOrdinalNode } = prepareGraph({ data });
|
|
2367
|
+
const t1 = performance.now();
|
|
2368
|
+
trace("nav", " \u2502 \u2514\u2500 Total ", t1 - t0);
|
|
2369
|
+
const t2 = performance.now();
|
|
2370
|
+
const { findByIdSync } = createFindByIdSync(data);
|
|
2371
|
+
const t3 = performance.now();
|
|
2372
|
+
trace("nav", " \u2514\u2500 findByIdSync", t3 - t2);
|
|
2373
|
+
const findCoordinateOrdinalUnit = (params) => {
|
|
2374
|
+
const [lat, lng, ordinal] = parseOrdinalCoordinate(params);
|
|
2375
|
+
const levelIdsWithOrdinal = levels.filter((level) => level.properties.ordinal === ordinal).map((level) => level.id);
|
|
2376
|
+
const unit = units.find((unit2) => levelIdsWithOrdinal.includes(unit2.properties.level_id) && (0, import_boolean_point_in_polygon4.booleanPointInPolygon)([lat, lng], unit2));
|
|
2377
|
+
return unit;
|
|
2378
|
+
};
|
|
2379
|
+
const stepUtils = createStepUtils({ ...options, findByIdSync });
|
|
2380
|
+
const findRoute = async (routeOriginParam, routeDestinationParam, options2) => {
|
|
2381
|
+
if (!routeOriginParam || !routeDestinationParam) return null;
|
|
2382
|
+
const graph = options2?.mode === "accessible" ? accessibleGraph : defaultGraph;
|
|
2383
|
+
if (isCoordinateOrdinalString(routeOriginParam)) {
|
|
2384
|
+
const walkwayUnit = findCoordinateOrdinalUnit(routeOriginParam);
|
|
2385
|
+
addCoordinateOrdinalNode(routeOriginParam, walkwayUnit);
|
|
2386
|
+
}
|
|
2387
|
+
if (isCoordinateOrdinalString(routeDestinationParam)) {
|
|
2388
|
+
const walkwayUnit = findCoordinateOrdinalUnit(routeDestinationParam);
|
|
2389
|
+
addCoordinateOrdinalNode(routeDestinationParam, walkwayUnit);
|
|
2390
|
+
}
|
|
2391
|
+
try {
|
|
2392
|
+
trace("nav", "\u2713 findRoute", 0);
|
|
2393
|
+
const t02 = performance.now();
|
|
2394
|
+
const path = graph.path(routeOriginParam, routeDestinationParam);
|
|
2395
|
+
const t12 = performance.now();
|
|
2396
|
+
trace("nav", " \u251C\u2500 path (dijkstra)", t12 - t02);
|
|
2397
|
+
const waypoints = stepUtils.toWaypoints(path);
|
|
2398
|
+
console.log({ waypoints });
|
|
2399
|
+
const t22 = performance.now();
|
|
2400
|
+
trace("nav", " \u251C\u2500 toWaypoints", t22 - t12);
|
|
2401
|
+
trace("nav", " \u251C\u2500 toSteps", 0);
|
|
2402
|
+
const steps = stepUtils.toSteps(waypoints);
|
|
2403
|
+
const t32 = performance.now();
|
|
2404
|
+
const totalDistance = calculateTotalDistance(steps);
|
|
2405
|
+
const roundedDistance = calculateRoundedDistance(totalDistance);
|
|
2406
|
+
const duration = calculateTravelingDuration(totalDistance);
|
|
2407
|
+
const t4 = performance.now();
|
|
2408
|
+
trace("nav", " \u2514\u2500 postProcess", t4 - t32);
|
|
2409
|
+
return {
|
|
2410
|
+
// origin: routeOrigin,
|
|
2411
|
+
// destination: routeDestination,
|
|
2412
|
+
description: null,
|
|
2413
|
+
distance: roundedDistance,
|
|
2414
|
+
duration,
|
|
2415
|
+
steps
|
|
2416
|
+
};
|
|
2417
|
+
} catch (error) {
|
|
2418
|
+
console.log(error);
|
|
2419
|
+
throw error;
|
|
2420
|
+
}
|
|
2127
2421
|
};
|
|
2128
2422
|
return {
|
|
2129
|
-
|
|
2423
|
+
findRoute,
|
|
2424
|
+
findByIdSync
|
|
2130
2425
|
};
|
|
2131
2426
|
};
|
|
2132
2427
|
|
|
2133
2428
|
// src/data/getDataClient.ts
|
|
2134
2429
|
var getDataClient = (options) => {
|
|
2135
2430
|
let searchClient;
|
|
2431
|
+
let navigateClient;
|
|
2136
2432
|
const observers = /* @__PURE__ */ new Map();
|
|
2137
2433
|
const queryClient = options.queryClient ?? new import_query_core.QueryClient();
|
|
2138
2434
|
const { mode = "delivery", projectId, apiKey, baseUrl, previewToken } = options;
|
|
@@ -2255,6 +2551,24 @@ var getDataClient = (options) => {
|
|
|
2255
2551
|
}
|
|
2256
2552
|
return searchClient.search(txt);
|
|
2257
2553
|
};
|
|
2554
|
+
const navigateFn = async (origin, destination) => {
|
|
2555
|
+
if (!navigateClient) {
|
|
2556
|
+
const [levels, occupants, openings, relationships, units, fixtures, kiosks, amenities, anchors] = await Promise.all([
|
|
2557
|
+
filterByType("level"),
|
|
2558
|
+
filterByType("occupant"),
|
|
2559
|
+
filterByType("opening"),
|
|
2560
|
+
filterByType("relationship"),
|
|
2561
|
+
filterByType("unit"),
|
|
2562
|
+
filterByType("fixture"),
|
|
2563
|
+
filterByType("kiosk"),
|
|
2564
|
+
filterByType("amenity"),
|
|
2565
|
+
filterByType("anchor")
|
|
2566
|
+
]);
|
|
2567
|
+
const haystack = { levels, occupants, openings, relationships, units, fixtures, kiosks, amenities, anchors };
|
|
2568
|
+
navigateClient = getNavigateClient({ data: haystack });
|
|
2569
|
+
}
|
|
2570
|
+
return navigateClient.findRoute(origin, destination);
|
|
2571
|
+
};
|
|
2258
2572
|
return {
|
|
2259
2573
|
projectId,
|
|
2260
2574
|
queryClient,
|
|
@@ -2266,7 +2580,8 @@ var getDataClient = (options) => {
|
|
|
2266
2580
|
_internalFindById: internalFindById,
|
|
2267
2581
|
filterByType,
|
|
2268
2582
|
findById,
|
|
2269
|
-
search: searchFn
|
|
2583
|
+
search: searchFn,
|
|
2584
|
+
navigate: navigateFn
|
|
2270
2585
|
};
|
|
2271
2586
|
};
|
|
2272
2587
|
|
|
@@ -2274,115 +2589,9 @@ var getDataClient = (options) => {
|
|
|
2274
2589
|
var import_maptalks_gl = require("maptalks-gl");
|
|
2275
2590
|
var import_transcoders = require("@maptalks/transcoders.draco");
|
|
2276
2591
|
var import_tween = __toESM(require("@tweenjs/tween.js"));
|
|
2277
|
-
var
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
var earthRadius = 63710088e-1;
|
|
2281
|
-
var factors = {
|
|
2282
|
-
centimeters: earthRadius * 100,
|
|
2283
|
-
centimetres: earthRadius * 100,
|
|
2284
|
-
degrees: 360 / (2 * Math.PI),
|
|
2285
|
-
feet: earthRadius * 3.28084,
|
|
2286
|
-
inches: earthRadius * 39.37,
|
|
2287
|
-
kilometers: earthRadius / 1e3,
|
|
2288
|
-
kilometres: earthRadius / 1e3,
|
|
2289
|
-
meters: earthRadius,
|
|
2290
|
-
metres: earthRadius,
|
|
2291
|
-
miles: earthRadius / 1609.344,
|
|
2292
|
-
millimeters: earthRadius * 1e3,
|
|
2293
|
-
millimetres: earthRadius * 1e3,
|
|
2294
|
-
nauticalmiles: earthRadius / 1852,
|
|
2295
|
-
radians: 1,
|
|
2296
|
-
yards: earthRadius * 1.0936
|
|
2297
|
-
};
|
|
2298
|
-
function feature(geom, properties, options = {}) {
|
|
2299
|
-
const feat = { type: "Feature" };
|
|
2300
|
-
if (options.id === 0 || options.id) {
|
|
2301
|
-
feat.id = options.id;
|
|
2302
|
-
}
|
|
2303
|
-
if (options.bbox) {
|
|
2304
|
-
feat.bbox = options.bbox;
|
|
2305
|
-
}
|
|
2306
|
-
feat.properties = properties || {};
|
|
2307
|
-
feat.geometry = geom;
|
|
2308
|
-
return feat;
|
|
2309
|
-
}
|
|
2310
|
-
function point(coordinates, properties, options = {}) {
|
|
2311
|
-
if (!coordinates) {
|
|
2312
|
-
throw new Error("coordinates is required");
|
|
2313
|
-
}
|
|
2314
|
-
if (!Array.isArray(coordinates)) {
|
|
2315
|
-
throw new Error("coordinates must be an Array");
|
|
2316
|
-
}
|
|
2317
|
-
if (coordinates.length < 2) {
|
|
2318
|
-
throw new Error("coordinates must be at least 2 numbers long");
|
|
2319
|
-
}
|
|
2320
|
-
if (!isNumber2(coordinates[0]) || !isNumber2(coordinates[1])) {
|
|
2321
|
-
throw new Error("coordinates must contain numbers");
|
|
2322
|
-
}
|
|
2323
|
-
const geom = {
|
|
2324
|
-
type: "Point",
|
|
2325
|
-
coordinates
|
|
2326
|
-
};
|
|
2327
|
-
return feature(geom, properties, options);
|
|
2328
|
-
}
|
|
2329
|
-
function polygon(coordinates, properties, options = {}) {
|
|
2330
|
-
for (const ring of coordinates) {
|
|
2331
|
-
if (ring.length < 4) {
|
|
2332
|
-
throw new Error(
|
|
2333
|
-
"Each LinearRing of a Polygon must have 4 or more Positions."
|
|
2334
|
-
);
|
|
2335
|
-
}
|
|
2336
|
-
if (ring[ring.length - 1].length !== ring[0].length) {
|
|
2337
|
-
throw new Error("First and last Position are not equivalent.");
|
|
2338
|
-
}
|
|
2339
|
-
for (let j = 0; j < ring[ring.length - 1].length; j++) {
|
|
2340
|
-
if (ring[ring.length - 1][j] !== ring[0][j]) {
|
|
2341
|
-
throw new Error("First and last Position are not equivalent.");
|
|
2342
|
-
}
|
|
2343
|
-
}
|
|
2344
|
-
}
|
|
2345
|
-
const geom = {
|
|
2346
|
-
type: "Polygon",
|
|
2347
|
-
coordinates
|
|
2348
|
-
};
|
|
2349
|
-
return feature(geom, properties, options);
|
|
2350
|
-
}
|
|
2351
|
-
function lineString(coordinates, properties, options = {}) {
|
|
2352
|
-
if (coordinates.length < 2) {
|
|
2353
|
-
throw new Error("coordinates must be an array of two or more positions");
|
|
2354
|
-
}
|
|
2355
|
-
const geom = {
|
|
2356
|
-
type: "LineString",
|
|
2357
|
-
coordinates
|
|
2358
|
-
};
|
|
2359
|
-
return feature(geom, properties, options);
|
|
2360
|
-
}
|
|
2361
|
-
function featureCollection(features, options = {}) {
|
|
2362
|
-
const fc = { type: "FeatureCollection" };
|
|
2363
|
-
if (options.id) {
|
|
2364
|
-
fc.id = options.id;
|
|
2365
|
-
}
|
|
2366
|
-
if (options.bbox) {
|
|
2367
|
-
fc.bbox = options.bbox;
|
|
2368
|
-
}
|
|
2369
|
-
fc.features = features;
|
|
2370
|
-
return fc;
|
|
2371
|
-
}
|
|
2372
|
-
function multiPoint(coordinates, properties, options = {}) {
|
|
2373
|
-
const geom = {
|
|
2374
|
-
type: "MultiPoint",
|
|
2375
|
-
coordinates
|
|
2376
|
-
};
|
|
2377
|
-
return feature(geom, properties, options);
|
|
2378
|
-
}
|
|
2379
|
-
function isNumber2(num) {
|
|
2380
|
-
return !isNaN(num) && num !== null && !Array.isArray(num);
|
|
2381
|
-
}
|
|
2382
|
-
|
|
2383
|
-
// src/IndoorMap/IndoorMap.ts
|
|
2384
|
-
var import_distance = __toESM(require("@turf/distance"));
|
|
2385
|
-
var import_center6 = __toESM(require("@turf/center"));
|
|
2592
|
+
var import_lodash20 = __toESM(require("lodash"));
|
|
2593
|
+
var import_distance6 = __toESM(require("@turf/distance"));
|
|
2594
|
+
var import_center13 = __toESM(require("@turf/center"));
|
|
2386
2595
|
var import_three6 = require("three");
|
|
2387
2596
|
var import_maptalks10 = require("maptalks.three");
|
|
2388
2597
|
|
|
@@ -2461,9 +2670,9 @@ var VENUE_EVENTS = {
|
|
|
2461
2670
|
};
|
|
2462
2671
|
|
|
2463
2672
|
// src/IndoorMap/utils/createElements.js
|
|
2464
|
-
var
|
|
2673
|
+
var import_lodash16 = __toESM(require("lodash"));
|
|
2465
2674
|
var import_maptalks4 = require("maptalks");
|
|
2466
|
-
var
|
|
2675
|
+
var import_center11 = __toESM(require("@turf/center"));
|
|
2467
2676
|
var import_buffer = __toESM(require("@turf/buffer"));
|
|
2468
2677
|
var import_three4 = require("three");
|
|
2469
2678
|
|
|
@@ -2471,7 +2680,7 @@ var import_three4 = require("three");
|
|
|
2471
2680
|
var maptalks = __toESM(require("maptalks"));
|
|
2472
2681
|
var import_maptalks = require("maptalks.three");
|
|
2473
2682
|
var import_three = require("three");
|
|
2474
|
-
var
|
|
2683
|
+
var import_lodash13 = __toESM(require("lodash"));
|
|
2475
2684
|
var OPTIONS = {
|
|
2476
2685
|
altitude: 25,
|
|
2477
2686
|
scale: 15e-5,
|
|
@@ -2497,14 +2706,14 @@ var Billboard = class extends import_maptalks.BaseObject {
|
|
|
2497
2706
|
this._initOptions(options);
|
|
2498
2707
|
const {
|
|
2499
2708
|
altitude = OPTIONS.altitude,
|
|
2500
|
-
scale:
|
|
2709
|
+
scale: scale3 = OPTIONS.scale,
|
|
2501
2710
|
alphaTest = OPTIONS.alphaTest,
|
|
2502
2711
|
legColor = OPTIONS.legColor,
|
|
2503
2712
|
showLeg = OPTIONS.showLeg
|
|
2504
2713
|
} = options;
|
|
2505
2714
|
this.properties = { ...properties };
|
|
2506
2715
|
this._createGroup();
|
|
2507
|
-
const divider =
|
|
2716
|
+
const divider = import_lodash13.default.clamp(window.innerWidth / 375 / 1.75, 1, 1.7);
|
|
2508
2717
|
if (showLeg) {
|
|
2509
2718
|
const lineMaterial = new import_three.LineBasicMaterial({
|
|
2510
2719
|
color: legColor,
|
|
@@ -2531,17 +2740,17 @@ var Billboard = class extends import_maptalks.BaseObject {
|
|
|
2531
2740
|
const sprite = new import_three.Sprite(material);
|
|
2532
2741
|
sprite.material.sizeAttenuation = false;
|
|
2533
2742
|
sprite.scale.set(
|
|
2534
|
-
|
|
2535
|
-
|
|
2743
|
+
scale3 * naturalWidth / divider,
|
|
2744
|
+
scale3 * naturalHeight / divider,
|
|
2536
2745
|
1
|
|
2537
2746
|
);
|
|
2538
2747
|
this.getObject3d().add(sprite);
|
|
2539
2748
|
});
|
|
2540
2749
|
const z = layer.altitudeToVector3(altitude, altitude).x;
|
|
2541
2750
|
const position = layer.coordinateToVector3(coordinate, z);
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2751
|
+
import_lodash13.default.set(this.properties, "default.position", position);
|
|
2752
|
+
import_lodash13.default.set(this.properties, "default.altitude", altitude);
|
|
2753
|
+
import_lodash13.default.set(this.properties, "default.scale", scale3);
|
|
2545
2754
|
this.getObject3d().position.copy(position);
|
|
2546
2755
|
}
|
|
2547
2756
|
setLineHeight(altitude) {
|
|
@@ -2557,7 +2766,7 @@ var Billboard = class extends import_maptalks.BaseObject {
|
|
|
2557
2766
|
// src/IndoorMap/object3d/SpriteMarker.ts
|
|
2558
2767
|
var import_maptalks2 = require("maptalks.three");
|
|
2559
2768
|
var import_three2 = require("three");
|
|
2560
|
-
var
|
|
2769
|
+
var import_lodash14 = __toESM(require("lodash"));
|
|
2561
2770
|
var DEFAULT_SCALE = 0.05;
|
|
2562
2771
|
var DEFAULT_ALTITUDE = 0;
|
|
2563
2772
|
var DEFAULT_ALPHATEST = 0.3;
|
|
@@ -2581,23 +2790,23 @@ var SpriteMarker = class extends import_maptalks2.BaseObject {
|
|
|
2581
2790
|
this._createGroup();
|
|
2582
2791
|
const {
|
|
2583
2792
|
altitude = DEFAULT_OPTIONS.altitude,
|
|
2584
|
-
scale:
|
|
2793
|
+
scale: scale3 = DEFAULT_OPTIONS.scale,
|
|
2585
2794
|
highlight = DEFAULT_OPTIONS.highlight,
|
|
2586
2795
|
alphaTest = DEFAULT_OPTIONS.alphaTest
|
|
2587
2796
|
} = options;
|
|
2588
2797
|
this.properties = { ...properties };
|
|
2589
2798
|
const modifiedAltitude = altitude + 2;
|
|
2590
|
-
this.#default = { options: { scale:
|
|
2591
|
-
this.#highlight =
|
|
2799
|
+
this.#default = { options: { scale: scale3, altitude: modifiedAltitude }, material };
|
|
2800
|
+
this.#highlight = import_lodash14.default.merge({}, DEFAULT_OPTIONS.highlight, highlight);
|
|
2592
2801
|
if (material && material instanceof import_three2.SpriteMaterial)
|
|
2593
2802
|
material.alphaTest = alphaTest;
|
|
2594
2803
|
const sprite = new import_three2.Sprite(material);
|
|
2595
|
-
sprite.scale.set(
|
|
2804
|
+
sprite.scale.set(scale3, scale3, scale3);
|
|
2596
2805
|
const obj3d = this.getObject3d();
|
|
2597
2806
|
obj3d.add(sprite);
|
|
2598
2807
|
const z = layer.altitudeToVector3(modifiedAltitude, modifiedAltitude).x;
|
|
2599
2808
|
const position = layer.coordinateToVector3(coordinate, z);
|
|
2600
|
-
|
|
2809
|
+
import_lodash14.default.set(this.properties, "default.position", position);
|
|
2601
2810
|
this.getObject3d().position.copy(position);
|
|
2602
2811
|
}
|
|
2603
2812
|
// Different objects need to implement their own methods
|
|
@@ -2738,15 +2947,15 @@ var NavigationPath = class extends import_maptalks3.BaseObject {
|
|
|
2738
2947
|
};
|
|
2739
2948
|
|
|
2740
2949
|
// src/IndoorMap/utils/geometry.ts
|
|
2741
|
-
var
|
|
2742
|
-
var
|
|
2950
|
+
var import_center10 = __toESM(require("@turf/center"));
|
|
2951
|
+
var import_lodash15 = __toESM(require("lodash"));
|
|
2743
2952
|
var import_line_offset = __toESM(require("@turf/line-offset"));
|
|
2744
2953
|
var getCenterFromGeometry = (geometry) => {
|
|
2745
2954
|
try {
|
|
2746
2955
|
const { type = null, coordinates = null } = geometry;
|
|
2747
2956
|
if (!type || !coordinates) return null;
|
|
2748
|
-
const centerPoint = (0,
|
|
2749
|
-
return
|
|
2957
|
+
const centerPoint = (0, import_center10.default)(geometry);
|
|
2958
|
+
return import_lodash15.default.get(centerPoint, "geometry.coordinates");
|
|
2750
2959
|
} catch (error) {
|
|
2751
2960
|
return null;
|
|
2752
2961
|
}
|
|
@@ -2792,8 +3001,8 @@ var createSVGPathFromMarkerSymbol = (style) => {
|
|
|
2792
3001
|
markerFill,
|
|
2793
3002
|
markerPath
|
|
2794
3003
|
} = style;
|
|
2795
|
-
const
|
|
2796
|
-
return `<path d="${markerPath}" style="transform:translate(${markerDx}px, ${markerDy}px) scale(${
|
|
3004
|
+
const scale3 = markerWidth / 24;
|
|
3005
|
+
return `<path d="${markerPath}" style="transform:translate(${markerDx}px, ${markerDy}px) scale(${scale3})" fill="${markerFill}"/>`;
|
|
2797
3006
|
};
|
|
2798
3007
|
|
|
2799
3008
|
// src/IndoorMap/utils/createElements.js
|
|
@@ -2897,7 +3106,7 @@ var createWaterFixture = (feature2, style, options = {}) => {
|
|
|
2897
3106
|
const { geometry, properties } = feature2;
|
|
2898
3107
|
const { allowOverride, inheritFillColorToLine, zIndex } = options;
|
|
2899
3108
|
const symbolStyle = { ...style };
|
|
2900
|
-
if (allowOverride)
|
|
3109
|
+
if (allowOverride) import_lodash16.default.merge(symbolStyle, properties.style);
|
|
2901
3110
|
if (inheritFillColorToLine) symbolStyle.lineColor = symbolStyle.polygonFill;
|
|
2902
3111
|
return new GeometryType[geometry.type](geometry.coordinates, {
|
|
2903
3112
|
properties: {
|
|
@@ -2913,7 +3122,7 @@ var createVegetationFixture = (feature2, style, options = {}) => {
|
|
|
2913
3122
|
const { geometry, properties } = feature2;
|
|
2914
3123
|
const { allowOverride, inheritFillColorToLine, zIndex } = options;
|
|
2915
3124
|
const symbolStyle = { ...style };
|
|
2916
|
-
if (allowOverride)
|
|
3125
|
+
if (allowOverride) import_lodash16.default.merge(symbolStyle, properties.style);
|
|
2917
3126
|
if (inheritFillColorToLine) symbolStyle.lineColor = symbolStyle.polygonFill;
|
|
2918
3127
|
return new GeometryType[geometry.type](geometry.coordinates, {
|
|
2919
3128
|
properties: {
|
|
@@ -2930,8 +3139,8 @@ var createObstructionalFixture = (feature2, style = {}, options = {}) => {
|
|
|
2930
3139
|
const { model3d } = properties;
|
|
2931
3140
|
const { allowOverride, inheritFillColorToLine, zIndex } = options;
|
|
2932
3141
|
const symbolStyle = { ...style };
|
|
2933
|
-
if (!
|
|
2934
|
-
if (allowOverride)
|
|
3142
|
+
if (!import_lodash16.default.isEmpty(model3d)) return;
|
|
3143
|
+
if (allowOverride) import_lodash16.default.merge(symbolStyle, properties.style);
|
|
2935
3144
|
if (inheritFillColorToLine) symbolStyle.lineColor = symbolStyle.polygonFill;
|
|
2936
3145
|
if (geometry.type === "LineString") {
|
|
2937
3146
|
const polygon2 = createPolygonFromLineString(geometry);
|
|
@@ -3001,7 +3210,7 @@ var createPrincipalOpening = (feature2, style, options = {}) => {
|
|
|
3001
3210
|
const { geometry, properties } = feature2;
|
|
3002
3211
|
const { allowOverride, zIndex } = options;
|
|
3003
3212
|
const symbolStyle = { ...style };
|
|
3004
|
-
if (allowOverride)
|
|
3213
|
+
if (allowOverride) import_lodash16.default.merge(symbolStyle, properties.style);
|
|
3005
3214
|
try {
|
|
3006
3215
|
return new import_maptalks4.LineString(geometry.coordinates, {
|
|
3007
3216
|
properties: {
|
|
@@ -3018,7 +3227,7 @@ var createEmergencyExitOpening = (feature2, style, options = {}) => {
|
|
|
3018
3227
|
const { geometry, properties } = feature2;
|
|
3019
3228
|
const { allowOverride, zIndex } = options;
|
|
3020
3229
|
const symbolStyle = { ...style };
|
|
3021
|
-
if (allowOverride)
|
|
3230
|
+
if (allowOverride) import_lodash16.default.merge(symbolStyle, properties.style);
|
|
3022
3231
|
try {
|
|
3023
3232
|
return new import_maptalks4.LineString(geometry.coordinates, {
|
|
3024
3233
|
properties: {
|
|
@@ -3035,7 +3244,7 @@ var createPedestrianOpening = (feature2, style, options = {}) => {
|
|
|
3035
3244
|
const { geometry, properties, id } = feature2;
|
|
3036
3245
|
const { allowOverride, zIndex } = options;
|
|
3037
3246
|
const symbolStyle = { ...style };
|
|
3038
|
-
if (allowOverride)
|
|
3247
|
+
if (allowOverride) import_lodash16.default.merge(symbolStyle, properties.style);
|
|
3039
3248
|
try {
|
|
3040
3249
|
return new import_maptalks4.LineString(geometry.coordinates, {
|
|
3041
3250
|
properties: {
|
|
@@ -3073,9 +3282,9 @@ var create3DMarker = (coordinates, options, material, threeLayer, markerProperti
|
|
|
3073
3282
|
};
|
|
3074
3283
|
var getExtrudeConfigByFeature = (baseExtrudeConfig, feature2 = {}) => {
|
|
3075
3284
|
const { feature_type: featureType } = feature2;
|
|
3076
|
-
const featureExtrudeConfig =
|
|
3077
|
-
const featureCategory =
|
|
3078
|
-
const baseFeatureExtrudeConfig =
|
|
3285
|
+
const featureExtrudeConfig = import_lodash16.default.get(feature2, "properties.extrude");
|
|
3286
|
+
const featureCategory = import_lodash16.default.get(feature2, "properties.category");
|
|
3287
|
+
const baseFeatureExtrudeConfig = import_lodash16.default.get(
|
|
3079
3288
|
baseExtrudeConfig,
|
|
3080
3289
|
`${featureType}.${featureCategory || featureType}`
|
|
3081
3290
|
);
|
|
@@ -3133,50 +3342,50 @@ var createStyledUIMarkerElement = ({
|
|
|
3133
3342
|
var styledFeatureGenerator = (mapTheme) => {
|
|
3134
3343
|
const getElementSymbol = (key) => {
|
|
3135
3344
|
const [featureType] = key.split(".");
|
|
3136
|
-
const featureTypeTheme =
|
|
3345
|
+
const featureTypeTheme = import_lodash16.default.get(mapTheme, `${featureType}.geometry.symbol`);
|
|
3137
3346
|
if (featureType === key) return featureTypeTheme;
|
|
3138
|
-
const categoryTheme =
|
|
3139
|
-
return
|
|
3347
|
+
const categoryTheme = import_lodash16.default.get(mapTheme, `${key}.geometry.symbol`);
|
|
3348
|
+
return import_lodash16.default.merge({}, featureTypeTheme, categoryTheme);
|
|
3140
3349
|
};
|
|
3141
3350
|
const getLabelSymbol = (key) => {
|
|
3142
3351
|
const [featureType] = key.split(".");
|
|
3143
|
-
const featureTypeTheme =
|
|
3144
|
-
const categoryTheme =
|
|
3145
|
-
const mergedSymbol =
|
|
3146
|
-
let symbols =
|
|
3352
|
+
const featureTypeTheme = import_lodash16.default.get(mapTheme, `${featureType}.label`);
|
|
3353
|
+
const categoryTheme = import_lodash16.default.get(mapTheme, `${key}.label`);
|
|
3354
|
+
const mergedSymbol = import_lodash16.default.merge({}, featureTypeTheme, categoryTheme);
|
|
3355
|
+
let symbols = import_lodash16.default.values(import_lodash16.default.map(mergedSymbol, "symbol"));
|
|
3147
3356
|
const markerIndexToMove = symbols.findIndex(
|
|
3148
3357
|
({ elementType }) => elementType === "label.marker"
|
|
3149
3358
|
);
|
|
3150
3359
|
if (markerIndexToMove >= 0) {
|
|
3151
|
-
const markerSymbolToMove =
|
|
3360
|
+
const markerSymbolToMove = import_lodash16.default.pullAt(symbols, markerIndexToMove)[0];
|
|
3152
3361
|
symbols.push(markerSymbolToMove);
|
|
3153
3362
|
}
|
|
3154
3363
|
return symbols;
|
|
3155
3364
|
};
|
|
3156
3365
|
const getUIMarkerSymbol = (key) => {
|
|
3157
3366
|
const [featureType] = key.split(".");
|
|
3158
|
-
const featureTypeTheme =
|
|
3159
|
-
const categoryTheme =
|
|
3160
|
-
const mergedSymbol =
|
|
3161
|
-
const symbol =
|
|
3367
|
+
const featureTypeTheme = import_lodash16.default.get(mapTheme, `${featureType}.ui.marker`);
|
|
3368
|
+
const categoryTheme = import_lodash16.default.get(mapTheme, `${key}.ui.marker`);
|
|
3369
|
+
const mergedSymbol = import_lodash16.default.merge({}, featureTypeTheme, categoryTheme);
|
|
3370
|
+
const symbol = import_lodash16.default.get(mergedSymbol, "symbol");
|
|
3162
3371
|
return symbol;
|
|
3163
3372
|
};
|
|
3164
3373
|
const getUIMarkerOptions = (key) => {
|
|
3165
3374
|
const [featureType] = key.split(".");
|
|
3166
|
-
const featureTypeTheme =
|
|
3167
|
-
const categoryTheme =
|
|
3168
|
-
const mergedSymbol =
|
|
3169
|
-
const options =
|
|
3375
|
+
const featureTypeTheme = import_lodash16.default.get(mapTheme, `${featureType}.ui.marker`);
|
|
3376
|
+
const categoryTheme = import_lodash16.default.get(mapTheme, `${key}.ui.marker`);
|
|
3377
|
+
const mergedSymbol = import_lodash16.default.merge({}, featureTypeTheme, categoryTheme);
|
|
3378
|
+
const options = import_lodash16.default.get(mergedSymbol, "options");
|
|
3170
3379
|
return options;
|
|
3171
3380
|
};
|
|
3172
3381
|
const getLabelOptions = (key) => {
|
|
3173
3382
|
const [featureType] = key.split(".");
|
|
3174
|
-
const featureTypeSymbol =
|
|
3175
|
-
const categorySymbol =
|
|
3176
|
-
const mergedSymbol =
|
|
3177
|
-
return
|
|
3383
|
+
const featureTypeSymbol = import_lodash16.default.get(mapTheme, `${featureType}.label`);
|
|
3384
|
+
const categorySymbol = import_lodash16.default.get(mapTheme, `${key}.label`);
|
|
3385
|
+
const mergedSymbol = import_lodash16.default.merge({}, featureTypeSymbol, categorySymbol);
|
|
3386
|
+
return import_lodash16.default.reduce(
|
|
3178
3387
|
mergedSymbol,
|
|
3179
|
-
(acc, symbol) => ({ ...acc, ...
|
|
3388
|
+
(acc, symbol) => ({ ...acc, ...import_lodash16.default.get(symbol, "options", {}) }),
|
|
3180
3389
|
{}
|
|
3181
3390
|
);
|
|
3182
3391
|
};
|
|
@@ -3191,13 +3400,13 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
3191
3400
|
};
|
|
3192
3401
|
const generateSpriteHighlightMarkerOption = () => {
|
|
3193
3402
|
return SPRITE_HIGHLIGHT_MARKER_FEATURE.reduce((acc, featCate) => {
|
|
3194
|
-
const categoryKey =
|
|
3403
|
+
const categoryKey = import_lodash16.default.last(featCate.split("-"));
|
|
3195
3404
|
const defaultLabelSymbol = getLabelSymbol(categoryKey);
|
|
3196
3405
|
const highlightLabelSymbol = getLabelSymbol(featCate);
|
|
3197
3406
|
const [defaultBase, defaultIcon] = defaultLabelSymbol;
|
|
3198
3407
|
const [highlightBase, highlightIcon] = highlightLabelSymbol;
|
|
3199
|
-
const base =
|
|
3200
|
-
const icon =
|
|
3408
|
+
const base = import_lodash16.default.merge({}, defaultBase, highlightBase);
|
|
3409
|
+
const icon = import_lodash16.default.merge({}, defaultIcon, highlightIcon);
|
|
3201
3410
|
const material = createSpriteMaterialByLabelSymbol([base, icon]);
|
|
3202
3411
|
const options = getLabelOptions(featCate);
|
|
3203
3412
|
return { ...acc, [featCate]: { material, options } };
|
|
@@ -3207,32 +3416,32 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
3207
3416
|
const spriteHighlightMarkerOptionObj = generateSpriteHighlightMarkerOption();
|
|
3208
3417
|
const getElementOptions = (key) => {
|
|
3209
3418
|
const [featureType] = key.split(".");
|
|
3210
|
-
const featureTypeOptions =
|
|
3419
|
+
const featureTypeOptions = import_lodash16.default.get(
|
|
3211
3420
|
mapTheme,
|
|
3212
3421
|
`${featureType}.geometry.options`
|
|
3213
3422
|
);
|
|
3214
|
-
const categoryOptions =
|
|
3215
|
-
return
|
|
3423
|
+
const categoryOptions = import_lodash16.default.get(mapTheme, `${key}.geometry.options`);
|
|
3424
|
+
return import_lodash16.default.merge({}, featureTypeOptions, categoryOptions);
|
|
3216
3425
|
};
|
|
3217
3426
|
const createOccupantMarker = (feature2, locatedFeature, mapConfig) => {
|
|
3218
3427
|
const { textMarkerType, featureExtrudeConfig } = getFeatureMarkerConfig(
|
|
3219
3428
|
feature2,
|
|
3220
3429
|
mapConfig
|
|
3221
3430
|
);
|
|
3222
|
-
const markerHeight =
|
|
3431
|
+
const markerHeight = import_lodash16.default.get(featureExtrudeConfig, "height", 0);
|
|
3223
3432
|
const { properties, id, feature_type } = feature2;
|
|
3224
3433
|
if (!properties.anchor) return;
|
|
3225
|
-
const mainLocationId =
|
|
3434
|
+
const mainLocationId = import_lodash16.default.get(properties, "unit.id") || import_lodash16.default.get(properties, "kiosk.id");
|
|
3226
3435
|
const isMainLocationFeature = mainLocationId === locatedFeature?.id;
|
|
3227
3436
|
const { geometry: mainLocationGeometry } = properties?.anchor;
|
|
3228
|
-
const geometry = isMainLocationFeature ? mainLocationGeometry : (0,
|
|
3437
|
+
const geometry = isMainLocationFeature ? mainLocationGeometry : (0, import_center11.default)(locatedFeature)?.geometry;
|
|
3229
3438
|
const baseProperties = {
|
|
3230
3439
|
id,
|
|
3231
3440
|
feature_type,
|
|
3232
3441
|
category: properties.category,
|
|
3233
3442
|
altitude: getAltitude(properties)
|
|
3234
3443
|
};
|
|
3235
|
-
const occupantName =
|
|
3444
|
+
const occupantName = import_lodash16.default.isEmpty(properties.short_name) ? properties.name : properties.short_name;
|
|
3236
3445
|
if (locatedFeature) {
|
|
3237
3446
|
const { feature_type: feature_type2, properties: properties2 } = locatedFeature;
|
|
3238
3447
|
const { category } = properties2;
|
|
@@ -3246,21 +3455,21 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
3246
3455
|
}
|
|
3247
3456
|
return requestedType;
|
|
3248
3457
|
};
|
|
3249
|
-
const logoUrl =
|
|
3250
|
-
const requestedRenderType =
|
|
3458
|
+
const logoUrl = import_lodash16.default.get(properties, "logo.url");
|
|
3459
|
+
const requestedRenderType = import_lodash16.default.get(properties, "render_type", "Name");
|
|
3251
3460
|
const renderType = getValidatedRenderType(requestedRenderType, logoUrl);
|
|
3252
3461
|
if (renderType === "Label") return null;
|
|
3253
3462
|
const renderPriority = properties.render_priority || 3;
|
|
3254
|
-
const labelSymbol = getLabelSymbol(`occupant-${
|
|
3255
|
-
const markerSymbol =
|
|
3256
|
-
const coordinates =
|
|
3463
|
+
const labelSymbol = getLabelSymbol(`occupant-${import_lodash16.default.toLower(renderType)}`);
|
|
3464
|
+
const markerSymbol = import_lodash16.default.last(labelSymbol);
|
|
3465
|
+
const coordinates = import_lodash16.default.get(geometry, "coordinates");
|
|
3257
3466
|
const priorityLabelSymbol = getLabelSymbol(
|
|
3258
|
-
`occupant-${
|
|
3467
|
+
`occupant-${import_lodash16.default.toLower(renderType)}-${renderPriority}`
|
|
3259
3468
|
);
|
|
3260
|
-
const priorityMarkerSymbol =
|
|
3469
|
+
const priorityMarkerSymbol = import_lodash16.default.last(priorityLabelSymbol) || {};
|
|
3261
3470
|
switch (renderType) {
|
|
3262
3471
|
case "Logo":
|
|
3263
|
-
|
|
3472
|
+
import_lodash16.default.set(priorityMarkerSymbol, "markerFile", logoUrl);
|
|
3264
3473
|
return new import_maptalks4.Marker(coordinates, {
|
|
3265
3474
|
properties: {
|
|
3266
3475
|
altitude: getAltitude(properties) + markerHeight,
|
|
@@ -3321,13 +3530,13 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
3321
3530
|
});
|
|
3322
3531
|
}
|
|
3323
3532
|
const uiMarkerSymbol = getUIMarkerSymbol(
|
|
3324
|
-
`occupant-${
|
|
3533
|
+
`occupant-${import_lodash16.default.toLower(renderType)}`
|
|
3325
3534
|
);
|
|
3326
3535
|
const uiMarkerPrioritySymbol = getUIMarkerSymbol(
|
|
3327
|
-
`occupant-${
|
|
3536
|
+
`occupant-${import_lodash16.default.toLower(renderType)}-${renderPriority}`
|
|
3328
3537
|
);
|
|
3329
3538
|
const uiMarkerPriorityOptions = getUIMarkerOptions(
|
|
3330
|
-
`occupant-${
|
|
3539
|
+
`occupant-${import_lodash16.default.toLower(renderType)}-${renderPriority}`
|
|
3331
3540
|
);
|
|
3332
3541
|
const style = { ...uiMarkerSymbol, ...uiMarkerPrioritySymbol };
|
|
3333
3542
|
return new import_maptalks4.ui.UIMarker(coordinates, {
|
|
@@ -3349,7 +3558,7 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
3349
3558
|
const { category, ordinal, style = {} } = properties;
|
|
3350
3559
|
const elementStyle = getElementSymbol(`${feature_type}.${category}`);
|
|
3351
3560
|
const { allowOverride } = getElementOptions(`${feature_type}.${category}`);
|
|
3352
|
-
if (allowOverride)
|
|
3561
|
+
if (allowOverride) import_lodash16.default.merge(elementStyle, style);
|
|
3353
3562
|
const { polygonFill: color } = elementStyle;
|
|
3354
3563
|
const featureProperty = {
|
|
3355
3564
|
id,
|
|
@@ -3438,9 +3647,9 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
3438
3647
|
feature2,
|
|
3439
3648
|
mapConfig
|
|
3440
3649
|
);
|
|
3441
|
-
const markerHeight =
|
|
3650
|
+
const markerHeight = import_lodash16.default.get(featureExtrudeConfig, "height");
|
|
3442
3651
|
const { id, properties } = feature2;
|
|
3443
|
-
const geometry =
|
|
3652
|
+
const geometry = import_lodash16.default.get(feature2, "geometry") || import_lodash16.default.get(feature2, "properties.anchor.geometry");
|
|
3444
3653
|
const coordinates = getCenterFromGeometry(geometry);
|
|
3445
3654
|
const symbol = getElementSymbol("pin-marker");
|
|
3446
3655
|
try {
|
|
@@ -3460,10 +3669,10 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
3460
3669
|
feature2,
|
|
3461
3670
|
mapConfig
|
|
3462
3671
|
);
|
|
3463
|
-
const markerHeight =
|
|
3672
|
+
const markerHeight = import_lodash16.default.get(featureExtrudeConfig, "height", 0);
|
|
3464
3673
|
const { properties, id } = feature2;
|
|
3465
3674
|
const { geometry } = properties.anchor;
|
|
3466
|
-
const logoUrl =
|
|
3675
|
+
const logoUrl = import_lodash16.default.get(properties, "logo.url");
|
|
3467
3676
|
const coordinates = getCenterFromGeometry(geometry);
|
|
3468
3677
|
const [markerBase, markerLabel] = getLabelSymbol(
|
|
3469
3678
|
"highlighted-logo-marker"
|
|
@@ -3533,7 +3742,7 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
3533
3742
|
feature2,
|
|
3534
3743
|
mapConfig
|
|
3535
3744
|
);
|
|
3536
|
-
const markerHeight =
|
|
3745
|
+
const markerHeight = import_lodash16.default.get(featureExtrudeConfig, "height");
|
|
3537
3746
|
const { id, feature_type, properties } = feature2;
|
|
3538
3747
|
if (!properties.anchor) return;
|
|
3539
3748
|
const markerProperties = {
|
|
@@ -3543,8 +3752,8 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
3543
3752
|
altitude: getAltitude(properties) + markerHeight
|
|
3544
3753
|
};
|
|
3545
3754
|
const { geometry } = properties?.anchor;
|
|
3546
|
-
const coordinates =
|
|
3547
|
-
const logoUrl =
|
|
3755
|
+
const coordinates = import_lodash16.default.get(geometry, "coordinates");
|
|
3756
|
+
const logoUrl = import_lodash16.default.get(properties, "logo.url");
|
|
3548
3757
|
if (markerSymbol) {
|
|
3549
3758
|
return new import_maptalks4.Marker(coordinates, {
|
|
3550
3759
|
properties: markerProperties,
|
|
@@ -3559,8 +3768,8 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
3559
3768
|
});
|
|
3560
3769
|
}
|
|
3561
3770
|
const labelSymbol = getLabelSymbol("highlight-occupant-logo");
|
|
3562
|
-
const priorityMarkerSymbol =
|
|
3563
|
-
|
|
3771
|
+
const priorityMarkerSymbol = import_lodash16.default.last(labelSymbol) || {};
|
|
3772
|
+
import_lodash16.default.set(priorityMarkerSymbol, "markerFile", logoUrl);
|
|
3564
3773
|
return new import_maptalks4.Marker(coordinates, {
|
|
3565
3774
|
properties: markerProperties,
|
|
3566
3775
|
symbol: labelSymbol
|
|
@@ -3568,14 +3777,14 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
3568
3777
|
},
|
|
3569
3778
|
createHighlight2DAmenityMarkerFrom3DMarker: (feature2, mapConfig) => {
|
|
3570
3779
|
const { coordinates, units, kiosk } = feature2;
|
|
3571
|
-
const amenityLocatedUnit =
|
|
3780
|
+
const amenityLocatedUnit = import_lodash16.default.first(units);
|
|
3572
3781
|
const unitConfig = getExtrudeConfigByFeature(
|
|
3573
3782
|
mapConfig,
|
|
3574
3783
|
amenityLocatedUnit
|
|
3575
3784
|
);
|
|
3576
|
-
const unitHeight =
|
|
3785
|
+
const unitHeight = import_lodash16.default.get(unitConfig, "height", 0);
|
|
3577
3786
|
const kioskConfig = getExtrudeConfigByFeature(mapConfig, kiosk);
|
|
3578
|
-
const kioskHeight =
|
|
3787
|
+
const kioskHeight = import_lodash16.default.get(kioskConfig, "height", 0);
|
|
3579
3788
|
const markerHeight = unitHeight + kioskHeight;
|
|
3580
3789
|
const symbol = getElementSymbol("highlight-amenity-marker");
|
|
3581
3790
|
return new import_maptalks4.Marker(coordinates, {
|
|
@@ -3651,7 +3860,7 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
3651
3860
|
}
|
|
3652
3861
|
},
|
|
3653
3862
|
createLineStringFromGeometries: (geometries) => {
|
|
3654
|
-
const mergedCoordinates = (0,
|
|
3863
|
+
const mergedCoordinates = (0, import_lodash16.default)(geometries).map((geometry) => {
|
|
3655
3864
|
switch (geometry.type) {
|
|
3656
3865
|
case "Point":
|
|
3657
3866
|
return [
|
|
@@ -3729,7 +3938,7 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
3729
3938
|
const {
|
|
3730
3939
|
logo,
|
|
3731
3940
|
altitude,
|
|
3732
|
-
scale:
|
|
3941
|
+
scale: scale3,
|
|
3733
3942
|
alphaTest,
|
|
3734
3943
|
legColor,
|
|
3735
3944
|
showLeg,
|
|
@@ -3743,7 +3952,7 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
3743
3952
|
};
|
|
3744
3953
|
const options = {
|
|
3745
3954
|
altitude,
|
|
3746
|
-
scale:
|
|
3955
|
+
scale: scale3,
|
|
3747
3956
|
alphaTest,
|
|
3748
3957
|
legColor,
|
|
3749
3958
|
showLeg,
|
|
@@ -3760,29 +3969,29 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
3760
3969
|
create3DAmenityMarker: (feature2, threeLayer, config) => {
|
|
3761
3970
|
const { geometry, properties, feature_type, id } = feature2;
|
|
3762
3971
|
const { category, units, kiosk, is_clickable } = properties;
|
|
3763
|
-
const amenityLocatedUnit =
|
|
3764
|
-
const isLocatedUnitModel3dAvailable = !
|
|
3972
|
+
const amenityLocatedUnit = import_lodash16.default.first(units);
|
|
3973
|
+
const isLocatedUnitModel3dAvailable = !import_lodash16.default.isEmpty(
|
|
3765
3974
|
amenityLocatedUnit?.properties?.model3d
|
|
3766
3975
|
);
|
|
3767
|
-
const isLocatedKioskModel3dAvailable = !
|
|
3976
|
+
const isLocatedKioskModel3dAvailable = !import_lodash16.default.isEmpty(
|
|
3768
3977
|
kiosk?.properties?.model3d
|
|
3769
3978
|
);
|
|
3770
3979
|
const unitConfig = getExtrudeConfigByFeature(config, amenityLocatedUnit);
|
|
3771
|
-
const unitHeight = isLocatedUnitModel3dAvailable ? 0 :
|
|
3980
|
+
const unitHeight = isLocatedUnitModel3dAvailable ? 0 : import_lodash16.default.get(unitConfig, "height", 0);
|
|
3772
3981
|
const kioskConfig = getExtrudeConfigByFeature(config, kiosk);
|
|
3773
|
-
const kioskHeight = isLocatedKioskModel3dAvailable ? 0 :
|
|
3774
|
-
const coordinates =
|
|
3982
|
+
const kioskHeight = isLocatedKioskModel3dAvailable ? 0 : import_lodash16.default.get(kioskConfig, "height", 0);
|
|
3983
|
+
const coordinates = import_lodash16.default.get(geometry, "coordinates");
|
|
3775
3984
|
const markerProperties = {
|
|
3776
3985
|
...properties,
|
|
3777
3986
|
coordinates,
|
|
3778
3987
|
id,
|
|
3779
3988
|
feature_type
|
|
3780
3989
|
};
|
|
3781
|
-
const material =
|
|
3990
|
+
const material = import_lodash16.default.get(
|
|
3782
3991
|
spriteMarkerMaterialObj,
|
|
3783
3992
|
`${feature_type}.${category}`
|
|
3784
3993
|
);
|
|
3785
|
-
const highlightOptions =
|
|
3994
|
+
const highlightOptions = import_lodash16.default.get(
|
|
3786
3995
|
spriteHighlightMarkerOptionObj,
|
|
3787
3996
|
`${PREFIX_HIGHLIGHTED_SYMBOL_KEY}-${feature_type}.${category}`
|
|
3788
3997
|
);
|
|
@@ -3805,24 +4014,24 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
3805
4014
|
const { category, unit, kiosk } = properties;
|
|
3806
4015
|
const amenityLocation = kiosk || unit;
|
|
3807
4016
|
const locationConfig = getExtrudeConfigByFeature(config, amenityLocation);
|
|
3808
|
-
const coordinates =
|
|
4017
|
+
const coordinates = import_lodash16.default.get(geometry, "coordinates");
|
|
3809
4018
|
const markerProperties = {
|
|
3810
4019
|
...properties,
|
|
3811
4020
|
coordinates,
|
|
3812
4021
|
id,
|
|
3813
4022
|
feature_type
|
|
3814
4023
|
};
|
|
3815
|
-
const material =
|
|
4024
|
+
const material = import_lodash16.default.get(
|
|
3816
4025
|
spriteMarkerMaterialObj,
|
|
3817
4026
|
`${feature_type}.${category}`
|
|
3818
4027
|
);
|
|
3819
|
-
const highlightOptions =
|
|
4028
|
+
const highlightOptions = import_lodash16.default.get(
|
|
3820
4029
|
spriteHighlightMarkerOptionObj,
|
|
3821
4030
|
`${PREFIX_HIGHLIGHTED_SYMBOL_KEY}-${feature_type}.${category}`
|
|
3822
4031
|
);
|
|
3823
4032
|
const options = {
|
|
3824
4033
|
scale: 0.05,
|
|
3825
|
-
altitude:
|
|
4034
|
+
altitude: import_lodash16.default.get(locationConfig, "height", 0),
|
|
3826
4035
|
highlight: highlightOptions
|
|
3827
4036
|
};
|
|
3828
4037
|
return create3DMarker(
|
|
@@ -3838,24 +4047,24 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
3838
4047
|
const { category, unit, kiosk } = properties;
|
|
3839
4048
|
const amenityLocation = kiosk || unit;
|
|
3840
4049
|
const locationConfig = getExtrudeConfigByFeature(config, amenityLocation);
|
|
3841
|
-
const coordinates =
|
|
4050
|
+
const coordinates = import_lodash16.default.get(geometry, "coordinates");
|
|
3842
4051
|
const markerProperties = {
|
|
3843
4052
|
...properties,
|
|
3844
4053
|
coordinates,
|
|
3845
4054
|
id,
|
|
3846
4055
|
feature_type
|
|
3847
4056
|
};
|
|
3848
|
-
const material =
|
|
4057
|
+
const material = import_lodash16.default.get(
|
|
3849
4058
|
spriteMarkerMaterialObj,
|
|
3850
4059
|
`${feature_type}.${category}`
|
|
3851
4060
|
);
|
|
3852
|
-
const highlightOptions =
|
|
4061
|
+
const highlightOptions = import_lodash16.default.get(
|
|
3853
4062
|
spriteHighlightMarkerOptionObj,
|
|
3854
4063
|
`${PREFIX_HIGHLIGHTED_SYMBOL_KEY}-${feature_type}.${category}`
|
|
3855
4064
|
);
|
|
3856
4065
|
const options = {
|
|
3857
4066
|
scale: 0.05,
|
|
3858
|
-
altitude:
|
|
4067
|
+
altitude: import_lodash16.default.get(locationConfig, "height", 0),
|
|
3859
4068
|
highlight: highlightOptions
|
|
3860
4069
|
};
|
|
3861
4070
|
return create3DMarker(
|
|
@@ -3867,13 +4076,13 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
3867
4076
|
);
|
|
3868
4077
|
},
|
|
3869
4078
|
createExtrudedUnit: (unit, threeLayer, options) => {
|
|
3870
|
-
const extrudeHeight =
|
|
4079
|
+
const extrudeHeight = import_lodash16.default.get(options, "height");
|
|
3871
4080
|
if (!extrudeHeight) return;
|
|
3872
4081
|
const unitProperty = getFeatureProperties(unit);
|
|
3873
4082
|
const options3d = {
|
|
3874
4083
|
// TODO: Move to extrude config later
|
|
3875
4084
|
offset: -0.1,
|
|
3876
|
-
altitude:
|
|
4085
|
+
altitude: import_lodash16.default.get(options, "altitude", 0)
|
|
3877
4086
|
};
|
|
3878
4087
|
const color = unitProperty.defaultColor;
|
|
3879
4088
|
if (color === "transparent") return;
|
|
@@ -3916,14 +4125,14 @@ var EXCEPT_AMENITY_LOCATION_CATEGORIES = [
|
|
|
3916
4125
|
"unspecified"
|
|
3917
4126
|
];
|
|
3918
4127
|
var getLocationByAmenity = (feature2) => {
|
|
3919
|
-
const unit =
|
|
3920
|
-
const unitCategory =
|
|
4128
|
+
const unit = import_lodash16.default.get(feature2, "properties.units[0]", null);
|
|
4129
|
+
const unitCategory = import_lodash16.default.get(unit, "properties.category");
|
|
3921
4130
|
if (!unit) return feature2.id;
|
|
3922
4131
|
return EXCEPT_AMENITY_LOCATION_CATEGORIES.includes(unitCategory) ? feature2 : unit;
|
|
3923
4132
|
};
|
|
3924
4133
|
var getLocationByOccupant = (feature2) => {
|
|
3925
|
-
const kiosk =
|
|
3926
|
-
const unit =
|
|
4134
|
+
const kiosk = import_lodash16.default.get(feature2, "properties.kiosk", null);
|
|
4135
|
+
const unit = import_lodash16.default.get(feature2, "properties.anchor.properties.unit", null);
|
|
3927
4136
|
return kiosk || unit;
|
|
3928
4137
|
};
|
|
3929
4138
|
var getLocationIdByFeature = (feature2) => {
|
|
@@ -3951,10 +4160,10 @@ var getFeatureByLocationId = (id, features = []) => {
|
|
|
3951
4160
|
});
|
|
3952
4161
|
};
|
|
3953
4162
|
var isClickableFeature = (feature2) => {
|
|
3954
|
-
const isClickable =
|
|
4163
|
+
const isClickable = import_lodash16.default.get(feature2, "properties.is_clickable");
|
|
3955
4164
|
switch (feature2?.feature_type) {
|
|
3956
4165
|
case "amenity":
|
|
3957
|
-
return
|
|
4166
|
+
return import_lodash16.default.isNull(isClickable) ? true : isClickable;
|
|
3958
4167
|
case "occupant":
|
|
3959
4168
|
return true;
|
|
3960
4169
|
default:
|
|
@@ -3972,15 +4181,15 @@ var getLocationByFeature = (feature2) => {
|
|
|
3972
4181
|
}
|
|
3973
4182
|
};
|
|
3974
4183
|
var getRelatedLocationsByOccupant = (feature2) => {
|
|
3975
|
-
const kiosks =
|
|
3976
|
-
const units =
|
|
4184
|
+
const kiosks = import_lodash16.default.get(feature2, "properties.kiosks", []);
|
|
4185
|
+
const units = import_lodash16.default.get(feature2, "properties.units", []);
|
|
3977
4186
|
return [...kiosks, ...units];
|
|
3978
4187
|
};
|
|
3979
4188
|
var getRelatedLocationsByAmenity = (feature2) => {
|
|
3980
|
-
const units =
|
|
4189
|
+
const units = import_lodash16.default.get(feature2, "properties.units", []);
|
|
3981
4190
|
if (units.length === 0) return [feature2];
|
|
3982
4191
|
return units.filter((unit) => {
|
|
3983
|
-
const unitCategory =
|
|
4192
|
+
const unitCategory = import_lodash16.default.get(unit, "properties.category");
|
|
3984
4193
|
return !EXCEPT_AMENITY_LOCATION_CATEGORIES.includes(unitCategory);
|
|
3985
4194
|
});
|
|
3986
4195
|
};
|
|
@@ -4006,8 +4215,8 @@ var getRelatedLocationsByFeature = (feature2) => {
|
|
|
4006
4215
|
};
|
|
4007
4216
|
var getOrdinalByLocationId = (locationId, feature2) => {
|
|
4008
4217
|
if (!feature2) return null;
|
|
4009
|
-
const mainUnit =
|
|
4010
|
-
const mainKiosk =
|
|
4218
|
+
const mainUnit = import_lodash16.default.get(feature2, "properties.unit");
|
|
4219
|
+
const mainKiosk = import_lodash16.default.get(feature2, "properties.kiosk");
|
|
4011
4220
|
const relatedLocations = getRelatedLocationsByFeature(feature2);
|
|
4012
4221
|
const allLocations = [mainUnit, mainKiosk, ...relatedLocations].filter(
|
|
4013
4222
|
Boolean
|
|
@@ -4015,7 +4224,7 @@ var getOrdinalByLocationId = (locationId, feature2) => {
|
|
|
4015
4224
|
const targetLocation = allLocations.find(
|
|
4016
4225
|
(location) => location.id === locationId
|
|
4017
4226
|
);
|
|
4018
|
-
return targetLocation ?
|
|
4227
|
+
return targetLocation ? import_lodash16.default.get(targetLocation, "properties.level.properties.ordinal") || import_lodash16.default.get(targetLocation, "properties.ordinal") : null;
|
|
4019
4228
|
};
|
|
4020
4229
|
|
|
4021
4230
|
// src/IndoorMap/utils/math.ts
|
|
@@ -4028,140 +4237,16 @@ var getBearingBetweenPoints = (origin, destination) => {
|
|
|
4028
4237
|
return Math.floor(radToDegree(theta));
|
|
4029
4238
|
};
|
|
4030
4239
|
var getSuitablyValueBetweenBearings = (newBearing, currentBearing) => {
|
|
4031
|
-
const
|
|
4032
|
-
if (
|
|
4240
|
+
const difference2 = Math.abs(newBearing - currentBearing);
|
|
4241
|
+
if (difference2 > 180)
|
|
4033
4242
|
return newBearing > 0 ? newBearing - 360 : newBearing + 360;
|
|
4034
4243
|
return newBearing;
|
|
4035
4244
|
};
|
|
4036
4245
|
|
|
4037
4246
|
// src/IndoorMap/camera/CameraManager.ts
|
|
4038
4247
|
var import_maptalks5 = require("maptalks");
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
function coordEach(geojson, callback, excludeWrapCoord) {
|
|
4042
|
-
if (geojson === null) return;
|
|
4043
|
-
var j, k, l, geometry, stopG, coords, geometryMaybeCollection, wrapShrink = 0, coordIndex = 0, isGeometryCollection, type = geojson.type, isFeatureCollection = type === "FeatureCollection", isFeature = type === "Feature", stop = isFeatureCollection ? geojson.features.length : 1;
|
|
4044
|
-
for (var featureIndex = 0; featureIndex < stop; featureIndex++) {
|
|
4045
|
-
geometryMaybeCollection = isFeatureCollection ? geojson.features[featureIndex].geometry : isFeature ? geojson.geometry : geojson;
|
|
4046
|
-
isGeometryCollection = geometryMaybeCollection ? geometryMaybeCollection.type === "GeometryCollection" : false;
|
|
4047
|
-
stopG = isGeometryCollection ? geometryMaybeCollection.geometries.length : 1;
|
|
4048
|
-
for (var geomIndex = 0; geomIndex < stopG; geomIndex++) {
|
|
4049
|
-
var multiFeatureIndex = 0;
|
|
4050
|
-
var geometryIndex = 0;
|
|
4051
|
-
geometry = isGeometryCollection ? geometryMaybeCollection.geometries[geomIndex] : geometryMaybeCollection;
|
|
4052
|
-
if (geometry === null) continue;
|
|
4053
|
-
coords = geometry.coordinates;
|
|
4054
|
-
var geomType = geometry.type;
|
|
4055
|
-
wrapShrink = excludeWrapCoord && (geomType === "Polygon" || geomType === "MultiPolygon") ? 1 : 0;
|
|
4056
|
-
switch (geomType) {
|
|
4057
|
-
case null:
|
|
4058
|
-
break;
|
|
4059
|
-
case "Point":
|
|
4060
|
-
if (callback(
|
|
4061
|
-
coords,
|
|
4062
|
-
coordIndex,
|
|
4063
|
-
featureIndex,
|
|
4064
|
-
multiFeatureIndex,
|
|
4065
|
-
geometryIndex
|
|
4066
|
-
) === false)
|
|
4067
|
-
return false;
|
|
4068
|
-
coordIndex++;
|
|
4069
|
-
multiFeatureIndex++;
|
|
4070
|
-
break;
|
|
4071
|
-
case "LineString":
|
|
4072
|
-
case "MultiPoint":
|
|
4073
|
-
for (j = 0; j < coords.length; j++) {
|
|
4074
|
-
if (callback(
|
|
4075
|
-
coords[j],
|
|
4076
|
-
coordIndex,
|
|
4077
|
-
featureIndex,
|
|
4078
|
-
multiFeatureIndex,
|
|
4079
|
-
geometryIndex
|
|
4080
|
-
) === false)
|
|
4081
|
-
return false;
|
|
4082
|
-
coordIndex++;
|
|
4083
|
-
if (geomType === "MultiPoint") multiFeatureIndex++;
|
|
4084
|
-
}
|
|
4085
|
-
if (geomType === "LineString") multiFeatureIndex++;
|
|
4086
|
-
break;
|
|
4087
|
-
case "Polygon":
|
|
4088
|
-
case "MultiLineString":
|
|
4089
|
-
for (j = 0; j < coords.length; j++) {
|
|
4090
|
-
for (k = 0; k < coords[j].length - wrapShrink; k++) {
|
|
4091
|
-
if (callback(
|
|
4092
|
-
coords[j][k],
|
|
4093
|
-
coordIndex,
|
|
4094
|
-
featureIndex,
|
|
4095
|
-
multiFeatureIndex,
|
|
4096
|
-
geometryIndex
|
|
4097
|
-
) === false)
|
|
4098
|
-
return false;
|
|
4099
|
-
coordIndex++;
|
|
4100
|
-
}
|
|
4101
|
-
if (geomType === "MultiLineString") multiFeatureIndex++;
|
|
4102
|
-
if (geomType === "Polygon") geometryIndex++;
|
|
4103
|
-
}
|
|
4104
|
-
if (geomType === "Polygon") multiFeatureIndex++;
|
|
4105
|
-
break;
|
|
4106
|
-
case "MultiPolygon":
|
|
4107
|
-
for (j = 0; j < coords.length; j++) {
|
|
4108
|
-
geometryIndex = 0;
|
|
4109
|
-
for (k = 0; k < coords[j].length; k++) {
|
|
4110
|
-
for (l = 0; l < coords[j][k].length - wrapShrink; l++) {
|
|
4111
|
-
if (callback(
|
|
4112
|
-
coords[j][k][l],
|
|
4113
|
-
coordIndex,
|
|
4114
|
-
featureIndex,
|
|
4115
|
-
multiFeatureIndex,
|
|
4116
|
-
geometryIndex
|
|
4117
|
-
) === false)
|
|
4118
|
-
return false;
|
|
4119
|
-
coordIndex++;
|
|
4120
|
-
}
|
|
4121
|
-
geometryIndex++;
|
|
4122
|
-
}
|
|
4123
|
-
multiFeatureIndex++;
|
|
4124
|
-
}
|
|
4125
|
-
break;
|
|
4126
|
-
case "GeometryCollection":
|
|
4127
|
-
for (j = 0; j < geometry.geometries.length; j++)
|
|
4128
|
-
if (coordEach(geometry.geometries[j], callback, excludeWrapCoord) === false)
|
|
4129
|
-
return false;
|
|
4130
|
-
break;
|
|
4131
|
-
default:
|
|
4132
|
-
throw new Error("Unknown Geometry Type");
|
|
4133
|
-
}
|
|
4134
|
-
}
|
|
4135
|
-
}
|
|
4136
|
-
}
|
|
4137
|
-
|
|
4138
|
-
// ../../node_modules/@turf/bbox/dist/esm/index.js
|
|
4139
|
-
function bbox(geojson, options = {}) {
|
|
4140
|
-
if (geojson.bbox != null && true !== options.recompute) {
|
|
4141
|
-
return geojson.bbox;
|
|
4142
|
-
}
|
|
4143
|
-
const result = [Infinity, Infinity, -Infinity, -Infinity];
|
|
4144
|
-
coordEach(geojson, (coord) => {
|
|
4145
|
-
if (result[0] > coord[0]) {
|
|
4146
|
-
result[0] = coord[0];
|
|
4147
|
-
}
|
|
4148
|
-
if (result[1] > coord[1]) {
|
|
4149
|
-
result[1] = coord[1];
|
|
4150
|
-
}
|
|
4151
|
-
if (result[2] < coord[0]) {
|
|
4152
|
-
result[2] = coord[0];
|
|
4153
|
-
}
|
|
4154
|
-
if (result[3] < coord[1]) {
|
|
4155
|
-
result[3] = coord[1];
|
|
4156
|
-
}
|
|
4157
|
-
});
|
|
4158
|
-
return result;
|
|
4159
|
-
}
|
|
4160
|
-
var index_default = bbox;
|
|
4161
|
-
|
|
4162
|
-
// src/IndoorMap/camera/CameraManager.ts
|
|
4163
|
-
var import_transform_scale = __toESM(require("@turf/transform-scale"));
|
|
4164
|
-
var import_bbox_polygon = __toESM(require("@turf/bbox-polygon"));
|
|
4248
|
+
var import_transform_scale2 = __toESM(require("@turf/transform-scale"));
|
|
4249
|
+
var import_bbox_polygon2 = __toESM(require("@turf/bbox-polygon"));
|
|
4165
4250
|
var CameraManager = class {
|
|
4166
4251
|
map;
|
|
4167
4252
|
constructor(map, options) {
|
|
@@ -4187,7 +4272,7 @@ var CameraManager = class {
|
|
|
4187
4272
|
}
|
|
4188
4273
|
getFeatureExtent = (feature2, scaleFactor = 1) => {
|
|
4189
4274
|
const [minX, minY, maxX, maxY] = index_default(
|
|
4190
|
-
(0,
|
|
4275
|
+
(0, import_transform_scale2.default)((0, import_bbox_polygon2.default)(index_default(feature2)), scaleFactor)
|
|
4191
4276
|
);
|
|
4192
4277
|
return new import_maptalks5.Extent(minX, minY, maxX, maxY);
|
|
4193
4278
|
};
|
|
@@ -4224,8 +4309,8 @@ var CameraManager = class {
|
|
|
4224
4309
|
};
|
|
4225
4310
|
|
|
4226
4311
|
// src/IndoorMap/renderer/RendererManager.ts
|
|
4227
|
-
var
|
|
4228
|
-
var
|
|
4312
|
+
var import_lodash19 = require("lodash");
|
|
4313
|
+
var import_center12 = require("@turf/center");
|
|
4229
4314
|
var THREE4 = __toESM(require("three"));
|
|
4230
4315
|
|
|
4231
4316
|
// src/IndoorMap/renderer/3d/Element3DRenderer.ts
|
|
@@ -4233,10 +4318,10 @@ var maptalks4 = __toESM(require("maptalks-gl"));
|
|
|
4233
4318
|
var THREE = __toESM(require("three"));
|
|
4234
4319
|
var import_maptalks7 = require("maptalks.three");
|
|
4235
4320
|
var import_buffer2 = __toESM(require("@turf/buffer"));
|
|
4236
|
-
var
|
|
4321
|
+
var import_clean_coords2 = require("@turf/clean-coords");
|
|
4237
4322
|
var import_polygon_to_line = require("@turf/polygon-to-line");
|
|
4238
4323
|
var import_nearest_point_on_line = require("@turf/nearest-point-on-line");
|
|
4239
|
-
var
|
|
4324
|
+
var import_length2 = require("@turf/length");
|
|
4240
4325
|
var import_along = require("@turf/along");
|
|
4241
4326
|
var import_point_to_line_distance = require("@turf/point-to-line-distance");
|
|
4242
4327
|
|
|
@@ -4245,7 +4330,7 @@ var maptalks3 = __toESM(require("maptalks-gl"));
|
|
|
4245
4330
|
var import_maptalks6 = require("maptalks.three");
|
|
4246
4331
|
var import_three5 = require("three");
|
|
4247
4332
|
var import_d3plus_shape = require("d3plus-shape");
|
|
4248
|
-
var
|
|
4333
|
+
var import_lodash17 = require("lodash");
|
|
4249
4334
|
var OPTIONS3 = {
|
|
4250
4335
|
// Allowing click through and prevent interaction
|
|
4251
4336
|
interactive: false,
|
|
@@ -4263,9 +4348,9 @@ var defaultFlatLabelOptions = {
|
|
|
4263
4348
|
textBaseline: "middle",
|
|
4264
4349
|
fillStyle: "#000"
|
|
4265
4350
|
};
|
|
4266
|
-
var defaultRectAngleToCalc = (0,
|
|
4351
|
+
var defaultRectAngleToCalc = (0, import_lodash17.range)(-90, 92, 2);
|
|
4267
4352
|
var getMaterial = (text, flatLabelOptions) => {
|
|
4268
|
-
const options = (0,
|
|
4353
|
+
const options = (0, import_lodash17.merge)({}, defaultFlatLabelOptions, flatLabelOptions);
|
|
4269
4354
|
const {
|
|
4270
4355
|
fontSize: initialFontSize,
|
|
4271
4356
|
fontFamily,
|
|
@@ -4318,23 +4403,23 @@ var getMaterial = (text, flatLabelOptions) => {
|
|
|
4318
4403
|
const maxWidth = SIZE - 2 * margin;
|
|
4319
4404
|
texts = wrapText(ctx, text, maxWidth);
|
|
4320
4405
|
}
|
|
4321
|
-
let textWidth = (0,
|
|
4322
|
-
let
|
|
4323
|
-
while (
|
|
4324
|
-
|
|
4325
|
-
ctx.font = `${fontWeight} ${
|
|
4326
|
-
textWidth = (0,
|
|
4327
|
-
}
|
|
4328
|
-
const
|
|
4329
|
-
if (
|
|
4330
|
-
const totalHeight = texts.length * (fontSize *
|
|
4331
|
-
const startY =
|
|
4406
|
+
let textWidth = (0, import_lodash17.max)(texts.map((text2) => ctx.measureText(text2).width));
|
|
4407
|
+
let scale3 = 1;
|
|
4408
|
+
while (scale3 > 0 && textWidth + 2 * margin > SIZE) {
|
|
4409
|
+
scale3 -= scaleStep;
|
|
4410
|
+
ctx.font = `${fontWeight} ${scale3 * fontSize}px "${fontFamily}", Arial`;
|
|
4411
|
+
textWidth = (0, import_lodash17.max)(texts.map((text2) => ctx.measureText(text2).width));
|
|
4412
|
+
}
|
|
4413
|
+
const center8 = { x: 0.5 * SIZE, y: 0.5 * SIZE };
|
|
4414
|
+
if (scale3 > scaleMin) {
|
|
4415
|
+
const totalHeight = texts.length * (fontSize * scale3 * lineHeight);
|
|
4416
|
+
const startY = center8.y - totalHeight / 2 + fontSize * scale3 * lineHeight * 0.5;
|
|
4332
4417
|
texts.forEach((text2, index) => {
|
|
4333
|
-
const yOffset = startY + index * (fontSize *
|
|
4418
|
+
const yOffset = startY + index * (fontSize * scale3 * lineHeight);
|
|
4334
4419
|
if (strokeStyle && lineWidth) {
|
|
4335
|
-
ctx.strokeText(text2,
|
|
4420
|
+
ctx.strokeText(text2, center8.x, yOffset);
|
|
4336
4421
|
}
|
|
4337
|
-
ctx.fillText(text2,
|
|
4422
|
+
ctx.fillText(text2, center8.x, yOffset);
|
|
4338
4423
|
});
|
|
4339
4424
|
}
|
|
4340
4425
|
const texture = new import_three5.Texture(canvas);
|
|
@@ -4391,7 +4476,7 @@ var GroundLabel = class extends import_maptalks6.BaseObject {
|
|
|
4391
4476
|
strokeStyle,
|
|
4392
4477
|
lineWidth
|
|
4393
4478
|
});
|
|
4394
|
-
const rectAngles = (0,
|
|
4479
|
+
const rectAngles = (0, import_lodash17.isArray)(angle) ? angle : [angle];
|
|
4395
4480
|
material.needsUpdate = true;
|
|
4396
4481
|
const rect = (0, import_d3plus_shape.largestRect)(bound, {
|
|
4397
4482
|
cache: true,
|
|
@@ -4411,8 +4496,8 @@ var GroundLabel = class extends import_maptalks6.BaseObject {
|
|
|
4411
4496
|
const basePosition = layer.coordinateToVector3([cx, cy], z);
|
|
4412
4497
|
this.#originalPosition = basePosition.clone();
|
|
4413
4498
|
const finalPosition = this.#calculateFinalPosition(basePosition);
|
|
4414
|
-
const
|
|
4415
|
-
const finalScale = maxFontScale &&
|
|
4499
|
+
const scale3 = width / 6456122659e-13;
|
|
4500
|
+
const finalScale = maxFontScale && scale3 > maxFontScale ? maxFontScale : scale3;
|
|
4416
4501
|
this.getObject3d().scale.set(finalScale, finalScale, finalScale);
|
|
4417
4502
|
this.getObject3d().position.copy(finalPosition);
|
|
4418
4503
|
this.getObject3d().rotation.z = Math.PI / 180 * this.#angle;
|
|
@@ -4464,32 +4549,32 @@ var GroundLabel = class extends import_maptalks6.BaseObject {
|
|
|
4464
4549
|
return { x: this.#offsetX, y: this.#offsetY };
|
|
4465
4550
|
}
|
|
4466
4551
|
set offsetX(value) {
|
|
4467
|
-
if ((0,
|
|
4552
|
+
if ((0, import_lodash17.isNumber)(value)) {
|
|
4468
4553
|
this.#offsetX = value;
|
|
4469
4554
|
this.#updatePosition();
|
|
4470
4555
|
}
|
|
4471
4556
|
}
|
|
4472
4557
|
set offsetY(value) {
|
|
4473
|
-
if ((0,
|
|
4558
|
+
if ((0, import_lodash17.isNumber)(value)) {
|
|
4474
4559
|
this.#offsetY = value;
|
|
4475
4560
|
this.#updatePosition();
|
|
4476
4561
|
}
|
|
4477
4562
|
}
|
|
4478
4563
|
set angle(newAngle) {
|
|
4479
|
-
if ((0,
|
|
4564
|
+
if ((0, import_lodash17.isNumber)(newAngle)) {
|
|
4480
4565
|
this.#angle = newAngle;
|
|
4481
4566
|
this.getObject3d().rotation.z = Math.PI / 180 * this.#angle;
|
|
4482
4567
|
}
|
|
4483
4568
|
}
|
|
4484
4569
|
setOffset(offsetX, offsetY) {
|
|
4485
|
-
if ((0,
|
|
4570
|
+
if ((0, import_lodash17.isNumber)(offsetX) && (0, import_lodash17.isNumber)(offsetY)) {
|
|
4486
4571
|
this.#offsetX = offsetX;
|
|
4487
4572
|
this.#offsetY = offsetY;
|
|
4488
4573
|
this.#updatePosition();
|
|
4489
4574
|
}
|
|
4490
4575
|
}
|
|
4491
4576
|
addOffset(deltaX, deltaY) {
|
|
4492
|
-
if ((0,
|
|
4577
|
+
if ((0, import_lodash17.isNumber)(deltaX) && (0, import_lodash17.isNumber)(deltaY)) {
|
|
4493
4578
|
this.#offsetX += deltaX;
|
|
4494
4579
|
this.#offsetY += deltaY;
|
|
4495
4580
|
this.#updatePosition();
|
|
@@ -4591,6 +4676,7 @@ var Element3DRenderer = class extends EventTarget {
|
|
|
4591
4676
|
threeLayer;
|
|
4592
4677
|
scene;
|
|
4593
4678
|
lineMaterial;
|
|
4679
|
+
navigationLineMaterial;
|
|
4594
4680
|
materialByColorMap;
|
|
4595
4681
|
// Renderer is Ready
|
|
4596
4682
|
isReady = false;
|
|
@@ -4602,6 +4688,7 @@ var Element3DRenderer = class extends EventTarget {
|
|
|
4602
4688
|
this.threeLayer = groupLayer.getLayer("three");
|
|
4603
4689
|
this.gltfLayer = groupLayer.getLayer("gltf");
|
|
4604
4690
|
this.lineMaterial = new THREE.LineBasicMaterial({ color: "#000" });
|
|
4691
|
+
this.navigationLineMaterial = new THREE.LineBasicMaterial({ color: "#f00" });
|
|
4605
4692
|
this.render();
|
|
4606
4693
|
}
|
|
4607
4694
|
animation() {
|
|
@@ -4717,7 +4804,7 @@ var Element3DRenderer = class extends EventTarget {
|
|
|
4717
4804
|
const polygons = unit.geometry.type === "Polygon" ? [unit.geometry.coordinates] : unit.geometry.coordinates;
|
|
4718
4805
|
return polygons.map((plg) => {
|
|
4719
4806
|
return plg.map((ring) => {
|
|
4720
|
-
const roomWall = (0,
|
|
4807
|
+
const roomWall = (0, import_clean_coords2.cleanCoords)((0, import_polygon_to_line.polygonToLine)(polygon([ring])));
|
|
4721
4808
|
if (openings.length === 0) {
|
|
4722
4809
|
const color = "#ababab";
|
|
4723
4810
|
const material = this.getOrCreateMaterialByColor(color);
|
|
@@ -4745,7 +4832,7 @@ var Element3DRenderer = class extends EventTarget {
|
|
|
4745
4832
|
try {
|
|
4746
4833
|
const split = (0, import_line_split.default)(roomWall, multiPoint(openingPoints));
|
|
4747
4834
|
const wallsOnly = split.features.filter((seg) => {
|
|
4748
|
-
const mid = (0, import_along.along)(seg, (0,
|
|
4835
|
+
const mid = (0, import_along.along)(seg, (0, import_length2.length)(seg, { units: "meters" }) / 2, { units: "meters" });
|
|
4749
4836
|
for (const opening of openings) {
|
|
4750
4837
|
const dist = (0, import_point_to_line_distance.pointToLineDistance)(mid, opening, { units: "meters" });
|
|
4751
4838
|
if (dist < 0.05) return false;
|
|
@@ -4804,10 +4891,10 @@ var Element3DRenderer = class extends EventTarget {
|
|
|
4804
4891
|
this.threeLayer.addMesh(groundLabel);
|
|
4805
4892
|
return groundLabel;
|
|
4806
4893
|
}
|
|
4807
|
-
async createModel3d(
|
|
4808
|
-
const marker = new maptalks4.GLTFMarker(
|
|
4894
|
+
async createModel3d(center8, url) {
|
|
4895
|
+
const marker = new maptalks4.GLTFMarker(center8, {
|
|
4809
4896
|
symbol: {
|
|
4810
|
-
url
|
|
4897
|
+
url
|
|
4811
4898
|
}
|
|
4812
4899
|
});
|
|
4813
4900
|
marker.addTo(this.gltfLayer);
|
|
@@ -4866,11 +4953,23 @@ var Element3DRenderer = class extends EventTarget {
|
|
|
4866
4953
|
}
|
|
4867
4954
|
}
|
|
4868
4955
|
}
|
|
4956
|
+
drawNavigation = (route) => {
|
|
4957
|
+
const lines = [];
|
|
4958
|
+
route.steps.map((step) => {
|
|
4959
|
+
const lineString2 = new maptalks4.LineString(step.path);
|
|
4960
|
+
const line = this.threeLayer.toPath(lineString2, { altitude: 0.2, cornerRadius: 1, width: 1, asynchronous: true }, this.navigationLineMaterial);
|
|
4961
|
+
lines.push(line);
|
|
4962
|
+
});
|
|
4963
|
+
this.threeLayer.addMesh(lines);
|
|
4964
|
+
};
|
|
4869
4965
|
render() {
|
|
4870
4966
|
this.threeLayer._needsUpdate = !this.threeLayer._needsUpdate;
|
|
4871
4967
|
if (this.threeLayer._needsUpdate) {
|
|
4872
4968
|
this.threeLayer.redraw();
|
|
4873
4969
|
}
|
|
4970
|
+
if (this.navigationLineMaterial?.map?.offset) {
|
|
4971
|
+
this.navigationLineMaterial.map.offset.x -= 2e-3;
|
|
4972
|
+
}
|
|
4874
4973
|
requestAnimationFrame(this.render.bind(this));
|
|
4875
4974
|
}
|
|
4876
4975
|
};
|
|
@@ -5010,6 +5109,8 @@ var Element2DRenderer = class extends EventTarget {
|
|
|
5010
5109
|
}
|
|
5011
5110
|
};
|
|
5012
5111
|
}
|
|
5112
|
+
drawNavigation(route) {
|
|
5113
|
+
}
|
|
5013
5114
|
};
|
|
5014
5115
|
|
|
5015
5116
|
// src/IndoorMap/renderer/2d/Marker2DRenderer.ts
|
|
@@ -5055,7 +5156,7 @@ var THREE3 = __toESM(require("three"));
|
|
|
5055
5156
|
var import_maptalks8 = require("maptalks");
|
|
5056
5157
|
var THREE2 = __toESM(require("three"));
|
|
5057
5158
|
var import_maptalks9 = require("maptalks.three");
|
|
5058
|
-
var
|
|
5159
|
+
var import_lodash18 = require("lodash");
|
|
5059
5160
|
|
|
5060
5161
|
// src/IndoorMap/renderer/utils/interpolateStops.ts
|
|
5061
5162
|
var interpolateStops = ({ stops }, zoom) => {
|
|
@@ -5065,8 +5166,8 @@ var interpolateStops = ({ stops }, zoom) => {
|
|
|
5065
5166
|
const [z1, v1] = stops[i];
|
|
5066
5167
|
const [z2, v2] = stops[i + 1];
|
|
5067
5168
|
if (zoom >= z1 && zoom <= z2) {
|
|
5068
|
-
const
|
|
5069
|
-
return v1 +
|
|
5169
|
+
const t2 = (zoom - z1) / (z2 - z1);
|
|
5170
|
+
return v1 + t2 * (v2 - v1);
|
|
5070
5171
|
}
|
|
5071
5172
|
}
|
|
5072
5173
|
};
|
|
@@ -5150,7 +5251,7 @@ var TextSpriteMarker = class extends import_maptalks9.BaseObject {
|
|
|
5150
5251
|
const paragraphs = String(text).split("\n");
|
|
5151
5252
|
const wrappedLines = [];
|
|
5152
5253
|
paragraphs.forEach((paragraph) => {
|
|
5153
|
-
if ((0,
|
|
5254
|
+
if ((0, import_lodash18.isNil)(maxWidth) || isNaN(maxWidth)) {
|
|
5154
5255
|
wrappedLines.push(paragraph);
|
|
5155
5256
|
return;
|
|
5156
5257
|
}
|
|
@@ -5211,7 +5312,7 @@ var TextSpriteMarker = class extends import_maptalks9.BaseObject {
|
|
|
5211
5312
|
const altitude = (options.altitude || 0) + this.#altitudeOffset;
|
|
5212
5313
|
const z = layer.altitudeToVector3(altitude, altitude).x;
|
|
5213
5314
|
const position = layer.coordinateToVector3(this._coordinate, z);
|
|
5214
|
-
(0,
|
|
5315
|
+
(0, import_lodash18.set)(this.properties, "default.position", position);
|
|
5215
5316
|
this.getObject3d().position.copy(position);
|
|
5216
5317
|
}
|
|
5217
5318
|
_animation() {
|
|
@@ -5386,10 +5487,10 @@ var angleBetweenLineStrings = (line1, line2) => {
|
|
|
5386
5487
|
};
|
|
5387
5488
|
|
|
5388
5489
|
// src/IndoorMap/renderer/utils/findUnitOnPoint.ts
|
|
5389
|
-
var
|
|
5490
|
+
var import_boolean_point_in_polygon5 = require("@turf/boolean-point-in-polygon");
|
|
5390
5491
|
var findUnitOnPoint = (units, point2) => {
|
|
5391
5492
|
try {
|
|
5392
|
-
return units.find((unit) => (0,
|
|
5493
|
+
return units.find((unit) => (0, import_boolean_point_in_polygon5.booleanPointInPolygon)(point2, polygon(unit.geometry.coordinates)));
|
|
5393
5494
|
} catch (err) {
|
|
5394
5495
|
return null;
|
|
5395
5496
|
}
|
|
@@ -5476,6 +5577,7 @@ var RendererManager = class extends EventTarget {
|
|
|
5476
5577
|
options.onRendererReady();
|
|
5477
5578
|
}
|
|
5478
5579
|
_this.#createElements();
|
|
5580
|
+
_this.elementRenderer.createModel3d([100.54724407, 13.72699081], "https://s3.venue.in.th/all_park_f95ac5be3c.gltf");
|
|
5479
5581
|
setTimeout(() => {
|
|
5480
5582
|
findBadMeshes(scene);
|
|
5481
5583
|
}, 3e3);
|
|
@@ -5493,7 +5595,7 @@ var RendererManager = class extends EventTarget {
|
|
|
5493
5595
|
if (this.#isClicked) return;
|
|
5494
5596
|
this.#isClicked = true;
|
|
5495
5597
|
const onClickElement = this.#onClickElement;
|
|
5496
|
-
if (!(0,
|
|
5598
|
+
if (!(0, import_lodash19.isFunction)(onClickElement)) return;
|
|
5497
5599
|
this.#onClickElement(e);
|
|
5498
5600
|
this.#isClicked = false;
|
|
5499
5601
|
};
|
|
@@ -5546,7 +5648,7 @@ var RendererManager = class extends EventTarget {
|
|
|
5546
5648
|
});
|
|
5547
5649
|
units.filter((u) => u.properties.category === "room").forEach((unit) => {
|
|
5548
5650
|
const openingRelationships = relationships.filter((r) => r.properties.origin?.id === unit.id || r.properties.destination?.id === unit.id);
|
|
5549
|
-
const roomOpenings = (0,
|
|
5651
|
+
const roomOpenings = (0, import_lodash19.compact)(openingRelationships.map((rel) => {
|
|
5550
5652
|
const openingId = rel?.properties.intermediary[0].id;
|
|
5551
5653
|
return openings.find((o) => o.id === openingId);
|
|
5552
5654
|
}));
|
|
@@ -5592,7 +5694,7 @@ var RendererManager = class extends EventTarget {
|
|
|
5592
5694
|
const thatLevelOpening = bothOpenings.find((opening) => opening.properties.ordinal !== thisOrdinal);
|
|
5593
5695
|
const angle = 180 * (1 / Math.PI) * angleBetweenLineStrings(thisLevelOpening.geometry.coordinates, thatLevelOpening.geometry.coordinates);
|
|
5594
5696
|
const direction = thisOrdinal < thatLevelOpening.properties.ordinal ? "up" : "down";
|
|
5595
|
-
const escalatorEntryPoint = (0,
|
|
5697
|
+
const escalatorEntryPoint = (0, import_center12.center)(thisLevelOpening).geometry.coordinates;
|
|
5596
5698
|
const element = await this.elementRenderer.createEscalator(escalator, escalatorEntryPoint, { direction, angle });
|
|
5597
5699
|
if (element) {
|
|
5598
5700
|
const _elements = Array.isArray(element) ? element : [element];
|
|
@@ -5604,8 +5706,8 @@ var RendererManager = class extends EventTarget {
|
|
|
5604
5706
|
}
|
|
5605
5707
|
const groundLabels = await this.#dataClient.filterByType("label");
|
|
5606
5708
|
for (const label of groundLabels) {
|
|
5607
|
-
const
|
|
5608
|
-
const unit = findUnitOnPoint(units,
|
|
5709
|
+
const center8 = (0, import_center12.center)(polygon(label.geometry.coordinates)).geometry.coordinates;
|
|
5710
|
+
const unit = findUnitOnPoint(units, center8);
|
|
5609
5711
|
if (unit) {
|
|
5610
5712
|
const element = this.elementRenderer.createGroundLabel(label, unit);
|
|
5611
5713
|
if (element) {
|
|
@@ -5614,12 +5716,6 @@ var RendererManager = class extends EventTarget {
|
|
|
5614
5716
|
}
|
|
5615
5717
|
}
|
|
5616
5718
|
}
|
|
5617
|
-
if (this.options.type === "3D") {
|
|
5618
|
-
const model3ds = await this.#dataClient.filterByType("model3d");
|
|
5619
|
-
for (const model3d of model3ds) {
|
|
5620
|
-
this.elementRenderer.createModel3d(model3d);
|
|
5621
|
-
}
|
|
5622
|
-
}
|
|
5623
5719
|
this.changeLevelByOrdinal(this.currentOrdinals);
|
|
5624
5720
|
this.dispatchEvent(new CustomEvent("renderermanager:elements_created"));
|
|
5625
5721
|
}
|
|
@@ -5634,7 +5730,7 @@ var RendererManager = class extends EventTarget {
|
|
|
5634
5730
|
this.markerRenderer.showMarkers(markers, ordinal - baseOrdinal);
|
|
5635
5731
|
}
|
|
5636
5732
|
} else {
|
|
5637
|
-
const baseOrdinal = Array.isArray(targetOrdinal) ? (0,
|
|
5733
|
+
const baseOrdinal = Array.isArray(targetOrdinal) ? (0, import_lodash19.min)(targetOrdinal) : targetOrdinal;
|
|
5638
5734
|
for (const [ordinal, elements] of this.elementsByOrdinal) {
|
|
5639
5735
|
const inOrdinal = Array.isArray(targetOrdinal) ? targetOrdinal.includes(ordinal) : ordinal === targetOrdinal;
|
|
5640
5736
|
if (inOrdinal) {
|
|
@@ -5661,7 +5757,7 @@ var RendererManager = class extends EventTarget {
|
|
|
5661
5757
|
const elements = elemIds.map((id) => this.elementsMap.get(id)).flat();
|
|
5662
5758
|
elements.forEach((element) => {
|
|
5663
5759
|
const controller = this.elementRenderer.createHighlightController(element);
|
|
5664
|
-
if (controller && (0,
|
|
5760
|
+
if (controller && (0, import_lodash19.isFunction)(controller.start)) {
|
|
5665
5761
|
controller.start();
|
|
5666
5762
|
this.highlightControllers.push(controller);
|
|
5667
5763
|
}
|
|
@@ -5669,7 +5765,7 @@ var RendererManager = class extends EventTarget {
|
|
|
5669
5765
|
};
|
|
5670
5766
|
clearHighlightElements = () => {
|
|
5671
5767
|
this.highlightControllers.forEach((controller) => {
|
|
5672
|
-
if ((0,
|
|
5768
|
+
if ((0, import_lodash19.isFunction)(controller?.clear)) controller.clear();
|
|
5673
5769
|
});
|
|
5674
5770
|
};
|
|
5675
5771
|
/**
|
|
@@ -5704,6 +5800,9 @@ var RendererManager = class extends EventTarget {
|
|
|
5704
5800
|
this.markerRenderer.removeMarker(marker);
|
|
5705
5801
|
}
|
|
5706
5802
|
}
|
|
5803
|
+
drawNavigation(route) {
|
|
5804
|
+
this.elementRenderer.drawNavigation(route);
|
|
5805
|
+
}
|
|
5707
5806
|
};
|
|
5708
5807
|
|
|
5709
5808
|
// src/IndoorMap/IndoorMap.ts
|
|
@@ -5781,7 +5880,7 @@ var IndoorMap = class extends EventTarget {
|
|
|
5781
5880
|
};
|
|
5782
5881
|
constructor(elementId, options) {
|
|
5783
5882
|
super();
|
|
5784
|
-
const combinedOptions =
|
|
5883
|
+
const combinedOptions = import_lodash20.default.merge({}, defaultOptions, options);
|
|
5785
5884
|
this.options = combinedOptions;
|
|
5786
5885
|
const {
|
|
5787
5886
|
onMapReady,
|
|
@@ -5828,7 +5927,7 @@ var IndoorMap = class extends EventTarget {
|
|
|
5828
5927
|
this.dataClient = options.dataClient;
|
|
5829
5928
|
}
|
|
5830
5929
|
setOptions(options) {
|
|
5831
|
-
const combinedOptions =
|
|
5930
|
+
const combinedOptions = import_lodash20.default.merge({}, defaultOptions, options);
|
|
5832
5931
|
this.options = combinedOptions;
|
|
5833
5932
|
const maptalksOptions = parseMaptalksOptions(combinedOptions);
|
|
5834
5933
|
this.map.setOptions(maptalksOptions);
|
|
@@ -5838,10 +5937,10 @@ var IndoorMap = class extends EventTarget {
|
|
|
5838
5937
|
if (!this.options.camera?.defaultView?.center) {
|
|
5839
5938
|
this.#dataClient.filterByType("venue").then((venues) => {
|
|
5840
5939
|
this.#venues = venues;
|
|
5841
|
-
const venueCenters = (0,
|
|
5940
|
+
const venueCenters = (0, import_center13.default)(featureCollection(venues));
|
|
5842
5941
|
const [x, y] = venueCenters.geometry.coordinates;
|
|
5843
|
-
const
|
|
5844
|
-
this.camera.setView({ center:
|
|
5942
|
+
const center8 = new import_maptalks_gl.Coordinate(x, y);
|
|
5943
|
+
this.camera.setView({ center: center8, pitch: 60, zoom: 19 });
|
|
5845
5944
|
});
|
|
5846
5945
|
}
|
|
5847
5946
|
}
|
|
@@ -5854,7 +5953,7 @@ var IndoorMap = class extends EventTarget {
|
|
|
5854
5953
|
handleMapClick = ({ coordinate }) => {
|
|
5855
5954
|
const { x, y } = coordinate;
|
|
5856
5955
|
console.log(
|
|
5857
|
-
`[Coordinates]: x: ${
|
|
5956
|
+
`[Coordinates]: x: ${import_lodash20.default.round(x, 8)} y: ${import_lodash20.default.round(
|
|
5858
5957
|
y,
|
|
5859
5958
|
8
|
|
5860
5959
|
)}, [Bearing]: ${this.map.getBearing()}, [Pitch]: ${this.map.getPitch()}`
|
|
@@ -5940,7 +6039,7 @@ var IndoorMap = class extends EventTarget {
|
|
|
5940
6039
|
if (this.#isClicked) return;
|
|
5941
6040
|
this.#isClicked = true;
|
|
5942
6041
|
const onClickElement = this.#onClickElement;
|
|
5943
|
-
if (!
|
|
6042
|
+
if (!import_lodash20.default.isFunction(onClickElement)) return;
|
|
5944
6043
|
this.#onClickElement(e);
|
|
5945
6044
|
this.#isClicked = false;
|
|
5946
6045
|
};
|
|
@@ -5960,16 +6059,16 @@ var IndoorMap = class extends EventTarget {
|
|
|
5960
6059
|
for (const feature2 of this.#features) {
|
|
5961
6060
|
try {
|
|
5962
6061
|
const { feature_type: featureType, properties, id } = feature2;
|
|
5963
|
-
const layerName =
|
|
6062
|
+
const layerName = import_lodash20.default.get(
|
|
5964
6063
|
LAYER_FEATURE_TYPE_OBJ,
|
|
5965
6064
|
featureType,
|
|
5966
6065
|
featureType
|
|
5967
6066
|
);
|
|
5968
6067
|
const layer = this.map.getLayer(layerName);
|
|
5969
6068
|
let geometry;
|
|
5970
|
-
const category =
|
|
5971
|
-
const extrudeConfig =
|
|
5972
|
-
const textMarkerType =
|
|
6069
|
+
const category = import_lodash20.default.get(feature2, "properties.category");
|
|
6070
|
+
const extrudeConfig = import_lodash20.default.get(this.#mapConfig, "extrude");
|
|
6071
|
+
const textMarkerType = import_lodash20.default.get(
|
|
5973
6072
|
this.#mapConfig,
|
|
5974
6073
|
"text_marker_type",
|
|
5975
6074
|
"ui-marker"
|
|
@@ -6001,7 +6100,7 @@ var IndoorMap = class extends EventTarget {
|
|
|
6001
6100
|
case "opening": {
|
|
6002
6101
|
switch (category) {
|
|
6003
6102
|
case "emergencyexit":
|
|
6004
|
-
const { geometry: geometry2 } = (0,
|
|
6103
|
+
const { geometry: geometry2 } = (0, import_center13.default)(feature2);
|
|
6005
6104
|
const markerFeature = {
|
|
6006
6105
|
...feature2,
|
|
6007
6106
|
geometry: geometry2
|
|
@@ -6084,9 +6183,9 @@ var IndoorMap = class extends EventTarget {
|
|
|
6084
6183
|
const mapCenter = this.map.getCenter();
|
|
6085
6184
|
const result = this.#venues.reduce((closest, venue) => {
|
|
6086
6185
|
const { display_point: displayPoint } = venue.properties;
|
|
6087
|
-
const
|
|
6088
|
-
if (!closest ||
|
|
6089
|
-
return { venueId: venue.id, distance };
|
|
6186
|
+
const distance5 = (0, import_distance6.default)(displayPoint, [mapCenter.x, mapCenter.y]);
|
|
6187
|
+
if (!closest || distance5 < closest.distance) {
|
|
6188
|
+
return { venueId: venue.id, distance: distance5 };
|
|
6090
6189
|
}
|
|
6091
6190
|
return closest;
|
|
6092
6191
|
}, null);
|
|
@@ -6136,15 +6235,15 @@ var IndoorMap = class extends EventTarget {
|
|
|
6136
6235
|
}
|
|
6137
6236
|
}
|
|
6138
6237
|
updateUserLocationSymbolByLocale(locale) {
|
|
6139
|
-
const userLocationGeometry =
|
|
6238
|
+
const userLocationGeometry = import_lodash20.default.get(
|
|
6140
6239
|
this.#elements,
|
|
6141
6240
|
`${USER_LOCATION_ELEMENT_ID}.geometry`
|
|
6142
6241
|
);
|
|
6143
6242
|
if (!userLocationGeometry) return;
|
|
6144
6243
|
const currentSymbol = userLocationGeometry.getSymbol();
|
|
6145
6244
|
const localeSymbolToUpdate = currentSymbol.map((symbol) => {
|
|
6146
|
-
const localeSymbol =
|
|
6147
|
-
if (!
|
|
6245
|
+
const localeSymbol = import_lodash20.default.get(symbol, `${LOCALE_SYMBOL_KEY}.${locale}`) || import_lodash20.default.get(symbol, `${LOCALE_SYMBOL_KEY}.default`);
|
|
6246
|
+
if (!import_lodash20.default.isPlainObject(localeSymbol)) return symbol;
|
|
6148
6247
|
return {
|
|
6149
6248
|
...symbol,
|
|
6150
6249
|
...localeSymbol
|
|
@@ -6218,14 +6317,14 @@ var IndoorMap = class extends EventTarget {
|
|
|
6218
6317
|
* END of User Location
|
|
6219
6318
|
****************************/
|
|
6220
6319
|
showGeometryByElementId = (elementId) => {
|
|
6221
|
-
const geometry =
|
|
6320
|
+
const geometry = import_lodash20.default.get(
|
|
6222
6321
|
this.#elements,
|
|
6223
6322
|
`${elementId}.geometry`
|
|
6224
6323
|
);
|
|
6225
6324
|
if (geometry) geometry.show();
|
|
6226
6325
|
};
|
|
6227
6326
|
hideGeometryByElementId = (elementId) => {
|
|
6228
|
-
const geometry =
|
|
6327
|
+
const geometry = import_lodash20.default.get(this.#elements, `${elementId}.geometry`);
|
|
6229
6328
|
if (geometry) geometry.hide();
|
|
6230
6329
|
};
|
|
6231
6330
|
setSpriteMarkersOpacity = (opacity = 1) => {
|
|
@@ -6264,7 +6363,7 @@ var IndoorMap = class extends EventTarget {
|
|
|
6264
6363
|
* Navigation
|
|
6265
6364
|
****************************/
|
|
6266
6365
|
combineNearbyLineStrings(lineStrings, options = { properties: {}, distance: 3e-4 }) {
|
|
6267
|
-
const { properties = {}, distance = 3e-4 } = options || {};
|
|
6366
|
+
const { properties = {}, distance: distance5 = 3e-4 } = options || {};
|
|
6268
6367
|
const combinedLineStrings = [];
|
|
6269
6368
|
const accLine = [];
|
|
6270
6369
|
if (lineStrings.length === 1) return lineStrings;
|
|
@@ -6272,14 +6371,14 @@ var IndoorMap = class extends EventTarget {
|
|
|
6272
6371
|
const line = lineStrings[i];
|
|
6273
6372
|
const coords = line.geometry.coordinates;
|
|
6274
6373
|
const prevLine = lineStrings[i - 1];
|
|
6275
|
-
const firstCoord =
|
|
6374
|
+
const firstCoord = import_lodash20.default.first(coords);
|
|
6276
6375
|
const isFirstLine = i === 0;
|
|
6277
6376
|
if (isFirstLine) {
|
|
6278
6377
|
accLine.push(...coords);
|
|
6279
6378
|
continue;
|
|
6280
6379
|
}
|
|
6281
|
-
const prevLastCoord =
|
|
6282
|
-
const isNearby = (0,
|
|
6380
|
+
const prevLastCoord = import_lodash20.default.last(prevLine.geometry.coordinates);
|
|
6381
|
+
const isNearby = (0, import_distance6.default)(point(firstCoord), point(prevLastCoord)) < distance5;
|
|
6283
6382
|
if (!isNearby) {
|
|
6284
6383
|
const remainingLines = lineStrings.slice(i);
|
|
6285
6384
|
const res = this.combineNearbyLineStrings(remainingLines, properties);
|
|
@@ -6299,8 +6398,8 @@ var IndoorMap = class extends EventTarget {
|
|
|
6299
6398
|
create3DStepPath
|
|
6300
6399
|
} = this.#styler;
|
|
6301
6400
|
const routeMarkerLayer = this.map.getLayer(HIGHLIGHT_LAYER_NAME);
|
|
6302
|
-
const linesByOrdinal = (0,
|
|
6303
|
-
const joinedLines = (0,
|
|
6401
|
+
const linesByOrdinal = (0, import_lodash20.default)(stepGeometries).filter(({ geometry }) => geometry.type === "LineString").groupBy("properties.ordinal").value();
|
|
6402
|
+
const joinedLines = (0, import_lodash20.default)(linesByOrdinal).reduce((acc, lines, key) => {
|
|
6304
6403
|
const joined = this.combineNearbyLineStrings(lines, {
|
|
6305
6404
|
properties: { ordinal: +key }
|
|
6306
6405
|
});
|
|
@@ -6328,14 +6427,14 @@ var IndoorMap = class extends EventTarget {
|
|
|
6328
6427
|
stepElement = createOriginMarker(stepGeometry).addTo(routeMarkerLayer);
|
|
6329
6428
|
break;
|
|
6330
6429
|
case "destination-marker":
|
|
6331
|
-
const extrudeConfig =
|
|
6430
|
+
const extrudeConfig = import_lodash20.default.get(this.#mapConfig, "extrude");
|
|
6332
6431
|
if (destinationFeature.feature_type === "occupant") {
|
|
6333
|
-
const stepId =
|
|
6432
|
+
const stepId = import_lodash20.default.get(stepGeometry, "id");
|
|
6334
6433
|
const normalizedDestinationFeature = {
|
|
6335
6434
|
...destinationFeature,
|
|
6336
6435
|
id: stepId
|
|
6337
6436
|
};
|
|
6338
|
-
const logoUrl =
|
|
6437
|
+
const logoUrl = import_lodash20.default.get(
|
|
6339
6438
|
normalizedDestinationFeature,
|
|
6340
6439
|
"properties.logo.url"
|
|
6341
6440
|
);
|
|
@@ -6380,15 +6479,15 @@ var IndoorMap = class extends EventTarget {
|
|
|
6380
6479
|
const routeMarkerLayer = this.map.getLayer(
|
|
6381
6480
|
HIGHLIGHT_LAYER_NAME
|
|
6382
6481
|
);
|
|
6383
|
-
const originMarkerGeometry =
|
|
6482
|
+
const originMarkerGeometry = import_lodash20.default.get(
|
|
6384
6483
|
this.#elements,
|
|
6385
6484
|
`${ORIGIN_MARKER_ID}.geometry`
|
|
6386
6485
|
);
|
|
6387
|
-
const destinationMarkerGeometry =
|
|
6486
|
+
const destinationMarkerGeometry = import_lodash20.default.get(
|
|
6388
6487
|
this.#elements,
|
|
6389
6488
|
`${DESTINATION_MARKER_ID}.geometry`
|
|
6390
6489
|
);
|
|
6391
|
-
const geometriesToRemove =
|
|
6490
|
+
const geometriesToRemove = import_lodash20.default.compact([
|
|
6392
6491
|
originMarkerGeometry,
|
|
6393
6492
|
destinationMarkerGeometry
|
|
6394
6493
|
]);
|
|
@@ -6399,7 +6498,7 @@ var IndoorMap = class extends EventTarget {
|
|
|
6399
6498
|
(obj) => !(obj instanceof NavigationPath)
|
|
6400
6499
|
);
|
|
6401
6500
|
const objects = this.#navigationGeometries || {};
|
|
6402
|
-
|
|
6501
|
+
import_lodash20.default.forEach(objects, (obj) => {
|
|
6403
6502
|
if (!obj) return;
|
|
6404
6503
|
this.#navigationGeometries[obj.properties.id] = null;
|
|
6405
6504
|
obj.remove();
|
|
@@ -6436,7 +6535,7 @@ var IndoorMap = class extends EventTarget {
|
|
|
6436
6535
|
}
|
|
6437
6536
|
if (this.threeLayer) {
|
|
6438
6537
|
const currentView = this.camera.getView();
|
|
6439
|
-
const objectOpacity =
|
|
6538
|
+
const objectOpacity = import_lodash20.default.clamp(38 - 2 * currentView.zoom, 0, 1);
|
|
6440
6539
|
this.#objects.forEach((object) => {
|
|
6441
6540
|
object.getObject3d().traverse((child) => {
|
|
6442
6541
|
if (child.isMesh) child.material.opacity = objectOpacity;
|
|
@@ -6446,7 +6545,7 @@ var IndoorMap = class extends EventTarget {
|
|
|
6446
6545
|
});
|
|
6447
6546
|
if (this.#billboardObjects) {
|
|
6448
6547
|
this.#billboardObjects.forEach((object) => {
|
|
6449
|
-
const objectScale =
|
|
6548
|
+
const objectScale = import_lodash20.default.clamp(
|
|
6450
6549
|
20 - 1 * currentView.zoom,
|
|
6451
6550
|
1,
|
|
6452
6551
|
1.05
|
|
@@ -6455,7 +6554,7 @@ var IndoorMap = class extends EventTarget {
|
|
|
6455
6554
|
});
|
|
6456
6555
|
}
|
|
6457
6556
|
if (this.#isLayersFadingOnZoom) {
|
|
6458
|
-
const layerOpacity =
|
|
6557
|
+
const layerOpacity = import_lodash20.default.clamp(1 - objectOpacity, 0, 1);
|
|
6459
6558
|
LAYERS.forEach((layerKey) => {
|
|
6460
6559
|
const layer = this.map.getLayer(layerKey);
|
|
6461
6560
|
if (layer) layer.setOpacity(layerOpacity);
|