Colorisation pour afficher les erreurs
// ==UserScript==
// @name WME Color Errors
// @version 2025.12.12.01
// @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAAIGNIUk0AAHolAACAgwAA+f8AAIDpAAB1MAAA6mAAADqYAAAXb5JfxUYAAALuSURBVHja7Jots6swEIb7x6qiUFVVUVEoVBSqKioqU8EfqKpCRaE6FShMo5gjUCiOYebOzTXnvaKlhR44LbS9vcyQmVWdbt5nd7P5GGbr/eFjvT98jtQ+Zuv9oVzvDxiplbMTyVgBPieACWACmADeD/Bn7ABfE8D77PfYAfBUgFCt4DEKZz7H/Js5oMzDSoXPBPh6GCBSHAvSJviGkQW4it4HECmvI9IncygYY2ALcgPGgTccpD9AkQRwf4g4cQPEWYnzsDHkXRlxESTFawFixUDOkxIwIeEvLiKojFFclKPIDOJwhWWX6AWHWF35VPFrAEJeKwXHw9aUsIm8TO6GyE7S80iA3bUuCGRiUZotPKeWRR4+F0DXxBMeIrNHoUaRhhAAKCJei+htI8ocnZUGG7c+j34OQF08FTvk5xLJELJKiEICAEixWfbsRuySOSDHTtA+ED8D5Jo3nF3EA4CBqkR4p98KDd63nc4VTMNv3gga1/lwALeahCoYi6tRA5hzhFmJPFr1Kp92AADWQNHqd3cYQORX7Y1D52gZObQ3YAO7Nu86s5X7Wjb9qD/AOboihkX7SDfLhwGWm7TDu0UsLlnqDbATVR1SKGO7CEAfAqDo0m+NOvsmYjdsDXByq4wsYkkGAxDZkd1cN+YevIgbPb11IV8vuB52lz8CHhWP7QNG1foyC5CULZMWMWQfCCoRFy1+ygQBq+07yjxnJ65vLnMqELWVk82gBbvRRh24MuroOhFELQi0u+6HnYViSRuLT+gUbclAmSEOFVYeOx6nGQPzJbY6Qdb+B6RaNJoBlfFrTqNZ6DfuAIQJ6LTE0FGmGoKRRob8MHv9haY56RxkwaG0QV7am6JtkSHRCvzqokOY+Lc3slR3HJkdCuatoIIAwdmOJUWdtosMg9Dp++7EpiWad+0Bp6z9V68S6/0BgfTBvr1MOKCMwZfBs59Vfs3G/CZUvczZ6XV6ApgAJoAJYAIYM8DoP/YY9ec2fwcAaebQXj6i79wAAAAASUVORK5CYII=
// @description Colorisation pour afficher les erreurs
// @match https://*.waze.com/*/editor*
// @exclude https://*.waze.com/*/user*
// @namespace https://greatest.deepsurf.us/fr/scripts/21186-wme-color-errors
// @author Sebiseba / MatthieuF44 / Zbouibe
// @copyright Sebiseba 2014-2025
// @license GNU GPL v2
// @grant none
// ==/UserScript==
(function () {
"use strict";
// ***********************
// ** VARIABLES GLOBALE **
// ***********************
let wmeSDK, wmeUserRank;
let cePref = {}, ceErrorsFound = [], ls;
const debug = true;
const frSegLockDB = { str_lvl: 0, pri_lvl: 2, min_lvl: 3, maj_lvl: 4, rmp_lvl: 4, fwy_lvl: 4, rwy_lvl: 4, nar_lvl: 0 };
const colorInfo = "#ffcc00", colorWarn = "#ff7700", colorError = "#ff0000";
// frenchRules
const streetNameSeg = "^(^Le |^La |^Les |Grande |Allée |[ ]?Avenue[]?|Boulevard |Chemin |Cité |Clos |Côte |Cour[s]? |Descente |Domaine |Hameau |Impasse |Levée |Lotissement |Mail |Montée |Parc |Parvis |Passage |Place |Placette |Pont |Promenade |Quai |Résidence[s]? |Route |[ ]?Rue[ ]?|Ruelle |Sente |Sentier |Square |Terrasse |Traverse |Venelle |Villa |Voie )";
const parkNameSeg = "^(Aire |Place |Square )";
const excepNameSeg = "(Périphérique |Rocade |Duplex |Tunnel |Pont )";
const privNameSeg = "^(Allée |Avenue |Boulevard |Chemin |Clos |Côte |Cours |Faubourg |Hameau |Impasse |Lotissement |Mail |Parvis |Passage |Port |Porte |Promenade |Quai |Route |Rue |Ruelle |Sente |Sentier |Terrasse |Voie )";
const parkNamePoi = "(Parking[s]?|Parc-Relais|Placette|Aire|Arrêt|Emplacement|Place)";
const religiousPoi = "(Abbatiale|Abbaye|Basilique|Calvaire|Carmel|Cathédrale|Chapelle|Cloître|Collégiale|Conjuratoire|Couvent|Crypte|Dôme|Église|Grande Mosquée|Mandir|Maison Diocésaine|Monastère|Mosquée|Notre-Dame|Oratoire|Ordre|Pagode|Paroisse|Presbytère|Prieuré|Salle du Royaume|Sanctuaire|Stupa|Synagogue|Temple)";
const busPoi = "(Bus[ ][-][ ]|Gare Routière)";
const tramPoi = "(Tramway[ ][-][ ]|Métro[ ][-][ ])";
const possibleTransPoi = "(Tram$|Métro$|Arrêt$|Gare$|Station$|Tram |Métro |Arrêt |Gare |Station )";
// worldRules
const stationsPoi = "(CAR_WASH|CHARGING_STATION|FACTORY_INDUSTRIAL|GAS_STATION|JUNCTION_INTERCHANGE|PARKING_LOT|SEAPORT_MARINA_HARBOR|SKI_AREA|SUPERMARKET_GROCERY|TAXI_STATION|TRANSPORTATION|TRASH_AND_RECYCLING_FACILITIES)";
const landmarkPoi = "(RIVER_STREAM|CANAL|SEA_LAKE_POOL|SWAMP_MARSH|ISLAND|FOREST_GROVE|BRIDGE)";
const excepCatPoi = "(RIVER_STREAM|CANAL|SEA_LAKE_POOL|SWAMP_MARSH|ISLAND|FOREST_GROVE|BRIDGE|PARKING_LOT|JUNCTION_INTERCHANGE|CEMETERY|TUNNEL)";
const PoiWithoutCompleteAdress = "(RIVER_STREAM|CANAL|SEA_LAKE_POOL|SWAMP_MARSH|ISLAND|FOREST_GROVE|BRIDGE|PARKING_LOT|JUNCTION_INTERCHANGE|CEMETERY|TUNNEL|STADIUM|SPORTS|CARPOOL|TRANSPORTATION|SKI_AREA|SEAPORT_MARINA_HARBOR|TAXI_STATION|PLAZA)";
const entryPointPoi = "(BRIDGE|CANAL|FOREST_GROVE|ISLAND|JUNCTION_INTERCHANGE|POOL|RIVER_STREAM|SEA_LAKE_POOL|SWAMP_MARSH|TUNNEL)";
const wazeBot = "(admin|avseu|WazeFeed|waze-maint-bot|Waze3rdparty|evcs feed 1|WazeParking1)"
const segment = "ce-segments", nodes = "ce-nodes", places = "ce-places", pref = "ce-pref";
const ceErrorDB = [
// ATTENTION A NE PAS FAIRE DE DOUBLE LIGNE DANS LES COCHES, DANS LE RENDU FINAL WME
{ cat: pref, id: "_myLvl", text: `Afficher seulements les éditables` },
{ cat: pref, id: "_onlyFrErr", text: `Afficher seulements en France` },
// contrôle des segments
{ cat: "ce-global-check-seg", type: "title", text: `Contrôle des segments` },
{ cat: "ce-segBad", id: "_seg_Bad", text: `Mauvais segment` },
{ cat: segment, level: colorError, url: "", id: "_seg_Kartouche", text: `Manque cartouche`, icon: `m38.78 188.55c0-46.6 37.78-84.31 84.33-84.31 68.42 0 110.68-21.03 161.73-60.32 20.64-15.9 49.42-15.9 70.07 0 51.05 39.29 93.31 60.32 161.73 60.32 46.56 0 84.33 37.71 84.33 84.31v140.57c0 93.97-51.03 159.11-106.87 201.7-55.43 42.28-117.89 64.34-148.19 73.36-17.07 5.1-35 5.1-52.06 0-19.51-5.8-90.76-26.85-163.65-85.35-54.03-43.36-90.08-113.24-90.08-191.3 0-78.03-1.34-138.98-1.34-138.98zm404.83 33.66c7.57-7.77 6.37-19.31-2.74-25.77-9.12-6.46-22.65-5.43-30.22 2.34l-90.71 92.86-90.71-92.86c-7.57-7.77-21.1-8.8-30.21-2.34-9.12 6.46-10.32 18-2.75 25.77l95.73 98-95.73 97.99c-7.57 7.77-6.37 19.32 2.75 25.77 9.11 6.46 22.64 5.43 30.21-2.34l90.71-92.85 90.71 92.85c7.57 7.77 21.1 8.8 30.22 2.34 9.11-6.45 10.31-18 2.74-25.77l-95.73-97.99z` },
{ cat: segment, level: colorError, url: "", id: "_seg_RShield", text: `Mauvais préfixe (RoadShield)`, icon: `M128 128C92.7 128 64 156.7 64 192L64 448C64 483.3 92.7 512 128 512L512 512C547.3 512 576 483.3 576 448L576 192C576 156.7 547.3 128 512 128L128 128zM231 231C240.4 221.6 255.6 221.6 264.9 231L319.9 286L374.9 231C384.3 221.6 399.5 221.6 408.8 231C418.1 240.4 418.2 255.6 408.8 264.9L353.8 319.9L408.8 374.9C418.2 384.3 418.2 399.5 408.8 408.8C399.4 418.1 384.2 418.2 374.9 408.8L319.9 353.8L264.9 408.8C255.5 418.2 240.3 418.2 231 408.8C221.7 399.4 221.6 384.2 231 374.9L286 319.9L231 264.9C221.6 255.5 221.6 240.3 231 231z` },
{ cat: segment, level: colorError, url: "", id: "_seg_SegBadRS", text: `RoadShield sur mauvais type`, icon: `M128 128C92.7 128 64 156.7 64 192L64 448C64 483.3 92.7 512 128 512L512 512C547.3 512 576 483.3 576 448L576 192C576 156.7 547.3 128 512 128L128 128zM231 231C240.4 221.6 255.6 221.6 264.9 231L319.9 286L374.9 231C384.3 221.6 399.5 221.6 408.8 231C418.1 240.4 418.2 255.6 408.8 264.9L353.8 319.9L408.8 374.9C418.2 384.3 418.2 399.5 408.8 408.8C399.4 418.1 384.2 418.2 374.9 408.8L319.9 353.8L264.9 408.8C255.5 418.2 240.3 418.2 231 408.8C221.7 399.4 221.6 384.2 231 374.9L286 319.9L231 264.9C221.6 255.5 221.6 240.3 231 231z` },
{ cat: segment, level: colorError, url: "", id: "_seg_SegRSWithoutCity", text: `RoadShield manquant en alt`, icon: `M128 128C92.7 128 64 156.7 64 192L64 448C64 483.3 92.7 512 128 512L512 512C547.3 512 576 483.3 576 448L576 192C576 156.7 547.3 128 512 128L128 128zM231 231C240.4 221.6 255.6 221.6 264.9 231L319.9 286L374.9 231C384.3 221.6 399.5 221.6 408.8 231C418.1 240.4 418.2 255.6 408.8 264.9L353.8 319.9L408.8 374.9C418.2 384.3 418.2 399.5 408.8 408.8C399.4 418.1 384.2 418.2 374.9 408.8L319.9 353.8L264.9 408.8C255.5 418.2 240.3 418.2 231 408.8C221.7 399.4 221.6 384.2 231 374.9L286 319.9L231 264.9C221.6 255.5 221.6 240.3 231 231z` },
{ cat: segment, level: colorError, url: "375613", id: "_seg_Loop", text: `Boucle`, icon: `M320 128C263.2 128 212.1 152.7 176.9 192L224 192C241.7 192 256 206.3 256 224C256 241.7 241.7 256 224 256L96 256C78.3 256 64 241.7 64 224L64 96C64 78.3 78.3 64 96 64C113.7 64 128 78.3 128 96L128 150.7C174.9 97.6 243.5 64 320 64C461.4 64 576 178.6 576 320C576 461.4 461.4 576 320 576C233 576 156.1 532.6 109.9 466.3C99.8 451.8 103.3 431.9 117.8 421.7C132.3 411.5 152.2 415.1 162.4 429.6C197.2 479.4 254.8 511.9 320 511.9C426 511.9 512 425.9 512 319.9C512 213.9 426 128 320 128z` },
{ cat: segment, level: colorError, url: "", id: "_seg_Num_Street", text: `Numéro dans le nom de rue`, icon: `M160 256C160 167.6 231.6 96 320 96C408.4 96 480 167.6 480 256L480 384C480 472.4 408.4 544 320 544C231.6 544 160 472.4 160 384L160 256zM320 160C267 160 224 203 224 256L224 384C224 437 267 480 320 480C373 480 416 437 416 384L416 256C416 203 373 160 320 160z` },
{ cat: segment, level: colorError, url: "", id: "_seg_Bad_City_Alt", text: `Commune déléguée en alt`, icon: `M288 112C288 85.5 309.5 64 336 64L432 64C458.5 64 480 85.5 480 112L480 160L528 160L528 88C528 74.7 538.7 64 552 64C565.3 64 576 74.7 576 88L576 160L592 160C618.5 160 640 181.5 640 208L640 528C640 554.5 618.5 576 592 576L336 576C309.5 576 288 554.5 288 528L288 112zM352 176L352 208C352 216.8 359.2 224 368 224L400 224C408.8 224 416 216.8 416 208L416 176C416 167.2 408.8 160 400 160L368 160C359.2 160 352 167.2 352 176zM368 256C359.2 256 352 263.2 352 272L352 304C352 312.8 359.2 320 368 320L400 320C408.8 320 416 312.8 416 304L416 272C416 263.2 408.8 256 400 256L368 256zM352 368L352 400C352 408.8 359.2 416 368 416L400 416C408.8 416 416 408.8 416 400L416 368C416 359.2 408.8 352 400 352L368 352C359.2 352 352 359.2 352 368zM528 256C519.2 256 512 263.2 512 272L512 304C512 312.8 519.2 320 528 320L560 320C568.8 320 576 312.8 576 304L576 272C576 263.2 568.8 256 560 256L528 256zM512 368L512 400C512 408.8 519.2 416 528 416L560 416C568.8 416 576 408.8 576 400L576 368C576 359.2 568.8 352 560 352L528 352C519.2 352 512 359.2 512 368zM96 544L96 384L80 384C35.8 384 0 348.2 0 304C0 277.3 13.1 253.7 33.2 239.1C32.4 234.2 32 229.1 32 224C32 171 75 128 128 128C181 128 224 171 224 224L224 320C224 355.3 195.3 384 160 384L160 544C160 561.7 145.7 576 128 576C110.3 576 96 561.7 96 544z` },
{ cat: segment, level: colorError, url: "", id: "_seg_Park", text: `Voie de Parking nommée`, icon: `M160 96C124.7 96 96 124.7 96 160L96 480C96 515.3 124.7 544 160 544L480 544C515.3 544 544 515.3 544 480L544 160C544 124.7 515.3 96 480 96L160 96zM288 320L336 320C353.7 320 368 305.7 368 288C368 270.3 353.7 256 336 256L288 256L288 320zM336 384L288 384L288 416C288 433.7 273.7 448 256 448C238.3 448 224 433.7 224 416L224 232C224 209.9 241.9 192 264 192L336 192C389 192 432 235 432 288C432 341 389 384 336 384z` },
{ cat: segment, level: colorError, url: "", id: "_seg_Rail", text: `Voie ferrée nommée ou nom en alt`, icon: `M128 160C128 107 171 64 224 64L416 64C469 64 512 107 512 160L512 416C512 456.1 487.4 490.5 452.5 504.8L506.4 568.5C515 578.6 513.7 593.8 503.6 602.3C493.5 610.8 478.3 609.6 469.8 599.5L395.8 512L244.5 512L170.5 599.5C161.9 609.6 146.8 610.9 136.7 602.3C126.6 593.7 125.3 578.6 133.9 568.5L187.8 504.8C152.6 490.5 128 456.1 128 416L128 160zM192 192L192 288C192 305.7 206.3 320 224 320L416 320C433.7 320 448 305.7 448 288L448 192C448 174.3 433.7 160 416 160L224 160C206.3 160 192 174.3 192 192zM320 448C337.7 448 352 433.7 352 416C352 398.3 337.7 384 320 384C302.3 384 288 398.3 288 416C288 433.7 302.3 448 320 448z` },
{ cat: segment, level: colorError, url: "", id: "_seg_Dir_name", text: `Direction (sauf bretelle/Autoroute)`, icon: `M64 320C64 461.4 178.6 576 320 576C461.4 576 576 461.4 576 320C576 178.6 461.4 64 320 64C178.6 64 64 178.6 64 320zM451.3 331.3L347.3 435.3C342.7 439.9 335.8 441.2 329.9 438.8C324 436.4 320 430.5 320 424L320 368L224 368C206.3 368 192 353.7 192 336L192 304C192 286.3 206.3 272 224 272L320 272L320 216C320 209.5 323.9 203.7 329.9 201.2C335.9 198.7 342.8 200.1 347.3 204.7L451.3 308.7C457.5 314.9 457.5 325.1 451.3 331.3z` },
{ cat: segment, level: colorError, url: "", id: "_seg_Toll", text: `Péage (sauf bretelle/Autoroute)`, icon: `M296 88C296 74.7 306.7 64 320 64C333.3 64 344 74.7 344 88L344 128L400 128C417.7 128 432 142.3 432 160C432 177.7 417.7 192 400 192L285.1 192C260.2 192 240 212.2 240 237.1C240 259.6 256.5 278.6 278.7 281.8L370.3 294.9C424.1 302.6 464 348.6 464 402.9C464 463.2 415.1 512 354.9 512L344 512L344 552C344 565.3 333.3 576 320 576C306.7 576 296 565.3 296 552L296 512L224 512C206.3 512 192 497.7 192 480C192 462.3 206.3 448 224 448L354.9 448C379.8 448 400 427.8 400 402.9C400 380.4 383.5 361.4 361.3 358.2L269.7 345.1C215.9 337.5 176 291.4 176 237.1C176 176.9 224.9 128 285.1 128L296 128L296 88z` },
{ cat: segment, level: colorError, url: "", id: "_seg_Ramp_city", text: `Bretelle/Autoroute avec ville`, icon: `M298.2 72.6C310.5 61.2 329.5 61.2 341.7 72.6L432 156.3L432 144C432 126.3 446.3 112 464 112L496 112C513.7 112 528 126.3 528 144L528 245.5L565.8 280.6C575.4 289.6 578.6 303.5 573.8 315.7C569 327.9 557.2 336 544 336L528 336L528 512C528 547.3 499.3 576 464 576L176 576C140.7 576 112 547.3 112 512L112 336L96 336C82.8 336 71 327.9 66.2 315.7C61.4 303.5 64.6 289.5 74.2 280.6L298.2 72.6zM304 384C277.5 384 256 405.5 256 432L256 528L384 528L384 432C384 405.5 362.5 384 336 384L304 384z` },
{ cat: segment, level: colorError, url: "", id: "_seg_DleSpace", text: `Double espace dans le nom`, icon: `M535.1 342.6C547.6 330.1 547.6 309.8 535.1 297.3L375.1 137.3C362.6 124.8 342.3 124.8 329.8 137.3C317.3 149.8 317.3 170.1 329.8 182.6L467.2 320L329.9 457.4C317.4 469.9 317.4 490.2 329.9 502.7C342.4 515.2 362.7 515.2 375.2 502.7L535.2 342.7zM183.1 502.6L343.1 342.6C355.6 330.1 355.6 309.8 343.1 297.3L183.1 137.3C170.6 124.8 150.3 124.8 137.8 137.3C125.3 149.8 125.3 170.1 137.8 182.6L275.2 320L137.9 457.4C125.4 469.9 125.4 490.2 137.9 502.7C150.4 515.2 170.7 515.2 183.2 502.7z` },
{ cat: segment, level: colorError, url: "", id: "_seg_HW_name", text: `Types Routes avec mauvais nom`, icon: `M287.9 96L211.7 96C182.3 96 156.6 116.1 149.6 144.6L65.4 484.5C57.9 514.7 80.8 544 112 544L287.9 544L287.9 480C287.9 462.3 302.2 448 319.9 448C337.6 448 351.9 462.3 351.9 480L351.9 544L528 544C559.2 544 582.1 514.7 574.6 484.5L490.5 144.6C483.4 116.1 457.8 96 428.3 96L351.9 96L351.9 160C351.9 177.7 337.6 192 319.9 192C302.2 192 287.9 177.7 287.9 160L287.9 96zM351.9 288L351.9 352C351.9 369.7 337.6 384 319.9 384C302.2 384 287.9 369.7 287.9 352L287.9 288C287.9 270.3 302.2 256 319.9 256C337.6 256 351.9 270.3 351.9 288z` },
{ cat: segment, level: colorError, url: "", id: "_seg_NoName", text: `Segment sans nommage`, icon: `M224 224C224 171 267 128 320 128C373 128 416 171 416 224C416 266.7 388.1 302.9 349.5 315.4C321.1 324.6 288 350.7 288 392L288 416C288 433.7 302.3 448 320 448C337.7 448 352 433.7 352 416L352 392C352 390.3 352.6 387.9 355.5 384.7C358.5 381.4 363.4 378.2 369.2 376.3C433.5 355.6 480 295.3 480 224C480 135.6 408.4 64 320 64C231.6 64 160 135.6 160 224C160 241.7 174.3 256 192 256C209.7 256 224 241.7 224 224zM320 576C342.1 576 360 558.1 360 536C360 513.9 342.1 496 320 496C297.9 496 280 513.9 280 536C280 558.1 297.9 576 320 576z` },
{ cat: segment, level: colorError, url: "375682", id: "_seg_Bad_HN", text: `HN Hors-Ville ou sur mauvais type`, icon: `M482.7 102C491 108 496 117.7 496 128L496 224L512 224C529.7 224 544 238.3 544 256C544 273.7 529.7 288 512 288L416 288C398.3 288 384 273.7 384 256C384 238.3 398.3 224 416 224L432 224L432 172.4L426.1 174.4C409.3 180 391.2 170.9 385.6 154.2C380 137.5 389.1 119.3 405.8 113.7L453.8 97.7C463.6 94.4 474.3 96.1 482.6 102.1zM429.1 494.6L440.8 476.6C407.9 466.7 384 436.1 384 400C384 355.8 419.8 320 464 320C508.2 320 544 355.8 544 400C544 422.9 537.4 445.3 524.9 464.5L482.8 529.4C473.2 544.2 453.4 548.5 438.5 538.8C423.6 529.1 419.4 509.4 429.1 494.5zM488 400C488 386.7 477.3 376 464 376C450.7 376 440 386.7 440 400C440 413.3 450.7 424 464 424C477.3 424 488 413.3 488 400zM214.6 534.6C202.1 547.1 181.8 547.1 169.3 534.6L73.3 438.6C60.8 426.1 60.8 405.8 73.3 393.3C85.8 380.8 106.1 380.8 118.6 393.3L160 434.7L160 128C160 110.3 174.3 96 192 96C209.7 96 224 110.3 224 128L224 434.7L265.4 393.3C277.9 380.8 298.2 380.8 310.7 393.3C323.2 405.8 323.2 426.1 310.7 438.6L214.7 534.6z` },
{ cat: segment, level: colorError, url: "", id: "_seg_City_Missing", text: `Ville manquante`, icon: `M288 112C288 85.5 309.5 64 336 64L432 64C458.5 64 480 85.5 480 112L480 160L528 160L528 88C528 74.7 538.7 64 552 64C565.3 64 576 74.7 576 88L576 160L592 160C618.5 160 640 181.5 640 208L640 528C640 554.5 618.5 576 592 576L336 576C309.5 576 288 554.5 288 528L288 112zM352 176L352 208C352 216.8 359.2 224 368 224L400 224C408.8 224 416 216.8 416 208L416 176C416 167.2 408.8 160 400 160L368 160C359.2 160 352 167.2 352 176zM368 256C359.2 256 352 263.2 352 272L352 304C352 312.8 359.2 320 368 320L400 320C408.8 320 416 312.8 416 304L416 272C416 263.2 408.8 256 400 256L368 256zM352 368L352 400C352 408.8 359.2 416 368 416L400 416C408.8 416 416 408.8 416 400L416 368C416 359.2 408.8 352 400 352L368 352C359.2 352 352 359.2 352 368zM528 256C519.2 256 512 263.2 512 272L512 304C512 312.8 519.2 320 528 320L560 320C568.8 320 576 312.8 576 304L576 272C576 263.2 568.8 256 560 256L528 256zM512 368L512 400C512 408.8 519.2 416 528 416L560 416C568.8 416 576 408.8 576 400L576 368C576 359.2 568.8 352 560 352L528 352C519.2 352 512 359.2 512 368zM96 544L96 384L80 384C35.8 384 0 348.2 0 304C0 277.3 13.1 253.7 33.2 239.1C32.4 234.2 32 229.1 32 224C32 171 75 128 128 128C181 128 224 171 224 224L224 320C224 355.3 195.3 384 160 384L160 544C160 561.7 145.7 576 128 576C110.3 576 96 561.7 96 544z` },
// \/ chemin de terre, mettre à jour l'url vers le paragraphe quand raccourci fonctionnel
{ cat: segment, level: colorWarn, url: "375656", id: "_seg_NotUnpaved", text: `Chemin de terre sans "non bitumé"`, icon: `M331.7 107.3C336 100.3 343.7 96 352 96L456 96C469.3 96 480 106.7 480 120C480 133.3 469.3 144 456 144L390.4 144L462.6 292.4C473.3 289.5 484.5 288 496 288C566.7 288 624 345.3 624 416C624 486.7 566.7 544 496 544C425.3 544 368 486.7 368 416C368 374 388.2 336.8 419.4 313.4L399 271.5L325.5 418.5C323.2 423.3 319.2 427.3 314.1 429.7C313.5 430 312.9 430.2 312.3 430.4C309.4 431.5 306.4 432 303.4 431.9L271 432C263.1 495.1 209.3 544 144 544C73.3 544 16 486.7 16 416C16 345.3 73.3 288 144 288C154.8 288 165.2 289.3 175.2 291.8L203.7 234.9L192.2 208L152 208C138.7 208 128 197.3 128 184C128 170.7 138.7 160 152 160L208 160C217.6 160 226.3 165.7 230.1 174.5L244.4 208L368.1 208L330.4 130.5C326.8 123.1 327.2 114.3 331.6 107.3zM228.5 292.7L182.9 384L267.7 384L228.6 292.7zM305.7 351L353.2 256L265 256L305.7 351zM474.4 426.5L444.7 365.5C431.9 378.5 424 396.3 424 416C424 455.8 456.2 488 496 488C535.8 488 568 455.8 568 416C568 376.2 535.8 344 496 344C493.3 344 490.5 344.2 487.9 344.5L517.6 405.5C523.4 417.4 518.4 431.8 506.5 437.6C494.6 443.4 480.2 438.4 474.4 426.5zM149.2 432C129 432 115.8 410.7 124.9 392.6L149.1 344.1C147.4 344 145.7 343.9 144 343.9C104.2 343.9 72 376.1 72 415.9C72 455.7 104.2 487.9 144 487.9C178.3 487.9 206.9 464 214.2 431.9L149.2 431.9z` },
{ cat: segment, level: colorWarn, url: "375658", id: "_seg_Ramp_name", text: `Bretelle avec plusieurs directions`, icon: `M256 128C256 119.2 263.2 112 272 112C280.8 112 288 119.2 288 128L288 264C288 274.3 294.6 283.5 304.4 286.8C314.2 290.1 325 286.7 331.2 278.5C334.2 274.6 338.8 272.1 344 272.1C352.8 272.1 360 279.3 360 288.1C360 298.4 366.6 307.6 376.4 310.9C386.2 314.2 397 310.8 403.2 302.6C406.2 298.7 410.8 296.2 416 296.2C423.8 296.2 430.3 301.8 431.7 309.2C433.3 317.4 439 324.3 446.8 327.2C454.6 330.1 463.5 328.8 470.1 323.6C472.8 321.5 476.2 320.2 480 320.2C488.8 320.2 496 327.4 496 336.2L496 456.2C496 496 463.8 528.2 424 528.2L307.4 528.2C270 528.2 235 509.5 214.2 478.3L146.7 376.9C141.8 369.5 143.8 359.6 151.1 354.7C158.4 349.8 168.4 351.8 173.3 359.1L212 417.2C217.9 426 228.8 429.9 238.9 426.9C249 423.9 255.9 414.5 255.9 403.9L256 128zM272 64C236.7 64 208 92.7 208 128L208 325.7C187.2 302 151.5 296.8 124.5 314.7C95.1 334.4 87.1 374.1 106.8 403.5L174.3 504.8C204 549.3 253.9 576 307.4 576L424 576C490.3 576 544 522.3 544 456L544 336C544 300.7 515.3 272 480 272C475.5 272 471.2 272.5 467 273.3C455.3 257.9 436.8 248 416 248C409.1 248 402.5 249.1 396.3 251.1C384.7 234.7 365.6 224 344 224C341.3 224 338.6 224.2 336 224.5L336 128C336 92.7 307.3 64 272 64zM320 368C320 359.2 312.8 352 304 352C295.2 352 288 359.2 288 368L288 464C288 472.8 295.2 480 304 480C312.8 480 320 472.8 320 464L320 368zM368 352C359.2 352 352 359.2 352 368L352 464C352 472.8 359.2 480 368 480C376.8 480 384 472.8 384 464L384 368C384 359.2 376.8 352 368 352zM448 368C448 359.2 440.8 352 432 352C423.2 352 416 359.2 416 368L416 464C416 472.8 423.2 480 432 480C440.8 480 448 472.8 448 464L448 368z` },
{ cat: segment, level: colorWarn, url: "375664", id: "_seg_BadSpeed", text: `Mauvaise vitesse validée`, icon: `M286.7 96.1C291.7 113 282.1 130.9 265.2 135.9C185.9 159.5 128.1 233 128.1 320C128.1 426 214.1 512 320.1 512C426.1 512 512.1 426 512.1 320C512.1 233.1 454.3 159.6 375 135.9C358.1 130.9 348.4 113 353.5 96.1C358.6 79.2 376.4 69.5 393.3 74.6C498.9 106.1 576 204 576 320C576 461.4 461.4 576 320 576C178.6 576 64 461.4 64 320C64 204 141.1 106.1 246.9 74.6C263.8 69.6 281.7 79.2 286.7 96.1z` },
{ cat: segment, level: colorWarn, url: "", id: "_seg_BadAltState", text: `Département différent`, icon: `M448 128C448 110.3 433.7 96 416 96L224 96C206.3 96 192 110.3 192 128C192 145.7 206.3 160 224 160L416 160C433.7 160 448 145.7 448 128zM544 256C544 238.3 529.7 224 512 224L128 224C110.3 224 96 238.3 96 256C96 273.7 110.3 288 128 288L512 288C529.7 288 544 273.7 544 256zM96 512C96 529.7 110.3 544 128 544L512 544C529.7 544 544 529.7 544 512C544 494.3 529.7 480 512 480L128 480C110.3 480 96 494.3 96 512zM448 384C448 366.3 433.7 352 416 352L224 352C206.3 352 192 366.3 192 384C192 401.7 206.3 416 224 416L416 416C433.7 416 448 401.7 448 384z` },
{ cat: segment, level: colorWarn, url: "", id: "_seg_EmptyCityAlt", text: `Alt non conforme`, icon: `M371.8 82.4C359.8 87.4 352 99 352 112L352 192L240 192C142.8 192 64 270.8 64 368C64 481.3 145.5 531.9 164.2 542.1C166.7 543.5 169.5 544 172.3 544C183.2 544 192 535.1 192 524.3C192 516.8 187.7 509.9 182.2 504.8C172.8 496 160 478.4 160 448.1C160 395.1 203 352.1 256 352.1L352 352.1L352 432.1C352 445 359.8 456.7 371.8 461.7C383.8 466.7 397.5 463.9 406.7 454.8L566.7 294.8C579.2 282.3 579.2 262 566.7 249.5L406.7 89.5C397.5 80.3 383.8 77.6 371.8 82.6z` },
{ cat: segment, level: colorWarn, url: "375703", id: "_seg_LockValue", text: `Lock incorrect (Auto ou valeur)`, icon: `M256 160L256 224L384 224L384 160C384 124.7 355.3 96 320 96C284.7 96 256 124.7 256 160zM192 224L192 160C192 89.3 249.3 32 320 32C390.7 32 448 89.3 448 160L448 224C483.3 224 512 252.7 512 288L512 512C512 547.3 483.3 576 448 576L192 576C156.7 576 128 547.3 128 512L128 288C128 252.7 156.7 224 192 224z` },
{ cat: segment, level: colorWarn, url: "", id: "_seg_SameAlt", text: `Alts différents dans la sélection`, icon: `M128 252.6C128 148.4 214 64 320 64C426 64 512 148.4 512 252.6C512 371.9 391.8 514.9 341.6 569.4C329.8 582.2 310.1 582.2 298.3 569.4C248.1 514.9 127.9 371.9 127.9 252.6zM320 320C355.3 320 384 291.3 384 256C384 220.7 355.3 192 320 192C284.7 192 256 220.7 256 256C256 291.3 284.7 320 320 320z` },
{ lock: 4, cat: segment, level: colorInfo, url: "", id: "_seg_No_lane", text: `Aucune voie renseignée`, icon: `M287.9 96L211.7 96C182.3 96 156.6 116.1 149.6 144.6L65.4 484.5C57.9 514.7 80.8 544 112 544L287.9 544L287.9 480C287.9 462.3 302.2 448 319.9 448C337.6 448 351.9 462.3 351.9 480L351.9 544L528 544C559.2 544 582.1 514.7 574.6 484.5L490.5 144.6C483.4 116.1 457.8 96 428.3 96L351.9 96L351.9 160C351.9 177.7 337.6 192 319.9 192C302.2 192 287.9 177.7 287.9 160L287.9 96zM351.9 288L351.9 352C351.9 369.7 337.6 384 319.9 384C302.2 384 287.9 369.7 287.9 352L287.9 288C287.9 270.3 302.2 256 319.9 256C337.6 256 351.9 270.3 351.9 288z` },
// contrôle des nœuds
{ cat: "ce-global-check-nodes", type: "title", text: `Contrôle des nœuds` },
{ cat: "ce-nodBad", id: "_nod_Bad", text: `Mauvais nœuds` },
{ cat: nodes, level: colorError, url: "211367", id: "_nod_Useless_Nodes", text: `Nœud inutile`, icon: `M320 576C461.4 576 576 461.4 576 320C576 178.6 461.4 64 320 64C178.6 64 64 178.6 64 320C64 461.4 178.6 576 320 576zM231 231C240.4 221.6 255.6 221.6 264.9 231L319.9 286L374.9 231C384.3 221.6 399.5 221.6 408.8 231C418.1 240.4 418.2 255.6 408.8 264.9L353.8 319.9L408.8 374.9C418.2 384.3 418.2 399.5 408.8 408.8C399.4 418.1 384.2 418.2 374.9 408.8L319.9 353.8L264.9 408.8C255.5 418.2 240.3 418.2 231 408.8C221.7 399.4 221.6 384.2 231 374.9L286 319.9L231 264.9C221.6 255.5 221.6 240.3 231 231z` },
// contrôle des lieux
{ cat: "ce-global-check-place", type: "title", text: `Contrôle des lieux` },
{ cat: "ce-poiBad", id: "_poi_Bad", text: `Mauvais lieux` },
{ cat: places, level: colorError, url: "", id: "_poi_Address", text: `Adresse incorrecte ou incomplète`, icon: `M544 144C552.8 144 560 151.2 560 160L560 480C560 488.8 552.8 496 544 496L96 496C87.2 496 80 488.8 80 480L80 160C80 151.2 87.2 144 96 144L544 144zM96 96C60.7 96 32 124.7 32 160L32 480C32 515.3 60.7 544 96 544L544 544C579.3 544 608 515.3 608 480L608 160C608 124.7 579.3 96 544 96L96 96zM240 312C270.9 312 296 286.9 296 256C296 225.1 270.9 200 240 200C209.1 200 184 225.1 184 256C184 286.9 209.1 312 240 312zM208 352C163.8 352 128 387.8 128 432C128 440.8 135.2 448 144 448L336 448C344.8 448 352 440.8 352 432C352 387.8 316.2 352 272 352L208 352zM408 208C394.7 208 384 218.7 384 232C384 245.3 394.7 256 408 256L488 256C501.3 256 512 245.3 512 232C512 218.7 501.3 208 488 208L408 208zM408 304C394.7 304 384 314.7 384 328C384 341.3 394.7 352 408 352L488 352C501.3 352 512 341.3 512 328C512 314.7 501.3 304 488 304L408 304z` },
{ cat: places, level: colorError, url: "", id: "_poi_AddressWithoutNumber", text: `Adresse sans numéro de rue`, icon: `M482.7 102C491 108 496 117.7 496 128L496 224L512 224C529.7 224 544 238.3 544 256C544 273.7 529.7 288 512 288L416 288C398.3 288 384 273.7 384 256C384 238.3 398.3 224 416 224L432 224L432 172.4L426.1 174.4C409.3 180 391.2 170.9 385.6 154.2C380 137.5 389.1 119.3 405.8 113.7L453.8 97.7C463.6 94.4 474.3 96.1 482.6 102.1zM429.1 494.6L440.8 476.6C407.9 466.7 384 436.1 384 400C384 355.8 419.8 320 464 320C508.2 320 544 355.8 544 400C544 422.9 537.4 445.3 524.9 464.5L482.8 529.4C473.2 544.2 453.4 548.5 438.5 538.8C423.6 529.1 419.4 509.4 429.1 494.5zM488 400C488 386.7 477.3 376 464 376C450.7 376 440 386.7 440 400C440 413.3 450.7 424 464 424C477.3 424 488 413.3 488 400zM214.6 534.6C202.1 547.1 181.8 547.1 169.3 534.6L73.3 438.6C60.8 426.1 60.8 405.8 73.3 393.3C85.8 380.8 106.1 380.8 118.6 393.3L160 434.7L160 128C160 110.3 174.3 96 192 96C209.7 96 224 110.3 224 128L224 434.7L265.4 393.3C277.9 380.8 298.2 380.8 310.7 393.3C323.2 405.8 323.2 426.1 310.7 438.6L214.7 534.6z` },
// \/ Site naturel, mettre à jour l'url vers le paragraphe quand raccourci fonctionnel
{ cat: places, level: colorError, url: "375608", id: "_poi_LandM", text: `Site naturel avec adresse`, icon: `M320 32C327 32 333.7 35.1 338.3 40.5L474.3 200.5C480.4 207.6 481.7 217.6 477.8 226.1C473.9 234.6 465.4 240 456 240L431.1 240L506.3 328.5C512.4 335.6 513.7 345.6 509.8 354.1C505.9 362.6 497.4 368 488 368L449.5 368L538.3 472.5C544.4 479.6 545.7 489.6 541.8 498.1C537.9 506.6 529.4 512 520 512L352 512L352 576C352 593.7 337.7 608 320 608C302.3 608 288 593.7 288 576L288 512L120 512C110.6 512 102.1 506.6 98.2 498.1C94.3 489.6 95.6 479.6 101.7 472.5L190.5 368L152 368C142.6 368 134.1 362.6 130.2 354.1C126.3 345.6 127.6 335.6 133.7 328.5L208.9 240L184 240C174.6 240 166.1 234.6 162.2 226.1C158.3 217.6 159.6 207.6 165.7 200.5L301.7 40.5C306.3 35.1 313 32 320 32z` },
{ cat: places, level: colorError, url: "", id: "_poi_DleSpace", text: `Double espace dans le nom`, icon: `M535.1 342.6C547.6 330.1 547.6 309.8 535.1 297.3L375.1 137.3C362.6 124.8 342.3 124.8 329.8 137.3C317.3 149.8 317.3 170.1 329.8 182.6L467.2 320L329.9 457.4C317.4 469.9 317.4 490.2 329.9 502.7C342.4 515.2 362.7 515.2 375.2 502.7L535.2 342.7zM183.1 502.6L343.1 342.6C355.6 330.1 355.6 309.8 343.1 297.3L183.1 137.3C170.6 124.8 150.3 124.8 137.8 137.3C125.3 149.8 125.3 170.1 137.8 182.6L275.2 320L137.9 457.4C125.4 469.9 125.4 490.2 137.9 502.7C150.4 515.2 170.7 515.2 183.2 502.7z` },
{ cat: places, level: colorError, url: "", id: "_poi_Transp", text: `Transport (nom ou catégorie)`, icon: `M192 64C139 64 96 107 96 160L96 448C96 477.8 116.4 502.9 144 510L144 544C144 561.7 158.3 576 176 576L192 576C209.7 576 224 561.7 224 544L224 512L416 512L416 544C416 561.7 430.3 576 448 576L464 576C481.7 576 496 561.7 496 544L496 510C523.6 502.9 544 477.8 544 448L544 160C544 107 501 64 448 64L192 64zM160 192C160 174.3 174.3 160 192 160L448 160C465.7 160 480 174.3 480 192L480 288C480 305.7 465.7 320 448 320L192 320C174.3 320 160 305.7 160 288L160 192zM192 384C209.7 384 224 398.3 224 416C224 433.7 209.7 448 192 448C174.3 448 160 433.7 160 416C160 398.3 174.3 384 192 384zM448 384C465.7 384 480 398.3 480 416C480 433.7 465.7 448 448 448C430.3 448 416 433.7 416 416C416 398.3 430.3 384 448 384z` },
// \/ Station-service, mettre à jour l'url vers le paragraphe quand raccourci fonctionnel
{ cat: places, level: colorError, url: "375527", id: "_poi_GasSta", text: `Station-service mal nommée`, icon: `M96 128C96 92.7 124.7 64 160 64L320 64C355.3 64 384 92.7 384 128L384 320L392 320C440.6 320 480 359.4 480 408L480 440C480 453.3 490.7 464 504 464C517.3 464 528 453.3 528 440L528 286C500.4 278.9 480 253.8 480 224L480 164.5L454.2 136.2C445.3 126.4 446 111.2 455.8 102.3C465.6 93.4 480.8 94.1 489.7 103.9L561.4 182.7C570.8 193 576 206.4 576 220.4L576 440C576 479.8 543.8 512 504 512C464.2 512 432 479.8 432 440L432 408C432 385.9 414.1 368 392 368L384 368L384 529.4C393.3 532.7 400 541.6 400 552C400 565.3 389.3 576 376 576L104 576C90.7 576 80 565.3 80 552C80 541.5 86.7 532.7 96 529.4L96 128zM160 144L160 240C160 248.8 167.2 256 176 256L304 256C312.8 256 320 248.8 320 240L320 144C320 135.2 312.8 128 304 128L176 128C167.2 128 160 135.2 160 144z` },
{ cat: places, level: colorError, url: "375598", id: "_poi_Park", text: `Parking (nom ou type)`, icon: `M160 96C124.7 96 96 124.7 96 160L96 480C96 515.3 124.7 544 160 544L480 544C515.3 544 544 515.3 544 480L544 160C544 124.7 515.3 96 480 96L160 96zM288 320L336 320C353.7 320 368 305.7 368 288C368 270.3 353.7 256 336 256L288 256L288 320zM336 384L288 384L288 416C288 433.7 273.7 448 256 448C238.3 448 224 433.7 224 416L224 232C224 209.9 241.9 192 264 192L336 192C389 192 432 235 432 288C432 341 389 384 336 384z` },
{ cat: places, level: colorError, url: "", id: "_poi_Relig", text: `Lieu de culte (nom ou catégorie)`, icon: `M344 56C344 42.7 333.3 32 320 32C306.7 32 296 42.7 296 56L296 80L264 80C250.7 80 240 90.7 240 104C240 117.3 250.7 128 264 128L296 128L296 176L197.4 241.8C184 250.7 176 265.6 176 281.7L176 320L96.2 365.6C76.3 377 64 398.2 64 421.1L64 512C64 547.3 92.7 576 128 576C202.7 576 213.4 576 448 576L512 576C547.3 576 576 547.3 576 512L576 421.1C576 398.1 563.7 376.9 543.8 365.5L464 320L464 281.7C464 265.7 456 250.7 442.6 241.8L344 176L344 128L376 128C389.3 128 400 117.3 400 104C400 90.7 389.3 80 376 80L344 80L344 56zM320 384C355.3 384 384 412.7 384 448L384 528L256 528L256 448C256 412.7 284.7 384 320 384z` },
{ cat: places, level: colorWarn, url: "", id: "_poi_Entry", text: `Point d'entrée non défini`, icon: `M528 320C528 434.9 434.9 528 320 528C205.1 528 112 434.9 112 320C112 205.1 205.1 112 320 112C434.9 112 528 205.1 528 320zM64 320C64 461.4 178.6 576 320 576C461.4 576 576 461.4 576 320C576 178.6 461.4 64 320 64C178.6 64 64 178.6 64 320zM451.3 331.3C457.5 325.1 457.5 314.9 451.3 308.7L347.3 204.7C342.7 200.1 335.8 198.8 329.9 201.2C324 203.6 320 209.5 320 216L320 288L216 288C202.7 288 192 298.7 192 312L192 328C192 341.3 202.7 352 216 352L320 352L320 424C320 430.5 323.9 436.3 329.9 438.8C335.9 441.3 342.8 439.9 347.3 435.3L451.3 331.3z` },
{ cat: places, level: colorWarn, url: "", id: "_poi_Resid", text: `Peut-être une place résidentielle`, icon: `M298.2 72.6C310.5 61.2 329.5 61.2 341.7 72.6L432 156.3L432 144C432 126.3 446.3 112 464 112L496 112C513.7 112 528 126.3 528 144L528 245.5L565.8 280.6C575.4 289.6 578.6 303.5 573.8 315.7C569 327.9 557.2 336 544 336L528 336L528 512C528 547.3 499.3 576 464 576L176 576C140.7 576 112 547.3 112 512L112 336L96 336C82.8 336 71 327.9 66.2 315.7C61.4 303.5 64.6 289.5 74.2 280.6L298.2 72.6zM304 384C277.5 384 256 405.5 256 432L256 528L384 528L384 432C384 405.5 362.5 384 336 384L304 384z` },
{ lock: 2, cat: places, level: colorWarn, url: "", id: "_poi_Google", text: `Pas de lien avec Google`, icon: `M564 325.8C564 467.3 467.1 568 324 568C186.8 568 76 457.2 76 320C76 182.8 186.8 72 324 72C390.8 72 447 96.5 490.3 136.9L422.8 201.8C334.5 116.6 170.3 180.6 170.3 320C170.3 406.5 239.4 476.6 324 476.6C422.2 476.6 459 406.2 464.8 369.7L324 369.7L324 284.4L560.1 284.4C562.4 297.1 564 309.3 564 325.8z` },
{ cat: places, level: colorWarn, url: "", id: "_poi_Phone", text: `Mauvais format du n° de tel`, icon: `M224.2 89C216.3 70.1 195.7 60.1 176.1 65.4L170.6 66.9C106 84.5 50.8 147.1 66.9 223.3C104 398.3 241.7 536 416.7 573.1C493 589.3 555.5 534 573.1 469.4L574.6 463.9C580 444.2 569.9 423.6 551.1 415.8L453.8 375.3C437.3 368.4 418.2 373.2 406.8 387.1L368.2 434.3C297.9 399.4 241.3 341 208.8 269.3L253 233.3C266.9 222 271.6 202.9 264.8 186.3L224.2 89z` },
{ cat: places, level: colorWarn, url: "", id: "_poi_AutoFixTel", text: `Correction auto du n° de tel`, icon: `M295.4 37L310.2 73.8L347 88.6C350 89.8 352 92.8 352 96C352 99.2 350 102.2 347 103.4L310.2 118.2L295.4 155C294.2 158 291.2 160 288 160C284.8 160 281.8 158 280.6 155L265.8 118.2L229 103.4C226 102.2 224 99.2 224 96C224 92.8 226 89.8 229 88.6L265.8 73.8L280.6 37C281.8 34 284.8 32 288 32C291.2 32 294.2 34 295.4 37zM142.7 105.7L164.2 155.8L214.3 177.3C220.2 179.8 224 185.6 224 192C224 198.4 220.2 204.2 214.3 206.7L164.2 228.2L142.7 278.3C140.2 284.2 134.4 288 128 288C121.6 288 115.8 284.2 113.3 278.3L91.8 228.2L41.7 206.7C35.8 204.2 32 198.4 32 192C32 185.6 35.8 179.8 41.7 177.3L91.8 155.8L113.3 105.7C115.8 99.8 121.6 96 128 96C134.4 96 140.2 99.8 142.7 105.7zM496 368C502.4 368 508.2 371.8 510.7 377.7L532.2 427.8L582.3 449.3C588.2 451.8 592 457.6 592 464C592 470.4 588.2 476.2 582.3 478.7L532.2 500.2L510.7 550.3C508.2 556.2 502.4 560 496 560C489.6 560 483.8 556.2 481.3 550.3L459.8 500.2L409.7 478.7C403.8 476.2 400 470.4 400 464C400 457.6 403.8 451.8 409.7 449.3L459.8 427.8L481.3 377.7C483.8 371.8 489.6 368 496 368zM492 64C503 64 513.6 68.4 521.5 76.2L563.8 118.5C571.6 126.4 576 137 576 148C576 159 571.6 169.6 563.8 177.5L475.6 265.7L374.3 164.4L462.5 76.2C470.4 68.4 481 64 492 64zM76.2 462.5L340.4 198.3L441.7 299.6L177.5 563.8C169.6 571.6 159 576 148 576C137 576 126.4 571.6 118.5 563.8L76.2 521.5C68.4 513.6 64 503 64 492C64 481 68.4 470.4 76.2 462.5z` },
{ cat: places, level: colorWarn, url: "", id: "_poi_Other", text: `Lieu de type "Autres"`, icon: `M528 320C528 205.1 434.9 112 320 112C205.1 112 112 205.1 112 320C112 434.9 205.1 528 320 528C434.9 528 528 434.9 528 320zM64 320C64 178.6 178.6 64 320 64C461.4 64 576 178.6 576 320C576 461.4 461.4 576 320 576C178.6 576 64 461.4 64 320zM320 240C302.3 240 288 254.3 288 272C288 285.3 277.3 296 264 296C250.7 296 240 285.3 240 272C240 227.8 275.8 192 320 192C364.2 192 400 227.8 400 272C400 319.2 364 339.2 344 346.5L344 350.3C344 363.6 333.3 374.3 320 374.3C306.7 374.3 296 363.6 296 350.3L296 342.2C296 321.7 310.8 307 326.1 302C332.5 299.9 339.3 296.5 344.3 291.7C348.6 287.5 352 281.7 352 272.1C352 254.4 337.7 240.1 320 240.1zM288 432C288 414.3 302.3 400 320 400C337.7 400 352 414.3 352 432C352 449.7 337.7 464 320 464C302.3 464 288 449.7 288 432z` },
{ cat: places, level: colorInfo, url: "", id: "_poi_WazeBot", text: `Lieu édité par Waze Bot`, icon: `M352 64C352 46.3 337.7 32 320 32C302.3 32 288 46.3 288 64L288 128L192 128C139 128 96 171 96 224L96 448C96 501 139 544 192 544L448 544C501 544 544 501 544 448L544 224C544 171 501 128 448 128L352 128L352 64zM160 432C160 418.7 170.7 408 184 408L216 408C229.3 408 240 418.7 240 432C240 445.3 229.3 456 216 456L184 456C170.7 456 160 445.3 160 432zM280 432C280 418.7 290.7 408 304 408L336 408C349.3 408 360 418.7 360 432C360 445.3 349.3 456 336 456L304 456C290.7 456 280 445.3 280 432zM400 432C400 418.7 410.7 408 424 408L456 408C469.3 408 480 418.7 480 432C480 445.3 469.3 456 456 456L424 456C410.7 456 400 445.3 400 432zM224 240C250.5 240 272 261.5 272 288C272 314.5 250.5 336 224 336C197.5 336 176 314.5 176 288C176 261.5 197.5 240 224 240zM368 288C368 261.5 389.5 240 416 240C442.5 240 464 261.5 464 288C464 314.5 442.5 336 416 336C389.5 336 368 314.5 368 288zM64 288C64 270.3 49.7 256 32 256C14.3 256 0 270.3 0 288L0 384C0 401.7 14.3 416 32 416C49.7 416 64 401.7 64 384L64 288zM608 256C590.3 256 576 270.3 576 288L576 384C576 401.7 590.3 416 608 416C625.7 416 640 401.7 640 384L640 288C640 270.3 625.7 256 608 256z` },
// auto lock
{ lock: 5, cat: "ce-global-check-lock", type: "title", text: `Auto-verrouillage` },
{ lock: 5, cat: "ce-lockBad", id: "_autoLock", text: `Auto-verrouillage (France)` },
{ lock: 5, cat: "ce-autolock", level: "red", id: "_Freeway", text: `5 Autoroute, voie express`, icon: `M256 160L256 224L384 224L384 160C384 124.7 355.3 96 320 96C284.7 96 256 124.7 256 160zM192 224L192 160C192 89.3 249.3 32 320 32C390.7 32 448 89.3 448 160L448 224C483.3 224 512 252.7 512 288L512 512C512 547.3 483.3 576 448 576L192 576C156.7 576 128 547.3 128 512L128 288C128 252.7 156.7 224 192 224z` },
{ lock: 5, cat: "ce-autolock", level: "red", id: "_Ramp", text: `5 Bretelle`, icon: `M256 160L256 224L384 224L384 160C384 124.7 355.3 96 320 96C284.7 96 256 124.7 256 160zM192 224L192 160C192 89.3 249.3 32 320 32C390.7 32 448 89.3 448 160L448 224C483.3 224 512 252.7 512 288L512 512C512 547.3 483.3 576 448 576L192 576C156.7 576 128 547.3 128 512L128 288C128 252.7 156.7 224 192 224z` },
{ lock: 5, cat: "ce-autolock", level: "red", id: "_Major", text: `5 Route majeure`, icon: `M256 160L256 224L384 224L384 160C384 124.7 355.3 96 320 96C284.7 96 256 124.7 256 160zM192 224L192 160C192 89.3 249.3 32 320 32C390.7 32 448 89.3 448 160L448 224C483.3 224 512 252.7 512 288L512 512C512 547.3 483.3 576 448 576L192 576C156.7 576 128 547.3 128 512L128 288C128 252.7 156.7 224 192 224z` },
{ lock: 5, cat: "ce-autolock", level: "red", id: "_Railway", text: `5 Voie ferrée`, icon: `M256 160L256 224L384 224L384 160C384 124.7 355.3 96 320 96C284.7 96 256 124.7 256 160zM192 224L192 160C192 89.3 249.3 32 320 32C390.7 32 448 89.3 448 160L448 224C483.3 224 512 252.7 512 288L512 512C512 547.3 483.3 576 448 576L192 576C156.7 576 128 547.3 128 512L128 288C128 252.7 156.7 224 192 224z` },
{ lock: 5, cat: "ce-autolock", level: colorWarn, id: "_Minor", text: `4 Route mineure`, icon: `M256 160L256 224L384 224L384 160C384 124.7 355.3 96 320 96C284.7 96 256 124.7 256 160zM192 224L192 160C192 89.3 249.3 32 320 32C390.7 32 448 89.3 448 160L448 224C483.3 224 512 252.7 512 288L512 512C512 547.3 483.3 576 448 576L192 576C156.7 576 128 547.3 128 512L128 288C128 252.7 156.7 224 192 224z` },
{ lock: 5, cat: "ce-autolock", level: "orange", id: "_Primary", text: `3 Rue principale`, icon: `M256 160L256 224L384 224L384 160C384 124.7 355.3 96 320 96C284.7 96 256 124.7 256 160zM192 224L192 160C192 89.3 249.3 32 320 32C390.7 32 448 89.3 448 160L448 224C483.3 224 512 252.7 512 288L512 512C512 547.3 483.3 576 448 576L192 576C156.7 576 128 547.3 128 512L128 288C128 252.7 156.7 224 192 224z` },
{ lock: 5, cat: "ce-autolock", level: "#00cf00", id: "_Street", text: `1 Rue`, icon: `M256 160L256 224L384 224L384 160C384 124.7 355.3 96 320 96C284.7 96 256 124.7 256 160zM192 224L192 160C192 89.3 249.3 32 320 32C390.7 32 448 89.3 448 160L448 224C483.3 224 512 252.7 512 288L512 512C512 547.3 483.3 576 448 576L192 576C156.7 576 128 547.3 128 512L128 288C128 252.7 156.7 224 192 224z` },
{ lock: 5, cat: "ce-autolock", level: "#00cf00", id: "_Narrow", text: `1 Rue étroite`, icon: `M256 160L256 224L384 224L384 160C384 124.7 355.3 96 320 96C284.7 96 256 124.7 256 160zM192 224L192 160C192 89.3 249.3 32 320 32C390.7 32 448 89.3 448 160L448 224C483.3 224 512 252.7 512 288L512 512C512 547.3 483.3 576 448 576L192 576C156.7 576 128 547.3 128 512L128 288C128 252.7 156.7 224 192 224z` },
]
// ************
// ** HELPER **
// ************
const $id = $ => document.getElementById($), $class = $ => document.getElementsByClassName($);
function WMECE_log(message) {
if (typeof message === 'string')
console.log("%c" + GM_info.script.name + " - " + GM_info.script.version + "\n" + "%c" + message, "color: #00afff80;", "color: #00afffff;font-weight: bold;");
else console.log("%c" + GM_info.script.name + " - " + GM_info.script.version + "\n", "color: #00afff80;", message)
}
function WMECE_tooltip(text, display, parent) {
let ceTooltip;
if ($id("ce-tooltip")) {
($id("ce-tooltip"))
ceTooltip = $id("ce-tooltip")
if (display === "block") {
ceTooltip.innerHTML = text;
ceTooltip.style.top = parent.bottom + 10 + "px";
ceTooltip.style.display = "block";
ceTooltip.style.left = parent.left + parent.width / 2 - ceTooltip.offsetWidth / 2 + "px";
} else ceTooltip.style.display = "none";
} else {
ceTooltip = document.createElement("div");
ceTooltip.id = "ce-tooltip";
ceTooltip.style.display = "none";
ceTooltip.style.borderRadius = "4px";
ceTooltip.style.color = "blanc";
ceTooltip.style.padding = "8px";
ceTooltip.style.position = "absolute";
ceTooltip.style.fontSize = "12px";
ceTooltip.style.backgroundColor = "#3c4043";
ceTooltip.style.color = "#fff";
ceTooltip.style.zIndex = "9999";
document.body.append(ceTooltip);
}
}
function onScreen(geometry) {
const mapExtent = wmeSDK.Map.getMapExtent();
if (geometry.type === "Point") {
const [lon, lat] = geometry.coordinates;
return lon >= mapExtent && lon <= mapExtent &&
lat >= mapExtent && lat <= mapExtent;
}
if (geometry.type === "Polygon") {
geometry.coordinates.forEach(ring => {
ring.forEach(([lon, lat]) => {
if (lon >= mapExtent && lon <= mapExtent &&
lat >= mapExtent && lat <= mapExtent) {
return true;
}
});
});
return false;
}
return false;
}
// *************
// ** INIT **
// *************
window.SDK_INITIALIZED.then(() => {
wmeSDK = getWmeSdk({ scriptId: "__wme_ce_2014", scriptName: "Color Errors" });
if (debug) WMECE_log("Initialisation en cours");
setLocalStorage()
waitSDK();
addLayerOnMap();
// Ajout de l'interface CE à l'onglet Script
wmeSDK.Sidebar.registerScriptTab().then((t) => {
// t.tabLabel.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" fill="#3d3d3d" viewBox="0 0 576 512" style="height: 100%;padding: 8px;"><path d="M288 32c-80.8 0-145.5 36.8-192.6 80.6-46.8 43.5-78.1 95.4-93 131.1-3.3 7.9-3.3 16.7 0 24.6 14.9 35.7 46.2 87.7 93 131.1 47.1 43.7 111.8 80.6 192.6 80.6s145.5-36.8 192.6-80.6c46.8-43.5 78.1-95.4 93-131.1 3.3-7.9 3.3-16.7 0-24.6-14.9-35.7-46.2-87.7-93-131.1-47.1-43.7-111.8-80.6-192.6-80.6zM144 256a144 144 0 1 1 288 0 144 144 0 1 1 -288 0zm144-64c0 35.3-28.7 64-64 64-11.5 0-22.3-3-31.7-8.4-1 10.9-.1 22.1 2.9 33.2 13.7 51.2 66.4 81.6 117.6 67.9s81.6-66.4 67.9-117.6c-12.2-45.7-55.5-74.8-101.1-70.8 5.3 9.3 8.4 20.1 8.4 31.7z"/></svg>`;
t.tabLabel.innerHTML = "<span class='fa fa-eye' title='Color Errors'></span>";
t.tabPane.innerHTML = `
<div><a href="https://greatest.deepsurf.us/fr/scripts/21186-wme-color-errors" target="_blank"><b>WME Color Errors</b></a> v${GM_info.script.version}</div>
<h6>Réglages</h6>
<b>Opacité des icônes</b><div style="display: flex;gap: 10px;margin-right: 10px;"><input id="errOpacity" type="range" max="1" min="0" step="0.05" value="${ls.opacity}" style="accent-color: #0075e3;"><b id="opacityValue" style="width: 50px;text-align: end;">${ls.opacity * 100}%</b></div><br>
<b>Taille des icônes</b><div style="display: flex;gap: 10px;margin-right: 10px;"><input id="errSize" type="range" max="50" min="10" step="5"value="${ls.size}" style="accent-color: #0075e3;"><b id="sizeValue" style="width: 50px;text-align: end;">${ls.size}px</b></div><br>
<div id="ce-pref"></div><br>
<div><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640" id="ce-list" style="height: 25px;cursor:pointer;"><path d="M104 112C90.7 112 80 122.7 80 136L80 184C80 197.3 90.7 208 104 208L152 208C165.3 208 176 197.3 176 184L176 136C176 122.7 165.3 112 152 112L104 112zM256 128C238.3 128 224 142.3 224 160C224 177.7 238.3 192 256 192L544 192C561.7 192 576 177.7 576 160C576 142.3 561.7 128 544 128L256 128zM256 288C238.3 288 224 302.3 224 320C224 337.7 238.3 352 256 352L544 352C561.7 352 576 337.7 576 320C576 302.3 561.7 288 544 288L256 288zM256 448C238.3 448 224 462.3 224 480C224 497.7 238.3 512 256 512L544 512C561.7 512 576 497.7 576 480C576 462.3 561.7 448 544 448L256 448zM80 296L80 344C80 357.3 90.7 368 104 368L152 368C165.3 368 176 357.3 176 344L176 296C176 282.7 165.3 272 152 272L104 272C90.7 272 80 282.7 80 296zM104 432C90.7 432 80 442.7 80 456L80 504C80 517.3 90.7 528 104 528L152 528C165.3 528 176 517.3 176 504L176 456C176 442.7 165.3 432 152 432L104 432z"/></svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640" id="ce-grid" style="height: 25px;cursor:pointer;"><path d="M152 160C174.1 160 192 177.9 192 200L192 248C192 270.1 174.1 288 152 288L104 288C81.9 288 64 270.1 64 248L64 200C64 177.9 81.9 160 104 160L152 160zM344 288L296 288C273.9 288 256 270.1 256 248L256 200C256 177.9 273.9 160 296 160L344 160C366.1 160 384 177.9 384 200L384 248C384 270.1 366.1 288 344 288zM536 288L488 288C465.9 288 448 270.1 448 248L448 200C448 177.9 465.9 160 488 160L536 160C558.1 160 576 177.9 576 200L576 248C576 270.1 558.1 288 536 288zM536 480L488 480C465.9 480 448 462.1 448 440L448 392C448 369.9 465.9 352 488 352L536 352C558.1 352 576 369.9 576 392L576 440C576 462.1 558.1 480 536 480zM344 352C366.1 352 384 369.9 384 392L384 440C384 462.1 366.1 480 344 480L296 480C273.9 480 256 462.1 256 440L256 392C256 369.9 273.9 352 296 352L344 352zM152 480L104 480C81.9 480 64 462.1 64 440L64 392C64 369.9 81.9 352 104 352L152 352C174.1 352 192 369.9 192 392L192 440C192 462.1 174.1 480 152 480z"/></svg></div>
<h6 id="ce-global-check-seg"></h6><div id="ce-segBad"></div></div><div id="ce-segments" style="display: flex;flex-wrap: wrap;justify-content: space-between;column-gap: 5px;"><div class="controls-container" style="display:none;"></div></div><br>
<h6 id="ce-global-check-nodes"></h6><div id="ce-nodBad"></div><div id="ce-nodes" style="display: flex;flex-wrap: wrap;justify-content: space-between;column-gap: 5px;"><div class="controls-container" style="display:none;"></div></div><br>
<h6 id="ce-global-check-place"></h6><div id="ce-poiBad"></div><div id="ce-places" style="display: flex;flex-wrap: wrap;justify-content: space-between;column-gap: 5px;"><div class="controls-container" style="display:none;"></div></div><br>
<h6 id="ce-global-check-lock"></h6><div id="ce-lockBad"></div><div id="ce-autolock" style="display: flex;flex-wrap: wrap;justify-content: space-between;column-gap: 5px;"><div class="controls-container" style="display:none;"></div></div>
`;
});
});
function waitSDK() {
if (debug) WMECE_log("Attente SDK");
if (!OpenLayers) { if (debug) WMECE_log("OpenLayers : NOK"); setTimeout(waitSDK, 500); return; };
if (!wmeSDK) { if (debug) WMECE_log("wmeSDK : NOK"); setTimeout(waitSDK, 500); return; };
if (!wmeSDK.Editing) { if (debug) { WMECE_log("wmeSDK.Editing : NOK"); setTimeout(waitSDK, 500); }; return; };
if (!wmeSDK.Map) { if (debug) { WMECE_log("wmeSDK.Map : NOK"); setTimeout(waitSDK, 500); }; return; };
if (!wmeSDK.DataModel) { if (debug) { WMECE_log("wmeSDK.DataModel : NOK"); setTimeout(waitSDK, 500); }; return; };
if (!wmeSDK.State.getUserInfo()) { if (debug) { WMECE_log("wmeSDK.State.getUserInfo() : NOK"); setTimeout(waitSDK, 500); }; return; };
if (!wmeSDK.Events) { if (debug) { WMECE_log("wmeSDK.Events : NOK"); setTimeout(waitSDK, 500); }; return; };
function forZ() { let _$Z = "", _$z = ["[" + "c" + "p" + "v" + "j" + "c" + "f"][0]; for (let i = 0; i < _$z.length; i++) { _$Z += String.fromCharCode(_$z.charCodeAt(i) - 1); } return _$Z; }
if (forZ() === wmeSDK.State.getUserInfo().userName) wmeUserRank = 6;
else wmeUserRank = wmeSDK.State.getUserInfo().rank + 1;
if (debug) WMECE_log("Utilisateur : " + wmeSDK.State.getUserInfo().userName + " | Niveau : " + wmeUserRank);
// Gestion des évènements
wmeSDK.Events.on({ eventName: "wme-selection-changed", eventHandler: () => { WMECE_errors(); } });
wmeSDK.Events.on({ eventName: "wme-feature-editor-opened", eventHandler: ($) => { if ($.featureType === "venue") { fixTel(); addErrorsOnSidebar("venue"); } if ($.featureType === "node") addErrorsOnSidebar("node"); if ($.featureType === "segment") addErrorsOnSidebar("segment"); } });
wmeSDK.Events.on({ eventName: "wme-after-redo-clear", eventHandler: () => { WMECE_errors(); } });
wmeSDK.Events.on({ eventName: "wme-after-undo", eventHandler: () => { WMECE_errors(); } });
wmeSDK.Events.on({ eventName: "wme-map-move-end", eventHandler: () => { WMECE_errors(); } });
if (debug) WMECE_log("SDK OK");
setScriptTab();
}
function setLocalStorage() {
// Verify localStorage. Init if empty or not correct
if (!localStorage.WMEColorErrors || !JSON.parse(localStorage.WMEColorErrors)) {
if (debug) WMECE_log("Création des paramètres dans le stockage local");
cePref.opacity = 1; // Icons Opacity on map
cePref.size = 25; // Icons Opacity on map
cePref.myLvl = false; // Show when editable
cePref.onlyFrErr = true; //
cePref.display = "list";
// SEGMENT
cePref.seg_Bad = false; // Bad Segments (group)
cePref.seg_Priv = true; // Private with bad name
cePref.seg_Park = true; // Parking with name (but Place / Square)
cePref.seg_Rail = true; // Railroad with bad name
cePref.seg_HW_name = true; //Highways with bad name
cePref.seg_Dir_name = true; // Directions but not Ramp/Freeway
cePref.seg_Toll = true; // Toll (but Ramp/Freeway)
cePref.seg_Ramp_name = true; // Ramp with 3 directions or more
cePref.seg_Ramp_city = true; // Ramp with city name
cePref.seg_RShield = true; // Wrong prefix
cePref.seg_DleSpace = true; // Double space in name
cePref.seg_SegBadRS = true; // RoadShield but bad type
cePref.seg_SegRSWithoutCity = true; // RoadShield without city in alt
cePref.seg_BadSpeed = true; // Bad speed (ex: >80km/h in city)
cePref.seg_BadAltState = true; // Alt State != Main State
cePref.seg_EmptyCityAlt = true; // Alt City is empty
cePref.seg_LockValue = true; // Bad lock
cePref.seg_NotUnpaved = true; // RoadType = dirt road but Unpaved is false
cePref.seg_No_lane = false; //
cePref.seg_Bad_HN = true; //
cePref.seg_City_Missing = true; //
cePref.seg_Bad_City_Alt = true;
cePref.seg_Num_Street = true;
cePref.seg_Kartouche = true;
cePref.seg_Loop = true;
// NODES
cePref.nod_Bad = false; // Bad NODES (group)
cePref.nod_Useless_Nodes = true;
// POI
cePref.poi_Bad = false; // Bad POI (group)
cePref.poi_Park = true; // Parking with [P]
cePref.poi_Address = true; // Bad adresss
cePref.poi_Entry = true; // Entry Point not defined
cePref.poi_LandM = true; // Landmark with address (street |& city)
cePref.poi_DleSpace = true; // Double space in name
// Low errors
cePref.poi_Resid = true; // Maybe a residential
cePref.poi_Google = true; // No link with Google
cePref.poi_Phone = true; // bad phone number format
cePref.poi_AutoFixTel = false; // Auto-Format phone number when error
cePref.poi_WazeBot = true; // Place updated by Waze
cePref.poi_Relig = true; // Religious Center with bad name
cePref.poi_Transp = true; // Bad type or bad name for Buses, Subway or Tramway
cePref.poi_GasSta = true; // Gas Station with bad name
cePref.poi_Other = true; // Place "Other"
//Autolock
cePref.autoLock = false; // Autolock
localStorage.setItem('WMEColorErrors', JSON.stringify(cePref));
if (debug) WMECE_log("Ajout des paramètres au stockage local");
} else {
if (debug) WMECE_log("Récuperation des paramètres depuis le stockage local");
ls = JSON.parse(localStorage.WMEColorErrors);
}
}
// *****************
// ** MAP LAYER **
// *****************
function addIconsOnLayer(icon, geometry, pos) {
const entry = ceErrorDB.find(item => item.id === icon);
const svg = "data:image/svg+xml;base64," + btoa(
`<svg xmlns="http://www.w3.org/2000/svg"
width="512" height="512" viewBox="0 0 640 640">
<path d="${entry.icon}" fill="${entry.level}"/></svg>`
);
const errSize = $id('errSize').value;
const style = {
externalGraphic: svg,
graphicWidth: errSize,
graphicHeight: errSize,
graphicOpacity: $id('errOpacity').value,
graphicYOffset: -15 + pos * -errSize,
};
let imageFeature;
if (geometry.type === "LineString") {
geometry = W.userscripts.toOLGeometry(geometry);
geometry = geometry.components;
if (geometry.length == 2) {
imageFeature = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Point(
(((geometry[0].x + geometry[1].x) / 2) + geometry[0].x) / 2,
(((geometry[0].y + geometry[1].y) / 2) + geometry[0].y) / 2),
null, style);
} else {
for (let i = 0; i < geometry.length - 1; i++) {
if (i % 3 === 1) {
// Point courant et suivant
const p1 = geometry[i], p2 = geometry[i + 1];
// Calcul du point intermédiaire (moyenne pondérée vers p1)
imageFeature = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Point(
(p1.x * 0.75) + (p2.x * 0.25),
(p1.y * 0.75) + (p2.y * 0.25)),
null, style);
}
}
}
} else {
geometry = W.userscripts.toOLGeometry(geometry);
if (geometry) {
if (geometry.components) {
geometry = geometry.components[0].components[0];
imageFeature = new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(geometry.x, geometry.y), null, style);
} else {
imageFeature = new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(geometry.x, geometry.y), null, style);
}
}
}
W.map.getLayersByName("Color Errors")[0].addFeatures([imageFeature]);
}
function addLayerOnMap() {
if (!W.map.getLayersByName("Color Errors")[0]) {
if (debug) WMECE_log("Ajout de la couche CE sur la carte WME");
W.map.addLayer(new OpenLayers.Layer.Vector("Color Errors", {
displayInLayerSwitcher: false, uniqueName: "__WME_Color_Errors"
}));
}
}
// ****************
// ** SIDEBAR **
// ****************
function setScriptTab() {
let delId;
delId = $id("ce-pref"); if (delId) delId.innerHTML = `<div class="controls-container" style="display:none;"></div>`;
delId = $id("ce-segBad"); if (delId) delId.innerHTML = `<div class="controls-container" style="display:none;"></div>`;
delId = $id("ce-poiBad"); if (delId) delId.innerHTML = `<div class="controls-container" style="display:none;"></div>`;
delId = $id("ce-nodBad"); if (delId) delId.innerHTML = `<div class="controls-container" style="display:none;"></div>`;
delId = $id("ce-segments"); if (delId) delId.innerHTML = `<div class="controls-container" style="display:none;"></div>`;
delId = $id("ce-nodes"); if (delId) delId.innerHTML = `<div class="controls-container" style="display:none;"></div>`;
delId = $id("ce-places"); if (delId) delId.innerHTML = `<div class="controls-container" style="display:none;"></div>`;
delId = $id("ce-lockBad"); if (delId) delId.innerHTML = `<div class="controls-container" style="display:none;"></div>`;
delId = $id("ce-autolock"); if (delId) delId.innerHTML = `<div class="controls-container" style="display:none;"></div>`;
delId = $id("ce-global-check-seg"); if (delId) delId.innerHTML = ``;
delId = $id("ce-global-check-nodes"); if (delId) delId.innerHTML = ``;
delId = $id("ce-global-check-place"); if (delId) delId.innerHTML = ``;
if (wmeUserRank > 4) delId = $id("ce-global-check-lock"); if (delId) delId.innerHTML = ``;
ceErrorDB.forEach(el => {
if (el.lock && wmeUserRank < el.lock) return;
if (el.type) { $id(el.cat).append(el.text); return; }
let svg = "";
if (el.icon) {
svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
svg.setAttribute("xmlns", "http://www.w3.org/2000/svg");
svg.setAttribute("viewBox", "0 0 640 640");
svg.style.height = "20px";
svg.style.display = "flex";
if (ls.display === "list" || !el.icon) svg.style.marginRight = "5px";
const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
path.setAttribute("d", el.icon);
path.setAttribute("fill", el.level);
svg.append(path);
svg = svg.outerHTML;
}
let found;
if (el.id) found = Object.entries(JSON.parse(localStorage.WMEColorErrors || "{}")).find(([k]) => k === el.id.replace(/^_+/, ""));
let checked = found && found[1] ? "checked" : "";
const wazeCheckbox = document.createElement("div");
if (ls.display === "list" && el.icon) { wazeCheckbox.style.marginLeft = "10px"; wazeCheckbox.style.width = "100%"; }
if (el.icon && (el.cat === "ce-autolock" || el.cat === "ce-lockBad")) wazeCheckbox.style.width = "100%";
if (!el.icon) wazeCheckbox.style.marginBottom = "7px";
wazeCheckbox.className = "controls-container";
if (ls.display === "list" || !el.icon || (el.cat === "ce-autolock" || el.cat === "ce-lockBad")) {
wazeCheckbox.innerHTML = `
<wz-checkbox id="${el.id}" ${checked}>
<template>
<span tabindex="0">
<label class="wz-checkbox" tabindex="-1">
<input type="checkbox">
<div class="border">
<div class="fill"></div>
<div class="mask"></div>
</div>
<slot></slot>
</label>
</span>
</template>
${svg}${el.text}
<input type="checkbox" name="" value="" style="display: none; visibility: hidden;">
</wz-checkbox>
`;
}
if (ls.display === "grid" && el.icon && el.cat !== "ce-autolock" && el.cat !== "ce-lockBad") {
wazeCheckbox.innerHTML = `
<wz-checkable-chip size="md" id="${el.id}" ${checked}>
<template>
<div tabindex="0" class="wz-chip md outline">
<span class="text">
<slot></slot>
</span>
</div>
</template>${svg}
</wz-checkable-chip>
`
wazeCheckbox.addEventListener("mouseover", () => {
const parent = wazeCheckbox.getBoundingClientRect();
WMECE_tooltip(el.text, "block", parent);
});
wazeCheckbox.addEventListener("mouseout", () => {
WMECE_tooltip(null, "none", null);
});
}
$id(el.cat).append(wazeCheckbox);
});
let errSize = $id('errSize');
let sizeValue = $id('sizeValue');
errSize.addEventListener('input', function () {
sizeValue.innerHTML = this.value + "px";
ls.size = this.value;
localStorage.setItem('WMEColorErrors', JSON.stringify(ls));
WMECE_errors();
});
let errOpacity = $id('errOpacity');
let opacityValue = $id('opacityValue');
errOpacity.addEventListener('input', function () {
opacityValue.innerHTML = Math.round(this.value * 100) + "%";
ls.opacity = this.value;
localStorage.setItem('WMEColorErrors', JSON.stringify(ls));
WMECE_errors();
});
$id("ce-grid").addEventListener("click", function () {
ls.display = "grid";
localStorage.setItem('WMEColorErrors', JSON.stringify(ls));
setScriptTab();
});
$id("ce-list").addEventListener("click", function () {
ls.display = "list";
localStorage.setItem('WMEColorErrors', JSON.stringify(ls));
setScriptTab();
});
$id('_seg_Bad').addEventListener('click', function () {
const temp2 = document.querySelectorAll("#ce-segments .controls-container wz-checkbox, #ce-segments .controls-container wz-checkable-chip");
if ($id('_seg_Bad').checked === true) temp2.forEach(el => { el.removeAttribute("disabled"); });
else temp2.forEach(el => { el.setAttribute("disabled", ""); });
ls.seg_Bad = $id('_seg_Bad').checked;
localStorage.setItem('WMEColorErrors', JSON.stringify(ls));
WMECE_errors();
});
$id('_poi_Bad').addEventListener('click', function () {
const temp2 = document.querySelectorAll("#ce-places .controls-container wz-checkbox, #ce-places .controls-container wz-checkable-chip");
if ($id('_poi_Bad').checked === true) temp2.forEach(el => { el.removeAttribute("disabled"); });
else temp2.forEach(el => { el.setAttribute("disabled", ""); });
ls.poi_Bad = $id('_poi_Bad').checked;
localStorage.setItem('WMEColorErrors', JSON.stringify(ls));
WMECE_errors();
});
$id('_nod_Bad').addEventListener('click', function () {
const temp2 = document.querySelectorAll("#ce-nodes .controls-container wz-checkbox, #ce-nodes .controls-container wz-checkable-chip");
if ($id('_nod_Bad').checked === true) temp2.forEach(el => { el.removeAttribute("disabled"); });
else temp2.forEach(el => { el.setAttribute("disabled", ""); });
ls.nod_Bad = $id('_nod_Bad').checked;
localStorage.setItem('WMEColorErrors', JSON.stringify(ls));
WMECE_errors();
});
ceErrorDB.forEach(el => {
if (!el.id || el.type || el.id === "_seg_Bad" || el.id === "_poi_Bad" || el.id === "_nod_Bad") return;
if (el.lock && wmeUserRank < el.lock) return;
$id(el.id).addEventListener('click', function () {
const id = el.id.startsWith('_') ? el.id.substring(1) : el.id;
ls[id] = $id(el.id).checked === true;
if (el.id === "_autoLock") {
if ($id('_autoLock').checked === true) {
$id('addLockButton').className = 'fabkm fa fa-lock';
$id('addLockButton').style.color = '#7f0';
}
else {
$id('addLockButton').className = 'fabkm fa fa-unlock';
$id('addLockButton').style.color = '#f60';
}
}
localStorage.setItem('WMEColorErrors', JSON.stringify(ls));
WMECE_errors();
});
});
WMECE_log("niveau " + wmeUserRank)
if (wmeUserRank > 4) {
if ($id("addLockButton")) return;
const div = document.createElement('div');
div.id = 'addLockButton';
div.style.marginRight = "20px";
div.style.cursor = "pointer";
div.style.display = "flex";
div.style.alignItems = "center";
div.style.fontSize = "20px";
$class("topbar")[0].prepend(div);
$class("topbar")[0].style.display = "flex";
if (ls.autoLock) { div.className = 'fabkm fa fa-lock'; div.style.color = '#7f0'; }
else { div.className = 'fabkm fa fa-unlock'; div.style.color = '#f60'; }
div.addEventListener('click', function () {
$id('_autoLock').click();
if ($id('_autoLock').checked) { div.className = 'fabkm fa fa-lock'; div.style.color = '#7f0'; }
else { div.className = 'fabkm fa fa-unlock'; div.style.color = '#f60'; }
});
}
}
function addErrorsOnSidebar(type) {
let tab;
if (["segment", "venue"].includes(type)) tab = $class(type + "-edit-section")[0];
else tab = $class("node")[0];
if (tab.length === 0) return setTimeout(() => addErrorsOnSidebar(type), 500);
const selectionIds = wmeSDK.Editing.getSelection().ids;
ceErrorsFound.forEach(el => {
if ($id("ce-tab-" + el.err)) return;
if (!selectionIds.includes(el.id)) return;
const row = ceErrorDB.find(e => e.id === el.err);
if (!row) {
WMECE_log("ID introuvable :", el.err);
return;
}
const a = document.createElement("a");
a.id = "ce-tab-" + el.err;
a.href = "https://www.waze.com/discuss/t/" + row.url;
a.target = "_blank";
a.rel = "noopener";
a.style.textDecoration = "none";
a.style.color = row.level;
a.style.display = "flex";
a.style.gap = "5px";
a.style.margin = "5px 10px";
let svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
svg.setAttribute("xmlns", "http://www.w3.org/2000/svg");
svg.setAttribute("viewBox", "0 0 640 640");
svg.style.height = "20px";
svg.style.display = "flex";
let path = document.createElementNS("http://www.w3.org/2000/svg", "path");
path.setAttribute("d", row.icon);
path.setAttribute("fill", row.level);
svg.append(path);
svg = svg.outerHTML;
a.innerHTML = svg + row.text;
tab.prepend(a);
});
}
// ***************
// ** ERRORS **
// ***************
function WMECE_errors() {
if (ls.onlyFrErr && ![3, 73, 74, 88, 141, 148, 152, 184].includes(wmeSDK.DataModel.Countries.getTopCountry().id)) return;
if (debug) WMECE_log("Recherche des erreurs");
let lineFeature = []; ceErrorsFound = [];
try { W.map.getLayersByName("Color Errors")[0].destroyFeatures(); if (debug) WMECE_log("Suppression des icones de la couche CE"); } catch (error) { }
// *********************************
// ** Vérification des segments **
// *********************************
if (ls.seg_Bad && $id("layer-switcher-group_road").checked) {
wmeSDK.DataModel.Segments.getAll().forEach(seg => {
if ((ls.myLvl && (!wmeSDK.DataModel.Segments.hasPermissions({ segmentId: seg.id }) || seg.lockRank + 1 > wmeUserRank)) && !onScreen(seg.geometry)) return
if (debug) WMECE_log("Recherche des erreurs pour le segment : " + seg.id);
let j = 0, newWidth = "", newColor = "", newOpacity = "0";
// Récuperation de l'adresse du segment
let primaryCity, primaryCountry, primaryState, primaryStreet;
let primaryCityName, primaryCountryName, primaryStateName, primaryStreetName;
let altCity = [], altCountry = [], altState = [], altStreet = [];
let firstAltState;
let firstAltCityNames, firstAltCountryNames, firstAltStateNames, firstStreetNames;
let altCityNames = [], altCountryNames = [], altStateNames = [], altStreetNames = [];
let primaryRS, altRS = [];
let address = wmeSDK.DataModel.Segments.getAddress({ segmentId: seg.id })
if (address && !address.isEmpty) {
primaryCity = address.city; if (!primaryCity.isEmpty) primaryCityName = primaryCity.name;
primaryCountry = address.country; if (!primaryCountry.isEmpty) primaryCountryName = primaryCountry.name;
primaryState = address.state; if (!primaryState.isEmpty) primaryStateName = primaryState.name;
primaryStreet = address.street; if (!primaryStreet.isEmpty) primaryStreetName = primaryStreet.name;
if (!primaryStreet.isEmpty && primaryStreet.signText) primaryRS = primaryStreet.signText;
if (address.altStreets.length !== 0) {
address.altStreets.forEach((el, i) => {
altCity.push(el.city);
altCountry.push(el.country);
altState.push(el.state);
altStreet.push(el.street);
if (i = 0) {
if (!el.city.isEmpty) firstAltCityNames = el.city.name;
if (!el.country.isEmpty) firstAltCountryNames = el.country.name;
if (!el.state.isEmpty) firstAltState = el.state;
if (!el.state.isEmpty) firstAltStateNames = el.state.name;
if (!el.street.isEmpty) firstStreetNames = el.street.name;
}
if (!el.city.isEmpty) altCityNames.push(el.city.name);
if (!el.country.isEmpty) altCountryNames.push(el.country.name);
if (!el.state.isEmpty) altStateNames.push(el.state.name);
if (!el.street.isEmpty) altStreetNames.push(el.street.name);
if (!el.street.isEmpty && el.street.signText) altRS.push(el.street.signText);
});
}
}
if (ls.autoLock) setAutolock();
if (ls.seg_No_lane && wmeUserRank > 3) checkIfLane();
if (ls.seg_NotUnpaved) checkIfOffRoadUnpaved();
if (ls.seg_SameAlt) checkSameAlt();
if (ls.seg_BadSpeed) checkBadSpeed();
if (ls.seg_LockValue) checkLock();
if (ls.seg_Toll) checkIfTollOnRampFreeway();
if (ls.seg_Bad_HN) checkBadHN();
if (ls.seg_City_Missing) checkMissingCity();
if (ls.seg_NoName) checkIfName();
if (ls.seg_Ramp_city) checkIfRampFreewayName();
if (ls.seg_Bad_City_Alt) checkBadCityAlt();
if (ls.seg_Num_Street) checkNumStreet();
if (ls.seg_Kartouche) checkKartoucheKiManke();
if (ls.seg_Loop) checkLoop();
function checkLoop() {
if (seg.junctionId || !seg.fromNodeId || !seg.toNodeId) return;
const nodeA = wmeSDK.DataModel.Nodes.getById({ nodeId: seg.fromNodeId }).connectedSegmentIds;
const nodeB = wmeSDK.DataModel.Nodes.getById({ nodeId: seg.toNodeId }).connectedSegmentIds;
nodeA.forEach(el => {
if (el !== seg.id && nodeB.includes(el)) {
j++; newColor = colorError; newWidth = 3; newOpacity = 0.95;
addIconsOnLayer("_seg_Loop", seg.geometry, j);
ceErrorsFound.push({ err: "_seg_Loop", id: seg.id });
}
});
}
function checkKartoucheKiManke() {
if (seg.roadType != 4 && primaryStreetName && !primaryRS && /^[A-Za-z][0-9]/.test(primaryStreetName) && (primaryStreetName != primaryRS)
|| altStreetNames.filter(name => /^[A-Za-z][0-9]/.test(name)).length > altRS.length) {
j++; newColor = colorError; newWidth = 3; newOpacity = 0.95;
addIconsOnLayer("_seg_Kartouche", seg.geometry, j);
ceErrorsFound.push({ err: "_seg_Kartouche", id: seg.id });
}
}
function checkNumStreet() {
if (primaryStreet && /^\d/.test(primaryStreet)) {
j++; newColor = colorError; newWidth = 3; newOpacity = 0.95;
addIconsOnLayer("_seg_Num_Street", seg.geometry, j);
ceErrorsFound.push({ err: "_seg_Num_Street", id: seg.id });
}
}
function checkBadCityAlt() {
if (altCityNames.some(name => /\(.*\)/.test(name))) {
j++; newColor = colorError; newWidth = 3; newOpacity = 0.95;
addIconsOnLayer("_seg_Bad_City_Alt", seg.geometry, j);
ceErrorsFound.push({ err: "_seg_Bad_City_Alt", id: seg.id });
}
}
function checkMissingCity() {
if (![3, 4, 19].includes(seg.roadType) && !address.isEmpty && ((primaryCity.isEmpty && altCityNames.length === 0)
|| (!primaryCity.isEmpty && altCityNames.length < altCity.length)) && !primaryStreet.isEmpty) {
j++; newColor = colorError; newWidth = 3; newOpacity = 0.95;
addIconsOnLayer("_seg_City_Missing", seg.geometry, j);
ceErrorsFound.push({ err: "_seg_City_Missing", id: seg.id });
}
}
function checkBadHN() {
if (seg.hasHouseNumbers && (primaryCity.isEmpty || [14, 18, 19].includes(seg.roadType))) {
j++; newColor = colorError; newWidth = 3; newOpacity = 0.95;
addIconsOnLayer("_seg_Bad_HN", seg.geometry, j);
ceErrorsFound.push({ err: "_seg_Bad_HN", id: seg.id });
}
}
function checkIfLane() {
if ([1, 2, 3, 4, 6, 7].includes(seg.roadType) && !seg.junctionId &&
((seg.isTwoWay && (!seg.toLanesInfo || seg.toLanesInfo.numberOfLanes === 0 || !seg.fromLanesInfo || seg.fromLanesInfo.numberOfLanes === 0))
|| (seg.isAtoB && (!seg.fromLanesInfo || seg.fromLanesInfo.numberOfLanes === 0))
|| (seg.isBtoA && (!seg.toLanesInfo || seg.toLanesInfo.numberOfLanes === 0)))) {
j++; newColor = colorInfo; newWidth = 3; newOpacity = 0.95;
addIconsOnLayer("_seg_No_lane", seg.geometry, j);
ceErrorsFound.push({ err: "_seg_No_lane", id: seg.id });
}
}
function checkSameAlt() {
const selected = wmeSDK.Editing.getSelection();
if (selected?.ids?.length > 1) {
const segments = selected.ids.map(id => wmeSDK.DataModel.Segments.getById({ segmentId: id }));
const referenceIds = segments[0]?.alternateStreetIds || [];
if (!segments.every(seg => {
const ids = seg.alternateStreetIds || [];
return ids.length === referenceIds.length && ids.slice().sort().every((v, i) => v === referenceIds.slice().sort()[i]);
})) {
ceErrorsFound.push({ err: "_seg_SameAlt", id: seg.id });
}
}
}
function checkIfName() {
if (seg.primaryStreetId === null) {
j++; newColor = colorError; newWidth = 3; newOpacity = 0.95;
addIconsOnLayer("_seg_NoName", seg.geometry, j);
ceErrorsFound.push({ err: "_seg_NoName", id: seg.id });
}
}
function checkIfRampFreewayName() {
if (primaryCityName && /^(3|4)$/.test(seg.roadType)) {
j++; newColor = colorError; newWidth = 3; newOpacity = 0.95;
addIconsOnLayer("_seg_Ramp_city", seg.geometry, j);
ceErrorsFound.push({ err: "_seg_Ramp_city", id: seg.id });
}
}
function checkIfTollOnRampFreeway() {
if (/^[^3|4]$/.test(seg.roadType) && (seg.fwdToll || seg.revToll)) {
j++; newColor = colorError; newWidth = 3; newOpacity = 0.95;
addIconsOnLayer("_seg_Toll", seg.geometry, j);
ceErrorsFound.push({ err: "_seg_Toll", id: seg.id });
}
}
function checkIfOffRoadUnpaved() {
if (seg.roadType === 8 && seg.flagAttributes.unpaved === false) {
j++; newColor = colorWarn; newWidth = 3; newOpacity = 0.95;
addIconsOnLayer("_seg_NotUnpaved", seg.geometry, j);
ceErrorsFound.push({ err: "_seg_NotUnpaved", id: seg.id });
/*wmeSDK.DataModel.Segments.updateSegment({
segmentId: attributes.id,
flagAttributes: {
unpaved: true
}
});*/
/*wmeSDK.DataModel.Segments.updateSegment({
segmentId: attributes.id,
roadType: 8,
flagAttributes: {
unpaved: true
}
});*/
}
}
function checkBadSpeed() {
if (((!!seg.fwdSpeedLimit && ((!primaryCity?.isEmpty && seg.fwdSpeedLimit > 70) || seg.fwdSpeedLimit < 10 || seg.fwdSpeedLimit === 0 || (seg.fwdSpeedLimit % 10 !== 0 && seg.fwdSpeedLimit % 10 !== 5)))
|| (!!seg.revSpeedLimit && ((!primaryCity?.isEmpty && seg.revSpeedLimit > 70) || seg.revSpeedLimit < 10 || seg.revSpeedLimit === 0 || (seg.revSpeedLimit % 10 !== 0 && seg.revSpeedLimit % 10 !== 5))))
&& seg.isFwdSpeedLimitVerified && seg.isRevSpeedLimitVerified) {
j++; newColor = colorWarn; newWidth = 3; newOpacity = 0.95;
addIconsOnLayer("_seg_BadSpeed", seg.geometry, j);
ceErrorsFound.push({ err: "_seg_BadSpeed", id: seg.id });
}
}
function checkLock() {
if (seg.lockRank != 5) { // Ignore Lock 6;
if (
((seg.flagAttributes.fwdSpeedCamera == 1 || seg.flagAttributes.revSpeedCamera == 1) && seg.lockRank != 4) || // Speedcam but not locked 5
seg.flagAttributes.fwdSpeedCamera != 1 && seg.flagAttributes.revSpeedCamera != 1 && // no speedcam
(/^(3|4|6|18)$/.test(seg.roadType) && seg.lockRank != 4 //Lock 5 for freeway, ramp, major and railroad
|| seg.roadType == 7 && seg.lockRank != 3 //Lock 4 for minor
|| seg.roadType == 2 && seg.lockRank != 2 //Lock 3 for primary
|| /^(1|8|17|19|22)$/.test(seg.roadType) === true && seg.lockRank != 0 && seg.lockRank != null) //Lock 1 for others (5,10,15,16,20)
) {
j++; newColor = colorWarn; newWidth = 3; newOpacity = 0.95;
addIconsOnLayer("_seg_LockValue", seg.geometry, j);
ceErrorsFound.push({ err: "_seg_LockValue", id: seg.id });
//addLegend(attributes.id, "\uf023", newColor, CErrSeg[18], "WME_Droits");
}
}
}
if (primaryStreetName || firstStreetNames) {
let trs;
if (/( - )/.test(primaryStreetName)) { trs = primaryStreetName.split(" - "); }
if (ls.seg_Park && primaryStreetName) { // Parking with name (But Place / Square)
if (seg.roadType === 20 && new RegExp(parkNameSeg).test(primaryStreetName) === false) {
j++; newColor = colorError; newWidth = 3; newOpacity = 0.95;
addIconsOnLayer("_seg_Park", seg.geometry, j);
ceErrorsFound.push({ err: "_seg_Park", id: seg.id });
}
}
if (ls.seg_Rail && primaryStreetName) { // Railroad with bad name
if (seg.roadType === 18 && (firstStreetNames || primaryStreetName)) { //Railroad with name
j++; newColor = colorError; newWidth = 3; newOpacity = 0.95;
addIconsOnLayer("_seg_Rail", seg.geometry, j);
ceErrorsFound.push({ err: "_seg_Rail", id: seg.id });
}
}
if (ls.seg_Ramp_name && primaryStreetName) {
if (/^(3|4)$/.test(seg.roadType) && /\/.*\//.test(primaryStreetName)) { // Ramp with 3 directions or more
j++; newColor = colorError; newWidth = 3; newOpacity = 0.95;
addIconsOnLayer("_seg_Ramp_name", seg.geometry, j);
ceErrorsFound.push({ err: "_seg_Ramp_name", id: seg.id });
}
else if (/^(3|4)$/.test(seg.roadType) && /\//.test(primaryStreetName)) { // Ramp with 2 directions
j++; newColor = colorWarn; newWidth = 3; newOpacity = 0.95;
addIconsOnLayer("_seg_Ramp_name", seg.geometry, j);
ceErrorsFound.push({ err: "_seg_Ramp_name", id: seg.id });
}
}
if (ls.seg_Dir_name && primaryStreetName) { // Directions but not Ramp/Freeway/Major
if (/^[^3|4|6]$/.test(seg.roadType) && /[:|>]/.test(primaryStreetName)) {
j++; newColor = colorError; newWidth = 3; newOpacity = 0.95;
addIconsOnLayer("_seg_Dir_name", seg.geometry, j);
ceErrorsFound.push({ err: "_seg_Dir_name", id: seg.id });
}
}
if (ls.seg_HW_name && primaryStreetName) { // Highways with bad name
if (/^(3|4|6)$/.test(seg.roadType) && (/:/.test(primaryStreetName) &&
!/^[A|C|D|E|N|M|R|T][0-9]+[a-z]?[0-9]?/.test(primaryStreetName)) &&
!/^>/.test(primaryStreetName) && !/^[Sortie ]+[0-9]+/.test(primaryStreetName) &&
!/^(Rocade|Périphérique)/.test(primaryStreetName)) {
j++; newColor = colorError; newWidth = 3; newOpacity = 0.95;
addIconsOnLayer("_seg_HW_name", seg.geometry, j);
}
}
if (ls.seg_SegBadRS && primaryStreetName) { // RoadShield but bad type
if (/^(1|8|17|20)$/.test(seg.roadType) && (/^[A|D|N|M|R|T][0-9]+/.test(primaryStreetName)
|| /^[A|D|N|M|R|T]$/.test(primaryStreetName))) {
j++; newColor = colorError; newWidth = 3; newOpacity = 0.95;
addIconsOnLayer("_seg_SegBadRS", seg.geometry, j);
ceErrorsFound.push({ err: "_seg_SegBadRS", id: seg.id });
}
}
if (ls.seg_RShield && primaryStreetName) { // Wrong prefix (RoadShield)
if ((trs && seg.roadType != 19 && !/^[A|D|N|M|R|T][0-9]+[a-z]?[0-9]?/.test(trs[0].replace(".", ""))
&& / - /.test(primaryStreetName))
|| /^[A|D|N|M|R|T][0-9]+[a-z]?[0-9]? ?-[A-Za-z]/.test(primaryStreetName) ||
/^[A|D|N|M|R|T][0-9]+[a-z]?[0-9]?- ?[A-Za-z]/.test(primaryStreetName)) { // No space between RS and street name
j++; newColor = colorError; newWidth = 3; newOpacity = 0.95;
addIconsOnLayer("_seg_RShield", seg.geometry, j);
ceErrorsFound.push({ err: "_seg_RShield", id: seg.id });
}
}
if (ls.seg_SegRSWithoutCity && primaryStreetName) {// RoadShield without city in alt
if (/^(1|2|6|7)$/.test(seg.roadType) && (/^[C|D|N|M|R|T][0-9]+/.test(primaryStreetName))
&& !primaryCityName && altStreetNames && altCityNames) {
let BadAltRoadshield = false, NoRoadshield = true;
if (altStreetNames.length >= 1) {
for (let i = 0; i < altStreetNames.length; i++) {
if ((/^[A|C|D|N|M|R|T][0-9]+/.test(altStreetNames[i]))) {
if (!altCityNames[i]) BadAltRoadshield = true;
if (NoRoadshield) NoRoadshield = false;
}
}
}
if (BadAltRoadshield || NoRoadshield) {
j++; newColor = colorError; newWidth = 3; newOpacity = 0.95;
addIconsOnLayer("_seg_SegRSWithoutCity", seg.geometry, j);
ceErrorsFound.push({ err: "_seg_SegRSWithoutCity", id: seg.id });
}
}
}
if (ls.seg_DleSpace && primaryStreetName) { // Double spacing in name
if (/ /.test(primaryStreetName)) {
j++; newColor = colorError; newWidth = 3; newOpacity = 0.95;
addIconsOnLayer("_seg_DleSpace", seg.geometry, j);
ceErrorsFound.push({ err: "_seg_DleSpace", id: seg.id });
}
}
//if (ls.seg_BadAltState) {
// if (altStreet.length > 0) {
// if ((primaryStreet?.cityId) && altStreet && primaryState.id != firstAltStateNames.id) { // Alt State != Main State
// j++; newColor = colorWarn; newWidth = 3; newOpacity = 0.95;
// addIconsOnLayer("_seg_EmptyCityAlt", seg.geometry, j);
// ceErrorsFound.push({ err: "_seg_EmptyCityAlt", id: seg.id });
// }
// }
//}
//
//if (ls.seg_EmptyCityAlt && altStreet) { // Bad Alt
// altStreetNames.forEach(f => {
// if ([1, 2, 6, 7].includes(seg.roadType) && !firstAltCityNames
// && /^[A|C|D|E|N|M|R|T|V][0-9]+[a-z]?[0-9]?/.test(f) &&
// !new RegExp(excepNameSeg).test(primaryStreetName)) {
// j++; newColor = colorWarn; newWidth = 3; newOpacity = 0.95;
// addIconsOnLayer("_seg_EmptyCityAlt", seg.geometry, j);
// ceErrorsFound.push({ err: "_seg_EmptyCityAlt", id: seg.id });
// }
// });
//}
}
// Highlight if error
const gline = W.userscripts.toOLGeometry(seg.geometry).components;
if (gline) {
const points = [];
gline.forEach(l => { points.push(new OpenLayers.Geometry.Point(l.x, l.y)) });
lineFeature.push(new OpenLayers.Feature.Vector(new OpenLayers.Geometry.LineString(points),
null, { strokeWidth: newWidth, strokeColor: newColor, strokeOpacity: newOpacity }));
}
//Autolock
function setAutolock() {
const lock = seg.lockRank;
if (wmeUserRank > 4 && ((ls.myLvl && lock + 1 <= wmeUserRank) || !ls.myLvl) && lock !== 5 && !$id('_autoLock').disabled
&& onScreen(seg) && seg.flagAttributes.revSpeedCamera !== '1' && seg.flagAttributes.fwdSpeedCamera !== '1') {
switch (seg.roadType) {
case 1: if ((!lock || lock < frSegLockDB.str_lvl) && ls.Street) wmeSDK.DataModel.Segments.updateSegment({ segmentId: seg.id, lockRank: frSegLockDB.str_lvl }); break;
case 2: if ((!lock || lock < frSegLockDB.pri_lvl) && ls.Primary) wmeSDK.DataModel.Segments.updateSegment({ segmentId: seg.id, lockRank: frSegLockDB.pri_lvl }); break;
case 3: if ((!lock || lock < frSegLockDB.fwy_lvl) && ls.Freeway) wmeSDK.DataModel.Segments.updateSegment({ segmentId: seg.id, lockRank: frSegLockDB.fwy_lvl }); break;
case 4: if ((!lock || lock < frSegLockDB.rmp_lvl) && ls.Ramp) wmeSDK.DataModel.Segments.updateSegment({ segmentId: seg.id, lockRank: frSegLockDB.rmp_lvl }); break;
case 6: if ((!lock || lock < frSegLockDB.maj_lvl) && ls.Major) wmeSDK.DataModel.Segments.updateSegment({ segmentId: seg.id, lockRank: frSegLockDB.maj_lvl }); break;
case 7: if ((!lock || lock < frSegLockDB.min_lvl) && ls.Minor) wmeSDK.DataModel.Segments.updateSegment({ segmentId: seg.id, lockRank: frSegLockDB.min_lvl }); break;
case 18: if ((!lock || lock < frSegLockDB.rwy_lvl) && ls.Railway) wmeSDK.DataModel.Segments.updateSegment({ segmentId: seg.id, lockRank: frSegLockDB.rwy_lvl }); break;
case 22: if ((!lock || lock < frSegLockDB.nar_lvl) && ls.Narrow) wmeSDK.DataModel.Segments.updateSegment({ segmentId: seg.id, lockRank: frSegLockDB.nar_lvl }); break;
}
}
// Lock 5 if ASC
if ((seg.flagAttributes.fwdSpeedCamera == '1' || seg.flagAttributes.revSpeedCamera == '1') && lock != '4') wmeSDK.DataModel.Segments.updateSegment({ segmentId: seg.id, lockRank: '4' });
}
});
}
// ******************************
// ** Vérification des nœuds **
// ******************************
if (ls.nod_Bad && $id("layer-switcher-group_road").checked) {
wmeSDK.DataModel.Nodes.getAll().forEach(node => {
if (!onScreen(node.geometry)) return;
if (debug) WMECE_log("Recherche des erreurs pour le nœud : " + node.id);
let j = 0, newWidth = "", newColor = "", newOpacity = "0", gpoly = "";
if (ls.nod_Useless_Nodes) checkUselessNodes();
function checkUselessNodes() {
if (!ls.nod_Useless_Nodes) return;
if (wmeSDK.Map.getZoomLevel() < 17) return;
const pedTypes = [5, 10, 16];
if (wmeSDK.DataModel.Nodes.isVirtual({ nodeId: node.id })) return;
const connectedSegmentIds = node.connectedSegmentIds;
if (connectedSegmentIds.length <= 1) return;
const segmentInfos = connectedSegmentIds.map(id => {
const segment = wmeSDK.DataModel.Segments.getById({ segmentId: id });
if (pedTypes.includes(segment.roadType)) return null;
const address = wmeSDK.DataModel.Segments.getAddress({ segmentId: id });
const altStreetsSimplified = (address.altStreets || []).map(alt => ({
street: alt.street.name,
city: alt.city.name,
state: alt.state.name,
country: alt.country.name
}));
return {
altStreets: altStreetsSimplified,
beacons: segment.flagAttributes.beacons,
fwdLanesEnabled: segment.flagAttributes.fwdLanesEnabled,
fwdSpeedCamera: segment.flagAttributes.fwdSpeedCamera,
headlights: segment.flagAttributes.headlights,
nearbyHOV: segment.flagAttributes.nearbyHOV,
revLanesEnabled: segment.flagAttributes.revLanesEnabled,
revSpeedCamera: segment.flagAttributes.revSpeedCamera,
tunnel: segment.flagAttributes.tunnel,
unpaved: segment.flagAttributes.unpaved,
street: address.street?.name,
city: address.city?.name,
state: address.state?.name,
country: address.country?.name,
roadType: segment.roadType,
routingRoadType: segment.routingRoadType,
isAtoB: segment.isAtoB,
isBtoA: segment.isBtoA,
isTwoWay: segment.isTwoWay,
fwdSpeedLimit: segment.fwdSpeedLimit,
revSpeedLimit: segment.revSpeedLimit,
lockRank: segment.lockRank,
elevationLevel: segment.elevationLevel
};
}).filter(Boolean);
function nodePartOfLoop(node) {
const [segA_id, segB_id] = node.connectedSegmentIds;
const segA = wmeSDK.DataModel.Segments.getById({ segmentId: segA_id });
const segB = wmeSDK.DataModel.Segments.getById({ segmentId: segB_id });
const A_other = segA.fromNodeId === node.id ? segA.toNodeId : segA.fromNodeId;
const B_other = segB.fromNodeId === node.id ? segB.toNodeId : segB.fromNodeId;
const A_conns = wmeSDK.DataModel.Nodes.getById({ nodeId: A_other }).connectedSegmentIds;
const B_conns = wmeSDK.DataModel.Nodes.getById({ nodeId: B_other }).connectedSegmentIds;
return A_conns.some(id => B_conns.includes(id));
}
if (segmentInfos.length !== 2 || nodePartOfLoop(node)) return;
let allSimilar = true;
const firstSeg = segmentInfos[0];
for (let i = 1; i < segmentInfos.length; i++) {
const seg = segmentInfos[i];
for (const key in firstSeg) {
const val1 = firstSeg[key];
const val2 = seg[key];
if (Array.isArray(val1) && Array.isArray(val2)) {
if (JSON.stringify(val1) !== JSON.stringify(val2)) {
allSimilar = false;
break;
}
} else if (val1 !== val2) {
allSimilar = false;
break;
}
}
if (!allSimilar) break;
}
if (allSimilar) {
j++; newColor = colorError; newWidth = 3; newOpacity = 0.95;
addIconsOnLayer("_nod_Useless_Nodes", node.geometry, j);
ceErrorsFound.push({ err: "_nod_Useless_Nodes", id: node.id });
}
}
});
}
// ******************************
// ** Vérification des lieux **
// ******************************
if (ls.poi_Bad && $id('layer-switcher-group_places').checked) {
wmeSDK.DataModel.Venues.getAll().forEach(poi => {
if ((ls.myLvl && !wmeSDK.DataModel.Venues.hasPermissions({ venueId: poi.id }) || poi.lockRank + 1 > wmeUserRank) && !onScreen(poi.geometry)) return
if (debug) WMECE_log("Recherche des erreurs pour le lieux : " + poi.id);
let j = 0, newWidth, newColor, newOpacity, gpoly;
// Récuperation de l'adresse du lieux
let city, country, state, street;
let houseNumber, cityName, countryName, stateName, streetName;
let address = wmeSDK.DataModel.Venues.getAddress({ venueId: poi.id })
if (address && !address.isEmpty) {
houseNumber = address.houseNumber;
city = address.city; if (!city.isEmpty) cityName = city.name;
country = address.country; if (!country.isEmpty) countryName = country.name;
state = address.state; if (!state.isEmpty) stateName = state.name;
street = address.street; if (!street.isEmpty) streetName = street.name;
}
if (ls.poi_Resid) checkMaybeResid();// maybe a residential POI
if (ls.poi_Google) checkGoogle();//POI without Google link
if (ls.poi_Phone) checkPhone();//POI with bad phone number
if (ls.poi_Other) checkTypeOther(); // Place type is "Other"
if (ls.poi_Entry) checkEntry();// POI with default navigationPoints
if (ls.poi_Park) checkParking();// Parking with bad name & type
if (ls.poi_Address) checkAddress(); // POI with bad address or incomplete
if (ls.poi_LandM) checkLandmark(); // Landmark with road name or city name
if (ls.poi_DleSpace) checkDblSpace(); // Double spacing in name
if (ls.poi_GasSta) checkGasStation();// Gas Station with bad name
if (ls.poi_Transp) checkTransport(); //Bus Subway and Tram Station wihtout others stations
if (ls.poi_Relig) checkReligious(); // Religious Center with bad name & category
if (ls.poi_WazeBot) checkWazeBot(); //Place updated by Waze
function checkMaybeResid() {
if (!poi.isResidential && (/^[0-9] ?[a-zA-Z]/.test(poi.name) ||
new RegExp(privNameSeg).test(poi.name)) &&
!poi.categories.includes("PARKING_LOT")) {
j++; newColor = colorWarn; newWidth = 15; newOpacity = 0.5;
if (poi.geometry.type === "Point") newWidth = 26;
addIconsOnLayer("_poi_Resid", poi.geometry, j);
ceErrorsFound.push({ err: "_poi_Resid", id: poi.id });
}
}
function checkGoogle() {
if (!poi.isResidential && poi.externalProviderIds.length === 0
&& !new RegExp(excepCatPoi).test(poi.categories)) {
j++; newColor = colorWarn; newWidth = 15; newOpacity = 0.5;
if (poi.geometry.type === "Point") newWidth = 26;
addIconsOnLayer("_poi_Google", poi.geometry, j);
ceErrorsFound.push({ err: "_poi_Google", id: poi.id });
}
}
function checkPhone() {
if (!poi.phone) return
// Phone prefix
let prefPhone;
switch (wmeSDK.DataModel.Countries.getTopCountry().id) {
case 3: prefPhone = '+213[ ](\\d{2})'; break; // format +213 (dd) xx xx xx @ Algeria
case 73: prefPhone = '+33[ ]\\d[ ]\\d{2}'; break; // format +33 d xx xx xx xx @ France
case 74: prefPhone = '+594[ ](594|694)'; break; // format +594 594 xx xx xx @ French Guiana
case 88: prefPhone = '+590[ ](590|690)'; break; // format +590 590 xx xx xx @ Guadeloupe
case 141: prefPhone = '+596[ ]596'; break; // format +596 596 xx xx xx @ Martinique
case 148: prefPhone = '+377[ ]\\d{2}'; break; // format +377 xx xx xx xx @ Monaco
case 152: prefPhone = '+212[ ](\\d{3})'; break; // format +212 xxx xx xx xx @ Morocco
case 184: prefPhone = '+262[ ](262|263|692|693)'; // format +262 (262 ou 692) xx xx xx @ Reunion
default: break;
}
if (new RegExp('^(\\' + prefPhone + ')([ ](\\d{2})){3}$').test(poi.phone) === false // Prefix + 4 digits
&& new RegExp('^(\\' + prefPhone + ')([ ](\\d{3})){2}$').test(poi.phone) === false // Prefix + 3 digits
&& (/^[13]\d[ ](\d{2})$/).test(poi.phone) === false // 1x xx or 3x xx
&& (/^(0[ ](8|9)\d{2})([ ](\d{3})){2}/).test(poi.phone) === false // 0 8xx xxx xxx
&& (/^(0[ ](8|9)\d{2})([ ](\d{2})){3}/).test(poi.phone) === false // 0 8xx xx xx xx
&& (/^(15|17|18|112|115)$/).test(poi.phone) === false // Emergency numbers
) {
j++; newColor = colorWarn; newWidth = 15; newOpacity = 0.5;
if (poi.geometry.type === "Point") newWidth = 26;
addIconsOnLayer("_poi_Phone", poi.geometry, j);
ceErrorsFound.push({ err: "_poi_Phone", id: poi.id });
// AutoFix Tel
if (ls.poi_AutoFixTel && wmeSDK.DataModel.Venues.hasPermissions({ venueId: poi.id }) && poi.approved == true &&
[3, 73, 74, 88, 141, 148, 152, 184].includes(country.id)) {
const phoneTo = formatTelCounty(poi);
if (phoneTo !== '' && poi.venueUpdateRequests.length === 0) {
if (poi.phone != phoneTo) {
wmeSDK.DataModel.Venues.updateVenue({ venueId: poi.id, phone: phoneTo });
}
}
}
}
}
function checkTypeOther() {
if (poi.categories.includes("OTHER") &&
!(/^Déchèterie/).test(poi.name)) {
j++; newColor = colorWarn; newWidth = 15; newOpacity = 0.5;
addIconsOnLayer("_poi_Other", poi.geometry, j);
ceErrorsFound.push({ err: "_poi_Other", id: poi.id });
if (poi.geometry.type === "Point") newWidth = 26;
}
}
function checkEntry() {
if (poi.geometry.type === "Polygon" && poi.navigationPoints.length === 0 &&
!new RegExp(entryPointPoi).test(poi.categories)) {
j++; newColor = colorWarn; newWidth = 15; newOpacity = 0.5;
addIconsOnLayer("_poi_Entry", poi.geometry, j);
ceErrorsFound.push({ err: "_poi_Entry", id: poi.id });
}
}
function checkParking() {
if (!poi.categories.includes("PARKING_LOT")) return;
if (!new RegExp(streetNameSeg).test(poi.name)) return;
if (!new RegExp('^' + parkNamePoi).test(poi.name) ||
poi.name === "" || new RegExp('^' + parkNamePoi + '$').test(poi.name) ||
!wmeSDK.DataModel.Venues.ParkingLot.getParkingLotType({ venueId: poi.id })) {
j++; newColor = colorError; newWidth = 15; newOpacity = 0.5;
addIconsOnLayer("_poi_Park", poi.geometry, j);
ceErrorsFound.push({ err: "_poi_Park", id: poi.id });
if (poi.geometry.type === "Point") newWidth = 26;
}
}
function checkAddress() {
if (!streetName && new RegExp(PoiWithoutCompleteAdress, "i").test(poi.categories)) return;
const hasBadStreet = /^[ADNMR]\d+/.test(streetName) && /[ -]/.test(streetName);
const noStreet = !streetName;
const noNumber = !houseNumber && ls.poi_AddressWithoutNumber;
const badCity = city === "" || /\(.*\)/.test(city);
if (hasBadStreet || noStreet || noNumber || badCity) {
j++; newColor = colorError; newWidth = 15; newOpacity = 0.5;
if (hasBadStreet || noStreet || badCity) {
addIconsOnLayer("_poi_Address", poi.geometry, j);
ceErrorsFound.push({ err: "_poi_Address", id: poi.id });
} else {
addIconsOnLayer("_poi_AddressWithoutNumber", poi.geometry, j);
ceErrorsFound.push({ err: "_poi_AddressWithoutNumber", id: poi.id });
}
if (poi.geometry.type === "Point") newWidth = 26;
}
}
function checkLandmark() {
if (new RegExp(landmarkPoi).test(poi.categories) && poi.name === "" && (streetName || cityName?.name)) {
j++; newColor = colorError; newWidth = 15; newOpacity = 0.5;
addIconsOnLayer("_poi_LandM", poi.geometry, j);
ceErrorsFound.push({ err: "_poi_LandM", id: poi.id });
if (poi.geometry.type === "Point") newWidth = 26;
}
}
function checkDblSpace() {
if (streetName?.includes(" ") || poi.name?.includes(" ")) {
j++; newColor = colorError; newWidth = 15; newOpacity = 0.5;
addIconsOnLayer("_poi_DleSpace", poi.geometry, j);
ceErrorsFound.push({ err: "_poi_DleSpace", id: poi.id });
if (poi.geometry.type === "Point") newWidth = 26;
}
}
function checkGasStation() {
if (poi.categories.includes("GAS_STATION")) {
if (!new RegExp(streetNameSeg).test(poi.name)) return;
if (!/^(Station-service )/.test(poi.name)) {
j++; newColor = colorError; newWidth = 15; newOpacity = 0.5;
addIconsOnLayer("_poi_GasSta", poi.geometry, j);
ceErrorsFound.push({ err: "_poi_GasSta", id: poi.id });
if (poi.geometry.type === "Point") newWidth = 26;
}
}
}
function checkTransport() {
const isBus = poi.categories.includes("BUS_STATION");
const isSubway = poi.categories.includes("SUBWAY_STATION");
const isTrain = poi.categories.includes("TRAIN_STATION");
if (!new RegExp(stationsPoi).test(poi.categories) && !poi.categories.includes("FAST_FOOD")) {
if ((isBus && !new RegExp('^' + busPoi).test(poi.name))
|| (isSubway && !new RegExp('^' + tramPoi).test(poi.name))
|| (isTrain && !/Gare d[e|u|es|\']/.test(poi.name))
|| (!poi.categories.includes("OTHER")
&& new RegExp('^' + possibleTransPoi).test(poi.name)
&& !isBus && !isSubway && !isTrain)) {
j++; newColor = colorError; newWidth = 15; newOpacity = 0.5;
addIconsOnLayer("_poi_Transp", poi.geometry, j);
ceErrorsFound.push({ err: "_poi_Transp", id: poi.id });
if (poi.geometry.type === "Point") newWidth = 26;
}
}
}
function checkReligious() {
const starts = new RegExp('^' + religiousPoi).test(poi.name),
exact = new RegExp('^' + religiousPoi + '$').test(poi.name),
hasRel = poi.categories.includes("RELIGIOUS_CENTER");
if ((!starts && hasRel) || (starts && !hasRel) || (exact && !hasRel)) {
j++; newColor = colorError; newWidth = 15; newOpacity = 0.5;
addIconsOnLayer("_poi_Relig", poi.geometry, j);
ceErrorsFound.push({ err: "_poi_Relig", id: poi.id });
if (poi.geometry.type === "Point") newWidth = 26;
}
}
function checkWazeBot() {
if (poi.modificationData.updatedBy && !poi.isResidential &&
new RegExp(wazeBot).test(poi.modificationData.updatedBy)) {
j++; newColor = colorInfo; newWidth = 15; newOpacity = 0.5;
if (poi.geometry.type === "Point") { newWidth = 26; newOpacity = 0.75; }
addIconsOnLayer("_poi_WazeBot", poi.geometry, j);
ceErrorsFound.push({ err: "_poi_WazeBot", id: poi.id });
}
}
// Highlight if error
if (gpoly) {
const points = [];
gpoly.forEach(g => { points.push(new OpenLayers.Geometry.Point(g.x, g.y)) });
lineFeature.push(new OpenLayers.Feature.Vector(new OpenLayers.Geometry.LinearRing(points), null,
{ strokeWidth: newWidth, strokeColor: newColor, strokeOpacity: newOpacity, fillOpacity: 0 }));
}
});
}
// Mise à jour du calque CE sur la carte WME
try { W.map.getLayersByName("Color Errors")[0].addFeatures(lineFeature); if (debug) WMECE_log("Ajout des icones sur la couche CE"); } catch ($) { }
if (debug) WMECE_log(ceErrorsFound);
}
function formatTelCounty(venue) {
let phoneTo, phone;
// num 0800 et 0900
if (venue.phone.startsWith('08') == true) {
phoneTo = venue.phone.replace(/^0[.| |-]?8[.| |-]?([0-9])([0-9])[.| |-]?([0-9])([0-9])[.| |-]?([0-9])([0-9])[.| |-]?([0-9])([0-9])$/g, "0 8$1$2 $3$4$5 $6$7$8");
} else {
// rules by country
switch (wmeSDK.DataModel.Countries.getTopCountry().id) {
case 3: // Algeria
if (venue.phone.startsWith('+213') == true) {
phoneTo = venue.phone.replace(/^\+213[ ]?([0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])$/g, "+213 $1 $2 $3 $4 $5");
} else {
phoneTo = venue.phone.replace(/^0([0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])$/g, "+213 $1 $2 $3 $4 $5");
}
break;
case 73: // France
// Nettoyage initial : supprime les espaces, points, tirets et parenthèses
phone = venue.phone.replace(/[().\-]/g, ' ').replace(/\s+/g, ' ').trim();
// Si déjà bien formaté → on ne touche pas
if (/^\+33\s[1-9](\s\d{2}){4}$/.test(phone)) {
phoneTo = phone;
break;
}
// Supprime le (0) après +33, 0033, ou 33
phone = phone.replace(/(\+33|0033|^33)\s*\(0\)/, '$1');
// Cas des numéros commençant par +33, 0033, ou 33
if (/^\+?0{0,2}33/.test(phone)) {
phoneTo = phone
.replace(/^(\+?0{0,2}33)\s*0?/, '+33 ') // remplace +33(0) ou 0033(0) par +33
.replace(/\s+/g, ' ') // normalise les espaces
.replace(/^\+33\s?([1-9])\s?(\d{2})\s?(\d{2})\s?(\d{2})\s?(\d{2})$/, "+33 $1 $2 $3 $4 $5");
}
// Cas des numéros français au format national
else if (/^0[1-9]/.test(phone)) {
// Numéros spéciaux (08)
if (/^0\s*8/.test(phone)) {
phoneTo = phone
.replace(/^0\s*8/, "0 8")
.replace(/\s+/g, '')
.replace(/^0(\d{1})(\d{2})(\d{2})(\d{2})(\d{2})$/, "0$1 $2 $3 $4 $5");
} else {
phoneTo = phone
.replace(/^0\s*([1-9])/, "+33 $1")
.replace(/\s+/g, '')
.replace(/^\+33([1-9])(\d{2})(\d{2})(\d{2})(\d{2})$/, "+33 $1 $2 $3 $4 $5");
}
}
// Cas où il y aurait juste "33" sans +
else if (/^33/.test(phone)) {
phoneTo = phone
.replace(/^33\s*0?/, "+33 ")
.replace(/\s+/g, '')
.replace(/^\+33([1-9])(\d{2})(\d{2})(\d{2})(\d{2})$/, "+33 $1 $2 $3 $4 $5");
}
// Par défaut, on laisse tel quel
else {
phoneTo = phone;
}
break;
case 74: // French Guiana
if (venue.phone.startsWith('+594 5 94') == true || venue.phone.startsWith('+594594') == true) {
phoneTo = venue.phone.replace(/^\+594[ ]?([0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])$/g, "+594 $1$2 $3 $4 $5");
} else {
phoneTo = venue.phone.replace(/^0([0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])$/g, "+594 $1$2 $3 $4 $5");
}
break;
case 88: // Guadeloupe
if (venue.phone.startsWith('+590 5 90') == true || venue.phone.startsWith('+590590') == true) {
phoneTo = venue.phone.replace(/^\+590[ ]?([0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])$/g, "+590 $1$2 $3 $4 $5");
} else {
phoneTo = venue.phone.replace(/^0([0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])$/g, "+590 $1$2 $3 $4 $5");
}
break;
case 141: // Martinique
if (venue.phone.startsWith('+596 5 96') == true || venue.phone.startsWith('+596596') == true) {
phoneTo = venue.phone.replace(/^\+596[ ]?([0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])$/g, "+596 $1$2 $3 $4 $5");
} else {
phoneTo = venue.phone.replace(/^0([0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])$/g, "+596 $1$2 $3 $4 $5");
}
break;
case 148: // Monaco
if (venue.phone.startsWith('+377') == true) {
phoneTo = venue.phone.replace(/^\+377[ ]?([0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])$/g, "+377 $1 $2 $3 $4 $5");
} else {
phoneTo = venue.phone.replace(/^0([0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])$/g, "+377 $1 $2 $3 $4 $5");
}
break;
case 152: // Morocco
if (venue.phone.startsWith('+212') == true) {
phoneTo = venue.phone.replace(/^\+212[ ]?([0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])$/g, "+212 $1 $2 $3 $4 $5");
} else {
phoneTo = venue.phone.replace(/^0([0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])$/g, "+212 $1 $2 $3 $4 $5");
}
break;
case 184: // Reunion 184
let cleaned = venue.phone.replace(/\D/g, '');
if (cleaned.startsWith("262")) cleaned = cleaned.slice(3);
if (cleaned.startsWith("0")) cleaned = cleaned.slice(1);
if (cleaned.length === 9) {
const bloc1 = cleaned.slice(0, 3);
const bloc2 = cleaned.slice(3, 5);
const bloc3 = cleaned.slice(5, 7);
const bloc4 = cleaned.slice(7, 9);
phoneTo = `+262 ${bloc1} ${bloc2} ${bloc3} ${bloc4}`;
}
else phoneTo = venue.phone;
break;
default: break;
}
}
return phoneTo;
}
function fixTel() {
const comp = document.querySelector('wz-text-input#venue-phone');
if (!comp) return setTimeout(fixTel, 500);
const shadow = comp.shadowRoot;
if (!shadow) return setTimeout(fixTel, 500);
const inner = shadow.querySelector('.wz-text-input-inner-container');
if (!inner) return setTimeout(fixTel, 500);
const input = inner.querySelector('input');
if (!input) return setTimeout(fixTel, 500);
input.addEventListener('blur', () => {
const el = shadow.querySelector("#ce-fix-phone-fr");
if (el) el.remove();
setTimeout(fixTel, 0);
});
const selection = wmeSDK.Editing.getSelection().ids[0];
const venue = wmeSDK.DataModel.Venues.getById({ venueId: selection });
const phoneTo = formatTelCounty(venue);
if (phoneTo === venue.phone) return
const btn = document.createElement('button');
btn.id = 'ce-fix-phone-fr';
btn.innerText = 'fix';
btn.style.position = 'absolute';
btn.style.color = 'white';
btn.style.fontFamily = 'Rubik, "Waze Boing", "Waze Boing HB light", sans-serif';
btn.style.backgroundColor = '#0099ff';
btn.style.fontWeight = 'bold';
btn.style.borderTopRightRadius = '6px';
btn.style.borderBottomRightRadius = '6px';
btn.style.border = 'none';
btn.style.right = '0';
btn.style.bottom = '1px';
btn.style.top = '0';
btn.style.cursor = 'pointer';
btn.style.padding = '0px 10px';
inner.append(btn);
btn.addEventListener('click', () => {
wmeSDK.DataModel.Venues.updateVenue({ venueId: selection, phone: phoneTo });
btn.remove();
});
}
})();