WME Color Errors

Adds colours to show errors

当前为 2016-11-18 提交的版本,查看 最新版本

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

QingJ © 2025

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