WME Color Errors

Adds colours to show errors

目前為 2016-07-06 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name WME Color Errors
  3. // @name:fr WME Color Errors
  4. // @version 0.03
  5. // @description Adds colours to show errors
  6. // @description:fr Colorisation pour afficher les erreurs
  7. // @include https://www.waze.com/editor/*
  8. // @include https://www.waze.com/*/editor/*
  9. // @include https://editor-beta.waze.com/*
  10. // @exclude https://www.waze.com/user/*
  11. // @exclude https://www.waze.com/*/user/*
  12. // @namespace https://gf.qytechs.cn/fr/scripts/21186-wme-color-errors
  13. // @author Sebiseba
  14. // @copyright Sebiseba 2014-2016
  15. // ==/UserScript==
  16.  
  17. var debug=true;
  18. var WMECErrors={};
  19. var ColorErrors_mapLayer=[];
  20.  
  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.  
  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=
  66. CErrWaze.map; if(typeof(CErrorsMap) == 'undefined'){ if (debug) { console.error("WME ColorErrors - CErrorsmap : NOK"); } window.setTimeout(CErrors_init, 500); return; }
  67. CErrorsModel=CErrWaze.model; if(typeof(CErrorsModel) == 'undefined'){ if (debug) { console.error("WME ColorErrors - CErrorsmodel : NOK"); } window.setTimeout(CErrors_init, 500); return; }
  68. CErrorsI18n=
  69. unsafeWindow.I18n; if(typeof (CErrorsI18n) == 'undefined') { if (debug) { console.error('WME ColorErrors - CErrorsI18n : NOK'); } setTimeout(CErrors_init, 500); return; }
  70. // OpenLayers
  71. CErrorsOpenLayers=unsafeWindow.OpenLayers; if(typeof(CErrorsOpenLayers) === 'undefined'){ if (debug) { console.error("WME ColorErrors - OpenLayers : NOK"); } window.setTimeout(CErrors_init, 500); return; }
  72. // Waze GUI needed
  73. CErrorshandle=
  74. getId("user-info"); if(typeof(CErrorshandle) == 'undefined'){ window.setTimeout(CErrors_init, 500); return; }
  75. CErrorshandleClass=
  76. getElementsByClassName("nav-tabs", CErrorshandle)[0]; if(typeof(CErrorshandleClass) === 'undefined'){ window.setTimeout(CErrors_init, 500); return; }
  77. CErrorshandleClass2=
  78. getElementsByClassName("tab-content", CErrorshandle)[0]; if(typeof(CErrorshandleClass2) === 'undefined'){ window.setTimeout(CErrors_init, 500); return; }
  79.  
  80. // Verify localStorage. Init if empty or not correct
  81. if (typeof(localStorage.WMEColorErrors) === "undefined" || localStorage.WMEColorErrors.lenght===null || !IsJsonString(localStorage.WMEColorErrors)) {
  82. WMECErrors.seg_Bad=false; // Bad Segments (group)
  83. WMECErrors.seg_Priv=true; // Private with bad name
  84. WMECErrors.seg_Park=true; // Parking with name (but Place / Square)
  85. WMECErrors.seg_Rail=true; // Railroad with bad name
  86. WMECErrors.seg_HW_name=true; //Highways with bad name
  87. WMECErrors.seg_Ramp_name=true; // Ramp with 3 directions or more
  88. WMECErrors.seg_Dir_name=true; // Directions but not Ramp/Freeway
  89. WMECErrors.seg_RShield=true; // Wrong prefix
  90. WMECErrors.seg_DleSpace=true; // Double space in name
  91. // POI
  92. WMECErrors.poi_Bad=false; // Bad POI (group)
  93. WMECErrors.poi_Park_name=true; // Parking with [P]
  94. WMECErrors.poi_Address=true; // Dxxx/Nxxx in or no address
  95. WMECErrors.poi_Entry=true; // Entry Point not defined
  96. WMECErrors.poi_LandM=true; // Landmark with address (street |& city)
  97. WMECErrors.poi_DleSpace=true; // Double space in name
  98. // Low errors
  99. WMECErrors.poi_Resid=true; // Maybe a residential
  100. WMECErrors.poi_Google=true; // No link with Google
  101. localStorage.setItem('WMEColorErrors', JSON.stringify(WMECErrors));
  102. }
  103.  
  104. // WME Layers check
  105. var layers=CErrorsMap.getLayersBy("uniqueName","__WME_Color_Errors");
  106. if(layers.length === 0) {
  107. var ColorErrors_style=new CErrorsOpenLayers.Style({
  108. pointRadius: 2,
  109. fontWeight: "normal",
  110. label : "${labelText}",
  111. fontFamily: "Tahoma, Courier New",
  112. labelOutlineColor: "#FFFFFF",
  113. labelOutlineWidth: 2,
  114. fontColor: '#000000',
  115. fontSize: "10px"
  116. });
  117.  
  118. ColorErrors_mapLayer=new CErrorsOpenLayers.Layer.Vector("Color Errors", {
  119. displayInLayerSwitcher: false,
  120. uniqueName: "__WME_Color_Errors",
  121. styleMap: new CErrorsOpenLayers.StyleMap(ColorErrors_style)
  122. });
  123.  
  124. I18n.translations.en.layers.name["__WME_Color_Errors"]="Color Errors";
  125. CErrorsMap.addLayer(ColorErrors_mapLayer);
  126. ColorErrors_mapLayer.setVisibility(true);
  127.  
  128. }
  129. CErrors_Mainhtml();
  130. }
  131.  
  132. // *************
  133. // ** HTML **
  134. // *************
  135.  
  136. function CErrors_Mainhtml() {
  137. if (CErrorsI18n.locale == 'fr') {
  138. CErrSeg=new Array('Contrôle des segments',
  139. 'Mauvais segments',
  140. 'Voie privée avec mauvais nom',
  141. 'Parking avec un nom (sauf Place & Square)',
  142. 'Mauvais nom de voie ferrée',
  143. 'Types Routes avec mauvais nom',
  144. 'Bretelle avec plusieurs directions',
  145. 'Direction (sauf bretelle et Autoroute)',
  146. 'Mauvais préfixe (RoadShield)',
  147. 'Double espace dans le nom'
  148. );
  149. CErrPoi=new Array('Contrôle des places',
  150. 'Mauvaise places',
  151. 'Parking nommé [P] ou rien',
  152. 'Pas d\'adresse ou contenant Dxxx/Nxxx',
  153. 'Point d\'entré non défini',
  154. 'Site naturel avec adresse',
  155. 'Double espace dans le nom',
  156. 'Sûrement une place résidentielle',
  157. 'Pas de lien avec Google'
  158. );
  159. }
  160. else {
  161. CErrSeg=new Array('Segments Checking',
  162. 'Bad Segments',
  163. 'Private with bad name',
  164. 'Parking with name (But Place / Square)',
  165. 'Railroad with bad name',
  166. 'Highways with bad name',
  167. 'Ramp with several directions',
  168. 'Direction (but Ramp/Freeway)',
  169. 'Wrong prefix (RoadShield)',
  170. 'Double spacing in name'
  171. );
  172. CErrPoi=new Array('Places Checking',
  173. 'Bad Places',
  174. 'Parking named [P] or null',
  175. 'No address or Dxxx/Nxxx within',
  176. 'Entry Point not defined',
  177. 'Natural features with address',
  178. 'Double spacing in name',
  179. 'Maybe a residential',
  180. 'No link with Google'
  181. );
  182. }
  183.  
  184. //Create content in CErrors's tab
  185. var CEnewtab=
  186. document.createElement('li');
  187. CEnewtab.innerHTML="<a href='#sidepanel-ColorErrors' data-toggle='tab'><span class='fa fa-eye' title='Color Errors'></span></a>";
  188. CErrorshandleClass.appendChild(CEnewtab);
  189.  
  190. var WMECErrors=JSON.parse(localStorage.getItem('WMEColorErrors'));
  191. var CEaddon=document.createElement('section');
  192. CEaddon.id="sidepanel-ColorErrors";
  193. 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>"
  194. + '<br><br><div class="waze-icon-road" style="float:left;"></div><h4 style="float:left;margin-left:3px;">'+CErrSeg[0]+'</h4><div style="clear:both;margin-left:5px;">'
  195. + '<input type="checkbox" id="_seg_Bad" '+(WMECErrors.seg_Bad ? ' checked' : '')+'/> '+CErrSeg[1]+'<br><div id="BadSeg" style="margin-left:10px;">'
  196. + '<input type="checkbox" class="_seg" id="_seg_Priv" '+(WMECErrors.seg_Priv ? ' checked' : '')+(WMECErrors.seg_Bad ? '' : ' disabled')+'/> '+CErrSeg[2]+'<br>'
  197. + '<input type="checkbox" class="_seg" id="_seg_Park" '+(WMECErrors.seg_Park ? ' checked' : '')+(WMECErrors.seg_Bad ? '' : ' disabled')+'/> '+CErrSeg[3]+'<br>'
  198. + '<input type="checkbox" class="_seg" id="_seg_Rail" '+(WMECErrors.seg_Rail ? ' checked' : '')+(WMECErrors.seg_Bad ? '' : ' disabled')+'/> '+CErrSeg[4]+'<br>'
  199. + '<input type="checkbox" class="_seg" id="_seg_HW_name" '+(WMECErrors.seg_HW_name ? ' checked' : '')+(WMECErrors.seg_Bad ? '' : ' disabled')+'/> '+CErrSeg[5]+'<br>'
  200. + '<input type="checkbox" class="_seg" id="_seg_Dir_name" '+(WMECErrors.seg_Dir_name ? ' checked' : '')+(WMECErrors.seg_Bad ? '' : ' disabled')+'/> '+CErrSeg[6]+'<br>'
  201. + '<input type="checkbox" class="_seg" id="_seg_Ramp_name"'+(WMECErrors.seg_Ramp_name ? ' checked' : '')+(WMECErrors.seg_Bad ? '' : ' disabled')+'/> '+CErrSeg[7]+'<br>'
  202. + '<input type="checkbox" class="_seg" id="_seg_RShield" '+(WMECErrors.seg_RShield ? ' checked' : '')+(WMECErrors.seg_Bad ? '' : ' disabled')+'/> '+CErrSeg[8]+'<br>'
  203. + '<input type="checkbox" class="_seg" id="_seg_DleSpace" '+(WMECErrors.seg_DleSpace ? ' checked' : '')+(WMECErrors.seg_Bad ? '' : ' disabled')+'/> '+CErrSeg[9]+'<br></div></div>'
  204. + '<br><div class="waze-icon-place" style="float:left;"></div><h4 style="float:left;margin-left:3px;">'+CErrPoi[0]+'</h4><div style="clear:both;margin-left:5px;">'
  205. + '<input type="checkbox" id="_poi_Bad" '+(WMECErrors.poi_Bad ? ' checked' : '')+'/> '+CErrPoi[1]+'<br><div id="BadPoi" style="margin-left:10px;">'
  206. + '<input type="checkbox" class="_poi" id="_poi_Park_name"'+(WMECErrors.poi_Park_name ? ' checked' : '')+(WMECErrors.poi_Bad ? '' : ' disabled')+'/> '+CErrPoi[2]+'<br>'
  207. + '<input type="checkbox" class="_poi" id="_poi_Address" '+(WMECErrors.poi_Address ? ' checked' : '')+(WMECErrors.poi_Bad ? '' : ' disabled')+'/> '+CErrPoi[3]+'<br>'
  208. + '<input type="checkbox" class="_poi" id="_poi_Entry" '+(WMECErrors.poi_Entry ? ' checked' : '')+(WMECErrors.poi_Bad ? '' : ' disabled')+'/> '+CErrPoi[4]+'<br>'
  209. + '<input type="checkbox" class="_poi" id="_poi_LandM" '+(WMECErrors.poi_LandM ? ' checked' : '')+(WMECErrors.poi_Bad ? '' : ' disabled')+'/> '+CErrPoi[5]+'<br>'
  210. + '<input type="checkbox" class="_poi" id="_poi_DleSpace" '+(WMECErrors.poi_DleSpace ? ' checked' : '')+(WMECErrors.poi_Bad ? '' : ' disabled')+'/> '+CErrPoi[6]+'<br>'
  211. + '<input type="checkbox" class="_poi" id="_poi_Resid" '+(WMECErrors.poi_Resid ? ' checked' : '')+(WMECErrors.poi_Bad ? '' : ' disabled')+'/> '+CErrPoi[7]+'<br>'
  212. + '<input type="checkbox" class="_poi" id="_poi_Google" '+(WMECErrors.poi_Google ? ' checked' : '')+(WMECErrors.poi_Bad ? '' : ' disabled')+'/> '+CErrPoi[8]+'<br></div></div>'
  213. ;
  214. CEaddon.className='tab-pane';
  215. CErrorshandleClass2.appendChild(CEaddon);
  216.  
  217. getId('_seg_Bad').onclick=(function(){
  218. var ls=JSON.parse(localStorage.WMEColorErrors);
  219. if (getId('_seg_Bad').checked === true) {
  220. for (var i=0; getElementsByClassName('_seg', BadSeg) [i]; i++) getElementsByClassName('_seg', BadSeg) [i].disabled=false;
  221. ls.seg_Bad=true;
  222. }
  223. else {
  224. for (var i=0; getElementsByClassName('_seg', BadSeg) [i]; i++) getElementsByClassName('_seg', BadSeg) [i].disabled=true;
  225. ls.seg_Bad=false;
  226. }
  227. localStorage.setItem('WMEColorErrors', JSON.stringify(ls));
  228. CErrColor();
  229. });
  230. getId('_poi_Bad').onclick=(function(){
  231. var ls=JSON.parse(localStorage.WMEColorErrors);
  232. if (getId('_poi_Bad').checked === true) {
  233. for (var i=0; getElementsByClassName('_poi', BadPoi) [i]; i++) getElementsByClassName('_poi', BadPoi) [i].disabled=false;
  234. ls.poi_Bad=true;
  235. }
  236. else {
  237. for (var i=0; getElementsByClassName('_poi', BadPoi) [i]; i++) getElementsByClassName('_poi', BadPoi) [i].disabled=true;
  238. ls.poi_Bad=false;
  239. }
  240. localStorage.setItem('WMEColorErrors', JSON.stringify(ls));
  241. CErrColor();
  242. });
  243. 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(); });
  244. 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(); });
  245. 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(); });
  246. 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(); });
  247. 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(); });
  248. 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(); });
  249. 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(); });
  250. 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(); });
  251. 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(); });
  252. 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(); });
  253. 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(); });
  254. 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(); });
  255. 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(); });
  256. 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(); });
  257. 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(); });
  258.  
  259. CErrWaze.selectionManager.events.register("selectionchanged", null, CErrColor);
  260. CErrorsModel.actionManager.events.register("afterclearactions", null, CErrColor);
  261. CErrorsModel.actionManager.events.register("afterundoaction", null, CErrColor);
  262. CErrorsMap.events.register("zoomend", null, CErrColor);
  263. CErrorsMap.events.register("moveend", null, CErrColor);
  264. CErrColor();
  265. }
  266.  
  267. function CErrColor(){
  268. var lineFeature=[], ls=JSON.parse(localStorage.WMEColorErrors);
  269.  
  270. // Initialize layer
  271. try { ColorErrors_mapLayer.destroyFeatures(); }
  272. catch(err){ log('err destroyFeatures: ',err); }
  273.  
  274. //Segments Checking
  275. if (ls.seg_Bad) {
  276. for (var seg in CErrorsModel.segments.objects) {
  277. // Get values
  278. var segment=CErrorsModel.segments.get(seg);
  279. var attributes=segment.attributes;
  280. var line=getId(segment.geometry.id);
  281. if (line === null || segment.state == "Update" || segment.selected == true) continue;
  282. var sid=attributes.primaryStreetID;
  283. var street=CErrorsModel.streets.get(sid);
  284. var name=street.name;
  285. var roadType=attributes.roadType;
  286. if (attributes.primaryStreetID === null || attributes.primaryStreetID === undefined) continue;
  287. if (Waze.model.streets.get(attributes.primaryStreetID) === null || Waze.model.streets.get(attributes.primaryStreetID) === undefined) continue;
  288. var newWidth="", newColor="", newOpacity="0", gline="";
  289.  
  290. if (street.name) {
  291. if (ls.seg_Priv) { // Private with bad name
  292. if (attributes.roadType===17 && /^(Le |La |Les |Allée|Avenue|Boulevard|Chemin|Cité|Clos|Cours|Domaine|Hameau|Impasse|Lotissement|Parc|Passage|Place|Promenade|Quai|Résidence|Rue|Route|Sente|Sentier|Square|Villa|Voie)/.test(street.name)===false) {
  293. newColor="#ff7700"; newWidth=3; newOpacity=0.95; gline=segment.geometry.getVertices();
  294. }
  295. }
  296. if (ls.seg_Park) { // Parking with name (But Place / Square)
  297. if (attributes.roadType===20 && /^(Place|Square)/.test(street.name)===false) {
  298. newColor="#ff0000"; newWidth=3; newOpacity=0.95; gline=segment.geometry.getVertices();
  299. }
  300. }
  301. if (ls.seg_Rail) { // Railroad with bad name
  302. if (attributes.roadType===18 && /^(Voie Ferrée$|Metro|Tramway)/.test(street.name)===false) {
  303. newColor="#ff0000"; newWidth=3; newOpacity=0.95; gline=segment.geometry.getVertices();
  304. }
  305. }
  306. if (ls.seg_HW_name) { // Highways with bad name
  307. 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) {
  308. newColor="#ff0000"; newWidth=3; newOpacity=0.95; gline=segment.geometry.getVertices();
  309. }
  310. }
  311. if (ls.seg_Ramp_name) {
  312. if (/^(3|4)$/.test(attributes.roadType) && /\/.*\//.test(street.name)) { // Ramp with 3 directions or more
  313. newColor="#ff0000"; newWidth=3; newOpacity=0.95; gline=segment.geometry.getVertices();
  314. }
  315. else if (/^(3|4)$/.test(attributes.roadType) && /\//.test(street.name)) { // Ramp with 2 directions
  316. newColor="#ff7700"; newWidth=3; newOpacity=0.95; gline=segment.geometry.getVertices();
  317. }
  318. }
  319. if (ls.seg_Dir_name) { // Directions but not Ramp/Freeway
  320. if (/^[^3|4]$/.test(attributes.roadType) && /[:|>]/.test(street.name)) {
  321. newColor="#ff0000"; newWidth=3; newOpacity=0.95; gline=segment.geometry.getVertices();
  322. }
  323. }
  324. if (ls.seg_RShield) { // Wrong prefix (RoadShield)
  325. var trs=street.name.split(" - ");
  326. if (/^[A|C|D|N|M|R][0-9]+[a-z]?[0-9]?$/.test(trs[0])===false && / - /.test(street.name)===true) {
  327. newColor="#ff0000"; newWidth=3; newOpacity=0.95; gline=segment.geometry.getVertices();
  328. }
  329. }
  330. if (ls.seg_DleSpace) { // Double spacing in name
  331. if (/ /.test(street.name)===true) {
  332. newColor="#ff0000"; newWidth=3; newOpacity=0.95; gline=segment.geometry.getVertices();
  333. }
  334. }
  335. }
  336. // Highlight if error
  337. if (gline!="") {
  338. var style={
  339. strokeWidth: newWidth,
  340. strokeColor: newColor,
  341. strokeOpacity: newOpacity
  342. };
  343. var points=[];
  344. for (var i=0; i<gline.length; i++) { points.push(new CErrorsOpenLayers.Geometry.Point(gline[i].x, gline[i].y)); }
  345. var newline=new CErrorsOpenLayers.Geometry.LineString(points);
  346. lineFeature.push(new CErrorsOpenLayers.Feature.Vector(newline, null, style));
  347. }
  348. }
  349. }
  350.  
  351. //Places Checking
  352. if (ls.poi_Bad) {
  353. for (var poi in CErrorsModel.venues.objects) {
  354. // Get values
  355. var venue=CErrorsModel.venues.get(poi);
  356. var pattributes=venue.attributes;
  357. var poly=getId(venue.geometry.id);
  358. if (poly === null || poi.state=="Update" || venue.selected) continue;
  359. var categories=pattributes.categories;
  360. var pname=pattributes.name;
  361. var venueStreet=CErrorsModel.streets.get(venue.attributes.streetID);
  362. if (venueStreet) { var venueCity = Waze.model.cities.get(venueStreet.cityID); }
  363. var newWidth="", newColor="", newOpacity="0", gpoly="";
  364.  
  365. if (ls.poi_Resid) { // maybe a residential POI
  366. if ((/^[0-9][ ]?[a-zA-Z]/.test(pname)===true || /^(Allée|Avenue|Boulevard|Chemin|Cité|Clos|Cours|Domaine|Hameau|Impasse|Lotissement|Parc|Passage|Place|Promenade|Quai|Résidence|Rue|Route|Sente|Sentier|Square|Villa|Voie)/.test(pname)===true) && venue.attributes.residential===false) {
  367. newColor="#ff7700"; newWidth=15; newOpacity=0.95; gline=segment.geometry.getVertices();
  368. }
  369. }
  370. if (ls.poi_Google) { //POI without Google link
  371. if (pattributes.externalProviderIDs.length===0 && pattributes.residential===false) {
  372. newColor="#ff7700"; newWidth=15; newOpacity=0.95; gline=segment.geometry.getVertices();
  373. }
  374. }
  375. if (ls.poi_Park_name && categories.indexOf("PARKING_LOT") > -1 && pattributes.residential===false) { // Parking named [P] or null
  376. if (pname.indexOf("[P]") > -1) {
  377. newColor="#ff0000"; newWidth=15; newOpacity=0.5; gpoly=venue.geometry.getVertices();
  378. }
  379. else if (pname==="") {
  380. newColor="#ff7700"; newWidth=15; newOpacity=0.5; gpoly=venue.geometry.getVertices();
  381. }
  382. }
  383. if (ls.poi_Address) { // POI with bad address (Nxxx/Dxxx) or without address
  384. if (typeof (venueStreet)!='undefined' && (/^[A|D|N|M|R][0-9]+/.test(venueStreet.name) || typeof (venueStreet.name)==='undefined')) {
  385. newColor="#ff0000"; newWidth=15; newOpacity=0.5; gpoly=venue.geometry.getVertices();
  386. }
  387. }
  388. if (ls.poi_Entry) { // POI with default entryExitPoints
  389. if (pattributes.entryExitPoints.length===0 && venue.isPoint()===false) {
  390. newColor="#ff0000"; newWidth=15; newOpacity=0.5; gpoly=venue.geometry.getVertices();
  391. }
  392. }
  393. if (ls.poi_LandM) { // Landmark with road name or city name
  394. if (/(RIVER_STREAM|CANAL|SEA_LAKE_POOL|SWAMP_MARSH|ISLAND|FOREST_GROVE|BRIDGE|SWAMP_MARSH)/.test(categories) && ((venueStreet && venueStreet.name) || (venueCity && venueCity.name))) {
  395. newColor="#ff0000"; newWidth=15; newOpacity=0.5; gpoly=venue.geometry.getVertices();
  396. }
  397. }
  398. if (ls.poi_DleSpace) { // Double spacing in name
  399. if (typeof (venueStreet)!='undefined' && (/ /.test(venueStreet.name)===true || / /.test(pname)===true)) {
  400. newColor="#ff0000"; newWidth=15; newOpacity=0.5; gpoly=venue.geometry.getVertices();
  401. }
  402. }
  403. // Highlight if error
  404. if (gpoly!="") {
  405. var style={
  406. strokeWidth: newWidth,
  407. strokeColor: newColor,
  408. strokeOpacity: newOpacity,
  409. fillOpacity: 0
  410. };
  411. var points=[];
  412. for (var i=0; i<gpoly.length; i++) { points.push(new CErrorsOpenLayers.Geometry.Point(gpoly[i].x, gpoly[i].y)); }
  413. var newpoly=new CErrorsOpenLayers.Geometry.LinearRing(points);
  414. lineFeature.push(new CErrorsOpenLayers.Feature.Vector(newpoly, null, style));
  415. }
  416. }
  417. }
  418.  
  419. // Display highlighted features
  420. try{ ColorErrors_mapLayer.addFeatures(lineFeature); }
  421. catch(err){ log('err addFeatures: ',err); }
  422. }
  423. CErrors_bootstrap();

QingJ © 2025

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