WME Color Errors

Adds colours to show errors

目前为 2017-06-22 提交的版本。查看 最新版本

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