Greasy Fork镜像 还支持 简体中文。

WME Color Errors

Adds colours to show errors

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

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

QingJ © 2025

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