WME Color Errors

Adds colours to show errors

当前为 2016-08-23 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name WME Color Errors
  3. // @name:fr WME Color Errors
  4. // @version 0.16
  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-2016
  16. // @grant none
  17. // ==/UserScript==
  18.  
  19. var debug=true;
  20. var WMECErrors={};
  21. var ColorErrors_mapLayer=[];
  22.  
  23. // *********************
  24. // ** HELPER FUNCTION **
  25. // *********************
  26.  
  27. function getId(node) {
  28. return document.getElementById(node);
  29. }
  30. function getElementsByClassName(classname, node) {
  31. node || (node=document.getElementsByTagName("body")[0]);
  32. for (var a=[], re=new RegExp("\\b" + classname + "\\b"), els=
  33. node.getElementsByTagName("*"), i=
  34. 0, j=
  35. els.length;i < j;i++) {
  36. re.test(els[i].className) && a.push(els[i]);
  37. }
  38. return a;
  39. }
  40. function IsJsonString(str) {
  41. try {
  42. JSON.parse(str);
  43. } catch (e) {
  44. return false;
  45. }
  46. return true;
  47. }
  48.  
  49. // *************
  50. // ** INIT **
  51. // *************
  52. function CErrors_bootstrap() {
  53. if (typeof unsafeWindow === "undefined") {
  54. unsafeWindow =( function () {
  55. var dummyElem=document.createElement('p');
  56. dummyElem.setAttribute('onclick', 'return window;');
  57. return dummyElem.onclick();
  58. }) ();
  59. }
  60. console.log("starting WME Color Errors", GM_info.script.version);
  61. CErrors_init();
  62. }
  63. function CErrors_init(){
  64. // Waze object needed
  65. CErrWaze=unsafeWindow.Waze; if(typeof(CErrWaze) === 'undefined'){ if (debug) { console.error("WME ColorErrors - CErrWaze : NOK"); } window.setTimeout(CErrors_init, 500); return; }
  66. CErrorsMap=CErrWaze.map; if(typeof(CErrorsMap) == 'undefined'){ if (debug) { console.error("WME ColorErrors - CErrorsmap : NOK"); } window.setTimeout(CErrors_init, 500); return; }
  67. CErrorsModel=CErrWaze.model; if(typeof(CErrorsModel) == 'undefined'){ if (debug) { console.error("WME ColorErrors - CErrorsmodel : NOK"); } window.setTimeout(CErrors_init, 500); return; }
  68. CErrorsI18n=unsafeWindow.I18n; if(typeof (CErrorsI18n) == 'undefined') { if (debug) { console.error('WME ColorErrors - CErrorsI18n : NOK'); } setTimeout(CErrors_init, 500); return; }
  69. // OpenLayers
  70. CErrorsOpenLayers=unsafeWindow.OpenLayers; if(typeof(CErrorsOpenLayers) === 'undefined'){ if (debug) { console.error("WME ColorErrors - OpenLayers : NOK"); } window.setTimeout(CErrors_init, 500); return; }
  71. // Waze GUI needed
  72. CErrorshandle=getId("user-info"); if(typeof(CErrorshandle) == 'undefined'){ window.setTimeout(CErrors_init, 500); return; }
  73. CErrorshandleClass=getElementsByClassName("nav-tabs", CErrorshandle)[0]; if(typeof(CErrorshandleClass) === 'undefined'){ window.setTimeout(CErrors_init, 500); return; }
  74. CErrorshandleClass2=getElementsByClassName("tab-content", CErrorshandle)[0]; if(typeof(CErrorshandleClass2) === 'undefined'){ window.setTimeout(CErrors_init, 500); return; }
  75.  
  76. // Verify localStorage. Init if empty or not correct
  77. if (typeof(localStorage.WMEColorErrors) === "undefined" || localStorage.WMEColorErrors.lenght===null || !IsJsonString(localStorage.WMEColorErrors)) {
  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_Ramp_name=true; // Ramp with 3 directions or more
  84. WMECErrors.seg_Dir_name=true; // Directions but not Ramp/Freeway
  85. WMECErrors.seg_RShield=true; // Wrong prefix
  86. WMECErrors.seg_DleSpace=true; // Double space in name
  87. WMECErrors.seg_Toll=true; // Toll (but Ramp/Freeway)
  88. // POI
  89. WMECErrors.poi_Bad=false; // Bad POI (group)
  90. WMECErrors.poi_Park_name=true; // Parking with [P]
  91. WMECErrors.poi_Address=true; // Dxxx/Nxxx in or no address
  92. WMECErrors.poi_Entry=true; // Entry Point not defined
  93. WMECErrors.poi_LandM=true; // Landmark with address (street |& city)
  94. WMECErrors.poi_DleSpace=true; // Double space in name
  95. // Low errors
  96. WMECErrors.poi_Resid=true; // Maybe a residential
  97. WMECErrors.poi_Google=true; // No link with Google
  98. WMECErrors.poi_WFeed=true; // Place created by WazeFeed
  99. WMECErrors.poi_WPark=true; // Place created by WazeParking1
  100. WMECErrors.poi_Other=true; // Place "Other"
  101. localStorage.setItem('WMEColorErrors', JSON.stringify(WMECErrors));
  102. }
  103.  
  104. // WME Layers check
  105. var layers=CErrorsMap.getLayersBy("uniqueName","__WME_Color_Errors");
  106. if(layers.length === 0) {
  107. var ColorErrors_style=new CErrorsOpenLayers.Style({
  108. pointRadius: 2,
  109. fontWeight: "normal",
  110. label : "${labelText}",
  111. fontFamily: "Tahoma, Courier New",
  112. labelOutlineColor: "#FFFFFF",
  113. labelOutlineWidth: 2,
  114. fontColor: '#000000',
  115. fontSize: "10px"
  116. });
  117.  
  118. ColorErrors_mapLayer=new CErrorsOpenLayers.Layer.Vector("Color Errors", {
  119. displayInLayerSwitcher: false,
  120. uniqueName: "__WME_Color_Errors",
  121. styleMap: new CErrorsOpenLayers.StyleMap(ColorErrors_style)
  122. });
  123.  
  124. CErrorsI18n.translations.en.layers.name["__WME_Color_Errors"]="Color Errors";
  125. CErrorsMap.addLayer(ColorErrors_mapLayer);
  126. ColorErrors_mapLayer.setVisibility(true);
  127.  
  128. }
  129. CErrors_Mainhtml();
  130. }
  131.  
  132. // *************
  133. // ** HTML **
  134. // *************
  135.  
  136. function CErrors_Mainhtml() {
  137. if (CErrorsI18n.locale == 'fr') {
  138. CErrSeg=new Array('Contrôle des segments',
  139. 'Mauvais segments',
  140. 'Voie privée avec mauvais nom',
  141. 'Parking avec un nom (sauf Place & Square)',
  142. 'Mauvais nom de voie ferrée',
  143. 'Types Routes avec mauvais nom',
  144. 'Bretelle avec plusieurs directions',
  145. 'Direction (sauf bretelle et Autoroute)',
  146. 'Mauvais préfixe (RoadShield)',
  147. 'Double espace dans le nom',
  148. 'Péage (sauf bretelle et Autoroute)'
  149. );
  150. CErrPoi=new Array('Contrôle des places',
  151. 'Mauvaise places',
  152. 'Parking nommé [P] ou rien',
  153. 'Pas d\'adresse ou contenant Dxxx/Nxxx',
  154. 'Point d\'entré non défini',
  155. 'Site naturel avec adresse',
  156. 'Double espace dans le nom',
  157. 'Peut-être une place résidentielle',
  158. 'Pas de lien avec Google',
  159. 'Lieu créé par WazeFeed',
  160. 'Lieu de type "Autres"',
  161. 'Lieu créé par WazeParking1'
  162. );
  163. CErrLeg=new Array('Légende',
  164. 'A corriger',
  165. 'A vérifier',
  166. 'Pour information'
  167. );
  168. }
  169. else {
  170. CErrSeg=new Array('Segments Checking',
  171. 'Bad Segments',
  172. 'Private with bad name',
  173. 'Parking with name (But Place / Square)',
  174. 'Railroad with bad name',
  175. 'Highways with bad name',
  176. 'Ramp with several directions',
  177. 'Direction (but Ramp/Freeway)',
  178. 'Wrong prefix (RoadShield)',
  179. 'Double spacing in name',
  180. 'Toll (but Ramp/Freeway)'
  181. );
  182. CErrPoi=new Array('Places Checking',
  183. 'Bad Places',
  184. 'Parking named [P] or null',
  185. 'No address or Dxxx/Nxxx within',
  186. 'Entry Point not defined',
  187. 'Natural features with address',
  188. 'Double spacing in name',
  189. 'Maybe a residential place',
  190. 'No link with Google',
  191. 'Place created by WazeFeed',
  192. 'Place type is "Other"',
  193. 'Place created by WazeParking1'
  194. );
  195. CErrLeg=new Array('Legend',
  196. 'To correct',
  197. 'To check',
  198. 'For information'
  199. );
  200. }
  201. //Create content in CErrors's tab
  202. var CEnewtab=document.createElement('li');
  203. CEnewtab.innerHTML="<a href='#sidepanel-ColorErrors' data-toggle='tab'><span class='fa fa-eye' title='Color Errors'></span></a>";
  204. CErrorshandleClass.appendChild(CEnewtab);
  205.  
  206. var WMECErrors=JSON.parse(localStorage.getItem('WMEColorErrors'));
  207. var CEaddon=document.createElement('section');
  208. CEaddon.id="sidepanel-ColorErrors";
  209. var red='<div style="width:8px;height:8px;border-radius:4px;background-color:#ff0000;margin-right:2px;"></div>';
  210. var ora='<div style="width:8px;height:8px;border-radius:4px;background-color:#ff7700;margin-right:2px;"></div>';
  211. var yel='<div style="width:8px;height:8px;border-radius:4px;background-color:#ffcc00;margin-right:2px;"></div>';
  212. CEaddon.innerHTML="<div style='float:left; margin-left:5px;'><b><a href='https://gf.qytechs.cn/scripts/xxx-wme-color-errors' target='_blank'><u>WME Color Errors</u></a></b> v"+ GM_info.script.version +"</div>"
  213. + '<br><br><h4 style="float:left;">'+CErrSeg[0]+'</h4><div style="clear:both;">'
  214. + '<input type="checkbox" id="_seg_Bad" '+(WMECErrors.seg_Bad ? ' checked' : '')+'/> '+CErrSeg[1]+'<br><div id="BadSeg" style="margin-left:5px;"><table>'
  215. + '<tr><td><input type="checkbox" class="_seg" id="_seg_Priv" '+(WMECErrors.seg_Priv ? ' checked' : '')+(WMECErrors.seg_Bad ? '' : ' disabled')+'/></td><td>'+ora+'</td><td>'+CErrSeg[2]+'</td></tr>'
  216. + '<tr><td><input type="checkbox" class="_seg" id="_seg_Park" '+(WMECErrors.seg_Park ? ' checked' : '')+(WMECErrors.seg_Bad ? '' : ' disabled')+'/></td><td>'+red+'</td><td>'+CErrSeg[3]+'</td></tr>'
  217. + '<tr><td><input type="checkbox" class="_seg" id="_seg_Rail" '+(WMECErrors.seg_Rail ? ' checked' : '')+(WMECErrors.seg_Bad ? '' : ' disabled')+'/></td><td>'+red+'</td><td>'+CErrSeg[4]+'</td></tr>'
  218. + '<tr><td><input type="checkbox" class="_seg" id="_seg_HW_name" '+(WMECErrors.seg_HW_name ? ' checked' : '')+(WMECErrors.seg_Bad ? '' : ' disabled')+'/></td><td>'+red+'</td><td>'+CErrSeg[5]+'</td></tr>'
  219. + '<tr><td><input type="checkbox" class="_seg" id="_seg_Dir_name" '+(WMECErrors.seg_Dir_name ? ' checked' : '')+(WMECErrors.seg_Bad ? '' : ' disabled')+'/></td><td>'+red+'</td><td>'+CErrSeg[6]+'</td></tr>'
  220. + '<tr><td><input type="checkbox" class="_seg" id="_seg_Toll" '+(WMECErrors.seg_Toll ? ' checked' : '')+(WMECErrors.seg_Bad ? '' : ' disabled')+'/></td><td>'+red+'</td><td>'+CErrSeg[10]+'</td></tr>'
  221. + '<tr><td><input type="checkbox" class="_seg" id="_seg_Ramp_name"'+(WMECErrors.seg_Ramp_name ? ' checked' : '')+(WMECErrors.seg_Bad ? '' : ' disabled')+'/></td><td>'+red+ora+'</td><td>'+CErrSeg[7]+'</td></tr>'
  222. + '<tr><td><input type="checkbox" class="_seg" id="_seg_RShield" '+(WMECErrors.seg_RShield ? ' checked' : '')+(WMECErrors.seg_Bad ? '' : ' disabled')+'/></td><td>'+red+'</td><td>'+CErrSeg[8]+'</td></tr>'
  223. + '<tr><td><input type="checkbox" class="_seg" id="_seg_DleSpace" '+(WMECErrors.seg_DleSpace ? ' checked' : '')+(WMECErrors.seg_Bad ? '' : ' disabled')+'/></td><td>'+red+'</td><td>'+CErrSeg[9]+'</td></tr></table></div></div>'
  224. + '<br><h4 style="float:left;">'+CErrPoi[0]+'</h4><div style="clear:both;">'
  225. + '<tr><td><input type="checkbox" id="_poi_Bad" '+(WMECErrors.poi_Bad ? ' checked' : '')+'/> '+CErrPoi[1]+'<br><div id="BadPoi" style="margin-left:5px;"><table>'
  226. + '<tr><td><input type="checkbox" class="_poi" id="_poi_Address" '+(WMECErrors.poi_Address ? ' checked' : '')+(WMECErrors.poi_Bad ? '' : ' disabled')+'/></td><td>'+red+'</td><td>'+CErrPoi[3]+'</td></tr>'
  227. + '<tr><td><input type="checkbox" class="_poi" id="_poi_LandM" '+(WMECErrors.poi_LandM ? ' checked' : '')+(WMECErrors.poi_Bad ? '' : ' disabled')+'/></td><td>'+red+'</td><td>'+CErrPoi[5]+'</td></tr>'
  228. + '<tr><td><input type="checkbox" class="_poi" id="_poi_DleSpace" '+(WMECErrors.poi_DleSpace ? ' checked' : '')+(WMECErrors.poi_Bad ? '' : ' disabled')+'/></td><td>'+red+'</td><td>'+CErrPoi[6]+'</td></tr>'
  229. + '<tr><td><input type="checkbox" class="_poi" id="_poi_Park_name"'+(WMECErrors.poi_Park_name ? ' checked' : '')+(WMECErrors.poi_Bad ? '' : ' disabled')+'/></td><td>'+red+ora+'</td><td>'+CErrPoi[2]+'</td></tr>'
  230. + '<tr><td><input type="checkbox" class="_poi" id="_poi_Entry" '+(WMECErrors.poi_Entry ? ' checked' : '')+(WMECErrors.poi_Bad ? '' : ' disabled')+'/></td><td>'+ora+'</td><td>'+CErrPoi[4]+'</td></tr>'
  231. + '<tr><td><input type="checkbox" class="_poi" id="_poi_Resid" '+(WMECErrors.poi_Resid ? ' checked' : '')+(WMECErrors.poi_Bad ? '' : ' disabled')+'/></td><td>'+ora+'</td><td>'+CErrPoi[7]+'</td></tr>'
  232. + '<tr><td><input type="checkbox" class="_poi" id="_poi_Google" '+(WMECErrors.poi_Google ? ' checked' : '')+(WMECErrors.poi_Bad ? '' : ' disabled')+'/></td><td>'+ora+'</td><td>'+CErrPoi[8]+'</td></tr>'
  233. + '<tr><td><input type="checkbox" class="_poi" id="_poi_Other" '+(WMECErrors.poi_Other ? ' checked' : '')+(WMECErrors.poi_Bad ? '' : ' disabled')+'/></td><td>'+ora+'</td><td>'+CErrPoi[10]+'</td></tr>'
  234. + '<tr><td><input type="checkbox" class="_poi" id="_poi_WFeed" '+(WMECErrors.poi_WFeed ? ' checked' : '')+(WMECErrors.poi_Bad ? '' : ' disabled')+'/></td><td>'+yel+'</td><td>'+CErrPoi[9]+'</td></tr>'
  235. + '<tr><td><input type="checkbox" class="_poi" id="_poi_WPark" '+(WMECErrors.poi_WPark ? ' checked' : '')+(WMECErrors.poi_Bad ? '' : ' disabled')+'/></td><td>'+yel+'</td><td>'+CErrPoi[11]+'</td></tr></table></div></div>'
  236. + '<br><h4 style="float:left;">'+CErrLeg[0]+'</h4><div style="clear:both;">'
  237. + '<table><tr><td><div style="margin:5px;width:30px;height:2px;background-color:#ff0000;"></div></td><td>'+CErrLeg[1]+'</td></tr>'
  238. + '<tr><td><div style="margin:5px;width:30px;height:2px;background-color:#ff7700;"></div></td><td>'+CErrLeg[2]+'</td></tr>'
  239. + '<tr><td><div style="margin:5px;width:30px;height:2px;background-color:#ffcc00;"></div></td><td>'+CErrLeg[3]+'</td></tr></table></div>'
  240. ;
  241. CEaddon.className='tab-pane';
  242. CErrorshandleClass2.appendChild(CEaddon);
  243.  
  244. getId('_seg_Bad').onclick=(function(){
  245. var ls=JSON.parse(localStorage.WMEColorErrors);
  246. if (getId('_seg_Bad').checked === true) {
  247. for (var i=0; getElementsByClassName('_seg', BadSeg) [i]; i++) getElementsByClassName('_seg', BadSeg) [i].disabled=false;
  248. ls.seg_Bad=true;
  249. }
  250. else {
  251. for (var i=0; getElementsByClassName('_seg', BadSeg) [i]; i++) getElementsByClassName('_seg', BadSeg) [i].disabled=true;
  252. ls.seg_Bad=false;
  253. }
  254. localStorage.setItem('WMEColorErrors', JSON.stringify(ls));
  255. CErrColor();
  256. });
  257. getId('_poi_Bad').onclick=(function(){
  258. var ls=JSON.parse(localStorage.WMEColorErrors);
  259. if (getId('_poi_Bad').checked === true) {
  260. for (var i=0; getElementsByClassName('_poi', BadPoi) [i]; i++) getElementsByClassName('_poi', BadPoi) [i].disabled=false;
  261. ls.poi_Bad=true;
  262. }
  263. else {
  264. for (var i=0; getElementsByClassName('_poi', BadPoi) [i]; i++) getElementsByClassName('_poi', BadPoi) [i].disabled=true;
  265. ls.poi_Bad=false;
  266. }
  267. localStorage.setItem('WMEColorErrors', JSON.stringify(ls));
  268. CErrColor();
  269. });
  270. 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(); });
  271. 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(); });
  272. 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(); });
  273. 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(); });
  274. 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(); });
  275. 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(); });
  276. 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(); });
  277. 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(); });
  278. 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(); });
  279. 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(); });
  280. 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(); });
  281. 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(); });
  282. 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(); });
  283. 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(); });
  284. 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(); });
  285. 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(); });
  286. 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(); });
  287. 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(); });
  288. 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(); });
  289. window.setInterval(checkClicLayer, 500);
  290. CErrWaze.selectionManager.events.register("selectionchanged", null, CErrColor);
  291. CErrorsModel.actionManager.events.register("afterclearactions", null, CErrColor);
  292. CErrorsModel.actionManager.events.register("afterundoaction", null, CErrColor);
  293. CErrorsMap.events.register("zoomend", null, CErrColor);
  294. CErrorsMap.events.register("moveend", null, CErrColor);
  295. window.setTimeout(CErrColor, 500);
  296. }
  297. function checkClicLayer(){
  298. var lieu=CErrorsI18n.translations[CErrorsI18n.locale].layers.name.landmarks;
  299. getId('layer-switcher-'+CErrorsMap.getLayersByName(lieu)[0].id).onclick=(function(){
  300. window.setTimeout((function() {
  301. CErrColor();
  302. }),10);
  303. });
  304. }
  305. function CErrColor(){
  306. var lineFeature=[], ls=JSON.parse(localStorage.WMEColorErrors);
  307. var lieu=CErrorsI18n.translations[CErrorsI18n.locale].layers.name.landmarks;
  308.  
  309. // Initialize layer
  310. try { ColorErrors_mapLayer.destroyFeatures(); }
  311. catch(err){ log('err destroyFeatures: ',err); }
  312.  
  313. //Segments Checking
  314. if (ls.seg_Bad) {
  315. for (var seg in CErrorsModel.segments.objects) {
  316. // Get values
  317. var segment=CErrorsModel.segments.get(seg);
  318. var attributes=segment.attributes;
  319. var line=getId(segment.geometry.id);
  320. if (typeof (segment)==='undefined' || line === null || segment.state == "Update" || segment.selected == true) continue;
  321. var sid=attributes.primaryStreetID;
  322. var street=CErrorsModel.streets.get(sid);
  323. if (street) { var name=street.name; }
  324. var roadType=attributes.roadType;
  325. if (attributes.primaryStreetID === null || attributes.primaryStreetID === undefined) continue;
  326. if (CErrorsModel.streets.get(attributes.primaryStreetID) === null || CErrorsModel.streets.get(attributes.primaryStreetID) === undefined) continue;
  327. var newWidth="", newColor="", newOpacity="0", gline="";
  328.  
  329. if (street.name) {
  330. if (ls.seg_Priv) { // Private with bad name
  331. if (attributes.roadType===17 && /^(Le |La |Les |Allée|Avenue|Boulevard|Chemin|Cité|Clos|Cours|Domaine|Hameau|Impasse|Lotissement|Montée|Parc|Passage|Place|Promenade|Quai|Résidence|Rue|Route|Sente|Sentier|Square|Traverse|Villa|Voie)/.test(street.name)===false) {
  332. newColor="#ff7700"; newWidth=3; newOpacity=0.95; gline=segment.geometry.getVertices();
  333. }
  334. }
  335. if (ls.seg_Park) { // Parking with name (But Place / Square)
  336. if (attributes.roadType===20 && /^(Place|Square)/.test(street.name)===false) {
  337. newColor="#ff0000"; newWidth=3; newOpacity=0.95; gline=segment.geometry.getVertices();
  338. }
  339. }
  340. if (ls.seg_Rail) { // Railroad with bad name
  341. if (attributes.roadType===18 && /^(Voie Ferrée$|Metro|Tram)/.test(street.name)===false) {
  342. newColor="#ff0000"; newWidth=3; newOpacity=0.95; gline=segment.geometry.getVertices();
  343. }
  344. }
  345. if (ls.seg_HW_name) { // Highways with bad name
  346. 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) {
  347. newColor="#ff0000"; newWidth=3; newOpacity=0.95; gline=segment.geometry.getVertices();
  348. }
  349. }
  350. if (ls.seg_Ramp_name) {
  351. if (/^(3|4)$/.test(attributes.roadType) && /\/.*\//.test(street.name)) { // Ramp with 3 directions or more
  352. newColor="#ff0000"; newWidth=3; newOpacity=0.95; gline=segment.geometry.getVertices();
  353. }
  354. else if (/^(3|4)$/.test(attributes.roadType) && /\//.test(street.name)) { // Ramp with 2 directions
  355. newColor="#ff7700"; newWidth=3; newOpacity=0.95; gline=segment.geometry.getVertices();
  356. }
  357. }
  358. if (ls.seg_Dir_name) { // Directions but not Ramp/Freeway
  359. if (/^[^3|4]$/.test(attributes.roadType) && /[:|>]/.test(street.name)) {
  360. newColor="#ff0000"; newWidth=3; newOpacity=0.95; gline=segment.geometry.getVertices();
  361. }
  362. }
  363. if (ls.seg_Toll) { // Toll but not Ramp/Freeway
  364. if (/^[^3|4]$/.test(attributes.roadType) && (attributes.fwdToll || attributes.revToll)) {
  365. newColor="#ff0000"; newWidth=3; newOpacity=0.95; gline=segment.geometry.getVertices();
  366. }
  367. }
  368. if (ls.seg_RShield) { // Wrong prefix (RoadShield)
  369. var trs=street.name.split(" - ");
  370. if (attributes.roadType!=19 && /^[A|C|D|N|M|R][0-9]+[a-z]?[0-9]?/.test(trs[0].replace(".",""))===false && / - /.test(street.name)===true) {
  371. newColor="#ff0000"; newWidth=3; newOpacity=0.95; gline=segment.geometry.getVertices();
  372. }
  373. }
  374. if (ls.seg_DleSpace) { // Double spacing in name
  375. if (/ /.test(street.name)===true) {
  376. newColor="#ff0000"; newWidth=3; newOpacity=0.95; gline=segment.geometry.getVertices();
  377. }
  378. }
  379. }
  380. // Highlight if error
  381. if (gline!="") {
  382. var style={
  383. strokeWidth: newWidth,
  384. strokeColor: newColor,
  385. strokeOpacity: newOpacity
  386. };
  387. var points=[];
  388. for (var i=0; i<gline.length; i++) { points.push(new CErrorsOpenLayers.Geometry.Point(gline[i].x, gline[i].y)); }
  389. var newline=new CErrorsOpenLayers.Geometry.LineString(points);
  390. lineFeature.push(new CErrorsOpenLayers.Feature.Vector(newline, null, style));
  391. }
  392. }
  393. }
  394.  
  395. //Places Checking
  396. if (ls.poi_Bad && getId(CErrorsMap.getLayersByName(lieu)[0].id).style.display=="block") {
  397. for (var poi in CErrorsModel.venues.objects) {
  398. // Get values
  399. var venue=CErrorsModel.venues.get(poi);
  400. var pattributes=venue.attributes;
  401. var poly=getId(venue.geometry.id);
  402. if (typeof (venue)==='undefined' || poly === null || poi.state=="Update" || venue.selected) continue;
  403. var categories=pattributes.categories;
  404. var pname=pattributes.name;
  405. var venueStreet=CErrorsModel.streets.get(venue.attributes.streetID);
  406. if (venueStreet) { var venueCity = CErrorsModel.cities.get(venueStreet.cityID); }
  407. var newWidth="", newColor="", newOpacity="0", gpoly="";
  408.  
  409. if (ls.poi_Resid) { // maybe a residential POI
  410. if ((/^[0-9][ ]?[a-zA-Z]/.test(pname)===true || /^(Allée|Avenue|Boulevard|Chemin|Clos|Cours|Hameau|Impasse|Lotissement|Passage|Promenade|Quai|Rue|Route|Sente|Sentier|Voie)/.test(pname)===true) && venue.attributes.residential===false) {
  411. newColor="#ff7700"; newWidth=15; newOpacity=0.5; gpoly=venue.geometry.getVertices();
  412. if (venue.isPoint()) newWidth=26;
  413. }
  414. }
  415. if (ls.poi_Google) { //POI without Google link
  416. 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) {
  417. newColor="#ff7700"; newWidth=15; newOpacity=0.5; gpoly=venue.geometry.getVertices();
  418. if (venue.isPoint()) newWidth=26;
  419. }
  420. }
  421. if (ls.poi_Other) { // Place type is "Other"
  422. if (categories.indexOf("OTHER") > -1) {
  423. newColor="#ff7700"; newWidth=15; newOpacity=0.5; gpoly=venue.geometry.getVertices();
  424. if (venue.isPoint()) newWidth=26;
  425. }
  426. }
  427. if (ls.poi_Entry) { // POI with default entryExitPoints
  428. if (/(RIVER_STREAM|CANAL|SEA_LAKE_POOL|SWAMP_MARSH|ISLAND|FOREST_GROVE|BRIDGE|SWAMP_MARSH|PARK|JUNCTION_INTERCHANGE)/.test(categories)===false && pattributes.entryExitPoints.length===0 && venue.isPoint()===false) {
  429. newColor="#ff7700"; newWidth=15; newOpacity=0.5; gpoly=venue.geometry.getVertices();
  430. }
  431. }
  432. if (ls.poi_WFeed || ls.poi_WPark) { //Place created by WazeFeed
  433. var pcrea=pattributes.createdBy;
  434. if (pcrea) { var creaName = CErrorsModel.users.get(pcrea).userName; }
  435. if (((ls.poi_WFeed && creaName=="WazeFeed") || (ls.poi_WPark && creaName=="WazeParking1")) && pattributes.residential===false) {
  436. newColor="#ffcc00"; newWidth=15; newOpacity=0.5; gpoly=venue.geometry.getVertices();
  437. if (venue.isPoint()) { newWidth=26; newOpacity=0.75; }
  438. }
  439. }
  440. if (ls.poi_Park_name && categories.indexOf("PARKING_LOT") > -1 && pattributes.residential===false) { // Parking named [P] or null
  441. if (pname.indexOf("[P]") > -1) {
  442. newColor="#ff0000"; newWidth=15; newOpacity=0.5; gpoly=venue.geometry.getVertices();
  443. }
  444. else if (pname==="") {
  445. newColor="#ff7700"; newWidth=15; newOpacity=0.5; gpoly=venue.geometry.getVertices();
  446. }
  447. if (venue.isPoint()) newWidth=26;
  448. }
  449. if (ls.poi_Address) { // POI with bad address (Nxxx/Dxxx) or without address
  450. if (typeof (venueStreet)!='undefined' && (/^[A|D|N|M|R][0-9]+/.test(venueStreet.name) || typeof (venueStreet.name)==='undefined')) {
  451. newColor="#ff0000"; newWidth=15; newOpacity=0.5; gpoly=venue.geometry.getVertices();
  452. }
  453. if (venue.isPoint()) newWidth=26;
  454. }
  455. if (ls.poi_LandM) { // Landmark with road name or city name
  456. if (/(RIVER_STREAM|CANAL|SEA_LAKE_POOL|SWAMP_MARSH|ISLAND|FOREST_GROVE|BRIDGE)/.test(categories) && ((venueStreet && venueStreet.name) && pname===false || (venueCity && venueCity.name && pname===false))) {
  457. newColor="#ff0000"; newWidth=15; newOpacity=0.5; gpoly=venue.geometry.getVertices();
  458. }
  459. }
  460. if (ls.poi_DleSpace) { // Double spacing in name
  461. if (typeof (venueStreet)!='undefined' && (/ /.test(venueStreet.name)===true || / /.test(pname)===true)) {
  462. newColor="#ff0000"; newWidth=15; newOpacity=0.5; gpoly=venue.geometry.getVertices();
  463. }
  464. if (venue.isPoint()) newWidth=26;
  465. }
  466. // Highlight if error
  467. if (gpoly!="") {
  468. var style={
  469. strokeWidth: newWidth,
  470. strokeColor: newColor,
  471. strokeOpacity: newOpacity,
  472. fillOpacity: 0
  473. };
  474. var points=[];
  475. for (var i=0; i<gpoly.length; i++) { points.push(new CErrorsOpenLayers.Geometry.Point(gpoly[i].x, gpoly[i].y)); }
  476. var newpoly=new CErrorsOpenLayers.Geometry.LinearRing(points);
  477. lineFeature.push(new CErrorsOpenLayers.Feature.Vector(newpoly, null, style));
  478. }
  479. }
  480. }
  481.  
  482. // Display highlighted features
  483. try{ ColorErrors_mapLayer.addFeatures(lineFeature); }
  484. catch(err){ log('err addFeatures: ',err); }
  485. }
  486. CErrors_bootstrap();

QingJ © 2025

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