WME Color Errors

Adds colours to show errors

当前为 2017-08-09 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name WME Color Errors
  3. // @name:fr WME Color Errors
  4. // @version 0.54
  5. // @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=
  6. // @description Adds colours to show errors
  7. // @description:fr Colorisation pour afficher les erreurs
  8. // @include https://www.waze.com/editor/*
  9. // @include https://www.waze.com/*/editor/*
  10. // @include https://beta.waze.com/*
  11. // @exclude https://www.waze.com/user/*
  12. // @exclude https://www.waze.com/*/user/*
  13. // @namespace https://gf.qytechs.cn/fr/scripts/21186-wme-color-errors
  14. // @author Sebiseba
  15. // @copyright Sebiseba 2014-2017
  16. // @grant none
  17. // ==/UserScript==
  18.  
  19. var WMECErrors={}, ColorErrors_mapLayer=[], CErrLeg, CErrSeg, CErrPoi, myLevel, prefPhone, debug;
  20. var CErrWaze, CErrorsMap, CErrorsModel, CErrorsI18n, CErrorsOpenLayers, CErrorshandle, CErrorshandleClass, CErrorshandleClass2,
  21.  
  22. //french rules
  23. streetNameSeg="^(^Le |^La |^Les |Grande |Allée |[ ]?Avenue[]?|Boulevard |Chemin |Cité |Clos |Côte |Cour[s]? |Domaine |Hameau |Impasse |Levée |Lotissement |Mail |Montée |Parc |Passage |Place |Pont |Promenade |Quai |Résidence[s]? |Route |[ ]?Rue[ ]?|Ruelle |Sente |Sentier |Square |Traverse |Venelle |Villa |Voie )",
  24. parkNameSeg="^(Aire |Place |Square )",
  25. excepNameSeg="(Périphérique|Rocade|Duplex|Tunnel|Pont)",
  26. privNameSeg="^(Allée |Avenue |Boulevard |Chemin |Clos |Côte |Cours |Faubourg |Hameau |Impasse |Lotissement |Mail |Passage |Porte |Promenade |Quai |Route |Rue |Ruelle |Sente |Sentier |Voie )",
  27. parkNamePoi="(Parking[s]?|Placette|Aire|Arrêt)",
  28. religiousPoi="(Abbatiale|Abbaye|Basilique|Calvaire|Cathédrale|Chapelle|Cloître|Collégiale|Conjuratoire|Couvent|Crypte|Dôme|Église|Mandir|Monastère|Mosquée|Notre-Dame|Oratoire|Pagode|Presbytère|Prieuré|Sanctuaire|Stupa|Synagogue|Temple)",
  29.  
  30. // common all countries
  31. landmarkPoi="(RIVER_STREAM|CANAL|SEA_LAKE_POOL|POOL|SWAMP_MARSH|ISLAND|FOREST_GROVE|BRIDGE)",
  32. excepCatPoi="(RIVER_STREAM|CANAL|SEA_LAKE_POOL|SWAMP_MARSH|ISLAND|FOREST_GROVE|BRIDGE|SWAMP_MARSH|PARK|JUNCTION_INTERCHANGE|CEMETERY|TUNNEL)",
  33. entryPointPoi="(BRIDGE|CANAL|FOREST_GROVE|ISLAND|JUNCTION_INTERCHANGE|POOL|RIVER_STREAM|SEA_LAKE_POOL|SWAMP_MARSH|TUNNEL)",
  34. wazeBot="(admin|avseu|WazeFeed|waze-maint-bot|Waze3rdparty)";
  35.  
  36. // *********************
  37. // ** HELPER FUNCTION **
  38. // *********************
  39.  
  40. function getId(node) {
  41. return document.getElementById(node);
  42. }
  43. function getElementsByClassName(classname, node) {
  44. node || (node=document.getElementsByTagName("body")[0]);
  45. for (var a=[], re=new RegExp("\\b" + classname + "\\b"), els=
  46. node.getElementsByTagName("*"), i=
  47. 0, j=
  48. els.length;i < j;i++) {
  49. re.test(els[i].className) && a.push(els[i]);
  50. }
  51. return a;
  52. }
  53. function IsJsonString(str) {
  54. try {
  55. JSON.parse(str);
  56. } catch (e) {
  57. return false;
  58. }
  59. return true;
  60. }
  61.  
  62. // *************
  63. // ** INIT **
  64. // *************
  65. function CErrors_bootstrap() {
  66. if (typeof unsafeWindow === "undefined") {
  67. unsafeWindow =( function () {
  68. var dummyElem=document.createElement('p');
  69. dummyElem.setAttribute('onclick', 'return window;');
  70. return dummyElem.onclick();
  71. }) ();
  72. }
  73. console.log("starting WME Color Errors", GM_info.script.version);
  74. CErrors_init();
  75. }
  76. function CErrors_init(){
  77. // Waze object needed
  78. CErrWaze=unsafeWindow.Waze; if(typeof(CErrWaze) === 'undefined'){ if (debug) { console.error("WME ColorErrors - CErrWaze : NOK"); } window.setTimeout(CErrors_init, 500); return; }
  79. CErrorsMap=CErrWaze.map; if(typeof(CErrorsMap) == 'undefined'){ if (debug) { console.error("WME ColorErrors - CErrorsmap : NOK"); } window.setTimeout(CErrors_init, 500); return; }
  80. CErrorsModel=CErrWaze.model; if(typeof(CErrorsModel) == 'undefined'){ if (debug) { console.error("WME ColorErrors - CErrorsmodel : NOK"); } window.setTimeout(CErrors_init, 500); return; }
  81. if(typeof(CErrorsModel.countries.top) == 'undefined'){ if (debug) { console.error("WME ColorErrors - CErrorsmodel Countries top : NOK"); } window.setTimeout(CErrors_init, 500); return; }
  82. CErrorsI18n=unsafeWindow.I18n; if(typeof (CErrorsI18n) == 'undefined') { if (debug) { console.error('WME ColorErrors - CErrorsI18n : NOK'); } setTimeout(CErrors_init, 500); return; }
  83. // OpenLayers
  84. CErrorsOpenLayers=unsafeWindow.OpenLayers; if(typeof(CErrorsOpenLayers) === 'undefined'){ if (debug) { console.error("WME ColorErrors - OpenLayers : NOK"); } window.setTimeout(CErrors_init, 500); return; }
  85. // Waze GUI needed
  86. CErrorshandle=getId("user-info"); if(typeof(CErrorshandle) == 'undefined'){ window.setTimeout(CErrors_init, 500); return; }
  87. CErrorshandleClass=getElementsByClassName("nav-tabs", CErrorshandle)[0]; if(typeof(CErrorshandleClass) === 'undefined'){ window.setTimeout(CErrors_init, 500); return; }
  88. CErrorshandleClass2=getElementsByClassName("tab-content", CErrorshandle)[0]; if(typeof(CErrorshandleClass2) === 'undefined'){ window.setTimeout(CErrors_init, 500); return; }
  89.  
  90. // Verify localStorage. Init if empty or not correct
  91. if (typeof(localStorage.WMEColorErrors) === "undefined" || localStorage.WMEColorErrors.lenght===null || !IsJsonString(localStorage.WMEColorErrors)) {
  92. WMECErrors.opacity=0.85; // Icons Opacity on map
  93. WMECErrors.myLvl=false; // Show when editable
  94. WMECErrors.seg_Bad=false; // Bad Segments (group)
  95. WMECErrors.seg_Priv=true; // Private with bad name
  96. WMECErrors.seg_Park=true; // Parking with name (but Place / Square)
  97. WMECErrors.seg_Rail=true; // Railroad with bad name
  98. WMECErrors.seg_HW_name=true; //Highways with bad name
  99. WMECErrors.seg_Dir_name=true; // Directions but not Ramp/Freeway
  100. WMECErrors.seg_Toll=true; // Toll (but Ramp/Freeway)
  101. WMECErrors.seg_Ramp_name=true; // Ramp with 3 directions or more
  102. WMECErrors.seg_Ramp_city=true; // Ramp with city name
  103. WMECErrors.seg_RShield=true; // Wrong prefix
  104. WMECErrors.seg_RSAlt=true; //Roadshield must be in alt
  105. WMECErrors.seg_SNameAlt=true; //Road name must be in alt
  106. WMECErrors.seg_DleSpace=true; // Double space in name
  107. WMECErrors.seg_SegBadRS=true; // RoadShield but bad type
  108. WMECErrors.seg_HNFree=true; // House number on Freeway or ramp
  109. WMECErrors.seg_BadSpeed=true; // Bad speed (ex: 90km/h in city)
  110. // POI
  111. WMECErrors.poi_Bad=false; // Bad POI (group)
  112. WMECErrors.poi_Park_name=true; // Parking with [P]
  113. WMECErrors.poi_Address=true; // Dxxx/Nxxx in or no address
  114. WMECErrors.poi_Entry=true; // Entry Point not defined
  115. WMECErrors.poi_LandM=true; // Landmark with address (street |& city)
  116. WMECErrors.poi_DleSpace=true; // Double space in name
  117. // Low errors
  118. WMECErrors.poi_Resid=true; // Maybe a residential
  119. WMECErrors.poi_Google=true; // No link with Google
  120. WMECErrors.poi_Phone=true; // bad phone number format
  121. WMECErrors.poi_WFeed=true; // Place created by WazeFeed
  122. WMECErrors.poi_WPark=true; // Place created by WazeParking1
  123. WMECErrors.poi_Relig=true; // Religious Center with bad name
  124. WMECErrors.poi_Other=true; // Place "Other"
  125. localStorage.setItem('WMEColorErrors', JSON.stringify(WMECErrors));
  126. }
  127.  
  128. // Phone prefix
  129. switch(CErrorsModel.countries.top.id) {
  130. case 73: prefPhone='+33[ ]\\d'; break; // format (+33 1) 22 33 44 55
  131. case 3: prefPhone='+213'; break; // format (+213) 11 22 33 44
  132. default : break;
  133. }
  134.  
  135. // WME Layers check
  136. var layersColor=CErrorsMap.getLayersBy("uniqueName","__WME_Color_Errors"), layersIcons=CErrorsMap.getLayersBy("uniqueName","__WME_Color_Errors_Icons");
  137. var ColorErrors_style=new CErrorsOpenLayers.Style({
  138. pointRadius: 2,
  139. fontWeight: "normal",
  140. label : "${labelText}",
  141. fontFamily: "Tahoma, Courier New",
  142. labelOutlineColor: "#FFFFFF",
  143. labelOutlineWidth: 2,
  144. fontColor: '#000000',
  145. fontSize: "10px"
  146. });
  147. if (layersColor.length === 0) {
  148. ColorErrors_mapLayer=new CErrorsOpenLayers.Layer.Vector("Color Errors", {
  149. displayInLayerSwitcher: false,
  150. uniqueName: "__WME_Color_Errors",
  151. styleMap: new CErrorsOpenLayers.StyleMap(ColorErrors_style)
  152. });
  153. CErrorsI18n.translations[CErrorsI18n.locale].layers.name["__WME_Color_Errors"]="Color Errors";
  154. CErrorsMap.addLayer(ColorErrors_mapLayer);
  155. ColorErrors_mapLayer.setVisibility(true);
  156. }
  157. if (layersIcons.length === 0) {
  158. ColorErrors_mapLayerIcons=new CErrorsOpenLayers.Layer.Vector("Color Errors Icons", {
  159. displayInLayerSwitcher: false,
  160. uniqueName: "__WME_Color_Errors_Icons",
  161. styleMap: new CErrorsOpenLayers.StyleMap(ColorErrors_style)
  162. });
  163. CErrorsI18n.translations[CErrorsI18n.locale].layers.name["__WME_Color_Errors_Icons"]="Color Errors Icons";
  164. CErrorsMap.addLayer(ColorErrors_mapLayerIcons);
  165. ColorErrors_mapLayerIcons.setVisibility(true);
  166. }
  167. myLevel=CErrWaze.loginManager.user.rank;
  168. CErrors_Mainhtml();
  169. }
  170. function CErrAddInfo(){
  171. if (CErrWaze.selectionManager.selectedItems.length !== 0 && !getId('ErrorsList')) {
  172. var CEtest = document.createElement('li');
  173. CEtest.id = "ErrorsList";
  174. if(getElementsByClassName('additional-attributes')[0]) getElementsByClassName('additional-attributes')[0].appendChild(CEtest);
  175. }
  176. }
  177. // *************
  178. // ** HTML **
  179. // *************
  180.  
  181. function CErrors_Mainhtml() {
  182. if (CErrorsI18n.locale == 'fr') {
  183. CErrSeg=new Array('Contrôle des segments',
  184. 'Mauvais segments',
  185. 'Voie privée avec possible mauvais nom',
  186. 'Voie de Parking nommée',
  187. 'Voie ferrée nommée ou nom en alt',
  188. 'Types Routes avec mauvais nom',
  189. 'Bretelle avec plusieurs directions',
  190. 'Direction (sauf bretelle et Autoroute)',
  191. 'Mauvais préfixe (RoadShield)',
  192. 'Double espace dans le nom',
  193. 'Péage (sauf bretelle et Autoroute)',
  194. 'Bretelle/Autoroute avec nom de ville',
  195. 'Le RoadShield doit être en alt',
  196. 'Le nom de route doit être en alt',
  197. 'RoadShield sur mauvais type de voie',
  198. 'N° de rue sur mauvais type de voie',
  199. 'Mauvaise vitesse validée'
  200. );
  201. CErrPoi=new Array('Contrôle des places',
  202. 'Mauvaises places',
  203. 'Parking mal nommé ou sans nom',
  204. 'Pas d\'adresse ou contenant Dxxx/Nxxx',
  205. 'Point d\'entré non défini',
  206. 'Site naturel avec adresse',
  207. 'Double espace dans le nom',
  208. 'Peut-être une place résidentielle',
  209. 'Pas de lien avec Google',
  210. 'Lieu édité par WazeFeed',
  211. 'Lieu de type "Autres"',
  212. 'Lieu édité par WazeParking1',
  213. 'Parking : type non défini',
  214. 'Mauvais format du n° de tel',
  215. 'Lieu de culte mal nommé ou mauvaise catégorie'
  216. );
  217. CErrLeg=new Array('Légende',
  218. 'A corriger',
  219. 'A vérifier',
  220. 'Pour information',
  221. 'Réglages',
  222. 'Opacité des icônes',
  223. 'Afficher seulements les éditables',
  224. 'Verrouillé par la publicité'
  225. );
  226. }
  227. else {
  228. CErrSeg=new Array('Segments Checking',
  229. 'Bad Segments',
  230. 'Private with possible bad name',
  231. 'Parking with bad name or without',
  232. 'Railroad with name or altname',
  233. 'Highways with bad name',
  234. 'Ramp with several directions',
  235. 'Direction (but Ramp/Freeway)',
  236. 'Wrong prefix (RoadShield)',
  237. 'Double spacing in name',
  238. 'Toll (but Ramp/Freeway)',
  239. 'Ramp/Freeway with city name',
  240. 'RoadShield must be in alt',
  241. 'Road name must be in alt',
  242. 'RoadShield but bad type',
  243. 'HN but bad type',
  244. 'Bad speed verified'
  245. );
  246. CErrPoi=new Array('Places Checking',
  247. 'Bad Places',
  248. 'Parking with bad name or null',
  249. 'No address or Dxxx/Nxxx within',
  250. 'Entry Point not defined',
  251. 'Natural features with address',
  252. 'Double spacing in name',
  253. 'Maybe a residential place',
  254. 'No link with Google',
  255. 'Place created by WazeFeed',
  256. 'Place type is "Other"',
  257. 'Place created by WazeParking1',
  258. 'Parking : type undefined',
  259. 'Bad phone number format',
  260. 'Religious Center with bad name'
  261. );
  262. CErrLeg=new Array('Legend',
  263. 'To correct',
  264. 'To check',
  265. 'For information',
  266. 'Settings',
  267. 'Icons opacity',
  268. 'Show when editable',
  269. 'Locked by ad'
  270. );
  271. }
  272. //Create content in CErrors's tab
  273. var CEnewtab=document.createElement('li');
  274. CEnewtab.innerHTML="<a href='#sidepanel-ColorErrors' data-toggle='tab'><span class='fa fa-eye' title='Color Errors'></span></a>";
  275. CErrorshandleClass.appendChild(CEnewtab);
  276.  
  277. var WMECErrors=JSON.parse(localStorage.getItem('WMEColorErrors'));
  278. var CEaddon=document.createElement('section');
  279. CEaddon.id="sidepanel-ColorErrors";
  280. var CEcontent='<div style="float:left; margin-left:5px;padding-bottom:10px;"><b><a href="https://gf.qytechs.cn/fr/scripts/21186-wme-color-errors" target="_blank"><u>WME Color Errors</u></a></b> v'+ GM_info.script.version +'</div>'
  281. + '<h4 style="float:left;clear:both;">'+CErrLeg[4]+'</h4><span style="float:left;clear:both;font-weight:bold;margin-top:10px;">'+CErrLeg[5]+'</span><input id="errOpacity" type="range" max="1" min="0" step="0.05" style="float:left;width:240px;"><div id="opacityValue" style="float:left;font-weight:bold;padding-left:10px;"></div>'
  282. + '<div style="float:left;clear:both;"><input type="checkbox" id="_myLvl"'+(WMECErrors.myLvl ? ' checked' : '')+'/> '+CErrLeg[6]+'</div>'
  283. + '<br><br><h4 style="float:left;margin-top:10px;">'+CErrSeg[0]+'</h4><div style="clear:both;">'
  284. + '<input type="checkbox" id="_seg_Bad"'+(WMECErrors.seg_Bad ? ' checked' : '')+'/> '+CErrSeg[1]+'<br><div id="BadSeg" style="margin-left:5px;"><table>';
  285. CEcontent += fillHtml("seg_Priv", "seg_Bad","#ff7700","\uf256",CErrSeg[2]);
  286. CEcontent += fillHtml("seg_Ramp_name","seg_Bad","#ff7700","\uf25a",CErrSeg[7]);
  287. CEcontent += fillHtml("seg_BadSpeed", "seg_Bad","#ff7700","\uf1ce",CErrSeg[16]);
  288. CEcontent += fillHtml("seg_Park", "seg_Bad","#ff0000","\uf288",CErrSeg[3]);
  289. CEcontent += fillHtml("seg_Rail", "seg_Bad","#ff0000","\uf238",CErrSeg[4]);
  290. CEcontent += fillHtml("seg_Dir_name", "seg_Bad","#ff0000","\uf0a9",CErrSeg[6]);
  291. CEcontent += fillHtml("seg_Toll", "seg_Bad","#ff0000","\uf155",CErrSeg[10]);
  292. CEcontent += fillHtml("seg_Ramp_city","seg_Bad","#ff0000","\uf015",CErrSeg[11]);
  293. CEcontent += fillHtml("seg_SNameAlt", "seg_Bad","#ff0000","\uf079",CErrSeg[13]);
  294. CEcontent += fillHtml("seg_DleSpace", "seg_Bad","#ff0000","\uf101",CErrSeg[9]);
  295. CEcontent += fillHtml("seg_HW_name", "seg_Bad","#ff0000","\uf018",CErrSeg[5]);
  296. CEcontent += fillHtml("seg_RSAlt", "seg_Bad","#ff0000","\uf074",CErrSeg[12]);
  297. CEcontent += fillHtml("seg_RShield", "seg_Bad","#ff0000","\uf152",CErrSeg[8]);
  298. CEcontent += fillHtml("seg_SegBadRS", "seg_Bad","#ff0000","\uf044",CErrSeg[14]);
  299. CEcontent += fillHtml("seg_HNFree", "seg_Bad","#ff0000","\uf162",CErrSeg[15]);
  300.  
  301. CEcontent += '</table></div></div><br><h4 style="float:left;">'+CErrPoi[0]+'</h4><div style="clear:both;"><tr><td><input type="checkbox" id="_poi_Bad"'+(WMECErrors.poi_Bad ? ' checked' : '')+'/> '+CErrPoi[1]+'<br><div id="BadPoi" style="margin-left:5px;"><table>';
  302. CEcontent += fillHtml("poi_Address", "poi_Bad","#ff0000","\uf2bc",CErrPoi[3]);
  303. CEcontent += fillHtml("poi_LandM", "poi_Bad","#ff0000","\uf1bb",CErrPoi[5]);
  304. CEcontent += fillHtml("poi_DleSpace", "poi_Bad","#ff0000","\uf101",CErrPoi[6]);
  305. CEcontent += fillHtml("poi_Park_name","poi_Bad","#ff0000","\uf288",CErrPoi[2]);
  306. CEcontent += fillHtml("poi_Park_type","poi_Bad","#ff0000","\uf11d",CErrPoi[12]);
  307. CEcontent += fillHtml("poi_Relig", "poi_Bad","#ff0000","\uf015",CErrPoi[14]);
  308. CEcontent += fillHtml("poi_Entry", "poi_Bad","#ff7700","\uf18e",CErrPoi[4]);
  309. CEcontent += fillHtml("poi_Resid", "poi_Bad","#ff7700","\uf015",CErrPoi[7]);
  310. CEcontent += fillHtml("poi_Google", "poi_Bad","#ff7700","\uf1a0",CErrPoi[8]);
  311. CEcontent += fillHtml("poi_Phone", "poi_Bad","#ff7700","\uf095",CErrPoi[13]);
  312. CEcontent += fillHtml("poi_Other", "poi_Bad","#ff7700","\uf29c",CErrPoi[10]);
  313. CEcontent += fillHtml("poi_WFeed", "poi_Bad","#ffcc00","\uf263",CErrPoi[9]);
  314. CEcontent += fillHtml("poi_WPark", "poi_Bad","#ffcc00","\uf263",CErrPoi[11]);
  315. CEcontent += '</table></div></div><br><h4 style="float:left;">'+CErrLeg[0]+'</h4><div style="clear:both;">';
  316. CEcontent += '<table><tr><td><div style="margin:5px;width:30px;height:2px;background-color:#ff0000;"></div></td><td>'+CErrLeg[1]+'</td></tr>';
  317. CEcontent += '<tr><td><div style="margin:5px;width:30px;height:2px;background-color:#ff7700;"></div></td><td>'+CErrLeg[2]+'</td></tr>';
  318. CEcontent += '<tr><td><div style="margin:5px;width:30px;height:2px;background-color:#ffcc00;"></div></td><td>'+CErrLeg[3]+'</td></tr></table></div>';
  319. CEaddon.innerHTML=CEcontent;
  320. CEaddon.className='tab-pane';
  321. CErrorshandleClass2.appendChild(CEaddon);
  322.  
  323. getId('errOpacity').value=WMECErrors.opacity;
  324. getId('opacityValue').innerHTML = getId('errOpacity').value;
  325.  
  326. getId('errOpacity').onmousemove = function(){
  327. getId('opacityValue').innerHTML = getId('errOpacity').value;
  328. var ls=JSON.parse(localStorage.WMEColorErrors);
  329. ls.opacity=getId('errOpacity').value;
  330. localStorage.setItem('WMEColorErrors', JSON.stringify(ls));
  331. CErrColor();
  332. };
  333. getId('_myLvl').onclick=(function(){
  334. var ls=JSON.parse(localStorage.WMEColorErrors);
  335. (getId('_myLvl').checked === true ? ls.myLvl=true : ls.myLvl=false);
  336. localStorage.setItem('WMEColorErrors', JSON.stringify(ls));
  337. CErrColor();
  338. });
  339. getId('_seg_Bad').onclick=(function(){
  340. var ls=JSON.parse(localStorage.WMEColorErrors);
  341. if (getId('_seg_Bad').checked === true) {
  342. for (var i=0; getElementsByClassName('_seg', BadSeg) [i]; i++) getElementsByClassName('_seg', BadSeg) [i].disabled=false;
  343. ls.seg_Bad=true;
  344. }
  345. else {
  346. for (var i=0; getElementsByClassName('_seg', BadSeg) [i]; i++) getElementsByClassName('_seg', BadSeg) [i].disabled=true;
  347. ls.seg_Bad=false;
  348. }
  349. localStorage.setItem('WMEColorErrors', JSON.stringify(ls));
  350. CErrColor();
  351. });
  352. getId('_poi_Bad').onclick=(function(){
  353. var ls=JSON.parse(localStorage.WMEColorErrors);
  354. if (getId('_poi_Bad').checked === true) {
  355. for (var i=0; getElementsByClassName('_poi', BadPoi) [i]; i++) getElementsByClassName('_poi', BadPoi) [i].disabled=false;
  356. ls.poi_Bad=true;
  357. }
  358. else {
  359. for (var i=0; getElementsByClassName('_poi', BadPoi) [i]; i++) getElementsByClassName('_poi', BadPoi) [i].disabled=true;
  360. ls.poi_Bad=false;
  361. }
  362. localStorage.setItem('WMEColorErrors', JSON.stringify(ls));
  363. CErrColor();
  364. });
  365. getId('_seg_Priv').onclick=(function(){ var ls=JSON.parse(localStorage.WMEColorErrors); (getId('_seg_Priv').checked === true) ? ls.seg_Priv=true : ls.seg_Priv=false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
  366. getId('_seg_Park').onclick=(function(){ var ls=JSON.parse(localStorage.WMEColorErrors); (getId('_seg_Park').checked === true) ? ls.seg_Park=true : ls.seg_Park=false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
  367. getId('_seg_Rail').onclick=(function(){ var ls=JSON.parse(localStorage.WMEColorErrors); (getId('_seg_Rail').checked === true) ? ls.seg_Rail=true : ls.seg_Rail=false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
  368. getId('_seg_HW_name').onclick=(function(){ var ls=JSON.parse(localStorage.WMEColorErrors); (getId('_seg_HW_name').checked === true) ? ls.seg_HW_name=true : ls.seg_HW_name=false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
  369. getId('_seg_Dir_name').onclick=(function(){ var ls=JSON.parse(localStorage.WMEColorErrors); (getId('_seg_Dir_name').checked === true) ? ls.seg_Dir_name=true : ls.seg_Dir_name=false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
  370. getId('_seg_Toll').onclick=(function(){ var ls=JSON.parse(localStorage.WMEColorErrors); (getId('_seg_Toll').checked === true) ? ls.seg_Toll=true : ls.seg_Toll=false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
  371. getId('_seg_Ramp_name').onclick=(function(){ var ls=JSON.parse(localStorage.WMEColorErrors); (getId('_seg_Ramp_name').checked === true) ? ls.seg_Ramp_name=true : ls.seg_Ramp_name=false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
  372. getId('_seg_Ramp_city').onclick=(function(){ var ls=JSON.parse(localStorage.WMEColorErrors); (getId('_seg_Ramp_city').checked === true) ? ls.seg_Ramp_city=true : ls.seg_Ramp_city=false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
  373. getId('_seg_RShield').onclick=(function(){ var ls=JSON.parse(localStorage.WMEColorErrors); (getId('_seg_RShield').checked === true) ? ls.seg_RShield=true : ls.seg_RShield=false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
  374. getId('_seg_RSAlt').onclick=(function(){ var ls=JSON.parse(localStorage.WMEColorErrors); (getId('_seg_RSAlt').checked === true) ? ls.seg_RSAlt=true : ls.seg_RSAlt=false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
  375. getId('_seg_SNameAlt').onclick=(function(){ var ls=JSON.parse(localStorage.WMEColorErrors); (getId('_seg_SNameAlt').checked === true) ? ls.seg_SNameAlt=true : ls.seg_SNameAlt=false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
  376. getId('_seg_DleSpace').onclick=(function(){ var ls=JSON.parse(localStorage.WMEColorErrors); (getId('_seg_DleSpace').checked === true) ? ls.seg_DleSpace=true : ls.seg_DleSpace=false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
  377. getId('_seg_SegBadRS').onclick=(function(){ var ls=JSON.parse(localStorage.WMEColorErrors); (getId('_seg_SegBadRS').checked === true) ? ls.seg_SegBadRS=true : ls.seg_SegBadRS=false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
  378. getId('_seg_HNFree').onclick=(function(){ var ls=JSON.parse(localStorage.WMEColorErrors); (getId('_seg_HNFree').checked === true) ? ls.seg_HNFree=true : ls.seg_HNFree=false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
  379. getId('_seg_BadSpeed').onclick=(function(){ var ls=JSON.parse(localStorage.WMEColorErrors); (getId('_seg_BadSpeed').checked === true) ? ls.seg_BadSpeed=true : ls.seg_BadSpeed=false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
  380.  
  381.  
  382. getId('_poi_Park_name').onclick=(function(){ var ls=JSON.parse(localStorage.WMEColorErrors); (getId('_poi_Park_name').checked === true) ? ls.poi_Park_name=true : ls.poi_Park_name=false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
  383. getId('_poi_Park_type').onclick=(function(){ var ls=JSON.parse(localStorage.WMEColorErrors); (getId('_poi_Park_type').checked === true) ? ls.poi_Park_type=true : ls.poi_Park_type=false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
  384. getId('_poi_Address').onclick=(function(){ var ls=JSON.parse(localStorage.WMEColorErrors); (getId('_poi_Address').checked === true) ? ls.poi_Address=true : ls.poi_Address=false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
  385. getId('_poi_Entry').onclick=(function(){ var ls=JSON.parse(localStorage.WMEColorErrors); (getId('_poi_Entry').checked === true) ? ls.poi_Entry=true : ls.poi_Entry=false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
  386. getId('_poi_LandM').onclick=(function(){ var ls=JSON.parse(localStorage.WMEColorErrors); (getId('_poi_LandM').checked === true) ? ls.poi_LandM=true : ls.poi_LandM=false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
  387. getId('_poi_DleSpace').onclick=(function(){ var ls=JSON.parse(localStorage.WMEColorErrors); (getId('_poi_DleSpace').checked === true) ? ls.poi_DleSpace=true : ls.poi_DleSpace=false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
  388. getId('_poi_Resid').onclick=(function(){ var ls=JSON.parse(localStorage.WMEColorErrors); (getId('_poi_Resid').checked === true) ? ls.poi_Resid=true : ls.poi_Resid=false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
  389. getId('_poi_Google').onclick=(function(){ var ls=JSON.parse(localStorage.WMEColorErrors); (getId('_poi_Google').checked === true) ? ls.poi_Google=true : ls.poi_Google=false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
  390. getId('_poi_Phone').onclick=(function(){ var ls=JSON.parse(localStorage.WMEColorErrors); (getId('_poi_Phone').checked === true) ? ls.poi_Phone=true : ls.poi_Phone=false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
  391. getId('_poi_WFeed').onclick=(function(){ var ls=JSON.parse(localStorage.WMEColorErrors); (getId('_poi_WFeed').checked === true) ? ls.poi_WFeed=true : ls.poi_WFeed=false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
  392. getId('_poi_WPark').onclick=(function(){ var ls=JSON.parse(localStorage.WMEColorErrors); (getId('_poi_WPark').checked === true) ? ls.poi_WPark=true : ls.poi_WPark=false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
  393. getId('_poi_Relig').onclick=(function(){ var ls=JSON.parse(localStorage.WMEColorErrors); (getId('_poi_Relig').checked === true) ? ls.poi_Relig=true : ls.poi_Relig=false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
  394. getId('_poi_Other').onclick=(function(){ var ls=JSON.parse(localStorage.WMEColorErrors); (getId('_poi_Other').checked === true) ? ls.poi_Other=true : ls.poi_Other=false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
  395.  
  396. CErrWaze.selectionManager.events.register("selectionchanged", null, CErrAddInfo);
  397. CErrWaze.selectionManager.events.register("selectionchanged", null, CErrColor);
  398. CErrorsModel.actionManager.events.register("afterclearactions", null, CErrColor);
  399. CErrorsModel.actionManager.events.register("afterundoaction", null, CErrColor);
  400. CErrorsMap.events.register("zoomend", null, CErrColor);
  401. CErrorsMap.events.register("moveend", null, CErrColor);
  402. window.setTimeout(CErrColor, 500);
  403. }
  404. function fillHtml(id,type,color,icon,text) {
  405. var WMECErrors=JSON.parse(localStorage.getItem('WMEColorErrors'));
  406. return '<tr style="line-height:14px;"><td style="width:20px;"><input type="checkbox" class="'+(type==="seg_Bad" ? '_seg' : '_poi')+'" id="_'+id+'"'+(WMECErrors[id] ? ' checked' : '')+(WMECErrors[type] ? '' : ' disabled')+'/></td><td style="width:20px;"><font style="color:'+color+';font-family:FontAwesome;">'+icon+'</font></td><td><label for="_'+id+'" style="font-weight:normal;">'+text+'</label></td></tr>';
  407. }
  408. function checkClicLayer(){
  409. var lieu=CErrorsI18n.translations[CErrorsI18n.locale].layers.name.landmarks;
  410. getId('layer-switcher-'+CErrorsMap.getLayersByName(lieu)[0].id).onclick=(function(){
  411. window.setTimeout((function() {
  412. CErrColor();
  413. }),10);
  414. });
  415. }
  416. function addIcon(icon,color,geometry,type,pos) {
  417. var style = {
  418. fill: false,
  419. stroke: false,
  420. label: icon,
  421. labelAlign: "cb",
  422. labelXOffset: -4,
  423. labelYOffset: (pos*20),
  424. fontColor: color,
  425. fontSize:"20px",
  426. fontOpacity: getId('errOpacity').value,
  427. fontFamily: "FontAwesome",
  428. labelOutlineWidth: 2,
  429. zIndex: 99999
  430. };
  431. if (type==="segment") {
  432. if(geometry.length==2){
  433. var midX = (((geometry[0].x + geometry[1].x) / 2) + geometry[0].x) / 2;
  434. var midY = (((geometry[0].y + geometry[1].y) / 2) + geometry[0].y) / 2;
  435. var labelPoint = new CErrorsOpenLayers.Geometry.Point(midX,midY);
  436. var imageFeature = new CErrorsOpenLayers.Feature.Vector(labelPoint, null, style);
  437. ColorErrors_mapLayer.addFeatures([imageFeature]);
  438. }
  439. else {
  440. for(i=0;i<geometry.length-1;i++){
  441. if(i%3==1){
  442. var midX = (((geometry[i].x + geometry[i+1].x) / 2) + geometry[i].x) / 2;
  443. var midY = (((geometry[i].y + geometry[i+1].y) / 2) + geometry[i].y) / 2;
  444. var labelPoint = new CErrorsOpenLayers.Geometry.Point(midX,midY);
  445. var imageFeature = new CErrorsOpenLayers.Feature.Vector(labelPoint, null, style);
  446. ColorErrors_mapLayer.addFeatures([imageFeature]);
  447. }
  448. }
  449. }
  450. }
  451. else {
  452. var midX = (((geometry.left + geometry.right) / 2) + geometry.right) / 2;
  453. var midY = (((geometry.bottom + geometry.top) / 2) + geometry.bottom) / 2;
  454. var labelPoint = new CErrorsOpenLayers.Geometry.Point(midX,midY);
  455. var imageFeature = new CErrorsOpenLayers.Feature.Vector(labelPoint, null, style);
  456. ColorErrors_mapLayer.addFeatures([imageFeature]);
  457. }
  458. }
  459. function addLegend(id,icon,color,text){
  460. if(CErrWaze.selectionManager.selectedItems[0] && CErrWaze.selectionManager.selectedItems[0].model.attributes.id===id && getId('ErrorsList')) {
  461. getId('ErrorsList').innerHTML +="<span style='color:"+color+";font-family:FontAwesome;'>"+icon+"</span> <span style='color:"+color+";'>"+text+"</span><br>";
  462. }
  463. }
  464. function CErrColor(){
  465. var lineFeature=[], ls=JSON.parse(localStorage.WMEColorErrors);
  466. var lieu=CErrorsI18n.translations[CErrorsI18n.locale].layers.name.landmarks;
  467.  
  468. // Initialize layer
  469. try { ColorErrors_mapLayer.destroyFeatures(); }
  470. catch(err){ log('err destroyFeatures: ',err); }
  471.  
  472. if (getId('ErrorsList')) { getId('ErrorsList').innerHTML=""; }
  473.  
  474. //Segments Checking
  475. if (ls.seg_Bad) {
  476. for (var seg in CErrorsModel.segments.objects) {
  477. // Get values
  478. var segment=CErrorsModel.segments.get(seg), j=0;
  479. var attributes=segment.attributes;
  480. var geometry=attributes.geometry.components;
  481. var line=getId(segment.geometry.id);
  482. if (typeof (segment)==='undefined' || line === null || segment.state === "Update") continue;
  483. //Name
  484. var sid=attributes.primaryStreetID;
  485. var street=CErrorsModel.streets.get(sid);
  486. if (typeof (street)==='undefined') continue;
  487. //Alt Name
  488. var salt=attributes.streetIDs[0];
  489. var streetalt=CErrorsModel.streets.get(salt);
  490. if (streetalt) { var altname=streetalt.name; } else { var altname=""; }
  491. //City
  492. var streetCity = CErrorsModel.cities.get(street.cityID);
  493. if (typeof (streetCity)==='undefined') continue;
  494. streetCity = streetCity.attributes.name;
  495.  
  496. var roadType=attributes.roadType;
  497. if (attributes.primaryStreetID === null || attributes.primaryStreetID === undefined) continue;
  498. if (CErrorsModel.streets.get(attributes.primaryStreetID) === null || CErrorsModel.streets.get(attributes.primaryStreetID) === undefined) continue;
  499. var newWidth="", newColor="", newOpacity="0", gline="";
  500.  
  501. if ((ls.myLvl && attributes.rank <= myLevel) || ls.myLvl===false) {
  502. if (ls.seg_Ramp_city) { // Ramp/Freeway with city name
  503. if (streetCity && /^(3|4)$/.test(attributes.roadType)) {
  504. newColor="#ff0000"; newWidth=3; newOpacity=0.95; gline=segment.attributes.geometry.getVertices();
  505. j++;
  506. addIcon("\uf015",newColor,geometry,"segment",j);
  507. addLegend(attributes.id,"\uf015",newColor,CErrSeg[11]);
  508. }
  509. }
  510. if (street.name || altname) {
  511. if (/( - )/.test(street.name)) { var trs=street.name.split(" - "); }
  512. if (ls.seg_Priv) { // Private with bad name
  513. if (attributes.roadType===17 && new RegExp(streetNameSeg).test(street.name)===false) {
  514. newColor="#ff7700"; newWidth=3; newOpacity=0.95; gline=segment.attributes.geometry.getVertices();
  515. j++;
  516. addIcon("\uf256",newColor,geometry,"segment",j);
  517. addLegend(attributes.id,"\uf256",newColor,CErrSeg[2]);
  518. }
  519. }
  520. if (ls.seg_Park && street.name) { // Parking with name (But Place / Square)
  521. if (attributes.roadType===20 && new RegExp(parkNameSeg).test(street.name)===false) {
  522. newColor="#ff0000"; newWidth=3; newOpacity=0.95; gline=segment.attributes.geometry.getVertices();
  523. j++;
  524. addIcon("\uf288",newColor,geometry,"segment",j);
  525. addLegend(attributes.id,"\uf288",newColor,CErrSeg[3]);
  526. }
  527. }
  528. if (ls.seg_Rail && street.name) { // Railroad with bad name
  529. if (attributes.roadType===18 && (altname || street.name)) { //Railroad with name
  530. newColor="#ff0000"; newWidth=3; newOpacity=0.95; gline=segment.attributes.geometry.getVertices();
  531. j++;
  532. addIcon("\uf238",newColor,geometry,"segment",j);
  533. addLegend(attributes.id,"\uf238",newColor,CErrSeg[4]);
  534. }
  535. }
  536. if (ls.seg_Ramp_name && street.name) {
  537. if (/^(3|4)$/.test(attributes.roadType) && /\/.*\//.test(street.name)) { // Ramp with 3 directions or more
  538. newColor="#ff0000"; newWidth=3; newOpacity=0.95; gline=segment.attributes.geometry.getVertices();
  539. j++;
  540. addIcon("\uf25b",newColor,geometry,"segment",j);
  541. addLegend(attributes.id,"\uf25b",newColor,CErrSeg[7]);
  542. }
  543. else if (/^(3|4)$/.test(attributes.roadType) && /\//.test(street.name)) { // Ramp with 2 directions
  544. newColor="#ff7700"; newWidth=3; newOpacity=0.95; gline=segment.attributes.geometry.getVertices();
  545. j++;
  546. addIcon("\uf25a",newColor,geometry,"segment",j);
  547. addLegend(attributes.id,"\uf25a",newColor,CErrSeg[7]);
  548. }
  549. }
  550. if (ls.seg_Dir_name && street.name) { // Directions but not Ramp/Freeway/Major
  551. if (/^[^3|4|6]$/.test(attributes.roadType) && /[:|>]/.test(street.name)) {
  552. newColor="#ff0000"; newWidth=3; newOpacity=0.95; gline=segment.attributes.geometry.getVertices();
  553. j++;
  554. addIcon("\uf0a9",newColor,geometry,"segment",j);
  555. addLegend(attributes.id,"\uf0a9",newColor,CErrSeg[6]);
  556. }
  557. }
  558. if (ls.seg_Toll) { // Toll but not Ramp/Freeway
  559. if (/^[^3|4]$/.test(attributes.roadType) && (attributes.fwdToll || attributes.revToll)) {
  560. newColor="#ff0000"; newWidth=3; newOpacity=0.95; gline=segment.attributes.geometry.getVertices();
  561. j++;
  562. addIcon("\uf155",newColor,geometry,"segment",j);
  563. addLegend(attributes.id,"\uf155",newColor,CErrSeg[10]);
  564. }
  565. }
  566. if (ls.seg_RSAlt && street.name) { // RoadShield must be in alt
  567. if (attributes.roadType!=19 && trs
  568. && /^[A|C|D|N|M|R][0-9]+[a-z]?[0-9]?/.test(trs[0].replace(".",""))===true // Roadshield (1st part)
  569. && / - /.test(street.name)===true // Roadshield & street name (separator -)
  570. && /Intérieure|Extérieure/.test(trs[1])===false
  571. && streetCity // City ok
  572. ) {
  573. newColor="#ff0000"; newWidth=3; newOpacity=0.95; gline=segment.attributes.geometry.getVertices();
  574. j++;
  575. addIcon("\uf074",newColor,geometry,"segment",j);
  576. addLegend(attributes.id,"\uf074",newColor,CErrSeg[12]);
  577. }
  578. }
  579. if (ls.seg_HW_name && street.name) { // Highways with bad name
  580. if (/^(3|4|6)$/.test(attributes.roadType) && (/:/.test(street.name)===true && /^[A|C|D|N|M|R][0-9]+[a-z]?[0-9]?/.test(street.name)===false) && /^>/.test(street.name)===false && /^[Sortie ]+[0-9]+/.test(street.name)===false && /^(Rocade|Périphérique)/.test(street.name)===false) {
  581. newColor="#ff0000"; newWidth=3; newOpacity=0.95; gline=segment.attributes.geometry.getVertices();
  582. j++;
  583. addIcon("\uf018",newColor,geometry,"segment",j);
  584. addLegend(attributes.id,"\uf018",newColor,CErrSeg[5]);
  585. }
  586. }
  587. if (ls.seg_SegBadRS && street.name) { // RoadShield but bad type
  588. if (/^(1|8|17|20)$/.test(attributes.roadType) && (/^[A|D|N|M][0-9]+/.test(street.name) || /^[A|D|N|M]$/.test(street.name))) {
  589. newColor="#ff0000"; newWidth=3; newOpacity=0.95; gline=segment.attributes.geometry.getVertices();
  590. j++;
  591. addIcon("\uf044",newColor,geometry,"segment",j);
  592. addLegend(attributes.id,"\uf044",newColor,CErrSeg[14]);
  593. }
  594. }
  595. if (ls.seg_HNFree) { // House number on Freeway or ramp (and some undrivables)
  596. if (/^(3|4|8|14|18|19)$/.test(attributes.roadType) && attributes.hasHNs===true) {
  597. newColor="#ff0000"; newWidth=3; newOpacity=0.95; gline=segment.attributes.geometry.getVertices();
  598. j++;
  599. addIcon("\uf162",newColor,geometry,"segment",j);
  600. addLegend(attributes.id,"\uf162",newColor,CErrSeg[15]);
  601. }
  602. }
  603. if (ls.seg_BadSpeed) { // Bad speed (ex: 90km/h in city)
  604. if (attributes.fwdMaxSpeed>=90 && attributes.fwdMaxSpeedUnverified===false && attributes.revMaxSpeed>=90 && attributes.revMaxSpeedUnverified===false && streetCity) {
  605. newColor="#ff7700"; newWidth=3; newOpacity=0.95; gline=segment.attributes.geometry.getVertices();
  606. j++;
  607. addIcon("\uf1ce",newColor,geometry,"segment",j);
  608. addLegend(attributes.id,"\uf1ce",newColor,CErrSeg[16]);
  609. }
  610. }
  611. if (ls.seg_RShield && street.name) { // Wrong prefix (RoadShield)
  612. if ((trs && attributes.roadType!=19 && /^[A|D|N|M|R][0-9]+[a-z]?[0-9]?/.test(trs[0].replace(".",""))===false && / - /.test(street.name)===true)
  613. || /^[A|D|N|M|R][0-9]+[a-z]?[0-9]? ?-[A-Za-z]/.test(street.name)===true || /^[A|D|N|M|R][0-9]+[a-z]?[0-9]?- ?[A-Za-z]/.test(street.name)===true// No space between RS and street name
  614. ) {
  615. newColor="#ff0000"; newWidth=3; newOpacity=0.95; gline=segment.attributes.geometry.getVertices();
  616. j++;
  617. addIcon("\uf152",newColor,geometry,"segment",j);
  618. addLegend(attributes.id,"\uf152",newColor,CErrSeg[8]);
  619. }
  620. }
  621. if (ls.seg_SNameAlt && street.name) { // Street Name must be in alt
  622. if (attributes.roadType!=19 && trs
  623. && /^[A|C|D|N|M|R][0-9]+[a-z]?[0-9]?/.test(trs[0].replace(".",""))===true // Roadshield (1st part)
  624. && /^[E][0-9]/.test(trs[1])===false // European Roadshield (2nd part)
  625. && new RegExp(excepNameSeg).test(street.name)===false // Exception
  626. && / - /.test(street.name)===true // Roadshield & street name (separator -)
  627. && /Intérieure|Extérieure/.test(trs[1])===false
  628. && !streetCity // No city
  629. ) {
  630. newColor="#ff0000"; newWidth=3; newOpacity=0.95; gline=segment.attributes.geometry.getVertices();
  631. j++;
  632. addIcon("\uf079",newColor,geometry,"segment",j);
  633. addLegend(attributes.id,"\uf079",newColor,CErrSeg[13]);
  634. }
  635. }
  636. if (ls.seg_DleSpace && street.name) { // Double spacing in name
  637. if (/ /.test(street.name)===true) {
  638. newColor="#ff0000"; newWidth=3; newOpacity=0.95; gline=segment.attributes.geometry.getVertices();
  639. j++;
  640. addIcon("\uf101",newColor,geometry,"segment",j);
  641. addLegend(attributes.id,"\uf101",newColor,CErrSeg[9]);
  642. }
  643. }
  644. }
  645. // Highlight if error
  646. if (gline !== "") {
  647. var style={
  648. strokeWidth: newWidth,
  649. strokeColor: newColor,
  650. strokeOpacity: newOpacity
  651. };
  652. var points=[];
  653. for (var i=0; i<gline.length; i++) { points.push(new CErrorsOpenLayers.Geometry.Point(gline[i].x, gline[i].y)); }
  654. var newline=new CErrorsOpenLayers.Geometry.LineString(points);
  655. lineFeature.push(new CErrorsOpenLayers.Feature.Vector(newline, null, style));
  656. }
  657. }
  658. }
  659. }
  660.  
  661. //Places Checking
  662. if (ls.poi_Bad && getId('layer-switcher-group_places').checked) {
  663. for (var poi in CErrorsModel.venues.objects) {
  664. // Get values
  665. var venue=CErrorsModel.venues.get(poi), j=0;
  666. var pattributes=venue.attributes;
  667. var geometry=pattributes.geometry.bounds;
  668. var poly=pattributes.id;
  669. if (typeof (venue)==='undefined' || poly === null || poi.state=="Update" || poi.selected) continue;
  670. var categories=pattributes.categories;
  671. var pname=pattributes.name;
  672. var venueStreet=CErrorsModel.streets.get(pattributes.streetID);
  673. if (venueStreet) { var venueCity = CErrorsModel.cities.get(venueStreet.cityID); }
  674. var newWidth="", newColor="", newOpacity="0", gpoly="";
  675.  
  676. if ((ls.myLvl && pattributes.rank <= myLevel && pattributes.adLocked===false) || ls.myLvl===false) {
  677. if (ls.poi_Resid) { // maybe a residential POI
  678. if ((/^[0-9][ ]?[a-zA-Z]/.test(pname)===true || new RegExp(privNameSeg).test(pname)===true) && pattributes.residential===false && pattributes.categories.indexOf("PARKING_LOT")===-1) {
  679. newColor="#ff7700"; newWidth=15; newOpacity=0.5; gpoly=pattributes.geometry.getVertices();
  680. if (venue.isPoint()) { newWidth=26; }
  681. j++;
  682. addIcon("\uf015",newColor,geometry,"venue",j);
  683. addLegend(poly,"\uf015",newColor,CErrPoi[7]);
  684. }
  685. }
  686. if (ls.poi_Google) { //POI without Google link
  687. if (pattributes.externalProviderIDs.length===0 && pattributes.residential===false && new RegExp(excepCatPoi).test(categories)===false) {
  688. newColor="#ff7700"; newWidth=15; newOpacity=0.5; gpoly=pattributes.geometry.getVertices();
  689. if (venue.isPoint()) { newWidth=26; }
  690. j++;
  691. addIcon("\uf1a0",newColor,geometry,"venue",j);
  692. addLegend(poly,"\uf1a0",newColor,CErrPoi[8]);
  693. }
  694. }
  695. if (ls.poi_Phone && pattributes.phone) { //POI with bad phone number
  696. if (new RegExp('^(\\'+prefPhone + ')([ ](\\d{2})){4}$').test(pattributes.phone)===false // Prefix + 4 digits
  697. && (/^[13]\d[ ](\d{2})$/).test(pattributes.phone)===false // 1x xx or 3x xx
  698. && (/^(0[ ]8\d{2})([ ](\d{3})){2}/).test(pattributes.phone)===false // 0 8xx xxx xxx
  699. && (/^(0[ ]8\d{2})([ ](\d{2})){3}/).test(pattributes.phone)===false // 0 8xx xx xx xx
  700. && (/^(15|17|18|112)$/).test(pattributes.phone)===false // Emergency numbers
  701. ) {
  702. newColor="#ff7700"; newWidth=15; newOpacity=0.5; gpoly=pattributes.geometry.getVertices();
  703. if (venue.isPoint()) { newWidth=26; }
  704. j++;
  705. addIcon("\uf095",newColor,geometry,"venue",j);
  706. addLegend(poly,"\uf095",newColor,CErrPoi[13]);
  707. }
  708. }
  709. if (ls.poi_Other) { // Place type is "Other"
  710. if (categories.indexOf("OTHER") > -1 && pname!="Déchetterie") {
  711. newColor="#ff7700"; newWidth=15; newOpacity=0.5; gpoly=pattributes.geometry.getVertices();
  712. if (venue.isPoint()) { newWidth=26; }
  713. j++;
  714. addIcon("\uf29c",newColor,geometry,"venue",j);
  715. addLegend(poly,"\uf29c",newColor,CErrPoi[10]);
  716. }
  717. }
  718. if (ls.poi_Entry) { // POI with default entryExitPoints
  719. if (new RegExp(entryPointPoi).test(categories)===false && pattributes.entryExitPoints.length===0 && venue.isPoint()===false) {
  720. newColor="#ff7700"; newWidth=15; newOpacity=0.5; gpoly=pattributes.geometry.getVertices();
  721. j++;
  722. addIcon("\uf18e",newColor,geometry,"venue",j);
  723. addLegend(poly,"\uf18e",newColor,CErrPoi[4]);
  724. }
  725. }
  726. if (ls.poi_Park_name && categories.indexOf("PARKING_LOT") > -1) { // Parking with bad name
  727. if (new RegExp(streetNameSeg).test(pname)===true) { continue; } //If parking name is a road
  728. if (new RegExp('^'+parkNamePoi+'$').test(pname)===true || // Only Parkings or Aire // ?️|?️️|
  729. new RegExp('^'+parkNamePoi).test(pname)===false // Don't start by ?️ or Parking
  730. // /^(Parking[s]?)( de[s]?| du | le[s]? | la | pour )/.test(pname)===true // Contain bad words
  731. ) {
  732. newColor="#ff0000"; newWidth=15; newOpacity=0.5; gpoly=pattributes.geometry.getVertices();
  733. j++;
  734. addIcon("\uf288",newColor,geometry,"venue",j);
  735. addLegend(poly,"\uf288",newColor,CErrPoi[2]);
  736. }
  737. else if (pname==="") {
  738. newColor="#ff7700"; newWidth=15; newOpacity=0.5; gpoly=pattributes.geometry.getVertices();
  739. j++;
  740. addIcon("\uf288",newColor,geometry,"venue",j);
  741. addLegend(poly,"\uf288",newColor,CErrPoi[2]);
  742. }
  743. if (venue.isPoint()) newWidth=26;
  744. }
  745. if (ls.poi_Park_type && categories.indexOf("PARKING_LOT") > -1) { // Parking with type undefined
  746. if (/PUBLIC|RESTRICTED|PRIVATE/.test(pattributes.categoryAttributes.PARKING_LOT.parkingType)===false) {
  747. newColor="#ff0000"; newWidth=15; newOpacity=0.5; gpoly=pattributes.geometry.getVertices();
  748. j++;
  749. addIcon("\uf11d",newColor,geometry,"venue",j);
  750. addLegend(poly,"\uf11d",newColor,CErrPoi[12]);
  751. }
  752. }
  753. if (ls.poi_Address) { // POI with bad address (Nxxx/Dxxx) or without address
  754. if (typeof (venueStreet)!='undefined' && ((/^[A|D|N|M|R][0-9]+/.test(venueStreet.name) && /[ - ]/.test(venueStreet.name)) || typeof (venueStreet.name)==='undefined')) {
  755. newColor="#ff0000"; newWidth=15; newOpacity=0.5; gpoly=pattributes.geometry.getVertices();
  756. if (venue.isPoint()) { newWidth=26; }
  757. j++;
  758. addIcon("\uf2bc",newColor,geometry,"venue",j);
  759. addLegend(poly,"\uf2bc",newColor,CErrPoi[3]);
  760. }
  761. }
  762. if (ls.poi_LandM) { // Landmark with road name or city name
  763. if (new RegExp(landmarkPoi).test(categories) && pname==="" && ((venueStreet && venueStreet.name) || (venueCity && venueCity.attributes.name))) {
  764. newColor="#ff0000"; newWidth=15; newOpacity=0.5; gpoly=pattributes.geometry.getVertices();
  765. if (venue.isPoint()) { newWidth=26; }
  766. j++;
  767. addIcon("\uf1bb",newColor,geometry,"venue",j);
  768. addLegend(poly,"\uf1bb",newColor,CErrPoi[5]);
  769. }
  770. }
  771. if (ls.poi_DleSpace) { // Double spacing in name
  772. if (venueStreet && (/ /.test(venueStreet.name)===true || / /.test(pname)===true)) {
  773. newColor="#ff0000"; newWidth=15; newOpacity=0.5; gpoly=pattributes.geometry.getVertices();
  774. j++;
  775. addIcon("\uf101",newColor,geometry,"venue",j);
  776. addLegend(poly,"\uf101",newColor,CErrPoi[6]);
  777. if (venue.isPoint()) { newWidth=26; }
  778. }
  779. }
  780. if (ls.poi_Relig && categories.indexOf("RELIGIOUS_CENTER") > -1) { // Religious Center with bad name
  781. if (new RegExp('^'+religiousPoi+'$').test(pname)===true || // category without name
  782. new RegExp('^'+religiousPoi).test(pname)===false) { // Bad 1st name
  783. newColor="#ff0000"; newWidth=15; newOpacity=0.5; gpoly=pattributes.geometry.getVertices();
  784. j++;
  785. addIcon("\uf015",newColor,geometry,"venue",j);
  786. addLegend(poly,"\uf015",newColor,CErrPoi[14]);
  787. if (venue.isPoint()) { newWidth=26; }
  788. }
  789. }
  790. if ((ls.poi_Relig && new RegExp('^'+religiousPoi).test(pname)===true && categories.indexOf("RELIGIOUS_CENTER") == -1) || // Religious Center Name but bad category
  791. (new RegExp('^'+religiousPoi+'$').test(pname)===true && categories.indexOf("RELIGIOUS_CENTER") == -1)) { // Bad Religious Center Name with bad category
  792. newColor="#ff0000"; newWidth=15; newOpacity=0.5; gpoly=pattributes.geometry.getVertices();
  793. j++;
  794. addIcon("\uf015",newColor,geometry,"venue",j);
  795. addLegend(poly,"\uf015",newColor,CErrPoi[14]);
  796. if (venue.isPoint()) { newWidth=26; }
  797. }
  798. if (ls.poi_WFeed || ls.poi_WPark) { //Place updated by WazeFeed
  799. if (pattributes.updatedBy && CErrorsModel.users.get(pattributes.updatedBy)) {
  800. var updName = CErrorsModel.users.get(pattributes.updatedBy).userName;
  801. if (((ls.poi_WFeed && new RegExp(wazeBot).test(updName)) || (ls.poi_WPark && updName=="WazeParking1")) && pattributes.residential===false) {
  802. newColor="#ffcc00"; newWidth=15; newOpacity=0.5; gpoly=pattributes.geometry.getVertices();
  803. if (venue.isPoint()) { newWidth=26; newOpacity=0.75; }
  804. j++;
  805. addIcon("\uf263",newColor,geometry,"venue",j);
  806. if (updName=="WazeFeed") { addLegend(poly,"\uf263",newColor,CErrPoi[9]); }
  807. else { addLegend(poly,"\uf263",newColor,CErrPoi[11]); }
  808. }
  809. }
  810. }
  811. // Highlight if error
  812.  
  813. }
  814. if (pattributes.adLocked) {
  815. newColor="#ff0000"; newWidth=15; newOpacity=0.75; gpoly=pattributes.geometry.getVertices();
  816. j++;
  817. addIcon("\uf023",newColor,geometry,"venue",j);
  818. addLegend(poly,"\uf023",newColor,CErrLeg[7]);
  819. if (venue.isPoint()) { newWidth=26; }
  820. }
  821. if (gpoly!=="") {
  822. var style={
  823. strokeWidth: newWidth,
  824. strokeColor: newColor,
  825. strokeOpacity: newOpacity,
  826. fillOpacity: 0
  827. };
  828. var points=[];
  829. for (var i=0; i<gpoly.length; i++) { points.push(new CErrorsOpenLayers.Geometry.Point(gpoly[i].x, gpoly[i].y)); }
  830. var newpoly=new CErrorsOpenLayers.Geometry.LinearRing(points);
  831. lineFeature.push(new CErrorsOpenLayers.Feature.Vector(newpoly, null, style));
  832. }
  833. }
  834. }
  835.  
  836. // Display highlighted features
  837. try{ ColorErrors_mapLayer.addFeatures(lineFeature); }
  838. catch(err){ log('err addFeatures: ',err); }
  839. }
  840. CErrors_bootstrap();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址