-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathWMEPIE.js
More file actions
4390 lines (4026 loc) · 251 KB
/
Copy pathWMEPIE.js
File metadata and controls
4390 lines (4026 loc) · 251 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
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
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ==UserScript==
// @name WME Place Interface Enhancements
// @namespace https://greasyfork.org/users/30701-justins83-waze
// @version 2026.06.09.01
// @description Enhancements to various Place interfaces
// @include https://www.waze.com/editor*
// @include https://www.waze.com/*/editor*
// @include https://beta.waze.com/editor*
// @include https://beta.waze.com/*/editor*
// @exclude https://www.waze.com/user/editor*
// @exclude https://www.waze.com/dashboard/editor
// @icon data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAMCAgMCAgMDAwMEAwMEBQgFBQQEBQoHBwYIDAoMDAsKCwsNDhIQDQ4RDgsLEBYQERMUFRUVDA8XGBYUGBIUFRT/2wBDAQMEBAUEBQkFBQkUDQsNFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBT/wAARCAEAAQADAREAAhEBAxEB/8QAHQABAAEFAQEBAAAAAAAAAAAAAAUBAwQGBwIICf/EAEAQAAICAQICBQgHBwQCAwAAAAABAgMEBREGMRIhQVFhBxMUIjJScYEXI0JUkZLBCBVVYpOhsRYzcoJEolPR4f/EABsBAQACAwEBAAAAAAAAAAAAAAADBAECBgUH/8QAMBEBAAIBAgUBCAEEAwEAAAAAAAECAwQRBRIhMVFBBhMiMmFxkdGBFCOhsVLB4fD/2gAMAwEAAhEDEQA/AP1TAAAAAAAAAAAAAAAAAAADwrFJtR9bbm+wyxu9mGQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAY+Vm04cd7JbPsiubNorNuzW1or3YONlW6tc0t6saPNJ9cvDckmsUj6o4tN5+iVjFQioxSSXJIhTKgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH1PWnVJ1UNdJdUp93wJ6Y9+soL5NukIOc5WScpScpPm2WdtleZ37tg4elF4ckvaU+sq5e6zi7JQhTAAAAAAAAAAAAAAAAAAAAAAAAAAA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Pp0rAow8eHQopgoRXgitPVKyTAAAAAAAAAANW470P07BWZVHe6hettzlDt/Alpbadmlo3c4LCIAAAAAAAAAAKS9l/ADnMvafxNW6gAAAAAAAADunke4S/c+kPVMiG2XmL1E11wr7Px5/gQXnedm8Q6IRtgAAAAAAAAAApKKlFprdPqaYGj5nk5ssyrZ0ZVddMpNxhKL3S7ieMiPlWfo2yfvlX5WPeR4OQ+jbJ++VflY95Hg5D6Nsn75V+Vj3keDkPo2yfvlX5WPeR4OQ+jbJ++VflY95Hg5D6Nsn75V+Vj3keDkPo2yfvlX5WPeR4OQ+jbJ++VflY95Hg5D6Nsn75V+Vj3keDkUfk1yWmvTKvyse8jwcjWH5B89tv96Y39ORj3kM8qn0D5/8AFMb+nIe8g5T6B8/+KY39OQ95Byn0D5/8Uxv6ch7yDlPoHz/4pjf05D3kHKfQPn/xTG/pyHvIOU+gfP8A4pjf05D3kHKfQPn/AMUxv6ch7yDlZWmeQy6jUMezM1Cm7FhNSsrhBpyS7DE3OV1yEI1xUYpRjFbJLkkRN3oAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP//Z
// @author JustinS83
// @grant GM_xmlhttpRequest
// @require https://greasyfork.org/scripts/24851-wazewrap/code/WazeWrap.js
// @require https://update.greasyfork.org/scripts/509664/WME%20Utils%20-%20Bootstrap.js
// @require https://greasyfork.org/scripts/37486-wme-utils-hoursparser/code/WME%20Utils%20-%20HoursParser.js
// @require https://greasyfork.org/scripts/38421-wme-utils-navigationpoint/code/WME%20Utils%20-%20NavigationPoint.js
// @require https://greasyfork.org/scripts/569692/code/WME%20Utils%20-%20SDK%20Google%20Link%20Enhancer.js
// @require https://greasyfork.org/scripts/375202-photo-viewer-db-interface/code/Photo%20Viewer%20DB%20Interface.js
// @require https://cdn.jsdelivr.net/npm/@turf/turf@7/turf.min.js
// @connect greasyfork.org
// @contributionURL https://github.com/WazeDev/Thank-The-Authors
// @license GPLv3
// @downloadURL https://update.greasyfork.org/scripts/26340/WME%20Place%20Interface%20Enhancements.user.js
// @updateURL https://update.greasyfork.org/scripts/26340/WME%20Place%20Interface%20Enhancements.meta.js
// ==/UserScript==
/* global W */
/* global OpenLayers */
/* global turf */
/* ecmaVersion 2017 */
/* global $ */
/* global I18n */
/* global bootstrap */
/* global WazeWrap */
/* global SDKGoogleLinkEnhancer */
/* global HoursParser */
/* global require */
/* global idbPVKeyval */
/* eslint curly: ["warn", "multi-or-nest"] */
(async function () {
'use strict';
var settings = {};
var resCategory = 'RESIDENTIAL';
var wazePL;
let hoursparser;
let GLE;
let navPointManager = null;
var catalog = [];
const updateMessage = 'Updating to latest Hours Parser';
var lastSelectedFeature;
const SCRIPT_VERSION = GM_info.script.version.toString();
const SCRIPT_NAME = GM_info.script.name;
const DOWNLOAD_URL = 'https://update.greasyfork.org/scripts/26340/WME%20Place%20Interface%20Enhancements.user.js';
// SDK layer name constants — must be at IIFE scope so all functions can reach them
const _PIE_SHOW_STOP_POINTS_LAYER = 'PIEShowStopPointsLayer';
const _PIE_CLOSEST_SEGMENT_LAYER = 'PIEClosestSegment';
// Place filter / hide-area state — controlled by predicates installed in init2 via addStyleRuleToLayer
let pieFilterRegex = null;
let pieFilterHideMode = true; // true = hide matching venues, false = show only matching
let pieHideAreaEnabled = false;
// WME DOM selectors — update here if WME changes panel structure
const WME_DOM = {
// Venue panel
venueEditGeneral: '#venue-edit-general',
venueExternalProviders: '#venue-edit-general > .external-providers-control',
venueNameInput: '#venue-edit-general wz-text-input[name="name"]',
venueAreaSize: '#AreaSize',
venueDescription: 'div.description-control',
venueAliasActions: '.alias-item-actions',
// Map comment panel
mcTypesSection: '.form-group.map-comment-types',
mcAttributesForm: 'form.attributes-form.side-panel-section',
// Address edit
addressEditView: '.address-edit-view',
addressEdit: '.address-edit',
addressFullAddress: '.full-address',
// Map / overlays
map: '#map',
wazeMap: '#WazeMap',
photoViewerResults: '#showDiv',
// Shadow DOM host elements
houseNumber: '.house-number', // RPP address — input lives in shadow root
sidebarAlert: 'wz-alert.sidebar-alert', // openPUR review button (shadow → shadow)
searchAutocomplete: '#search-autocomplete', // WME search bar (shadow → shadow → input)
};
const layerNames = {
closedPlaces: 'PIE - Highlight closed Places'
};
// Maps sdk shortcutId → settings key (needed because HideAreaPlacesShortcut uses ToggleAreaPlacesShortcut setting)
const _shortcutIdToSettingsKey = {
HideAreaPlacesShortcut: 'ToggleAreaPlacesShortcut',
};
// prettier-ignore
const _KEYCODE_TO_CHAR = {
// A-Z
65:'A',66:'B',67:'C',68:'D',69:'E',70:'F',71:'G',72:'H',73:'I',74:'J',75:'K',76:'L',
77:'M',78:'N',79:'O',80:'P',81:'Q',82:'R',83:'S',84:'T',85:'U',86:'V',87:'W',88:'X',
89:'Y',90:'Z',
// 0-9
48:'0',49:'1',50:'2',51:'3',52:'4',53:'5',54:'6',55:'7',56:'8',57:'9',
// Function keys
112:'F1',113:'F2',114:'F3',115:'F4',116:'F5',117:'F6',
118:'F7',119:'F8',120:'F9',121:'F10',122:'F11',123:'F12',
// Special keys
32:'Space',13:'Enter',9:'Tab',27:'Esc',8:'Backspace',46:'Delete',
36:'Home',35:'End',33:'PageUp',34:'PageDown',45:'Insert',
// Arrow keys
37:'←',38:'↑',39:'→',40:'↓',
// Common punctuation
188:',',190:'.',191:'/',186:';',222:"'",219:'[',221:']',220:'\\',189:'-',187:'=',192:'`',
};
// Reverse map: display name (uppercased) → keycode, for _comboToRaw special-key parsing.
// prettier-ignore
const _CHAR_TO_KEYCODE = Object.fromEntries(Object.entries(_KEYCODE_TO_CHAR).map(([k, v]) => [v.toUpperCase(), Number(k)]));
const _MOD_CHAR_TO_VAL = { C: 1, S: 2, A: 4 };
/**
* Converts any shortcut string to raw "modifier,keycode" format (e.g. "4,82").
* Handles: raw "4,82", combo "A+R", hybrid "A+82", bare key "R", WazeWrap "0,-1"/"-1".
* Returns null for empty / no-key values.
*
* WHY: The WME SDK is inconsistent — initial load returns combo format, after the user
* edits a shortcut it returns raw format, on next reload it's combo again. Normalizing
* everything to raw on save means we always have a stable, round-trippable value.
*/
function _comboToRaw(str) {
if (!str || str === '' || str === '-1' || str === 'None') return null;
if (/^\d+,-?\d+$/.test(str)) {
const kc = parseInt(str.split(',')[1], 10);
return kc < 0 ? null : str;
}
const s = String(str).toUpperCase(); // normalize input case so "c+g", "C+G", "cs+space" all parse
if (/^[A-Z0-9]$/.test(s)) return `0,${s.charCodeAt(0)}`; // bare alphanumeric key
if (_CHAR_TO_KEYCODE[s] !== undefined) return `0,${_CHAR_TO_KEYCODE[s]}`; // bare special key e.g. "F5", "SPACE", "←"
const mLetter = s.match(/^([ACS]+)\+([A-Z0-9])$/);
if (mLetter) {
const mod = mLetter[1].split('').reduce((a, c) => a | (_MOD_CHAR_TO_VAL[c] || 0), 0);
return `${mod},${mLetter[2].charCodeAt(0)}`;
}
const mNumeric = s.match(/^([ACS]+)\+(\d+)$/); // hybrid "A+82"
if (mNumeric) {
const mod = mNumeric[1].split('').reduce((a, c) => a | (_MOD_CHAR_TO_VAL[c] || 0), 0);
return `${mod},${mNumeric[2]}`;
}
const mSpecial = s.match(/^([ACS]+)\+(.+)$/); // modifier + special key e.g. "A+F5", "CS+SPACE", "A+←"
if (mSpecial && _CHAR_TO_KEYCODE[mSpecial[2]] !== undefined) {
const mod = mSpecial[1].split('').reduce((a, c) => a | (_MOD_CHAR_TO_VAL[c] || 0), 0);
return `${mod},${_CHAR_TO_KEYCODE[mSpecial[2]]}`;
}
return null;
}
/** Converts any shortcut string to human-readable combo format (e.g. "A+R"). Returns null if no key. */
function _rawToCombo(str) {
const raw = _comboToRaw(str);
if (!raw) return null;
const [modStr, keyStr] = raw.split(',');
const mod = parseInt(modStr, 10);
const keyCode = parseInt(keyStr, 10);
const keyChar = _KEYCODE_TO_CHAR[keyCode] || String(keyCode); // fall back to numeric string for unknown keycodes
let mods = '';
if (mod & 1) mods += 'C';
if (mod & 2) mods += 'S';
if (mod & 4) mods += 'A';
return mods ? `${mods}+${keyChar}` : keyChar;
}
/**
* Normalizes any shortcut value to a {raw, combo} pair for consistent storage.
* Accepts: flat string (any format), existing {raw,combo} object, or null.
*/
function _normalizeShortcut(val) {
const src = val && typeof val === 'object' ? (val.raw ?? val.combo) : val;
const raw = _comboToRaw(src);
const combo = _rawToCombo(raw);
return { raw, combo };
}
/** Returns the WME localized display name for a venue category or subcategory ID, or null. */
function _getCategoryLocalizedName(catId) {
if (!catId || catId === 'NONE') return null;
const sub = sdk.DataModel.Venues.getVenueSubCategories().find((s) => s.subCategoryId === catId);
if (sub) return sub.localizedName;
return sdk.DataModel.Venues.getVenueMainCategories().find((m) => m.id === catId)?.localizedName ?? null;
}
/**
* Re-registers a CreateItemN shortcut with a description reflecting the currently
* selected category, preserving the user's existing key binding. Also updates the
* key badge span in the Quick-Create Shortcuts UI.
*/
function _refreshItemShortcut(itemNum) {
const shortcutId = `CreateItem${itemNum}Shortcut`;
const cat = settings.NewPlacesList[itemNum - 1];
const catName = _getCategoryLocalizedName(cat);
const description = catName ? `${I18n.t('pie.prefs.CreateShortcut')} ${catName}` : `${I18n.t('pie.prefs.CreateShortcut')} ${I18n.t('pie.prefs.Item')} ${itemNum}`;
// Clear the key when no category is assigned; otherwise normalize whatever the SDK currently holds
const sdkKey = sdk.Shortcuts.getAllShortcuts().find((s) => s.shortcutId === shortcutId)?.shortcutKeys;
const normalized = !cat || cat === 'NONE' ? { raw: null, combo: null } : _normalizeShortcut(sdkKey);
settings[shortcutId] = normalized;
if (sdk.Shortcuts.isShortcutRegistered({ shortcutId })) sdk.Shortcuts.deleteShortcut({ shortcutId });
try {
sdk.Shortcuts.createShortcut({ shortcutId, description, callback: () => PlaceMenuShortcut(itemNum), shortcutKeys: normalized.combo });
} catch (ex) {
console.error(`PIE: Unable to re-register shortcut ${shortcutId}: ${ex}`);
}
}
const _sdkStyleContext = {
labelYOffset: (context) => context?.feature?.properties?.style?.labelYOffset,
label: (context) => context?.feature?.properties?.style?.label,
display: (context) => context?.feature?.properties?.style?.display,
fontWeight: (context) => context?.feature?.properties?.style?.fontWeight,
fontSize: (context) => context?.feature?.properties?.style?.fontSize,
labelOutlineWidth: (context) => context?.feature?.properties?.style?.labelOutlineWidth,
fontColor: (context) => context?.feature?.properties?.style?.fontColor,
labelOutlineColor: (context) => context?.feature?.properties?.style?.labelOutlineColor,
pointRadius: (context) => context?.feature?.properties?.style?.pointRadius,
};
const _sdkStyleRules = [
{
predicate: (p) => p.styleName === 'pointStyle',
style: { pointRadius: 6, fillColor: 'white', fillOpacity: 1, strokeColor: '#00ece3', strokeWidth: '3', strokeLinecap: 'round' },
},
{
predicate: (p) => p.styleName === 'lineStyleToNavPoint',
style: { strokeWidth: 3, strokeColor: '#00ece3', strokeLinecap: 'round', strokeDashstyle: 'dash' },
},
{
predicate: (p) => p.styleName === 'lineStyleToClosestSeg',
style: { strokeWidth: 4, strokeColor: '#00ece3', strokeLinecap: 'round' },
},
{
predicate: (p) => p.styleName === 'pointStyleNavPoint',
style: {
externalGraphic:
'data:image/gif;base64,R0lGODlhFgAWAPZ/AD09PT8/Pj8/P0M9PUA/P1s9PUBAPz09Qz09Zz09c0M9SWc9bT9AQD1DT0FBQEJBQURDQkRDQ0JGRkZFRUlIRklIR0lISElJSVFPTFJPTlJQTVNQTlNRT1ZTT1lWUlhWU11ZVmFbSXNDW2FhT2diXUlDYUNJbVtDc1thYWBgYGFhYWxsbG1tbZE9PbZzPaRVVZFnSbZzQ7BtYbB/Z8J/Q7yFW4uRbZGLc8iLYdqkZ8iqeeCwZ+y8cz09iz09kT1Dlz1nlz1JpENbkUNztmGFvD2R1EOR1H+wyG2w4HO25nO27Hm88p2dnZ6enraXl7a2ts7Cl/jIi/LOkfjUkf/Ukf/Ul//gqv/mtoW22pe22pfCzovI8pfU+KTa/7zs/8LCwsLOzs7Ozs/Pz9rOzubUzuzazvLgyP/syP//1P/42v//2s7U5s744NTm+Nrs/87y/8j4/9T//+bm5v//4P//5v//7ODy/+b///Pz8/jy8v//8vL4////+Pj//////wAAACH5BAUAAH8ALAAAAAAWABYAAAf+gH+CgyQeFQ8AAAQTHiSDj48ZDAIAlJWVAhyQjw8CAitMYXh4YUwrlQ+bf54VX36vsK9fEwKpnAIgcrBpTll9sHIgDLZ/GQITurBUAD1xsXIWAhmCnq6wZjMACFhusV+VfxyfsHw5JjfaNiVcsSsCHRUATLA8Qm9WBUFxUydesEwAKhgQEOaVmhddYr3KYcTPrzC1KOFRIwOEAhRbYNXBEaIBCSR+8CRKhAdNi5FKNLoIEABAkZCJWobhQwbKAi3dYJXRAQRMGz8QIVQQMM+PHhpJ/NQZs6YPnRhL/gmo8AfAClhXRGCRwoxNjSF3YJ2iJsCanzMwMB0gEvbVE09GgsQhixVFQA84z6JdGERLRTI/VQb8cPZKjgoBECAROGY2zx5YT6IJUNXpU6hRpdzVUhXXk6VEngx44PwIxAQJiSRUAKEqEAA7',
graphicWidth: 22,
graphicHeight: 22,
},
},
{
predicate: (p) => p.styleName === 'placeNameLabel',
style: {
display: '${display}',
label: '${label}',
labelYOffset: '${labelYOffset}',
fontWeight: '${fontWeight}',
fontSize: '${fontSize}',
labelOutlineWidth: '${labelOutlineWidth}',
fontColor: '${fontColor}',
labelOutlineColor: '${labelOutlineColor}',
pointRadius: 0,
},
},
];
const sdk = await bootstrap({
scriptName: SCRIPT_NAME,
scriptUpdateMonitor: {
downloadUrl: DOWNLOAD_URL,
scriptVersion: SCRIPT_VERSION,
},
});
const areaHandlers = {};
let _areaSizeRunId = 0;
const _SKIP_ROAD_TYPES = new Set([
10, // PEDESTRIAN_BOARDWALK
16, // STAIRWAY
18, // RAILROAD
19, // RUNWAY_TAXIWAY
]);
const eventHandlers = {}; // Store handlers for this feature
let _extProviderObserver = null;
await init(sdk);
function safeGetSelection() {
try {
return sdk.Editing.getSelection();
} catch (e) {
// sdk.Editing.getSelection() throws WMEError for types it doesn't support
// (e.g. 'googlePlace'). Treat as no-selection.
return null;
}
}
function getSelectedFeatures() {
const sel = safeGetSelection();
if (!sel || sel.objectType !== 'venue' || !sel.ids?.length) return [];
return sel.ids.map((id) => sdk.DataModel.Venues.getById({ venueId: id })).filter(Boolean);
}
function hasPlaceSelected() {
const sel = safeGetSelection();
return !!(sel && sel.objectType === 'venue' && sel.ids?.length);
}
function getSelectedPlace() {
const sel = safeGetSelection();
if (!sel || sel.objectType !== 'venue' || !sel.ids?.length) return null;
return sdk.DataModel.Venues.getById({ venueId: sel.ids[0] });
}
// SDK Venue Helper Functions (replace WazeWrap methods)
function venueIsPoint(venue) {
return venue && venue.geometry && venue.geometry.type === 'Point';
}
function venueIsParkingLot(venue) {
return venue && venue.categories && venue.categories.includes('PARKING_LOT');
}
function isInMapExtent(geometry) {
// Check if a GeoJSON geometry is within the current map extent
if (!geometry || !geometry.coordinates) return false;
const extent = sdk.Map.getMapExtent(); // [left, bottom, right, top]
if (!extent || extent.length < 4) return false;
const [left, bottom, right, top] = extent;
if (geometry.type === 'Point') {
const [lon, lat] = geometry.coordinates;
return lon >= left && lon <= right && lat >= bottom && lat <= top;
} else if (geometry.type === 'Polygon') {
// Check if any point in the polygon is within extent
for (const ring of geometry.coordinates) {
for (const [lon, lat] of ring) {
if (lon >= left && lon <= right && lat >= bottom && lat <= top) {
return true;
}
}
}
return false;
} else if (geometry.type === 'LineString') {
for (const [lon, lat] of geometry.coordinates) {
if (lon >= left && lon <= right && lat >= bottom && lat <= top) {
return true;
}
}
return false;
}
}
/**
* Find the closest road segment to a given point using Turf.js
*
* Searches all SDK segments and returns the one with minimum distance to the query point.
* Optionally skips parking lot roads (type 20) and/or private roads (type 17).
* All non-drivable road types are always skipped.
*
* Note: Made synchronous in PR #31 for better performance. Previously async but never
* actually performed async operations - removed unnecessary await overhead.
*
* @param {Object} pointGeoJSON - WGS84 GeoJSON Point geometry {type:'Point', coordinates:[lon,lat]}
* @param {boolean} [skipPLR=false] - If true, skip parking lot roads (roadType 20)
* @param {boolean} [skipPrivate=false] - If true, skip private roads (roadType 17) with blank names
* @param {Object} [sdkInstance=sdk] - SDK instance to use (defaults to global sdk, allows dependency injection for testing)
* @returns {Object|null} { closestPoint: WGS84 GeoJSON Point geometry, segment: SDK Segment } or null if no segments found
*/
function findClosestSegmentTurf(pointGeoJSON, skipPLR = false, skipPrivate = false, sdkInstance = sdk) {
try {
if (!pointGeoJSON || !pointGeoJSON.coordinates) return null;
const searchPoint = turf.point(pointGeoJSON.coordinates);
let minDistance = Infinity;
let nearestPt = null;
let closestSegment = null;
for (const seg of sdkInstance.DataModel.Segments.getAll()) {
if (!seg.geometry || seg.geometry.type !== 'LineString') continue;
const rt = seg.roadType;
if (_SKIP_ROAD_TYPES.has(rt)) continue; // always skip non-drivable
if (skipPLR && rt === 20 /* PARKING_LOT_ROAD */) continue;
if (skipPrivate && rt === 17 /* PRIVATE_ROAD */){
const segment = sdkInstance.DataModel.Segments.getById({ segmentId: seg.id });
const street = sdkInstance.DataModel.Streets.getById({ streetId: segment.primaryStreetId });
if(street?.name === null || street?.name == "")
continue;
}
// Cheap pre-pass: skip if even the minimum line distance >= current best
const approxDist = turf.pointToLineDistance(searchPoint, seg.geometry, { units: 'kilometers' });
if (approxDist >= minDistance) continue;
// Only run expensive nearestPointOnLine on segments that can beat the current best
const nearest = turf.nearestPointOnLine(seg.geometry, searchPoint);
if (nearest.properties.dist < minDistance) {
minDistance = nearest.properties.dist;
nearestPt = nearest;
closestSegment = seg;
}
}
if (!closestSegment || !nearestPt) return null;
return {
closestPoint: { type: 'Point', coordinates: nearestPt.geometry.coordinates },
segment: closestSegment,
getAddress: function () {
return this.segment;
},
};
} catch (err) {
console.error('Error in findClosestSegmentTurf:', err);
return null;
}
}
async function init(sdk) {
loadTranslations();
GLE = new SDKGoogleLinkEnhancer(sdk, turf, { layerName: layerNames.closedPlaces });
hoursparser = new HoursParser();
var $section = $('<div>', { id: 'WMEPIESettings' });
$section.html(
[
// Header
`<div class="pie-header">`,
`<div class="pie-header-title">${I18n.t('pie.prefs.title')}</div>`,
`<div class="pie-header-version">${SCRIPT_VERSION}</div>`,
`</div>`,
// --- Section 1: Place Filter ---
`<div class="pie-section" id="fieldPlaceFilter">`,
`<div class="pie-section-header"><i class="fa fa-filter"></i><span class="pie-section-title">${I18n.t('pie.filter.PlaceFilterPanel')}</span><i class="fa fa-chevron-down pie-chevron"></i></div>`,
`<div class="pie-section-body">`,
`<div id="divPlaceFilter" class="pie-filter-row"><span class="pie-toggle-label">${I18n.t('pie.filter.filter')}</span><input type="text" name="txtPlaceFilter" id="piePlaceFilter" class="pie-text-input"></div>`,
`<div id="divPlaceFilterOptions"><div class="pie-pill-group"><label class="pie-pill"><input type="radio" id="_rbHidePlaces" name="PlaceFilterToggle" checked><span>${I18n.t('pie.filter.Hide')}</span></label><label class="pie-pill"><input type="radio" id="_rbOnlyShowPlaces" name="PlaceFilterToggle"><span>${I18n.t('pie.filter.Show')}</span></label></div></div>`,
`</div></div>`,
// --- Section 2: Properties Panel ---
`<div class="pie-section" id="fieldPlacePanel">`,
`<div class="pie-section-header"><i class="fa fa-map-marker"></i><span class="pie-section-title">${I18n.t('pie.prefs.PropertiesPanel')}</span><i class="fa fa-chevron-down pie-chevron"></i></div>`,
`<div class="pie-section-body" id="divAreaPlaceSizeControls">`,
`<div id="divShowAreaPlaceSize" class="pie-toggle-row"><span class="pie-toggle-label">${I18n.t('pie.prefs.ShowAreaPlaceSize')}</span><label class="pie-toggle-switch"><input type="checkbox" id="_cbShowAreaPlaceSize" class="pieSettingsCheckbox"><span class="pie-slider"></span></label></div>`,
`<div id="divShowAreaPlaceSizeImperial" class="pie-toggle-row pie-sub-row"><span class="pie-toggle-label">${I18n.t('pie.prefs.ShowImperial')}</span><label class="pie-toggle-switch"><input type="checkbox" id="_cbShowAreaPlaceSizeImperial" class="pieSettingsCheckbox" disabled><span class="pie-slider"></span></label></div>`,
`<div id="divShowAreaPlaceSizeMetric" class="pie-toggle-row pie-sub-row"><span class="pie-toggle-label">${I18n.t('pie.prefs.ShowMetric')}</span><label class="pie-toggle-switch"><input type="checkbox" id="_cbShowAreaPlaceSizeMetric" class="pieSettingsCheckbox" disabled><span class="pie-slider"></span></label></div>`,
`<div id="divShowPlaceLocatorCrosshair" class="pie-toggle-row" title="${I18n.t('pie.prefs.ShowPlaceLocatorCrosshairTitle')}"><span class="pie-toggle-label">${I18n.t('pie.prefs.ShowPlaceLocatorCrosshair')}</span><label class="pie-toggle-switch"><input type="checkbox" id="_cbShowPlaceLocatorCrosshair" class="pieSettingsCheckbox"><span class="pie-slider"></span></label></div>`,
`<div class="pie-toggle-row pie-sub-row"><span class="pie-toggle-label">${I18n.t('pie.prefs.ProdPL')}</span><label class="pie-toggle-switch"><input type="checkbox" id="_cbPlaceLocatorCrosshairProdPL" class="pieSettingsCheckbox"><span class="pie-slider"></span></label></div>`,
`<div class="pie-toggle-row pie-sub-row" title="${I18n.t('pie.prefs.ZoomTitle')}"><span class="pie-toggle-label">${I18n.t('pie.prefs.Zoom')}</span><select id="piePlaceZoom" class="pie-select"><option value="22">22</option><option value="21">21</option><option value="20">20</option><option value="19">19</option><option value="18">18</option><option value="17">17</option><option value="16">16</option><option value="15">15</option><option value="14">14</option><option value="13">13</option><option value="12">12</option></select></div>`,
`<div id="divShowSearchButton" class="pie-toggle-row" title="${I18n.t('pie.prefs.ShowAddressSearchTitle')}"><span class="pie-toggle-label">${I18n.t('pie.prefs.ShowAddressSearch')}</span><label class="pie-toggle-switch"><input type="checkbox" id="_cbShowSearchButton" class="pieSettingsCheckbox"><span class="pie-slider"></span></label></div>`,
`<div id="divShowCopyPlaceButton" class="pie-toggle-row" title="${I18n.t('pie.prefs.ShowCopyPlaceButtonTitle')}"><span class="pie-toggle-label">${I18n.t('pie.prefs.ShowCopyPlaceButton')}</span><label class="pie-toggle-switch"><input type="checkbox" id="_cbShowCopyPlaceButton" class="pieSettingsCheckbox"><span class="pie-slider"></span></label></div>`,
`<div id="divShowExternalProviderTooltip" class="pie-toggle-row" title="${I18n.t('pie.prefs.ShowGPIDTooltipTitle')}"><span class="pie-toggle-label">${I18n.t('pie.prefs.ShowGPIDTooltip')}</span><label class="pie-toggle-switch"><input type="checkbox" id="_cbShowExternalProviderTooltip" class="pieSettingsCheckbox"><span class="pie-slider"></span></label></div>`,
`<div id="divClearDescription" class="pie-toggle-row" title="${I18n.t('pie.prefs.ClearDescriptionTitle')}"><span class="pie-toggle-label">${I18n.t('pie.prefs.ClearDescription')}</span><label class="pie-toggle-switch"><input type="checkbox" id="_cbClearDescription" class="pieSettingsCheckbox"><span class="pie-slider"></span></label></div>`,
`<div id="divGeometryMods" class="pie-toggle-row" title="${I18n.t('pie.prefs.GeometryModsTitle')}"><span class="pie-toggle-label">${I18n.t('pie.prefs.GeometryMods')}</span><label class="pie-toggle-switch"><input type="checkbox" id="_cbGeometryMods" class="pieSettingsCheckbox"><span class="pie-slider"></span></label></div>`,
`<div id="divSimplifyFactor" class="pie-toggle-row pie-sub-row" title="${I18n.t('pie.prefs.SimplifyFactorTitle')}"><span class="pie-toggle-label">${I18n.t('pie.prefs.SimplifyFactor')}</span><input type="number" min="0" max="10" step=".5" class="pie-select" style="width:60px;" id="pieSimplifyFactor"></div>`,
`</div></div>`,
// --- Section 3: New Places ---
`<div class="pie-section" id="fieldNewPlaces">`,
`<div class="pie-section-header"><i class="fa fa-plus-circle"></i><span class="pie-section-title">${I18n.t('pie.prefs.NewPlaces')}</span><i class="fa fa-chevron-down pie-chevron"></i></div>`,
`<div class="pie-section-body">`,
`<div id="divEditRPPAfterCreated" class="pie-toggle-row" title="${I18n.t('pie.prefs.EditRPPAfterCreateTitle')}"><span class="pie-toggle-label">${I18n.t('pie.prefs.EditRPPAfterCreate')}</span><label class="pie-toggle-switch"><input type="checkbox" id="_cbEditRPPAfterCreated" class="pieSettingsCheckbox"><span class="pie-slider"></span></label></div>`,
`<div id="divUseStreetFromClosestSeg" class="pie-toggle-row" title="${I18n.t('pie.prefs.UseStreetFromClosestSegmentTitle')}"><span class="pie-toggle-label">${I18n.t('pie.prefs.UseStreetFromClosestSegment')}</span><label class="pie-toggle-switch"><input type="checkbox" id="_cbUseStreetFromClosestSeg" class="pieSettingsCheckbox"><span class="pie-slider"></span></label></div>`,
`<div id="divUseCityFromClosestSeg" class="pie-toggle-row" title="${I18n.t('pie.prefs.UseCityFromClosestSegmentTitle')}"><span class="pie-toggle-label">${I18n.t('pie.prefs.UseCityFromClosestSegment')}</span><label class="pie-toggle-switch"><input type="checkbox" id="_cbUseCityFromClosestSeg" class="pieSettingsCheckbox"><span class="pie-slider"></span></label></div>`,
`<div id="divUseAltCity" class="pie-toggle-row pie-sub-row" title="${I18n.t('pie.prefs.ClosestSegmentAltCityTitle')}"><span class="pie-toggle-label">${I18n.t('pie.prefs.ClosestSegmentAltCity')}</span><label class="pie-toggle-switch"><input type="checkbox" id="_cbUseAltCity" class="pieSettingsCheckbox"><span class="pie-slider"></span></label></div>`,
`<div id="divSkipPLR" class="pie-toggle-row" title="${I18n.t('pie.prefs.ClosestSegmentIgnorePLRUnnamedPRTitle')}"><span class="pie-toggle-label">${I18n.t('pie.prefs.ClosestSegmentIgnorePLRUnnamedPR')}</span><label class="pie-toggle-switch"><input type="checkbox" id="_cbSkipPLR" class="pieSettingsCheckbox"><span class="pie-slider"></span></label></div>`,
`<div id="divDefaultLockLevel" class="pie-toggle-row" title="${I18n.t('pie.prefs.LockLevelTitle')}"><span class="pie-toggle-label">${I18n.t('pie.prefs.LockLevel')}</span><select id="pieDefaultLockLevel" class="pie-select">${buildLockLevelsList()}</select></div>`,
`</div></div>`,
// --- Section 4: Map Features ---
`<div class="pie-section" id="fieldMapMods">`,
`<div class="pie-section-header"><i class="fa fa-map"></i><span class="pie-section-title">${I18n.t('pie.prefs.MapChanges')}</span><i class="fa fa-chevron-down pie-chevron"></i></div>`,
`<div class="pie-section-body">`,
`<div id="divShowNames" class="pie-toggle-row" title="${I18n.t('pie.prefs.ShowPlaceNames')}"><span class="pie-toggle-label">${I18n.t('pie.prefs.ShowPlaceNames')}</span><label class="pie-toggle-switch"><input type="checkbox" id="_cbShowPlaceNames" class="pieSettingsCheckbox"><span class="pie-slider"></span></label></div>`,
`<div id="divShowNamesPoint" class="pie-toggle-row pie-sub-row" title="${I18n.t('pie.prefs.ShowPointNamesTitle')}"><span class="pie-toggle-label">${I18n.t('pie.prefs.ShowPointNames')}</span><label class="pie-toggle-switch"><input type="checkbox" id="_cbShowPlaceNamesPoint" class="pieSettingsCheckbox" disabled><span class="pie-slider"></span></label></div>`,
`<div id="divShowNamesArea" class="pie-toggle-row pie-sub-row" title="${I18n.t('pie.prefs.ShowAreaNamesTitle')}"><span class="pie-toggle-label">${I18n.t('pie.prefs.ShowAreaNames')}</span><label class="pie-toggle-switch"><input type="checkbox" id="_cbShowPlaceNamesArea" class="pieSettingsCheckbox" disabled><span class="pie-slider"></span></label></div>`,
`<div id="divShowNamesPLA" class="pie-toggle-row pie-sub-row" title="${I18n.t('pie.prefs.ShowPLANameTitle')}"><span class="pie-toggle-label">${I18n.t('pie.prefs.ShowPLAName')}</span><label class="pie-toggle-switch"><input type="checkbox" id="_cbShowPlaceNamesPLA" class="pieSettingsCheckbox" disabled><span class="pie-slider"></span></label></div>`,
`<div id="divShowNamesLock" class="pie-toggle-row pie-sub-row" title="${I18n.t('pie.prefs.ShowLockLevelTitle')}"><span class="pie-toggle-label">${I18n.t('pie.prefs.ShowLockLevel')}</span><label class="pie-toggle-switch"><input type="checkbox" id="_cbShowPlaceNamesLock" class="pieSettingsCheckbox" disabled><span class="pie-slider"></span></label></div>`,
`<div id="divhidePlaceNamesWhenPlacesHidden" class="pie-toggle-row pie-sub-row" title="${I18n.t('pie.prefs.hidePlaceNamesWhenPlacesHiddenTitle')}"><span class="pie-toggle-label">${I18n.t('pie.prefs.hidePlaceNamesWhenPlacesHidden')}</span><label class="pie-toggle-switch"><input type="checkbox" id="_cbhidePlaceNamesWhenPlacesHidden" class="pieSettingsCheckbox" disabled><span class="pie-slider"></span></label></div>`,
// Font customization sub-card
`<div id="divPlaceNamesFontCustomization" class="pie-font-settings">`,
`<div class="pie-font-row"><span>${I18n.t('pie.prefs.FontSize')}</span><span><input type="text" size="2" id="piePlaceNameFontSize" class="pie-select"> px</span></div>`,
`<div class="pie-font-row"><span>${I18n.t('pie.prefs.FontColor')}</span><input type="color" id="colorPickerFont" style="width:30px;height:20px;padding:1px;cursor:pointer;border:1px solid #ccc;border-radius:3px;"></div>`,
`<div class="pie-font-row"><span>${I18n.t('pie.prefs.Bold')}</span><label class="pie-toggle-switch"><input type="checkbox" id="_cbPlaceNameFontBold" class="pieSettingsCheckbox"><span class="pie-slider"></span></label></div>`,
`<div class="pie-font-row"><span>${I18n.t('pie.prefs.FontOutlineColor')}</span><input type="color" id="colorPickerFontOutline" style="width:30px;height:20px;padding:1px;cursor:pointer;border:1px solid #ccc;border-radius:3px;"></div>`,
`<div class="pie-font-row"><span>${I18n.t('pie.prefs.FontOutlineWidth')}</span><span><input type="text" size="2" id="piePlaceNameFontOutlineWidth" class="pie-select"> px</span></div>`,
`<div class="pie-font-reset"><button id="_btnResetFontDefaults"><i class="fa fa-undo"></i> Reset to defaults</button></div>`,
`</div>`,
`<div id="divShowNavPointClosestSegmentOnHover" class="pie-toggle-row"><span class="pie-toggle-label">${I18n.t('pie.prefs.ShowNavPointClosestSegmentOnHover')}</span><label class="pie-toggle-switch"><input type="checkbox" id="_cbShowNavPointClosestSegmentOnHover" class="pieSettingsCheckbox"><span class="pie-slider"></span></label></div>`,
`<div id="divShowClosestSegmentSelected" class="pie-toggle-row"><span class="pie-toggle-label">${I18n.t('pie.prefs.ShowClosestSegmentSelected')}</span><label class="pie-toggle-switch"><input type="checkbox" id="_cbShowClosestSegmentSelected" class="pieSettingsCheckbox"><span class="pie-slider"></span></label></div>`,
`<div id="divEnableGLE" class="pie-toggle-row" title="${I18n.t('pie.prefs.EnableGLETitle')}"><span class="pie-toggle-label">${I18n.t('pie.prefs.EnableGLE')}</span><label class="pie-toggle-switch"><input type="checkbox" id="_cbEnableGLE" class="pieSettingsCheckbox"><span class="pie-slider"></span></label></div>`,
`<div id="divGLEShowTempClosed" class="pie-toggle-row pie-sub-row"><span class="pie-toggle-label">${I18n.t('pie.prefs.GLEShowTempClosed')}</span><label class="pie-toggle-switch"><input type="checkbox" id="_cbGLEShowTempClosed" class="pieSettingsCheckbox" disabled><span class="pie-slider"></span></label></div>`,
`<div id="divOpenPUR" class="pie-toggle-row" title="${I18n.t('pie.prefs.OpenPURTitle')}"><span class="pie-toggle-label">${I18n.t('pie.prefs.OpenPUR')}</span><label class="pie-toggle-switch"><input type="checkbox" id="_cbOpenPUR" class="pieSettingsCheckbox"><span class="pie-slider"></span></label></div>`,
`<div id="divEnablePhotoViewer" class="pie-toggle-row" title="${I18n.t('pie.prefs.PhotoViewerTitle')}"><span class="pie-toggle-label">${I18n.t('pie.prefs.PhotoViewer')}</span><label class="pie-toggle-switch"><input type="checkbox" id="_cbEnablePhotoViewer" class="pieSettingsCheckbox"><span class="pie-slider"></span></label></div>`,
`<div id="divEnlargeGeoHandles" class="pie-toggle-row" title="${I18n.t('pie.prefs.EnlargeGeoHandlesTitle')}"><span class="pie-toggle-label">${I18n.t('pie.prefs.EnlargeGeoHandles')}</span><label class="pie-toggle-switch"><input type="checkbox" id="_cbEnlargeGeoHandles" class="pieSettingsCheckbox"><span class="pie-slider"></span></label></div>`,
`</div></div>`,
// --- Section 5: Quick-Create Shortcuts ---
`<div class="pie-section" id="divPlaceMenuCustomization">`,
`<div class="pie-section-header"><i class="fa fa-th-list"></i><span class="pie-section-title">${I18n.t('pie.prefs.PlaceMenuCustomization')}</span><i class="fa fa-chevron-down pie-chevron"></i></div>`,
`<div class="pie-section-body">`,
`<div class="pie-section-subtitle">${I18n.t('pie.prefs.PlaceMenuCustomizationSubtitle')}</div>`,
`<div class="pie-quick-create-list">`,
buildItemOption(1),
buildItemOption(2),
buildItemOption(3),
buildItemOption(4),
buildItemOption(5),
buildItemOption(6),
buildItemOption(7),
buildItemOption(8),
buildItemOption(9),
buildItemOption(10),
buildItemOption(11),
buildItemOption(12),
`</div>`,
`</div></div>`,
].join(''),
);
//Load settings
await loadSettings();
sdk.Map.addLayer({ layerName: 'PIEPlaceNameLayer', displayInLayerSwitcher: false, uniqueName: '__PIEPlaceNameLayer', styleRules: _sdkStyleRules, styleContext: _sdkStyleContext });
sdk.Map.setLayerVisibility({ layerName: 'PIEPlaceNameLayer', visibility: true });
sdk.Map.addLayer({ layerName: _PIE_SHOW_STOP_POINTS_LAYER, displayInLayerSwitcher: false, uniqueName: '__PIEShowStopPointsLayer', styleRules: _sdkStyleRules, styleContext: _sdkStyleContext });
sdk.Map.addLayer({ layerName: _PIE_CLOSEST_SEGMENT_LAYER, displayInLayerSwitcher: false, uniqueName: '__PIEClosesetSegmentLayer', styleRules: _sdkStyleRules, styleContext: _sdkStyleContext });
//***** Set Google Link Enhancer translations *****
GLE.strings.permClosedPlace = I18n.t('pie.GLE.closedPlace');
GLE.strings.tempClosedPlace = I18n.t('pie.GLE.tempClosedPlace');
GLE.strings.multiLinked = I18n.t('pie.GLE.multiLinked');
GLE.strings.linkedToThisPlace = I18n.t('pie.GLE.linkedToThisPlace');
GLE.strings.linkedNearby = I18n.t('pie.GLE.linkedNearby');
GLE.strings.linkedToXPlaces = I18n.t('pie.GLE.linkedToXPlaces');
GLE.strings.badLink = I18n.t('pie.GLE.badLink');
GLE.strings.tooFar = I18n.t('pie.GLE.tooFar');
injectCss();
const { tabLabel, tabPane } = await sdk.Sidebar.registerScriptTab();
tabLabel.innerText = 'PIE';
tabPane.classList.add('wme-pie-panel');
tabPane.innerHTML = $section.html();
init2();
}
function init2() {
/**
* NavPointManager - Caches venue navigation points to avoid expensive recalculation
*
* This manager significantly improves performance when moving venues by caching the
* "on-segment" navigation points and only invalidating when venue/segment data changes.
* Performance improvement: ~500% faster when moving venues in the Waze Editor.
*
* @class NavPointManager
* @param {Object} wmeSdk - The WME SDK instance for accessing data models and events
*/
navPointManager = new (class NavPointManager {
/**
* Initialize NavPointManager with SDK reference and empty caches
* @param {Object} wmeSdk - The WME SDK instance
*/
constructor(wmeSdk) {
this.sdk = wmeSdk;
/** @type {Map<string, Object>} Map of venue ID → cached navigation point */
this.navPoints = new Map();
/** @type {Set<Object>} Set of tracked event handlers for cleanup */
this.trackedEvents = new Set();
}
/**
* Generate a unique key for storing navigation points for a venue. Currently uses the venue ID, but can be extended to include other factors if needed.
* @param {Object} venue - SDK Venue object
* @returns {string} Unique key for the venue's navigation point
*/
getNavPointKey(venue) {
return String(venue.id);
}
/**
* Register and track a data model event handler for later cleanup
* @private
* @param {string} eventName - WME SDK event name (e.g., 'wme-data-model-objects-changed')
* @param {Function} handler - Event handler callback function
*/
_applyEventTracking(eventName, handler) {
const eventRecord = { eventName, eventHandler: handler };
this.sdk.Events.on(eventRecord);
this.trackedEvents.add(eventRecord);
}
/**
* Unregister all tracked event handlers and clear tracking set
* Called by stopTrackingChanges() to clean up event listeners
* @private
*/
_revertAllTrackedEvents() {
for (const { eventName, eventHandler } of this.trackedEvents) {
this.sdk.Events.off({ eventName, eventHandler });
}
this.trackedEvents.clear();
}
/**
* Start listening for venue and segment data model changes
* Registers handlers to invalidate cached navigation points when data changes
* Prevents duplicate handlers by calling stopTrackingChanges first
* @public
*/
startTrackingChanges() {
this.stopTrackingChanges(); // ensure no duplicate handlers
const invalidationHandler = ({ dataModelName }) => {
if (dataModelName !== 'venues' && dataModelName !== 'segments')
return;
this._invalidateAllNavPoints();
};
this._applyEventTracking('wme-data-model-object-state-deleted', invalidationHandler);
this._applyEventTracking('wme-data-model-objects-added', invalidationHandler);
this._applyEventTracking('wme-data-model-objects-changed', invalidationHandler);
this._applyEventTracking('wme-data-model-objects-removed', invalidationHandler);
this._applyEventTracking('wme-data-model-objects-saved', invalidationHandler);
// The following SDK calls won't be reverted by stopTrackingChanges, since they are shared SDK events that may be used by other features
this.sdk.Events.trackDataModelEvents({ dataModelName: 'venues' });
this.sdk.Events.trackDataModelEvents({ dataModelName: 'segments' });
}
/**
* Stop listening for data model changes and clear the navigation point cache
* Unregisters all event handlers added by startTrackingChanges()
* @public
*/
stopTrackingChanges() {
this._revertAllTrackedEvents();
this._invalidateAllNavPoints();
}
/**
* Invalidate all cached navigation points, forcing recalculation on next access.
*/
_invalidateAllNavPoints() {
this.navPoints.clear();
}
/**
* Get the raw navigation point for a venue, which is either the explicitly defined navigation point, the centroid of the polygon geometry, or the point geometry itself.
* @param {Object} venue
* @returns {Object|null} WGS84 GeoJSON Point geometry or null if it cannot be determined
*/
getVenueRawNavPoint(venue) {
if (!venue || !venue.id || !venue.geometry) return null;
if (venue.navigationPoints && venue.navigationPoints.length > 0) return venue.navigationPoints[0].point;
if (venue.geometry.type === 'Polygon') return turf.centroid(venue.geometry).geometry;
return venue.geometry; // assume Point
}
/**
* Calculate the "on-segment" navigation point for a venue by finding the closest point on the nearest road segment to the venue's raw nav point.
* Caches the result in this.navPoints for future retrieval.
* @param {Object} venue - SDK Venue object
* @return {Object|null} WGS84 GeoJSON Point geometry of the on-segment nav point, or null if it cannot be calculated
*/
calculateVenueOnSegmentNavPoint(venue) {
if (!venue || !venue.id || !venue.geometry) return null;
const navPoint = this.getVenueRawNavPoint(venue);
const closestSeg = findClosestSegmentTurf(navPoint, false, false, this.sdk);
if (!closestSeg || !closestSeg.closestPoint) return null;
this.navPoints.set(this.getNavPointKey(venue), closestSeg.closestPoint);
return closestSeg.closestPoint;
}
/**
* Get the navigation point for a venue, calculating and caching it if not already available.
* @param {Object} venue - SDK Venue object
* @returns {Object|null} WGS84 GeoJSON Point geometry or null if it cannot be determined
*/
getVenueOnSegmentNavPoint(venue) {
if (!venue || !venue.id) return null;
const venueKey = this.getNavPointKey(venue);
if (!this.navPoints.has(venueKey)) {
return this.calculateVenueOnSegmentNavPoint(venue);
}
return this.navPoints.get(venueKey);
}
})(sdk);
navPointManager.startTrackingChanges();
// Collapsible section headers — state persisted in localStorage
const PIE_LS_SECTIONS = 'WME_PIE_sectionStates';
// Sections collapsed by default (id → true means collapsed)
const PIE_SECTION_DEFAULTS = { divPlaceMenuCustomization: true };
function saveSectionStates() {
const states = {};
$('.wme-pie-panel .pie-section[id]').each(function () {
states[this.id] = $(this).hasClass('pie-collapsed');
});
try { localStorage.setItem(PIE_LS_SECTIONS, JSON.stringify(states)); } catch (e) {}
}
function restoreSectionStates() {
let stored = {};
try { stored = JSON.parse(localStorage.getItem(PIE_LS_SECTIONS)) || {}; } catch (e) {}
$('.wme-pie-panel .pie-section[id]').each(function () {
const id = this.id;
const collapsed = Object.prototype.hasOwnProperty.call(stored, id)
? stored[id]
: PIE_SECTION_DEFAULTS[id] === true;
$(this).toggleClass('pie-collapsed', collapsed);
});
}
$(document).on('click', '.wme-pie-panel .pie-section-header', function () {
$(this).closest('.pie-section').toggleClass('pie-collapsed');
saveSectionStates();
});
restoreSectionStates();
sdk.Events.trackDataModelEvents({ dataModelName: 'venues' });
sdk.Events.trackLayerEvents({ layerName: 'venues' });
// Place filter + hide-area-places — rules installed once, controlled by module flags + redrawLayer
sdk.Map.addStyleRuleToLayer({
layerName: 'venues',
styleRules: [
{
// Hide-area-places rule: hides polygon venues when pieHideAreaEnabled is true
predicate: (properties) => {
if (!pieHideAreaEnabled) return false;
if (!properties.id) return false;
const venue = sdk.DataModel.Venues.getById({ venueId: String(properties.id) });
return venue?.geometry.type === 'Polygon';
},
style: { display: 'none' },
},
{
// Place-name filter rule: hides venues matching/not-matching the filter regex
predicate: (properties) => {
if (!pieFilterRegex) return false;
if (!properties.id) return false;
const venue = sdk.DataModel.Venues.getById({ venueId: String(properties.id) });
if (!venue) return false;
const matches = pieFilterRegex.test(venue.name || '');
return pieFilterHideMode ? matches : !matches;
},
style: { display: 'none' },
},
],
});
$('#cboPlaceNameFontWeight').select2({ placeholder: 'No font weight set', allowClear: true });
$('#divPlaceNamesFontCustomization .select2-choices').css('font-size', '10px');
initColorPicker();
//Set up event handlers
$('#_cbShowAreaPlaceSize').change(async function () {
if (this.checked) {
attachPlaceSizeHandlers();
updatePlaceSizeDisplay();
$('#_cbShowAreaPlaceSizeImperial')[0].disabled = false;
$('#_cbShowAreaPlaceSizeMetric')[0].disabled = false;
} else {
removePlaceSizeHandlers();
$(WME_DOM.venueAreaSize).remove();
$('#_cbShowAreaPlaceSizeImperial')[0].disabled = true;
$('#_cbShowAreaPlaceSizeMetric')[0].disabled = true;
}
});
$('#_cbShowPlaceNames').change(async function () {
sdk.Map.setLayerVisibility({ layerName: 'PIEPlaceNameLayer', visibility: this.checked });
$('#_cbShowPlaceNamesPoint')[0].disabled = !this.checked;
$('#_cbShowPlaceNamesArea')[0].disabled = !this.checked;
$('#_cbShowPlaceNamesPLA')[0].disabled = !this.checked;
$('#_cbShowPlaceNamesLock')[0].disabled = !this.checked;
$('#_cbhidePlaceNamesWhenPlacesHidden')[0].disabled = !this.checked;
DisplayPlaceNames();
});
$('[id^="_cbShowPlaceNames"]').change(async function () {
DisplayPlaceNames();
});
$('#_cbhidePlaceNamesWhenPlacesHidden').change(async function () {
DisplayPlaceNames();
});
$('#_cbShowExternalProviderTooltip').change(function () {
if (this.checked) registerEvents(ShowExternalProviderTooltip);
else unregisterEvents(ShowExternalProviderTooltip);
});
$('#_cbShowPlaceLocatorCrosshair').change(async function () {
if (this.checked) registerEvents(ShowPlaceLocatorCrosshair);
else unregisterEvents(ShowPlaceLocatorCrosshair);
});
$('#_cbShowCopyPlaceButton').change(async function () {
if (this.checked) registerEvents(ShowCopyPlaceButton);
else unregisterEvents(ShowCopyPlaceButton);
});
$('#_cbShowSearchButton').change(async function () {
if (this.checked) registerEvents(ShowSearchButton);
else unregisterEvents(ShowSearchButton);
});
$('#_cbClearDescription').change(async function () {
if (this.checked) registerEvents(ShowClearDescription);
else unregisterEvents(ShowClearDescription);
});
// Create wrapper handlers that track enable/disable state
const navPointHandlers = {};
const closestSegmentHandlers = {};
const purHandlers = {};
$('#_cbShowNavPointClosestSegmentOnHover').change(async function () {
if (this.checked) {
navPointHandlers.mouseenter = ({ featureId, layerName }) => {
if (layerName !== 'venues') return;
const venue = sdk.DataModel.Venues.getById({ venueId: featureId });
if (!venue) return;
sdk.Map.removeAllFeaturesFromLayer({ layerName: _PIE_SHOW_STOP_POINTS_LAYER });
drawNavPointClosestSegmentLines(venue);
};
navPointHandlers.mouseleave = ({ layerName }) => {
if (layerName !== 'venues') return;
sdk.Map.removeAllFeaturesFromLayer({ layerName: _PIE_SHOW_STOP_POINTS_LAYER });
};
sdk.Events.on({ eventName: 'wme-layer-feature-mouse-enter', eventHandler: navPointHandlers.mouseenter });
sdk.Events.on({ eventName: 'wme-layer-feature-mouse-leave', eventHandler: navPointHandlers.mouseleave });
} else {
if (navPointHandlers.mouseenter) {
sdk.Events.off({ eventName: 'wme-layer-feature-mouse-enter', eventHandler: navPointHandlers.mouseenter });
delete navPointHandlers.mouseenter;
}
if (navPointHandlers.mouseleave) {
sdk.Events.off({ eventName: 'wme-layer-feature-mouse-leave', eventHandler: navPointHandlers.mouseleave });
delete navPointHandlers.mouseleave;
}
sdk.Map.removeAllFeaturesFromLayer({ layerName: _PIE_SHOW_STOP_POINTS_LAYER });
}
});
$('#_cbShowClosestSegmentSelected').change(async function () {
if (this.checked) {
closestSegmentHandlers.undo = () => checkSelection();
closestSegmentHandlers.afterEdit = () => checkSelection();
closestSegmentHandlers.selection = () => checkSelection();
sdk.Events.on({
eventName: 'wme-after-undo',
eventHandler: closestSegmentHandlers.undo,
});
sdk.Events.on({
eventName: 'wme-after-edit',
eventHandler: closestSegmentHandlers.afterEdit,
});
sdk.Events.on({
eventName: 'wme-selection-changed',
eventHandler: closestSegmentHandlers.selection,
});
sdk.Events.on({
eventName: 'wme-data-model-objects-changed',
eventHandler: ({ dataModelName, objectIds }) => {
if (dataModelName === 'venues') ObjectsChanged();
},
});
} else {
if (closestSegmentHandlers.undo) {
sdk.Events.off({
eventName: 'wme-after-undo',
eventHandler: closestSegmentHandlers.undo,
});
}
if (closestSegmentHandlers.afterEdit) {
sdk.Events.off({
eventName: 'wme-after-edit',
eventHandler: closestSegmentHandlers.afterEdit,
});
}
if (closestSegmentHandlers.selection) {
sdk.Events.off({
eventName: 'wme-selection-changed',
eventHandler: closestSegmentHandlers.selection,
});
}
// Can't easily unregister data model event, so we filter in handler above
delete closestSegmentHandlers.undo;
delete closestSegmentHandlers.afterEdit;
delete closestSegmentHandlers.selection;
}
});
$('#_cbOpenPUR').change(async function () {
if (this.checked) {
purHandlers.selection = () => openPUR();
sdk.Events.on({
eventName: 'wme-selection-changed',
eventHandler: purHandlers.selection,
});
} else if (purHandlers.selection) {
sdk.Events.off({
eventName: 'wme-selection-changed',
eventHandler: purHandlers.selection,
});
delete purHandlers.selection;
}
});
$('#_cbEnableGLE').change(async function () {
if (this.checked) GLE.enable();
else GLE.disable();
$('#_cbGLEShowTempClosed')[0].disabled = !this.checked;
});
$('#_cbGLEShowTempClosed').change(async function () {
const checked = this.checked;
// Keep the "PIE - Highlight closed Places" Map Layers entry in sync.
// The SDK has no setter for custom layer checkboxes, so remove+re-add is the workaround.
//sdk.LayerSwitcher.removeLayerCheckbox({ name: layerNames.closedPlaces });
//sdk.LayerSwitcher.addLayerCheckbox({ name: layerNames.closedPlaces, isChecked: checked });
sdk.LayerSwitcher.setLayerCheckboxChecked({name: layerNames.closedPlaces, isChecked: checked});
GLE.showTempClosedPOIs = checked;
});
// Keep the PIE "Highlight closed Places" checkbox in sync when the user
// toggles the "PIE - Highlight closed Places" entry in WME's Map Layers panel directly.
sdk.Events.on({
eventName: 'wme-layer-checkbox-toggled',
eventHandler: (payload) => {
if (payload.name === layerNames.closedPlaces) {
setChecked('_cbGLEShowTempClosed', payload.checked); // .prop() only — no change event
settings.GLEShowTempClosed = payload.checked;
GLE.showTempClosedPOIs = payload.checked;
}
},
});
$('#_cbEnablePhotoViewer').change(async function () {
if (this.checked) {
$('#launchDiv').addClass('pv-visible');
} else {
hide_visio();
$('#launchDiv').removeClass('pv-visible');
}
});
$('#_cbEnlargeGeoHandles').change(async function () {
if (this.checked) changeGeoHandleStyle(8);
else changeGeoHandleStyle(6);
});
$('#_cbGeometryMods').change(async function () {
if (this.checked) {
registerEvents(InsertGeometryMods);
InsertGeometryMods();
} else {
unregisterEvents(InsertGeometryMods);
$('#pieGeometryMods').remove();
}
});
//Load settings to interface
setChecked('_cbShowAreaPlaceSize', settings.ShowAreaPlaceSize);
setChecked('_cbShowAreaPlaceSizeImperial', settings.ShowAreaPlaceSizeImperial);
setChecked('_cbShowAreaPlaceSizeMetric', settings.ShowAreaPlaceSizeMetric);
setChecked('_cbShowLockButtonsRPP', settings.ShowLockButtonsRPP);
setChecked('_cbEditRPPAfterCreated', settings.EditRPPAfterCreated);
setChecked('_cbUseStreetFromClosestSeg', settings.UseStreetFromClosestSeg);
setChecked('_cbUseCityFromClosestSeg', settings.UseCityFromClosestSeg);
setChecked('_cbShowPlaceLocatorCrosshair', settings.ShowPlaceLocatorCrosshair);
setChecked('_cbShowCopyPlaceButton', settings.ShowCopyPlaceButton);
setChecked('_cbShowExternalProviderTooltip', settings.ShowExternalProviderTooltip);
setChecked('_cbUseAltCity', settings.UseAltCity);
setChecked('_cbShowSearchButton', settings.ShowSearchButton);
setChecked('_cbSkipPLR', settings.SkipPLR);
setChecked('_cbShowPlaceNames', settings.ShowPlaceNames);
setChecked('_cbShowPlaceNamesPoint', settings.ShowPlaceNamesPoint);
setChecked('_cbShowPlaceNamesArea', settings.ShowPlaceNamesArea);
setChecked('_cbShowPlaceNamesPLA', settings.ShowPlaceNamesPLA);
setChecked('_cbShowPlaceNamesLock', settings.ShowPlaceNamesLock);
setChecked('_cbClearDescription', settings.ClearDescription);