WME Color Errors

Adds colours to show errors

当前为 2016-10-29 提交的版本,查看 最新版本

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

QingJ © 2025

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