WME Color Errors

Adds colours to show errors

当前为 2017-07-19 提交的版本,查看 最新版本

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

QingJ © 2025

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