WME Validator Localization for New York

This script localizes WME Validator for New York. You also need main package (WME Validator) installed.

当前为 2017-01-09 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name WME Validator Localization for New York
  3. // @namespace https://greasyfork.org/en/users/15052
  4. // @version 1.1.964
  5. // @author New York Editors
  6. // @credit Credit to xanderb for the base template.
  7. // @description This script localizes WME Validator for New York. You also need main package (WME Validator) installed.
  8. // @match https://www.waze.com/*editor/*
  9. // @match https://beta.waze.com/*editor/*
  10. // @grant none
  11. // @run-at document-start
  12. // @require https://greasyfork.org/scripts/13097-proj4js/code/Proj4js.js
  13. // ^^^^^^^^ needed for the NYS FC Viewer PL to convert coordinated to proper projection
  14. // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAMAAABHPGVmAAAB9VBMVEUAAAD/gAD/nwD/lQD/nwD/mQD/lQD/kgD/mwD/lwD/nAD/mQD/lwD/mgD/mAD/mwD/mQD/lwD/mAD/mgD/mQD/mAD/mgD/mAD/mgD/mQD/mAD/mQD/mQD/mgD/mQD/////mAD/////mQD/////mQD/////mgD/mQD/////mAD/////mQD/mQD/mQD/////mgD//////Pj/mQD/////mAD/////mQD/mQD/////mgD/////mQD/mAD/////mQD/////mQD/////mgD/////mQD/mAD/////mQD/////mQD/mQD/////mQD/////mQD/////mQD/////mQD/////mQD/mQD/////mQD/////mQD/tkf/ulT/mQD/////mQD/mgD/mQD/////mgD/0Yz/mQD/////mQD///8AAAABAQECAgIDAwMJCQkRERESEhIWFhYZGRkaGhocHBwvLy8xMTFERERISEhXV1doaGhqamqBgYGEhISioqKjo6Ourq64uLi+vr7g4ODn5+fr6+v19fX4+Pj5+fn8/Pz9/f3+/v7/mQD/mwT/ngz/piD/qSj/rjT/s0D/uVD/u1T/w2j/xGz/xnD/x3T/zID/z4j/0Yz/05D/1pj/2aD/26T/3qz/5b//7M//79f/8dv/8t///Pf//fv////VAUOcAAAAaHRSTlMABAgMEBQYHBwgJCgsMDQ4PEBDR0tPU1dbX2Nna29zc3d3e3t/f4OHh4uLj5GTk5eXmZubn5+jp6erq6+zs7e3u7u/v8PHx8vLz9PT19fb29/f4+Pl5+fr6+3t7e/v8PLz8/T29/f7+1UbC/wAAAU+SURBVGje7drtf9NEHADwa7eWZRXWrKxrwAwfKlonghiRbt2YcQM2B4bCHChKFdpmPj/hs+KzLooPoKKITp3k7zRLcsk195iUvvHD71WbNPnud7mn3A0AUjxm24+AXoe9EU/c1VNjv+1Fe6KHSNsO4vEdvSEGi79e/vGH7y5e/MYKom44oet6TdN2l8tjilKQ85LUl+j+6eHKXMOKES3DOKTrrlyWhYh8NRYQjbIAIR+yugs+kqpYVq+RVLVrw1J5iNa9YSkcY6vVeyRdR3/87feXf/tj7a/19X/DNrnuxD9ra2t/Xrt29cqVn57SZvQ5wzgXB1HDej/9+982M94wTfMd2376fu/Pk6QhuaAoqtNONrMRAxpVaQ9TeM30YsX8wrYfjdXOC9CoAfAs5fYbt/7MROMVp5++h1FfI99h9V3O+J28vYohKyYeG/30FMXom+2s0ZmWj9zhjlbw7zZ5yop34tgOohFpN9thaQ3ARD7274Ik9CYxES+miEanMu0bM+Fohd3HNhkIZmQXo31AGtb2EgBN76oPgxut+k/oE9x4GxrHaQaibPEPnOvzS+stUygC5HaqYVnb/GPbwtI6ZpvC8S402gzDahW9g7CPrziJiBvhE5lgGIHycND1TK0mQZgGVGb9b7L7RF6NixzpMHJ1fBpQRDqunN9IvuoikdwSabJRDBHpJKtR0JQm17AsHQDYTNJoJ/KRKLKHb8w6bQN+Pkjod+nxKV5aDCNA8O79PD+Rg1xj0p1m0hGnQ6EZL2OJ5MlG1RtXWIgTr7MSORkaDZbBQ8h12j91r6DBR5x4ntJKRI0AST3UjN776qXr8OMLqPGSf/CAqAHgA5Ocz0c6DcsKFUYiFENL4fMhyf020UYNRCEY/mhVIBvjpEmXBA8cR4xQCScS70PkTvfnxRbfAEf9o7eEhw6ERqCYnUNyMFoJGUAPuno0zoa/jyodo5WYQUZU9ApPIXbyggYRUTuv6VDQ0YpiVLBJ0j585q9Gr3IVzziPJDLaEn3l0jBExa9zlRU0kSbxd7TXOgwhXguVFYg8GMfAkPSiRVNM873wsccx8EyyVOVF83NoHI5lgL2RGSVVefI6MtWPZxAePE2pPtD88gNvFnyWvNIyCsQRqpJy++mvL/xCNoogDsJQwP62/XNcg4ywFDAe26AgDCWBEczqS0BMuS+BQenq6QoxGgWQDImhNPIgKSKscA0WIqiEhlz2Qqat3gyChAqSR5m2UojNVmIqaFklRLjKEvo8kiIcZSmH/ha207G4CFPpNGi9hwDCUCJGNwhViRp0ZN4/McRoS9lTJOO5HBBFWI2RqTRyQBip+SdGQTzlVBaII5rYUntUIRl0BDagXSCOQjSCoh+OnijBlQNeT5p9hmfQn+9m+BzTPGXTGY4BYFXHVtSDhc4RIKrQDLBMbXMwxyoQVE7005a1Yab4qTG4nJoVU05Qd/5gydfxUwNxttc2naEb4NZwYRaLGZjKgICSYexgTtJeGTfeymAq88m2QIPdjNOMKpSCr/LW4pZukDy8DbFiKMhC23ByZCcsEHKe6GZpfe/WTLLSgmvCd1PqXuRd+WhtXC3KUn+iRKiDhkKb7xjGrK5Pa25UykGoilKSZQmpjn27g/Eyxd8FjBcNY17X91X1hRZjPSKIka62ydGXCFbHIU3eGKTC2ZGv3QBjgTtiSDsXujSWJKF/w1CrRnJjflC4xmeGSmWtNmfErQuny+kkrbhfkmRZHlHcuC1sJ7s0rarPGcuoUNveD3oTGWlIlouynM+Cm3Ez/rfxH6STRnmdq/GgAAAAAElFTkSuQmCC
  15. // ==/UserScript==
  16. //
  17. /*
  18. See Settings->About->Available checks for complete list of checks and their params.
  19. Examples:
  20. Enable #170 "Lowercase street name" but allow lowercase "exit" and "to":
  21. "170.enabled": true,
  22. "170.params": {
  23. "regexp": "/^((exit|to) )?[a-z]/",
  24. "},
  25. Enable #130 "Custom check" to find a dot in street names, but allow dots at Ramps:
  26. "130.enabled": true,
  27. "130.params": {
  28. "titleEN": "Street name with a dot",
  29. "problemEN": "There is a dot in the street name (excluding Ramps)",
  30. "solutionEN": "Expand the abbreviation or remove the dot",
  31. "template": "${type}:${street}",
  32. "regexp": "D/^[^4][0-9]?:.*\\./",
  33. },
  34. *Note: use D at the beginning of RegExp to enable debugging on JS console.
  35. *Note: do not forget to escape backslashes in strings, i.e. use "\\" instead of "\".
  36. */
  37.  
  38. window.WME_Validator_United_States = {
  39. ".country": "New York State, USA",
  40. ".codeISO": "US",
  41. ".author": "<a href=http://www.waze.com/forum/ucp.php?i=pm&mode=compose&username=tythesly>tythesly</a>, <a href=http://www.waze.com/forum/ucp.php?i=pm&mode=compose&username=dsfargeg>dsfargeg</a>, and <a href=http://www.waze.com/forum/ucp.php?i=pm&mode=compose&username=PesachZ>PesachZ</a>",
  42. ".updated": "2015-12-18",
  43. ".link": "https://greasyfork.org/en/scripts/12793-wme-validator-localization-for-new-york",
  44. //Default US checks
  45. "27.enabled": true,
  46. "90.enabled": true,
  47. "106.enabled": true,
  48. "112.enabled": false,
  49. /* #130 ## Disabled check for PLR <30m
  50. "130.enabled": true,
  51. "130.params": {
  52. "titleEN": "Short Parking Lot",
  53. "problemEN": "Dead End Parking Lot is less that 30 meters",
  54. "solutionEN": "Does it really need to be there?",
  55. "template": "${deadEnd}:${typeRank}:${length}",
  56. "regexp": "/1:7:([0-2]?[0-9])$/"
  57. },
  58. "130.solutionLink": "W:Best_map_editing_practice#Parking_Lots",
  59. */
  60. // #131 ##Check that all segments have NY as state. This check is active everywhere.
  61. "131.enabled": true,
  62. "131.params": {
  63. "titleEN": "Not New York",
  64. "problemEN": "The segment is assigned to another state",
  65. "solutionEN": "Make sure you are editing in NY and change it. If you are editing outside NY you can disable this check by entering \"!131, *\" (without the quotes) in the Reported As: field of Validators search settings (magnifying glass)",
  66. "template": "${state}",
  67. "regexp": "!/^New York/"
  68. },
  69. "131.solutionLink": "W:Creating_and_editing_road_segments#Address_Properties",
  70. // #132 ## Check for proper Exit ##: or to names, and check all ramps have an Exit or to name, or no-name.
  71. "132.enabled": true,
  72. "132.solutionLink": "W:Road_names/USA#Exit_ramps_and_entrance_ramps_.28on-ramps.29",
  73. "132.params": {
  74. "titleEN": "Improper Exit Naming",
  75. "problemEN": "This segment has an entrance / exit name which does not follow the USA standards for exit naming, or is a ramp with non entrance / exit name",
  76. "solutionEN": "For numbered exits use \"Exit(s) ##: Name / Other Name\". For entrances & unnumbered exits use \"to Name / Other Name\". Separate all shields and names with slashes (/) and spaces. Verify if this is supposed to be a ramp",
  77. "template": "${type}#${street}",
  78. "regexp": "//4#((?!(Exit|to|$))|( |\\b)(To|[Ee](?!xits? [\\d A-Z-]+:)[Xx][Ii][Tt][Ss]?( [Tt][Oo])?:?|to:|TO|Exits? \\d+[\\w\\- ]*( \\\/ | \\- |:[ \\w]*:))( |\\b|$))\//"
  79. },
  80. // #133 ## Check for database generated improper city names.
  81. "133.enabled": true,
  82. "133.solutionLink": "W:Duplicate_cities#Changing_or_Merging_an_Entire_City_Name",
  83. "133.params": {
  84. "titleEN": "Improper City Naming",
  85. "problemEN": "This segment has a generated city name which is not its' proper name",
  86. "solutionEN": "Fill out the form to have the city renamed, and contact your SM or RC to finalize the process",
  87. "template": "${city}#${altCity[#]}",
  88. "regexp": "/(^|#)Greater [\\w -]+ Area|[\\w -]+\\(\\d+\\)(#|$)/"
  89. },
  90. // #134 ## Check for lowercase banners
  91. "134.enabled": true,
  92. "134.params": {
  93. "titleEN": "Potential Incorrect BANNER Abbreviation",
  94. "problemEN": "Name abbreviation may be incorrect. Alternative routes should be labeled ALT and abbreviations ALT, BUS, BYP, CONN, LOOP, SCN, SPUR, or TRUCK should be in ALL CAPS",
  95. "solutionEN": "Change abbreviation to ALT, BUS, BYP, CONN, LOOP, SCN, SPUR, or TRUCK in ALL CAPS",
  96. "template": "${street}#{altStreet[#]}",
  97. "regexp": "/!?[0-9].+(Alt|Bus(iness)?|Byp|Conn?|L(oo)?p|Scn|Spu?r|Truck)\\b/"
  98. },
  99. // #135 ## Blank
  100. // #136 ## Check for lock standards on RR, Ferry statewide, and on PS, mH, MH in NYC.
  101. "136.enabled": true,
  102. "136.params": {
  103. "titleEN": "NYS Minimum Lock Levels",
  104. "problemEN": "NYC has higher locking levels than the rest of NYS. Ferries and RR should be locked as well",
  105. "solutionEN": "Lock the segment to at least; PS>=3, mH>=4, MH>=5, FW>=5, Ramp>=highest connection, Ferry>=5, RR>=2",
  106. "template": "${state}:${city}#${type}:${lock}",
  107. "regexp": "/^New York:((New York|Manhattan|Queens|Brooklyn|Bronx|Staten Island)#(6:[1-4]|7:[1-3]|2:[12])|.*#(15:[1-4]|18:1))/"
  108. },
  109. "136.solutionLink": "W:NY#Locking_standard",
  110. // #137 ## Check for cardinals not properly capitalized, or encased in improper characters (eg quotes, dashes, slashes, colons, semicolons)
  111. "137.enabled": true,
  112. "137.params": {
  113. "titleEN": "Improper Cardinal Usage",
  114. "problemEN": "This name contains a cardinal direction (NEWS) which does not match wiki guidelines",
  115. "solutionEN": "If this cardinal should be spoken as a direction by TTS, make sure it has space on either side of it. If this cardinal should be spoken by TTS as a letter, follow it with a period. All cardinals should be capitalized",
  116. "template": "${street} ${altStreet[#]}",
  117. "regexp": "/(^| )([NEWS]?[news][NEWS]?|[\"\']?(([ns]|N(?!-\\d{1,3}\\b)|S(?!-\\d{1,2}[A-Z]\\b))[EeWw]?|[EeWw])[\'\":;-]|[\"\']([NnSs][EeWw]?|[EeWw])[\'\":-]?)(\\b|\\d| |$)/"
  118. },
  119. "137.solutionLink": "W:Abbreviations_and_acronyms/USA#Standard_suffix_abbreviations",
  120. // #138 ## Check for standard hwy names (I-##, US-##, NY-##, CR-##, FS-##)
  121. "138.enabled": true,
  122. "138.params": {
  123. "titleEN": "Incorrect Hwy Name Prefix",
  124. "problemEN": "NY follows national guidelines for hwy naming prefixes (I-##, US-##, CR-##, FS-##), and uses NY-## for state routes",
  125. "solutionEN": "Rename the Street or Alt Street",
  126. "template": "${state}:${street}#${altStreet[#]}",
  127. "regexp": "/^New York:.*\\b((([Uu]\\.? ?( S|S(?!-\\d)[- ]|S\\.|s\\.?)|[Nn](?! \\d)(ew )?(y|Y- |[Yy]ork)? ?|[Ss]tate |[Ss] ?[RrHh]|[Cc]o(unty)? ?|[Rr]o?u?[Tt]e?|[Ff](s|S(?!-\\d)|[Rr]))([Ss][Pp][Uu][Rr]|[Rr]((ou)?(te)?|(oa)?d)|[Hh]((igh)?[Ww]a?[Yy])?)?|Ny|NY=|I- |[Cc]([HhrSs]|R(?!-\\d))|([Ii]|[NnCcUu][YyRrSs])[ =])[- ]{0,2}\\d+|([Uu] ?[Ss][- ]?)?([Hh](igh)?[Ww]a?[Yy] )?[Ff] ?([Ss] ?|[Ss]? ?[Rr])(oa)?d? )/"
  128. },
  129. "138.solutionLink": "W:NY#Major_roads",
  130. // #139 ## Check for common name errors causing improper TTS (Street/saint)
  131. "139.enabled": true,
  132. "139.params": {
  133. "titleEN": "Bad TTS Street name",
  134. "problemEN": "Streets that start with St and Dr result in TTS reading Street or Drive",
  135. "solutionEN": "Add a period after St or Dr at the beginning of the street name if you want TTS to say Saint, or Doctor",
  136. "template": "${street}#${altStreet[#]}",
  137. "regexp": "/((^| |#)(St|Dr)(?! ((Ext|[NEWS][EW]?)\\b|\\\/|\\(|Br(idge)?))|Rev) |(St|Dr)\\.($| ((Ext|[NEWS][EW]?)\\b|\\\/|\\(|Br(idge)?))/"
  138. },
  139. "139.solutionLink": "W:Abbreviations_and_acronyms/USA#Recommended_abbreviations",
  140. // #59 ## There already is a city on freeway check, enable it
  141. // disabling city on fwy check for now, we allow city names on fwy in NY >> "59.enabled": true,
  142. // #150 ## Freeway lock
  143. "150.enabled": true,
  144. "150.params": {
  145. // {number} minimum lock level
  146. "n": 5,
  147. },
  148. // #151 ## Major Highway lock
  149. "151.enabled": true,
  150. "151.params": {
  151. // {number} minimum lock level
  152. "n": 3,
  153. },
  154. // #152 ## Minor Highway lock
  155. "152.enabled": true,
  156. "152.params": {
  157. // {number} minimum lock level
  158. "n": 3,
  159. },
  160. // #153 ## Ramp lock
  161. "153.enabled": true,
  162. "153.solutionLink": "W:Road_types/USA#Ramps",
  163. "153.params": {
  164. // {number} minimum lock level
  165. "n": 5,
  166. "problemEN": "Ramps generally connect to Freeways, so they should be locked to Lvl 5. If not connected to a freeway, verify that this meets the criteria to be a ramp",
  167. "solutionEN": "Lock the segment, change it to a non-ramp type, or just verify it should be a ramp",
  168. },
  169. // #154 ## Primary Street lock
  170. "154.enabled": false,
  171. // #170 ## Enable check for lower case street name
  172. "170.enabled": true,
  173. "170.params": {
  174. regexp: "/^(?!to [^a-z])((S|N|W|E)(E|W)? )?[a-z]/"
  175. },
  176. // #171 ## Check for improper use of a period (.) that is not on the USA recommended abbreviations list.
  177. "171.enabled": true,
  178. "171.solutionLink": "W:Abbreviations_and_acronyms/USA#Standard_suffix_abbreviations",
  179. "171.params": {
  180. "regexp": "/((?!(\\bPhila|\\bPenna|.(\\bWash|\\bCmdr|\\bProf|\\bPres)|..(\\bAdm|\\bSte|\\bCpl|\\bMaj|\\bSgt|\\bRe[vc]|\\bR\\.R|\\bGov|\\bGen|\\bHon|\\bCpl)|...(\\bSt|\\b[JSD]r|\\bLt|\\bFt)|...(#| )[NEWSR])).{5}\\.|((?!(hila|enna|(\\bWash|\\bCmdr|\\bProf|\\bPres)|.(\\bAdm|\\bSte|\\bCpl|\\bMaj|\\bSgt|\\bRe[vc]|\\bR\\.R|\\bGov|\\bGen|\\bHon|\\bCpl)|..(\\bSt|\\b[JSD]r|\\bLt|\\bFt)|..(#| )[NEWSR])).{4}|(\\bhila|\\benna))\\.|((?!(ila|nna|(ash|mdr|rof|res)|(\\bAdm|\\bSte|\\bCpl|\\bMaj|\\bSgt|\\bRe[vc]|\\bR\\.R|\\bGov|\\bGen|\\bHon|\\bCpl)|.(\\bSt|\\b[JSD]r|\\bLt|\\bFt)|.(#| )[NEWSR])).{3}|\\b(ila|nna|ash|mdr|rof|res))\\.|((?!(la|na|(sh|dr|of|es)|(dm|te|pl|aj|gt|e[vc]|\\.R|ov|en|on|pl)|(\\bSt|\\b[JSD]r|\\bLt|\\bFt)|(#| )[NEWSR])).{2}|\\b(la|na|sh|dr|of|es|dm|te|pl|aj|gt|e[vc]|\\.R|ov|en|on|pl))\\.|(#|^)[^NEWSR]?\\.)|(((?!\\b(D|O|L)).|#|^)\'(?![sl]\\b)|(#|^)\'s|(?!\\b(In|Na)t).{3}\'l|(#|^).{0,2}\'l)|(Dr|St)\\.(#|$)|,|;|\\\\|((?!\\.( |#|$|R))\\..|(?!\\.( .|#.|$|R\\.))\\..{2}|\\.R(#|$|\\.R))|[Ee]x(p|w)y\\b|\\b[Ee]x[dn]\\b|Tunl\\b|Long Is\\b|Brg\\b/",
  181. "problemEN": "The street name has incorrect abbreviation, or character",
  182. "solutionEN": "Check upper/lower case, a space before/after the abbreviation and the accordance with the abbreviation table. Remove any comma (,), backslash (\\), or semicolon (;)"
  183. },
  184. };
  185. // --------------------------- Modifications for permalink buttons to NYS Orthos, and FC Viewer below this point -------------------------------------------------
  186.  
  187. // add NY Orthos PL button (credit: based on bookmarlet posted in NYS Waze wiki
  188. function open_map(server) {
  189. var center_lonlat=new OpenLayers.LonLat(Waze.map.center.lon,Waze.map.center.lat);
  190. center_lonlat.transform(new OpenLayers.Projection('EPSG:900913'),new OpenLayers.Projection('EPSG:4326'));
  191. var NYS_Orthos_PL = 'https://orthos.dhses.ny.gov/?lat='+center_lonlat.lat+'&long='+center_lonlat.lon+'&zoom='+((Waze.map.zoom)+12);
  192. window.open(NYS_Orthos_PL,'NYSOrthos');
  193. }
  194. var WazePermalink;
  195. setTimeout(function() {
  196. WazePermalink = document.getElementsByClassName('WazeControlPermalink')[0];
  197. var map_links = document.createElement('span');
  198. map_links.innerHTML = '<img src="http://static-assets.ny.gov/sites/all/themes/ny_gov/images/nygov\-logo.png" alt="NYS Orthos" width="18" height="18" id="NYS_Orthos_PL" title="NYS Orthos Permalink" style="cursor: pointer; float: left; display: inline-block; margin: 2px 5px 0 3px;"> ';
  199. map_links.innerHTML += '<style>.olControlAttribution {display: none;}</style>';
  200. WazePermalink.appendChild(map_links);
  201. document.getElementById("NYS_Orthos_PL")
  202. .addEventListener("click", open_map, false);
  203. }, 5000);
  204. // End pl button
  205.  
  206. // add NY FC PL button (credit: Joyriding)
  207. // TODO: 1) Move away from external library. 2) Fix zoom issue or wait until NY FC Viewer is upgraded. 3) Fix centering issue.
  208. function open_FC(server) {
  209. var e=Waze.map.getExtent();
  210. var geoNW=new OL.Geometry.Point(e.left,e.top);
  211. var geoSE=new OL.Geometry.Point(e.right,e.bottom);
  212. // Currently using Proj4js library (http://proj4js.org/) to handle the projection transformation to EPSG:26918.
  213. // The Proj4hs library is referenced in the header. If we continue to use it we should host it somewhere stable other than its source repository.
  214. // Transformation is also not perfect, the center is off by a small amount. I have not looked into why that is yet. May just be diffences in initial zoom vs scale.
  215. //
  216. // ** To move away from an external library we must understand and implement the conversion forumlas.
  217. // An example for creating a custom projection: http://openlayers.org/en/master/examples/wms-custom-proj.html?mode=raw
  218. // We would need to implement all of the functions they define there, customized for EPSG:26918.
  219. Proj4js.defs["EPSG:26918"] = "+proj=utm +zone=18 +ellps=GRS80 +datum=NAD83 +units=m +no_defs";
  220.  
  221. var source = new Proj4js.Proj('EPSG:900913');
  222. var dest = new Proj4js.Proj('EPSG:26918');
  223.  
  224. var geoNW = new Proj4js.Point(geoNW.x,geoNW.y);
  225. var geoSE = new Proj4js.Point(geoSE.x,geoSE.y);
  226.  
  227. Proj4js.transform(source, dest, geoNW);
  228. Proj4js.transform(source, dest, geoSE);
  229. // Zoom/scale in the NY FC Viewer does not currently work and defaults to 400ft if a location is specified.
  230. // I don't yet know exactly how zoom/scale levels are represented, but the values below work as expected if a location (&extents=) is not given.
  231. // If the NY FC Viewer is ever upgraded the zoom should then work correctly.
  232. // FC Viewer supports displaying FC layer at 400 ft - 4 mile scale
  233. // 4 mile: 288895.277144
  234. // 2 mile: 144447.638572
  235. // 1 mile: 72223.819286
  236. // 0.4 mile: 36111.909643
  237. // 0.2 mile: 18055.954822
  238. // 600 ft: 9027.977411
  239. // 300 ft: 4513.988705
  240. // 200 ft: 2256.994353
  241. // 60 ft: 1128.497176
  242. // WME zoom levels to FC Viewer scale:
  243. // zoom 0 / 1 mile : 72223.819286
  244. // zoom 1 / 5000 ft : 72223.819286
  245. // zoom 2 / 2000 ft : 36111.909643
  246. // zoom 3 / 1000 ft : 18055.954822
  247. // zoom 4 / 500 ft : 9027.977411
  248. var mapScale = 36111.909643
  249. switch (Waze.map.zoom) {
  250. case 0:
  251. case 1:
  252. mapScale = 72223.819286;
  253. break;
  254. case 2:
  255. mapScale = 36111.909643;
  256. break;
  257. case 3:
  258. mapScale = 18055.954822;
  259. break;
  260. default:
  261. mapScale = 9027.977411;
  262. break;
  263. }
  264. var URL='http://gis3.dot.ny.gov/html5viewer/?viewer=FC&scale='+mapScale+'&extent='+geoNW.x+'%2C'+geoNW.y+'%2C'+geoSE.x+'%2C'+geoSE.y;
  265. window.open(URL,"_blank");
  266. }
  267. var WazePermalinkFC;
  268. setTimeout(function() {
  269. WazePermalinkFC = document.getElementsByClassName('WazeControlPermalink')[0];
  270. var map_links = document.createElement('span');
  271. map_links.innerHTML = '<img src="https://www.dot.ny.gov/favicon.ico" alt="NYS FC" width="18" height="18" id="NYS_FC_PL" title="NYS FC Permalink" style="cursor: pointer; float: left; display: inline-block; margin: 2px 5px 0 3px;"> ';
  272. map_links.innerHTML += '<style>.olControlAttribution {display: none;}</style>';
  273. WazePermalinkFC.appendChild(map_links);
  274. document.getElementById("NYS_FC_PL")
  275. .addEventListener("click", open_FC, false);
  276. }, 5000);
  277. // End pl button
  278.  
  279. // add NYCityMap PL button
  280. // TODO: 1) Move away from external library. 2) Fix zoom issue or wait until NY FC Viewer is upgraded. 3) Fix centering issue.
  281. function open_NYC(server) {
  282. var geoPoint=new OL.Geometry.Point(Waze.map.center.lon,Waze.map.center.lat);
  283.  
  284. Proj4js.defs["ESRI:102718"] = "+proj=lcc +lat_1=40.66666666666666 +lat_2=41.03333333333333 +lat_0=40.16666666666666 +lon_0=-74 +x_0=300000 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192 no_defs";
  285.  
  286. var source = new Proj4js.Proj('EPSG:900913');
  287. var dest = new Proj4js.Proj('ESRI:102718');
  288.  
  289. Proj4js.transform(source, dest, geoPoint);
  290.  
  291. // Currently using Proj4js library (http://proj4js.org/) to handle the projection transformation to EPSG:26918.
  292. // The Proj4hs library is referenced in the header. If we continue to use it we should host it somewhere stable other than its source repository.
  293. // Transformation is also not perfect, the center is off by a small amount. I have not looked into why that is yet. May just be diffences in initial zoom vs scale.
  294. //
  295. // ** To move away from an external library we must understand and implement the conversion forumlas.
  296. // An example for creating a custom projection: http://openlayers.org/en/master/examples/wms-custom-proj.html?mode=raw
  297. // We would need to implement all of the functions they define there, customized for EPSG:26918.
  298. var zoom = (Waze.map.zoom)+3;
  299. var URL='http://maps.nyc.gov/doitt/nycitymap/?z='+zoom+'&p='+Math.round(geoPoint.x)+','+Math.round(geoPoint.y)+'&c=GISBasic&f=DDC_PROJECTS';
  300. window.open(URL,"_blank");
  301. }
  302. var WazePermalinkNYC;
  303. setTimeout(function() {
  304. WazePermalinkNYC = document.getElementsByClassName('WazeControlPermalink')[0];
  305. var map_links = document.createElement('span');
  306. map_links.innerHTML = '<img src="http://i.imgur.com/GnnrKxc.png" alt="NYCityMap" width="18" height="18" id="NYC_PL" title="NYCityMap Permalink" style="cursor: pointer; float: left; display: inline-block; margin: 2px 5px 0 3px;"> ';
  307. map_links.innerHTML += '<style>.olControlAttribution {display: none;}</style>';
  308. WazePermalinkNYC.appendChild(map_links);
  309. document.getElementById("NYC_PL")
  310. .addEventListener("click", open_NYC, false);
  311. }, 5000);
  312. // End pl button
  313.  
  314. // add NY SL PL button
  315. // TODO: 1) Move away from external library. 2) Fix zoom issue or wait until NY SL Viewer is upgraded. 3) Fix centering issue.
  316. function open_SL(server) {
  317. var e=Waze.map.getExtent();
  318. var geoNW=new OL.Geometry.Point(e.left,e.top);
  319. var geoSE=new OL.Geometry.Point(e.right,e.bottom);
  320. // Currently using Proj4js library (http://proj4js.org/) to handle the projection transformation to EPSG:26918.
  321. // The Proj4hs library is referenced in the header. If we continue to use it we should host it somewhere stable other than its source repository.
  322. // Transformation is also not perfect, the center is off by a small amount. I have not looked into why that is yet. May just be diffences in initial zoom vs scale.
  323. //
  324. // ** To move away from an external library we must understand and implement the conversion forumlas.
  325. // An example for creating a custom projection: http://openlayers.org/en/master/examples/wms-custom-proj.html?mode=raw
  326. // We would need to implement all of the functions they define there, customized for EPSG:26918.
  327. Proj4js.defs["EPSG:26918"] = "+proj=utm +zone=18 +ellps=GRS80 +datum=NAD83 +units=m +no_defs";
  328.  
  329. var source = new Proj4js.Proj('EPSG:900913');
  330. var dest = new Proj4js.Proj('EPSG:26918');
  331.  
  332. var geoNW = new Proj4js.Point(geoNW.x,geoNW.y);
  333. var geoSE = new Proj4js.Point(geoSE.x,geoSE.y);
  334.  
  335. Proj4js.transform(source, dest, geoNW);
  336. Proj4js.transform(source, dest, geoSE);
  337. // Zoom/scale in the NY SL Viewer does not currently work and defaults to 400ft if a location is specified.
  338. // I don't yet know exactly how zoom/scale levels are represented, but the values below work as expected if a location (&extents=) is not given.
  339. // If the NY SL Viewer is ever upgraded the zoom should then work correctly.
  340. // SL Viewer supports displaying SL layer at 400 ft - 4 mile scale
  341. // 4 mile: 288895.277144
  342. // 2 mile: 144447.638572
  343. // 1 mile: 72223.819286
  344. // 0.4 mile: 36111.909643
  345. // 0.2 mile: 18055.954822
  346. // 600 ft: 9027.977411
  347. // 300 ft: 4513.988705
  348. // 200 ft: 2256.994353
  349. // 60 ft: 1128.497176
  350. // WME zoom levels to SL Viewer scale:
  351. // zoom 0 / 1 mile : 72223.819286
  352. // zoom 1 / 5000 ft : 72223.819286
  353. // zoom 2 / 2000 ft : 36111.909643
  354. // zoom 3 / 1000 ft : 18055.954822
  355. // zoom 4 / 500 ft : 9027.977411
  356. var mapScale = 36111.909643
  357. switch (Waze.map.zoom) {
  358. case 0:
  359. case 1:
  360. mapScale = 72223.819286;
  361. break;
  362. case 2:
  363. mapScale = 36111.909643;
  364. break;
  365. case 3:
  366. mapScale = 18055.954822;
  367. break;
  368. default:
  369. mapScale = 9027.977411;
  370. break;
  371. }
  372. var URL='http://gis3.dot.ny.gov/html5viewer/?viewer=risvexternal&scale='+mapScale+'&extent='+geoNW.x+'%2C'+geoNW.y+'%2C'+geoSE.x+'%2C'+geoSE.y;
  373. window.open(URL,"_blank");
  374. }
  375. var WazePermalinkSL;
  376. setTimeout(function() {
  377. WazePermalinkSL = document.getElementsByClassName('WazeControlPermalink')[0];
  378. var map_links = document.createElement('span');
  379. map_links.innerHTML = '<img src="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAQAABILAAASCwAAAAAAAAAAAAAAAAAAq6urPJOTk/inp6f9p6en/aenp/2np6f9p6en/aenp/2np6f9p6en/aenp/2np6f9k5OT+KurqzwAAAAAAAAAAIiIiFvR0dH//////////////////////////////////////////////////////9HR0f+IiIhbAAAAAAAAAACIiIhb0dHR/7Ozs/8rKyv/ExMT/0xMTP/q6ur/tbW1/ywsLP8TExP/SkpK/+np6f/R0dH/iIiIWwAAAAAAAAAAiIiIW9HR0f/f39//0tLS//Ly8v91dXX/dHR0/+Hh4f/R0dH/8vLy/3h4eP9xcXH/0dHR/4iIiFsAAAAAAAAAAIiIiFvR0dH/8/Pz/8rKyv/n5+f/b29v/3d3d//z8/P/ysrK/+fn5/9xcXH/dHR0/9HR0f+IiIhbAAAAAAAAAACIiIhb0dHR/4+Pj/8WFhb/HR0d/1NTU//s7Oz/kpKS/xYWFv8dHR3/UVFR/+zs7P/R0dH/iIiIWwAAAAAAAAAAiIiIW9HR0f+fn5//Ozs7/4eHh/+Hh4f/5ubm/6Kiov85OTn/h4eH/4eHh//l5eX/0dHR/4iIiFsAAAAAAAAAAIiIiFvR0dH/2NjY/4iIiP+IiIj/iIiI/+Xl5f/a2tr/iIiI/4iIiP+IiIj/5OTk/9HR0f+IiIhbAAAAAAAAAACIiIhb0dHR//////+pqan/w8PD/8/Pz//Hx8f/yMjI/8/Pz//y8vL/4ODg///////R0dH/iIiIWwAAAAAAAAAAiIiIW9HR0f//////np6e//////+YmJj/SUlJ/0hISP+ZmZn/4+Pj/729vf//////0dHR/4iIiFsAAAAAAAAAAIiIiFvR0dH//////7+/v///////u7u7/6mpqf+oqKj/u7u7/7Kysv+ZmZn//////9HR0f+IiIhbAAAAAAAAAACIiIhb0dHR/8rKyv/k5OT/5OTk///////Jycn/xcXF/8zMzP/BwcH/0NDQ/9vb2//R0dH/iIiIWwAAAAAAAAAAiIiIW9DQ0P+bm5v/i4uL/2xsbP+8vLz/cXFx/9PT0/93d3f/zc3N/5KSkv+NjY3/yMjI/4iIiFsAAAAAAAAAAIiIiFvR0dH/eXl5/8zMzP95eXn/jo6O/3t7e/+rq6v/gYGB/6Wlpf+NjY3/jo6O/8/Pz/+IiIhbAAAAAAAAAACIiIhb0dHR///////////////////////////////////////////////////////R0dH/iIiIWwAAAAAAAAAAq6urPJSUlPinp6f9p6en/aenp/2np6f9p6en/aenp/2np6f9p6en/aenp/2np6f9lJSU+KurqzwAAAAAgAEAAIABAACAAQAAgAEAAIABAACAAQAAgAEAAIABAACAAQAAgAEAAIABAACAAQAAgAEAAIABAACAAQAAgAEAAA==" alt="NYS SL" width="18" height="18" id="NYS_SL_PL" title="NYS SL Permalink" style="cursor: pointer; float: left; display: inline-block; margin: 2px 5px 0 3px;"> ';
  380. map_links.innerHTML += '<style>.olControlAttribution {display: none;}</style>';
  381. WazePermalinkFC.appendChild(map_links);
  382. document.getElementById("NYS_SL_PL")
  383. .addEventListener("click", open_SL, false);
  384. }, 5000);
  385. // End pl button