WME Color Errors

Adds colours to show errors

目前为 2017-06-28 提交的版本,查看 最新版本

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