WME FC Layer

Adds a Functional Class layer for states that publish ArcGIS FC data.

目前為 2024-11-16 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name WME FC Layer
  3. // @namespace https://gf.qytechs.cn/users/45389
  4. // @version 2024.11.16.000
  5. // @description Adds a Functional Class layer for states that publish ArcGIS FC data.
  6. // @author MapOMatic
  7. // @match *://*.waze.com/*editor*
  8. // @exclude *://*.waze.com/user/editor*
  9. // @license GNU GPLv3
  10. // @contributionURL https://github.com/WazeDev/Thank-The-Authors
  11. // @require https://gf.qytechs.cn/scripts/39002-bluebird/code/Bluebird.js?version=255146
  12. // @require https://gf.qytechs.cn/scripts/24851-wazewrap/code/WazeWrap.js
  13. // @connect gf.qytechs.cn
  14. // @grant GM_xmlhttpRequest
  15. // @connect arcgis.com
  16. // @connect arkansas.gov
  17. // @connect azdot.gov
  18. // @connect ca.gov
  19. // @connect coloradodot.info
  20. // @connect delaware.gov
  21. // @connect dc.gov
  22. // @connect ga.gov
  23. // @connect uga.edu
  24. // @connect hawaii.gov
  25. // @connect idaho.gov
  26. // @connect in.gov
  27. // @connect iowadot.gov
  28. // @connect illinois.gov
  29. // @connect ksdot.org
  30. // @connect ky.gov
  31. // @connect la.gov
  32. // @connect maine.gov
  33. // @connect md.gov
  34. // @connect ma.us
  35. // @connect mn.us
  36. // @connect nv.gov
  37. // @connect memphistn.gov
  38. // @connect state.mi.us
  39. // @connect modot.org
  40. // @connect mt.gov
  41. // @connect unh.edu
  42. // @connect ny.gov
  43. // @connect ncdot.gov
  44. // @connect nd.gov
  45. // @connect oh.us
  46. // @connect or.us
  47. // @connect penndot.gov
  48. // @connect sd.gov
  49. // @connect shelbycountytn.gov
  50. // @connect utah.gov
  51. // @connect vermont.gov
  52. // @connect wa.gov
  53. // @connect wv.gov
  54. // @connect wyoroad.info
  55. // ==/UserScript==
  56.  
  57. /* global W */
  58. /* global OpenLayers */
  59. /* global I18n */
  60. /* global WazeWrap */
  61.  
  62. (function main() {
  63. 'use strict';
  64.  
  65. const SETTINGS_STORE_NAME = 'wme_fc_layer';
  66. const DEBUG = false;
  67. const SCRIPT_NAME = GM_info.script.name;
  68. const SCRIPT_VERSION = GM_info.script.version;
  69. const DOWNLOAD_URL = 'https://gf.qytechs.cn/scripts/369633-wme-fc-layer/code/WME%20FC%20Layer.user.js';
  70. let _mapLayer = null;
  71. let _isAM = false;
  72. let _uid;
  73. let _uName;
  74. let _settings = {};
  75. let _r;
  76. let MAP_LAYER_Z_INDEX;
  77. const BETA_IDS = [103400892];
  78. const MIN_ZOOM_LEVEL = 11;
  79. const STATES_HASH = {
  80. Alabama: 'AL',
  81. Alaska: 'AK',
  82. 'American Samoa': 'AS',
  83. Arizona: 'AZ',
  84. Arkansas: 'AR',
  85. California: 'CA',
  86. Colorado: 'CO',
  87. Connecticut: 'CT',
  88. Delaware: 'DE',
  89. 'District of Columbia': 'DC',
  90. 'Federated States Of Micronesia': 'FM',
  91. Florida: 'FL',
  92. Georgia: 'GA',
  93. Guam: 'GU',
  94. Hawaii: 'HI',
  95. Idaho: 'ID',
  96. Illinois: 'IL',
  97. Indiana: 'IN',
  98. Iowa: 'IA',
  99. Kansas: 'KS',
  100. Kentucky: 'KY',
  101. Louisiana: 'LA',
  102. Maine: 'ME',
  103. 'Marshall Islands': 'MH',
  104. Maryland: 'MD',
  105. Massachusetts: 'MA',
  106. Michigan: 'MI',
  107. Minnesota: 'MN',
  108. Mississippi: 'MS',
  109. Missouri: 'MO',
  110. Montana: 'MT',
  111. Nebraska: 'NE',
  112. Nevada: 'NV',
  113. 'New Hampshire': 'NH',
  114. 'New Jersey': 'NJ',
  115. 'New Mexico': 'NM',
  116. 'New York': 'NY',
  117. 'North Carolina': 'NC',
  118. 'North Dakota': 'ND',
  119. 'Northern Mariana Islands': 'MP',
  120. Ohio: 'OH',
  121. Oklahoma: 'OK',
  122. Oregon: 'OR',
  123. Palau: 'PW',
  124. Pennsylvania: 'PA',
  125. 'Puerto Rico': 'PR',
  126. 'Rhode Island': 'RI',
  127. 'South Carolina': 'SC',
  128. 'South Dakota': 'SD',
  129. Tennessee: 'TN',
  130. Texas: 'TX',
  131. Utah: 'UT',
  132. Vermont: 'VT',
  133. 'Virgin Islands': 'VI',
  134. Virginia: 'VA',
  135. Washington: 'WA',
  136. 'West Virginia': 'WV',
  137. Wisconsin: 'WI',
  138. Wyoming: 'WY'
  139. };
  140.  
  141. function reverseStatesHash(stateAbbr) {
  142. // eslint-disable-next-line no-restricted-syntax
  143. for (const stateName in STATES_HASH) {
  144. if (STATES_HASH[stateName] === stateAbbr) return stateName;
  145. }
  146. throw new Error(`FC Layer: reverseStatesHash function did not return a value for ${stateAbbr}.`);
  147. }
  148.  
  149. const STATE_SETTINGS = {
  150. global: {
  151. roadTypes: ['St', 'PS', 'PS2', 'mH', 'MH', 'Ew', 'Rmp', 'Fw'], // Ew = Expressway. For FC's that make it uncertain if they should be MH or FW.
  152. getFeatureRoadType(feature, layer) {
  153. const fc = feature.attributes[layer.fcPropName];
  154. return this.getRoadTypeFromFC(fc, layer);
  155. },
  156. getRoadTypeFromFC(fc, layer) {
  157. return Object.keys(layer.roadTypeMap).find(rt => layer.roadTypeMap[rt].indexOf(fc) !== -1);
  158. },
  159. isPermitted(stateAbbr) {
  160. if (BETA_IDS.indexOf(_uid) !== -1) {
  161. return true;
  162. }
  163. const state = STATE_SETTINGS[stateAbbr];
  164. if (state.isPermitted) return state.isPermitted();
  165. return (_r >= 3 && _isAM) || (_r >= 4);
  166. },
  167. getMapLayer(stateAbbr, layerID) {
  168. let returnValue;
  169. STATE_SETTINGS[stateAbbr].fcMapLayers.forEach(layer => {
  170. if (layer.layerID === layerID) {
  171. returnValue = layer;
  172. }
  173. });
  174. return returnValue;
  175. }
  176. },
  177. AL: {
  178. baseUrl: 'https://services.arcgis.com/LZzQi3xDiclG6XvQ/arcgis/rest/services/HPMS_Year2017_F_System_Data/FeatureServer/',
  179. defaultColors: {
  180. Fw: '#ff00c5', Ew: '#4f33df', MH: '#149ece', mH: '#4ce600', PS: '#cfae0e', St: '#eeeeee'
  181. },
  182. zoomSettings: { maxOffset: [30, 15, 8, 4, 2, 1, 1, 1, 1, 1], excludeRoadTypes: [['St'], ['St'], ['St'], ['St'], [], [], [], [], [], [], []] },
  183. fcMapLayers: [
  184. {
  185. layerID: 0,
  186. fcPropName: 'F_SYSTEM_V',
  187. idPropName: 'OBJECTID',
  188. outFields: ['FID', 'F_SYSTEM_V', 'State_Sys'],
  189. roadTypeMap: {
  190. Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6], St: [7]
  191. },
  192. maxRecordCount: 1000,
  193. supportsPagination: false
  194. }
  195. ],
  196. isPermitted() { return _r >= 3; },
  197. information: { Source: 'ALDOT', Permission: 'Visible to R3+', Description: 'Federal and State highways set to a minimum of mH.' },
  198. getWhereClause(context) {
  199. if (context.mapContext.zoom < 16) {
  200. return `${context.layer.fcPropName} <> 7`;
  201. }
  202. return null;
  203. },
  204. getFeatureRoadType(feature, layer) {
  205. let fc = parseInt(feature.attributes[layer.fcPropName], 10);
  206. if (fc > 4 && feature.attributes.State_Sys === 'YES') { fc = 4; }
  207. return STATE_SETTINGS.global.getRoadTypeFromFC(fc, layer);
  208. }
  209. },
  210. AK: {
  211. baseUrl: 'https://services.arcgis.com/r4A0V7UzH9fcLVvv/ArcGIS/rest/services/AKDOTPF_Route_Data/FeatureServer/',
  212. defaultColors: {
  213. Ew: '#4f33df', MH: '#149ece', mH: '#4ce600', PS: '#cfae0e', St: '#eeeeee'
  214. },
  215. zoomSettings: { maxOffset: [30, 15, 8, 4, 2, 1, 1, 1, 1, 1], excludeRoadTypes: [[], [], [], [], [], [], [], [], [], [], []] },
  216. fcMapLayers: [
  217. {
  218. layerID: 13,
  219. fcPropName: 'Functional_Class',
  220. idPropName: 'OBJECTID',
  221. outFields: ['OBJECTID', 'Functional_Class'],
  222. roadTypeMap: {
  223. Ew: [1, 2], MH: [3], mH: [4], PS: [5, 6], St: [7]
  224. },
  225. maxRecordCount: 1000,
  226. supportsPagination: false
  227. }
  228. ],
  229. information: { Source: 'Alaska DOT&PF', Permission: 'Visible to R4+ or R3-AM', Description: 'Raw unmodified FC data.' },
  230. getWhereClause(context) {
  231. if (context.mapContext.zoom < 16) {
  232. return `${context.layer.fcPropName} <> 7`;
  233. }
  234. return null;
  235. },
  236. getFeatureRoadType(feature, layer) {
  237. if (layer.getFeatureRoadType) {
  238. return layer.getFeatureRoadType(feature);
  239. }
  240. return STATE_SETTINGS.global.getFeatureRoadType(feature, layer);
  241. }
  242. },
  243. AZ: {
  244. baseUrl: 'https://services1.arcgis.com/XAiBIVuto7zeZj1B/arcgis/rest/services/ATIS_prod_gdb_1/FeatureServer/',
  245. defaultColors: {
  246. Fw: '#ff00c5', Ew: '#ff00c5', MH: '#149ece', mH: '#4ce600', PS: '#cfae0e', St: '#eeeeee'
  247. },
  248. zoomSettings: { maxOffset: [30, 15, 8, 4, 2, 1, 1, 1, 1, 1] },
  249. fcMapLayers: [
  250. {
  251. layerID: 38,
  252. fcPropName: 'FunctionalClass',
  253. idPropName: 'OBJECTID',
  254. outFields: ['OBJECTID', 'FunctionalClass', 'RouteId'],
  255. roadTypeMap: {
  256. Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6], St: [7]
  257. },
  258. maxRecordCount: 1000,
  259. supportsPagination: false
  260. }
  261. ],
  262. information: { Source: 'ADOT', Permission: 'Visible to R4+ or R3-AM' },
  263. getWhereClause() {
  264. return null;
  265. },
  266. getFeatureRoadType(feature, layer) {
  267. const attr = feature.attributes;
  268. const roadID = attr.RouteId.trim().replace(/ +/g, ' ');
  269. const roadNum = parseInt(roadID.substring(2, 5), 10);
  270. let fc = attr[layer.fcPropName];
  271. switch (fc) {
  272. case 'Rural Principal Arterial - Interstate':
  273. case 'Urban Principal Arterial - Interstate': fc = 1; break;
  274. case 'Rural Principal Arterial - Other Fwys & Expwys':
  275. case 'Urban Principal Arterial - Other Fwys & Expwys': fc = 2; break;
  276. case 'Rural Principal Arterial - Other':
  277. case 'Urban Principal Arterial - Other': fc = 3; break;
  278. case 'Rural Minor Arterial':
  279. case 'Urban Minor Arterial': fc = 4; break;
  280. case 'Rural Major Collector':
  281. case 'Urban Major Collector': fc = 5; break;
  282. case 'Rural Minor Collector':
  283. case 'Urban Minor Collector': fc = 6; break;
  284. default: fc = 7;
  285. }
  286. const azIH = [8, 10, 11, 17, 19, 40]; // Interstate hwys in AZ
  287. const isUS = /^U\D\d{3}\b/.test(roadID);
  288. const isState = /^S\D\d{3}\b/.test(roadID);
  289. const isBiz = /^SB\d{3}\b/.test(roadID);
  290. if (fc > 4 && isState && azIH.includes(roadNum) && isBiz) fc = 4;
  291. else if (fc > 4 && isUS) fc = isBiz ? 6 : 4;
  292. else if (fc > 6 && isState) fc = isBiz ? 7 : 6;
  293. return STATE_SETTINGS.global.getRoadTypeFromFC(fc, layer);
  294. }
  295. },
  296. AR: {
  297. baseUrl: 'https://gis.arkansas.gov/arcgis/rest/services/FEATURESERVICES/Transportation/FeatureServer/',
  298. defaultColors: {
  299. Fw: '#ff00c5', Ew: '#4f33df', MH: '#149ece', mH: '#4ce600', PS: '#cfae0e', St: '#eeeeee'
  300. },
  301. zoomSettings: { maxOffset: [30, 15, 8, 4, 2, 1, 1, 1, 1, 1], excludeRoadTypes: [[], [], [], [], [], [], [], [], [], [], []] },
  302. fcMapLayers: [
  303. {
  304. layerID: 8,
  305. fcPropName: 'functionalclass',
  306. idPropName: 'objectid',
  307. outFields: ['objectid', 'functionalclass', 'ah_route', 'ah_section'],
  308. roadTypeMap: {
  309. Fw: [1, 2], Ew: [], MH: [3], mH: [4], PS: [5, 6], St: [7]
  310. },
  311. maxRecordCount: 1000,
  312. supportsPagination: false
  313. }
  314. ],
  315. information: { Source: 'ARDOT', Permission: 'Visible to R4+ or R3-AM' },
  316. getWhereClause() {
  317. return null;
  318. },
  319. getFeatureRoadType(feature, layer) {
  320. const attr = feature.attributes;
  321. let fc = parseInt(attr[layer.fcPropName], 10);
  322. const roadID = parseInt(attr.ah_route, 10);
  323. const usHwys = [49, 59, 61, 62, 63, 64, 65, 67, 70, 71, 79, 82, 165, 167, 270, 271, 278, 371, 412, 425];
  324. const isUS = usHwys.includes(roadID);
  325. const isState = roadID < 613;
  326. const isBiz = attr.ah_section[attr.ah_section.length - 1] === 'B';
  327. if (fc > 3 && isUS) fc = isBiz ? 4 : 3;
  328. else if (fc > 4 && isState) fc = isBiz ? 5 : 4;
  329. return STATE_SETTINGS.global.getRoadTypeFromFC(fc, layer);
  330. }
  331. },
  332. CA: {
  333. baseUrl: 'https://caltrans-gis.dot.ca.gov/arcgis/rest/services/CHhighway/CRS_Functional_Classification/FeatureServer/',
  334. defaultColors: {
  335. Fw: '#ff00c5', Ew: '#4f33df', MH: '#149ece', mH: '#4ce600', PS: '#cfae0e', St: '#eeeeee'
  336. },
  337. zoomSettings: { maxOffset: [30, 15, 8, 4, 2, 1, 1, 1, 1, 1], excludeRoadTypes: [['St'], ['St'], ['St'], ['St'], [], [], [], [], [], [], []] },
  338. fcMapLayers: [
  339. {
  340. layerID: 0,
  341. fcPropName: 'F_System',
  342. idPropName: 'OBJECTID',
  343. outFields: ['OBJECTID', 'F_System'],
  344. roadTypeMap: {
  345. Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6], St: [7]
  346. },
  347. maxRecordCount: 1000,
  348. supportsPagination: false
  349. }
  350. ],
  351. isPermitted() { return ['mapomatic', 'turbomkt', 'tonestertm', 'ottonomy', 'jemay', 'ojlaw'].includes(_uName.toLowerCase()); },
  352. information: { Source: 'Caltrans', Permission: 'Visible to ?', Description: '' },
  353. getWhereClause(context) {
  354. if (context.mapContext.zoom < 16) {
  355. return `${context.layer.fcPropName} <> 7`;
  356. }
  357. return null;
  358. },
  359. getFeatureRoadType(feature, layer) {
  360. const fc = parseInt(feature.attributes[layer.fcPropName], 10);
  361. return STATE_SETTINGS.global.getRoadTypeFromFC(fc, layer);
  362. }
  363. },
  364. CO: {
  365. baseUrl: 'https://dtdapps.coloradodot.info/arcgis/rest/services/CPLAN/open_data_sde/FeatureServer/',
  366. defaultColors: {
  367. Fw: '#ff00c5', Ew: '#4f33df', MH: '#149ece', mH: '#4ce600', PS: '#cfae0e', St: '#eeeeee'
  368. },
  369. zoomSettings: { maxOffset: [30, 15, 8, 4, 2, 1, 1, 1, 1, 1], excludeRoadTypes: [[], [], [], [], [], [], [], [], [], [], []] },
  370. fcMapLayers: [
  371. {
  372. layerID: 14,
  373. fcPropName: 'FUNCCLASS',
  374. idPropName: 'OBJECTID',
  375. outFields: ['OBJECTID', 'FUNCCLASS', 'ROUTE', 'REFPT'],
  376. roadTypeMap: {
  377. Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6], St: [7]
  378. },
  379. maxRecordCount: 1000,
  380. supportsPagination: false
  381. },
  382. {
  383. layerID: 17,
  384. fcPropName: 'FUNCCLASSID',
  385. idPropName: 'OBJECTID',
  386. outFields: ['OBJECTID', 'FUNCCLASSID', 'ROUTE', 'FIPSCOUNTY'],
  387. roadTypeMap: {
  388. Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6], St: [7]
  389. },
  390. maxRecordCount: 1000,
  391. supportsPagination: false
  392. },
  393. {
  394. layerID: 21,
  395. fcPropName: 'FUNCCLASSID',
  396. idPropName: 'OBJECTID',
  397. outFields: ['OBJECTID', 'FUNCCLASSID', 'ROUTE'],
  398. roadTypeMap: {
  399. Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6], St: [7]
  400. },
  401. maxRecordCount: 1000,
  402. supportsPagination: false
  403. }
  404. ],
  405. isPermitted() { return _r >= 3; },
  406. information: {
  407. Source: 'CDOT',
  408. Permission: 'Visible to R3+',
  409. Description: 'Please consult with a state manager before making any changes to road types based on the data presented.'
  410. },
  411. getWhereClause(context) {
  412. if (context.mapContext.zoom < 16) {
  413. return `${context.layer.fcPropName} <> '7'`;
  414. }
  415. return null;
  416. },
  417. getFeatureRoadType(feature, layer) {
  418. const attr = feature.attributes;
  419. let fc = parseInt(attr[layer.fcPropName], 10);
  420. const route = attr.ROUTE.replace(/ +/g, ' ');
  421. if (layer.layerID === 7) {
  422. const rtnum = parseInt(route.slice(0, 3), 10);
  423. const refpt = attr.REFPT;
  424. const hwys = [6, 24, 25, 34, 36, 40, 50, 70, 84, 85, 87, 138, 160, 285, 287, 350, 385, 400, 491, 550];
  425. // Exceptions first, then normal classification
  426. const doNothing = ['024D', '040G'];
  427. const notNothing = ['070K', '070L', '070O', '070Q', '070R'];
  428. const doMin = ['024E', '050D', '070O', '085F', '160D'];
  429. if (doNothing.includes(route) || (rtnum === 70 && route !== '070K' && !notNothing.includes(route))) {
  430. // do nothing
  431. } else if (doMin.includes(route)
  432. || (rtnum === 40 && refpt > 320 && refpt < 385)
  433. || (rtnum === 36 && refpt > 79 && refpt < 100.99)
  434. || (route === '034D' && refpt > 11)) {
  435. fc = 4;
  436. } else if (hwys.includes(rtnum)) {
  437. fc = Math.min(fc, 3);
  438. } else {
  439. fc = Math.min(fc, 4);
  440. }
  441. } else {
  442. // All exceptions
  443. const fips = parseInt(attr.FIPSCOUNTY, 10);
  444. if ((fips === 19 && route === 'COLORADO BD') || (fips === 37 && (route === 'GRAND AV' || route === 'S H6'))) {
  445. fc = 3;
  446. } else if (fips === 67 && route === 'BAYFIELDPAY') {
  447. fc = 4;
  448. }
  449. }
  450. return STATE_SETTINGS.global.getRoadTypeFromFC(fc, layer);
  451. }
  452. },
  453. CT: {
  454. baseUrl: 'https://services1.arcgis.com/FCaUeJ5SOVtImake/ArcGIS/rest/services/CTDOT_Roadway_Classification_and_Characteristic_Data/FeatureServer/',
  455. defaultColors: {
  456. Fw: '#ff00c5', Ew: '#4f33df', MH: '#149ece', mH: '#4ce600', PS: '#cfae0e', St: '#eeeeee'
  457. },
  458. zoomSettings: { maxOffset: [30, 15, 8, 4, 2, 1, 1, 1, 1, 1], excludeRoadTypes: [['St'], ['St'], ['St'], ['St'], [], [], [], [], [], [], []] },
  459. fcMapLayers: [
  460. {
  461. layerID: 3,
  462. fcPropName: 'FC_FC_CODE',
  463. idPropName: 'OBJECTID',
  464. outFields: ['OBJECTID', 'FC_FC_CODE'],
  465. roadTypeMap: {
  466. Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6], St: [7]
  467. },
  468. maxRecordCount: 1000,
  469. supportsPagination: false
  470. }
  471. ],
  472. isPermitted() { return _r >= 3; },
  473. information: { Source: 'CTDOT', Permission: 'Visible to R3+', Description: 'Federal and State highways set to a minimum of mH.' },
  474. getWhereClause(context) {
  475. if (context.mapContext.zoom < 16) {
  476. return `${context.layer.fcPropName} <> 7`;
  477. }
  478. return null;
  479. },
  480. getFeatureRoadType(feature, layer) {
  481. let fc = parseInt(feature.attributes[layer.fcPropName], 10);
  482. if (fc > 4 && feature.attributes.State_Sys === 'YES') {
  483. fc = 4;
  484. }
  485. return STATE_SETTINGS.global.getRoadTypeFromFC(fc, layer);
  486. }
  487. },
  488. DE: {
  489. baseUrl: 'https://enterprise.firstmap.delaware.gov/arcgis/rest/services/Transportation/DE_Roadways_Main/FeatureServer/',
  490. defaultColors: {
  491. Fw: '#ff00c5', Ew: '#4f33df', MH: '#149ece', mH: '#4ce600', PS: '#cfae0e', St: '#eeeeee'
  492. },
  493. zoomSettings: { maxOffset: [30, 15, 8, 4, 2, 1, 1, 1, 1, 1], excludeRoadTypes: [['St'], ['St'], ['St'], ['St'], [], [], [], [], [], [], []] },
  494. fcMapLayers: [
  495. {
  496. layerID: 16,
  497. fcPropName: 'VALUE_TEXT',
  498. idPropName: 'OBJECTID',
  499. outFields: ['OBJECTID', 'VALUE_TEXT'],
  500. maxRecordCount: 1000,
  501. supportsPagination: false,
  502. roadTypeMap: {
  503. Fw: ['Interstate'], Ew: ['Other Expressways & Freeway'], MH: ['Other Principal Arterials'], mH: ['Minor Arterial'], PS: ['Major Collector', 'Minor Collector'], St: ['Local']
  504. }
  505. }
  506. ],
  507. information: { Source: 'Delaware FirstMap', Permission: 'Visible to R4+ or R3-AM', Description: 'Raw unmodified FC data.' },
  508. getWhereClause(context) {
  509. if (context.mapContext.zoom < 16) {
  510. return `${context.layer.fcPropName} <> 'Local'`;
  511. }
  512. return null;
  513. },
  514. getFeatureRoadType(feature, layer) {
  515. if (layer.getFeatureRoadType) {
  516. return layer.getFeatureRoadType(feature);
  517. }
  518. return STATE_SETTINGS.global.getFeatureRoadType(feature, layer);
  519. }
  520. },
  521. DC: {
  522. baseUrl: 'https://maps2.dcgis.dc.gov/dcgis/rest/services/DCGIS_DATA/Transportation_WebMercator/MapServer/',
  523. supportsPagination: false,
  524. defaultColors: {
  525. Fw: '#ff00c5', Ew: '#149ece', MH: '#149ece', mH: '#4ce600', PS: '#cfae0e', St: '#eeeeee'
  526. },
  527. zoomSettings: { maxOffset: [30, 15, 8, 4, 2, 1, 1, 1, 1, 1], excludeRoadTypes: [[], [], [], [], [], [], [], [], [], [], []] },
  528. fetchAllFC: false,
  529. fcMapLayers: [
  530. {
  531. layerID: 48,
  532. fcPropName: 'FHWAFUNCTIONALCLASS',
  533. idPropName: 'OBJECTID',
  534. outFields: ['OBJECTID', 'FHWAFUNCTIONALCLASS'],
  535. maxRecordCount: 1000,
  536. supportsPagination: false,
  537. roadTypeMap: {
  538. Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6], St: [7]
  539. }
  540. }
  541. ],
  542. information: { Source: 'DDOT', Permission: 'Visible to R4+ or R3-AM' },
  543. getWhereClause() {
  544. return null;
  545. },
  546. getFeatureRoadType(feature, layer) {
  547. if (layer.getFeatureRoadType) {
  548. return layer.getFeatureRoadType(feature);
  549. }
  550. return STATE_SETTINGS.global.getFeatureRoadType(feature, layer);
  551. }
  552. },
  553. FL: {
  554. baseUrl: 'https://services1.arcgis.com/O1JpcwDW8sjYuddV/ArcGIS/rest/services/Functional_Classification_TDA/FeatureServer/',
  555. supportsPagination: false,
  556. defaultColors: {
  557. Fw: '#ff00c5', Ew: '#149ece', MH: '#149ece', mH: '#4ce600', PS: '#cfae0e', St: '#eeeeee'
  558. },
  559. zoomSettings: { maxOffset: [30, 15, 8, 4, 2, 1, 1, 1, 1, 1], excludeRoadTypes: [[], [], [], [], [], [], [], [], [], [], []] },
  560. fetchAllFC: false,
  561. fcMapLayers: [
  562. {
  563. layerID: 0,
  564. fcPropName: 'FUNCLASS',
  565. idPropName: 'FID',
  566. outFields: ['FID', 'FUNCLASS'],
  567. maxRecordCount: 1000,
  568. supportsPagination: false,
  569. roadTypeMap: {
  570. Fw: ['01', '11'], Ew: ['02', '12'], MH: ['04', '14'], mH: ['06', '16'], PS: ['07', '08', '17', '18']
  571. }
  572. }
  573. ],
  574. information: { Source: 'FDOT', Permission: 'Visible to R4+ or R3-AM', Description: 'Raw unmodified FC data.' },
  575. getWhereClause() {
  576. return null;
  577. },
  578. getFeatureRoadType(feature, layer) {
  579. if (layer.getFeatureRoadType) {
  580. return layer.getFeatureRoadType(feature);
  581. }
  582. return STATE_SETTINGS.global.getFeatureRoadType(feature, layer);
  583. }
  584. },
  585. GA: {
  586. baseUrl: 'https://maps.itos.uga.edu/arcgis/rest/services/GDOT/GDOT_FunctionalClass/mapserver/',
  587. supportsPagination: true,
  588. defaultColors: {
  589. Fw: '#ff00c5', Ew: '#149ece', MH: '#149ece', mH: '#4ce600', PS: '#cfae0e', St: '#eeeeee'
  590. },
  591. zoomSettings: { maxOffset: [30, 15, 8, 4, 2, 1, 1, 1, 1, 1], excludeRoadTypes: [[], [], [], [], [], [], [], [], [], [], []] },
  592. fetchAllFC: false,
  593. /* eslint-disable object-curly-newline */
  594. fcMapLayers: [
  595. { layerID: 0, fcPropName: 'FUNCTIONAL_CLASS', idPropName: 'OBJECTID', outFields: ['OBJECTID', 'FUNCTIONAL_CLASS', 'SYSTEM_CODE'], maxRecordCount: 1000, supportsPagination: true, roadTypeMap: { Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6] } },
  596. { layerID: 1, fcPropName: 'FUNCTIONAL_CLASS', idPropName: 'OBJECTID', outFields: ['OBJECTID', 'FUNCTIONAL_CLASS', 'SYSTEM_CODE'], maxRecordCount: 1000, supportsPagination: true, roadTypeMap: { Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6] } },
  597. { layerID: 2, fcPropName: 'FUNCTIONAL_CLASS', idPropName: 'OBJECTID', outFields: ['OBJECTID', 'FUNCTIONAL_CLASS', 'SYSTEM_CODE'], maxRecordCount: 1000, supportsPagination: true, roadTypeMap: { Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6] } },
  598. { layerID: 3, fcPropName: 'FUNCTIONAL_CLASS', idPropName: 'OBJECTID', outFields: ['OBJECTID', 'FUNCTIONAL_CLASS', 'SYSTEM_CODE'], maxRecordCount: 1000, supportsPagination: true, roadTypeMap: { Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6] } },
  599. { layerID: 4, fcPropName: 'FUNCTIONAL_CLASS', idPropName: 'OBJECTID', outFields: ['OBJECTID', 'FUNCTIONAL_CLASS', 'SYSTEM_CODE'], maxRecordCount: 1000, supportsPagination: true, roadTypeMap: { Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6] } },
  600. { layerID: 5, fcPropName: 'FUNCTIONAL_CLASS', idPropName: 'OBJECTID', outFields: ['OBJECTID', 'FUNCTIONAL_CLASS', 'SYSTEM_CODE'], maxRecordCount: 1000, supportsPagination: true, roadTypeMap: { Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6] } },
  601. { layerID: 6, fcPropName: 'FUNCTIONAL_CLASS', idPropName: 'OBJECTID', outFields: ['OBJECTID', 'FUNCTIONAL_CLASS', 'SYSTEM_CODE'], maxRecordCount: 1000, supportsPagination: true, roadTypeMap: { Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6] } }
  602. ],
  603. /* eslint-enable object-curly-newline */
  604. information: { Source: 'GDOT', Permission: 'Visible to R4+ or R3-AM', Description: 'Federal and State highways set to a minimum of mH.' },
  605. getWhereClause() {
  606. return null;
  607. },
  608. getFeatureRoadType(feature, layer) {
  609. if (layer.getFeatureRoadType) {
  610. return layer.getFeatureRoadType(feature);
  611. }
  612. const attr = feature.attributes;
  613. const fc = attr.FUNCTIONAL_CLASS;
  614. if (attr.SYSTEM_CODE === '1' && fc > 4) {
  615. return STATE_SETTINGS.global.getRoadTypeFromFC(4, layer);
  616. }
  617. return STATE_SETTINGS.global.getFeatureRoadType(feature, layer);
  618. }
  619. },
  620. HI: {
  621. baseUrl: 'http://geodata.hawaii.gov/arcgis/rest/services/Transportation/MapServer/',
  622. defaultColors: {
  623. Fw: '#ff00c5', Ew: '#4f33df', MH: '#149ece', mH: '#4ce600', PS: '#cfae0e', St: '#eeeeee'
  624. },
  625. zoomSettings: { maxOffset: [30, 15, 8, 4, 2, 1, 1, 1, 1, 1], excludeRoadTypes: [[], [], [], [], [], [], [], [], [], [], []] },
  626. fcMapLayers: [
  627. {
  628. layerID: 12,
  629. fcPropName: 'funsystem',
  630. idPropName: 'OBJECTID',
  631. outFields: ['OBJECTID', 'funsystem'],
  632. roadTypeMap: {
  633. Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6], St: [7]
  634. },
  635. maxRecordCount: 1000,
  636. supportsPagination: false
  637. }
  638. ],
  639. information: { Source: 'HDOT', Permission: 'Visible to R4+ or R3-AM', Description: 'Raw unmodified FC data.' },
  640. getWhereClause(context) {
  641. if (context.mapContext.zoom < 16) {
  642. return `${context.layer.fcPropName} <> 7`;
  643. }
  644. return null;
  645. },
  646. getFeatureRoadType(feature, layer) {
  647. if (layer.getFeatureRoadType) {
  648. return layer.getFeatureRoadType(feature);
  649. }
  650. return STATE_SETTINGS.global.getFeatureRoadType(feature, layer);
  651. }
  652. },
  653. ID: {
  654. baseUrl: 'https://gisportalp.itd.idaho.gov/xserver/rest/services/RH_GeneralService/MapServer/',
  655. supportsPagination: false,
  656. defaultColors: {
  657. Fw: '#ff00c5', Ew: '#149ece', MH: '#149ece', mH: '#4ce600', PS: '#cfae0e', St: '#eeeeee'
  658. },
  659. zoomSettings: { maxOffset: [30, 15, 8, 4, 2, 1, 1, 1, 1, 1], excludeRoadTypes: [[], [], [], [], [], [], [], [], [], [], []] },
  660. fetchAllFC: true,
  661. /* eslint-disable object-curly-newline */
  662. fcMapLayers: [
  663. { layerID: 67, fcPropName: 'FunctionalClass', idPropName: 'ObjectId', outFields: ['ObjectId', 'FunctionalClass'], maxRecordCount: 1000, supportsPagination: false, roadTypeMap: { Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6] } }
  664. ],
  665. /* eslint-enable object-curly-newline */
  666. information: { Source: 'ITD', Permission: 'Visible to R4+ or R3-AM', Description: 'Raw unmodified FC data.' },
  667. getWhereClause() {
  668. return null;
  669. },
  670. getFeatureRoadType(feature, layer) {
  671. if (layer.getFeatureRoadType) {
  672. return layer.getFeatureRoadType(feature);
  673. }
  674. return STATE_SETTINGS.global.getFeatureRoadType(feature, layer);
  675. }
  676. },
  677. IL: {
  678. baseUrl: 'https://gis1.dot.illinois.gov/arcgis/rest/services/AdministrativeData/FunctionalClass/MapServer/',
  679. supportsPagination: false,
  680. defaultColors: {
  681. Fw: '#ff00c5', Ew: '#ff00c5', MH: '#149ece', mH: '#4ce600', PS: '#cfae0e', St: '#eeeeee'
  682. },
  683. zoomSettings: { maxOffset: [30, 15, 8, 4, 2, 1, 1, 1, 1, 1] },
  684. fcMapLayers: [
  685. {
  686. layerID: 0,
  687. idPropName: 'OBJECTID',
  688. fcPropName: 'FC',
  689. outFields: ['FC'],
  690. roadTypeMap: {
  691. Fw: ['1'], Ew: ['2'], MH: ['3'], mH: ['4'], PS: ['5', '6'], St: ['7']
  692. },
  693. maxRecordCount: 1000,
  694. supportsPagination: false
  695. }
  696. ],
  697. isPermitted() { return _r >= 4; },
  698. information: { Source: 'IDOT', Permission: 'Visible to R4+', Description: 'Raw unmodified FC data.' },
  699. getWhereClause(context) {
  700. return context.mapContext.zoom < 16 ? 'FC<>7' : null;
  701. },
  702. getFeatureRoadType(feature, layer) {
  703. if (layer.getFeatureRoadType) {
  704. return layer.getFeatureRoadType(feature);
  705. }
  706. return STATE_SETTINGS.global.getFeatureRoadType(feature, layer);
  707. }
  708. },
  709. IN: {
  710. baseUrl: 'https://gis.indot.in.gov/ro/rest/services/DOT/INDOT_LTAP/MapServer/',
  711. supportsPagination: false,
  712. overrideUrl: '1Sbwc7e6BfHpZWSTfU3_1otXGSxHrdDYcbn7fOf1VjpA',
  713. defaultColors: {
  714. Fw: '#ff00c5', Ew: '#149ece', MH: '#149ece', mH: '#4ce600', PS: '#cfae0e', St: '#eeeeee'
  715. },
  716. zoomSettings: { maxOffset: [30, 15, 8, 4, 2, 1, 1, 1, 1, 1], excludeRoadTypes: [['St'], ['St'], ['St'], ['St'], [], [], [], [], [], [], []], hideRoadTypes: [['St'], ['St'], ['St'], ['St'], [], [], [], [], [], [], []] },
  717. fcMapLayers: [
  718. {
  719. layerID: 10,
  720. idPropName: 'OBJECTID',
  721. fcPropName: 'FUNCTIONAL_CLASS',
  722. outFields: ['FUNCTIONAL_CLASS', 'OBJECTID', 'TO_DATE'],
  723. roadTypeMap: {
  724. Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6], St: [7]
  725. },
  726. maxRecordCount: 100000,
  727. supportsPagination: false
  728. }
  729. ],
  730. isPermitted() { return true; },
  731. information: { Source: 'INDOT', Description: 'Raw unmodified FC data.' },
  732. getWhereClause(context) {
  733. let whereParts = ['TO_DATE IS NULL'];
  734. if (context.mapContext.zoom < 16) {
  735. whereParts += ` AND ${context.layer.fcPropName} <> 7`;
  736. }
  737. return whereParts;
  738. },
  739. getFeatureRoadType(feature, layer) {
  740. if (layer.getFeatureRoadType) {
  741. return layer.getFeatureRoadType(feature);
  742. }
  743. return STATE_SETTINGS.global.getFeatureRoadType(feature, layer);
  744. }
  745. },
  746. IA: {
  747. baseUrl: 'https://gis.iowadot.gov/agshost/rest/services/RAMS/Road_Network/FeatureServer/',
  748. defaultColors: {
  749. Fw: '#ff00c5', Ew: '#149ece', MH: '#149ece', mH: '#4ce600', PS: '#cfae0e', St: '#eeeeee', PSGr: '#cc6533', StGr: '#e99cb6'
  750. },
  751. zoomSettings: { maxOffset: [30, 15, 8, 4, 2, 1, 1, 1, 1, 1], excludeRoadTypes: [['St'], ['St'], ['St'], ['St'], [], [], [], [], [], [], []] },
  752. fcMapLayers: [
  753. {
  754. layerID: 0,
  755. fcPropName: 'FED_FUNCTIONAL_CLASS',
  756. idPropName: 'OBJECTID',
  757. outFields: ['OBJECTID', 'FED_FUNCTIONAL_CLASS', 'STATE_ROUTE_NAME_1', 'ACCESS_CONTROL', 'SURFACE_TYPE'],
  758. roadTypeMap: {
  759. Fw: [1], MH: [2, 3], mH: [4], PS: [5, 6], St: [7]
  760. },
  761. maxRecordCount: 1000,
  762. supportsPagination: false
  763. }
  764. ],
  765. information: { Source: 'Iowa DOT', Permission: 'Visible to R4+ or R3-AM', Description: 'Additional colors denote unpaved PS and LS segements.' },
  766. getWhereClause(context) {
  767. let theWhereClause = "FACILITY_TYPE<>'7'"; // Removed proposed roads
  768. if (context.mapContext.zoom < 16) {
  769. theWhereClause += ` AND ${context.layer.fcPropName}<>'7'`;
  770. }
  771. return theWhereClause;
  772. },
  773. getFeatureRoadType(feature, layer) {
  774. const attr = feature.attributes;
  775. let fc = parseInt(attr[layer.fcPropName], 10);
  776. const isFw = attr.ACCESS_CONTROL === 1;
  777. const isUS = /^STATE OF IOWA, US/.test(attr.STATE_ROUTE_NAME_1);
  778. const isState = /^STATE OF IOWA, IA/.test(attr.STATE_ROUTE_NAME_1);
  779. if (isFw) fc = 1;
  780. else if (fc > 3 && isUS) fc = 3;
  781. else if (fc > 4 && isState) fc = 4;
  782. if (fc > 4 && attr.SURFACE_TYPE === 20) {
  783. return fc < 7 ? 'PSGr' : 'StGr';
  784. }
  785. return STATE_SETTINGS.global.getRoadTypeFromFC(fc, layer);
  786. }
  787. },
  788. KS: {
  789. baseUrl: 'http://wfs.ksdot.org/arcgis_web_adaptor/rest/services/Transportation/',
  790. defaultColors: {
  791. Fw: '#ff00c5', Ew: '#4f33df', MH: '#149ece', mH: '#4ce600', PS: '#cfae0e', St: '#eeeeee'
  792. },
  793. zoomSettings: { maxOffset: [30, 15, 8, 4, 2, 1, 1, 1, 1, 1], excludeRoadTypes: [['St'], ['St'], ['St'], ['St'], [], [], [], [], [], [], []] },
  794. fcMapLayers: [
  795. {
  796. layerID: 3,
  797. layerPath: 'Functional_Classification/MapServer/',
  798. idPropName: 'Id',
  799. fcPropName: 'FunctionalClassification',
  800. outFields: ['FunctionalClassification', 'Id'],
  801. roadTypeMap: {
  802. Fw: [1], MH: [2, 3], mH: [4], PS: [5, 6], St: [7]
  803. },
  804. maxRecordCount: 1000,
  805. supportsPagination: false
  806. }// ,
  807.  
  808. // 2024-03-20 (mapomatic) The "non-state system" layer was removed from the KS server,
  809. // so we're forced to use the function_classification layer (above) which doesn't include
  810. // any metadata for US/state road designations. I'm leaving the old layers commented below
  811. // in case they're of use in the future.
  812.  
  813. // {
  814. // layerID: 0,
  815. // layerPath: 'Non_State_System/MapServer/',
  816. // idPropName: 'ID2',
  817. // fcPropName: 'FUNCLASS',
  818. // outFields: ['FUNCLASS', 'ID2', 'ROUTE_ID'],
  819. // roadTypeMap: {
  820. // Fw: [1], MH: [2, 3], mH: [4], PS: [5, 6], St: [7]
  821. // },
  822. // maxRecordCount: 1000,
  823. // supportsPagination: false
  824. // },
  825. // {
  826. // layerID: 0,
  827. // layerPath: 'State_System/MapServer/',
  828. // idPropName: 'OBJECTID',
  829. // fcPropName: 'FUN_CLASS_CD',
  830. // outFields: ['FUN_CLASS_CD', 'OBJECTID', 'PREFIX', 'ACCESS_CONTROL'],
  831. // roadTypeMap: {
  832. // Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6], St: [7]
  833. // },
  834. // maxRecordCount: 1000,
  835. // supportsPagination: false
  836. // }
  837. ],
  838. isPermitted() { return _r >= 3 || _isAM; },
  839. information: { Source: 'KDOT', Permission: 'Visible to area managers' },
  840. getWhereClause(context) {
  841. if (context.mapContext.zoom < 16) {
  842. return `${context.layer.fcPropName}<>'7'`;
  843. }
  844. return null;
  845. },
  846. getFeatureRoadType(feature, layer) {
  847. const attr = feature.attributes;
  848. let fc = parseInt(attr[layer.fcPropName], 10);
  849. const roadPrefix = attr.PREFIX;
  850. const isUS = roadPrefix === 'U';
  851. const isState = roadPrefix === 'K';
  852. if ((fc > 3 && isUS) || (fc === 2 && parseInt(attr.ACCESS_CONTROL, 10) !== 1)) fc = 3;
  853. else if (fc > 4 && isState) fc = 4;
  854. return STATE_SETTINGS.global.getRoadTypeFromFC(fc, layer);
  855. }
  856. },
  857. KY: {
  858. baseUrl: 'https://maps.kytc.ky.gov/arcgis/rest/services/BaseMap/System/MapServer/',
  859. supportsPagination: false,
  860. defaultColors: {
  861. Fw: '#ff00c5', Ew: '#ff00c5', MH: '#149ece', mH: '#4ce600', PS: '#cfae0e', St: '#eeeeee'
  862. },
  863. zoomSettings: { maxOffset: [30, 15, 8, 4, 2, 1, 1, 1, 1, 1] },
  864. fcMapLayers: [
  865. {
  866. layerID: 0,
  867. idPropName: 'OBJECTID',
  868. fcPropName: 'FC',
  869. outFields: ['FC', 'OBJECTID', 'RT_PREFIX', 'RT_SUFFIX'],
  870. roadTypeMap: {
  871. Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6], St: [7]
  872. },
  873. maxRecordCount: 1000,
  874. supportsPagination: false
  875. }
  876. ],
  877. isPermitted() { return true; },
  878. information: { Source: 'KYTC' },
  879. getWhereClause(context) {
  880. if (context.mapContext.zoom < 16) {
  881. return `${context.layer.fcPropName}<>'7'`;
  882. }
  883. return null;
  884. },
  885. getFeatureRoadType(feature, layer) {
  886. const attr = feature.attributes;
  887. let fc = parseInt(attr[layer.fcPropName], 10);
  888. if (fc > 3 && attr.RT_PREFIX === 'US') {
  889. const suffix = attr.RT_SUFFIX;
  890. fc = (suffix && suffix.indexOf('X') > -1) ? 4 : 3;
  891. }
  892. return STATE_SETTINGS.global.getRoadTypeFromFC(fc, layer);
  893. }
  894. },
  895. LA: {
  896. baseUrl: 'https://giswebnew.dotd.la.gov/arcgis/rest/services/Transportation/LA_RoadwayFunctionalClassification/FeatureServer/',
  897. supportsPagination: false,
  898. defaultColors: {
  899. Fw: '#ff00c5', Ew: '#4f33df', MH: '#149ece', mH: '#4ce600', PS: '#cfae0e', St: '#eeeeee'
  900. },
  901. zoomSettings: { maxOffset: [30, 15, 8, 4, 2, 1, 1, 1, 1, 1], excludeRoadTypes: [['St'], ['St'], ['St'], ['St'], [], [], [], [], [], [], []] },
  902. /* eslint-disable object-curly-newline */
  903. fcMapLayers: [
  904. { layerID: 0, fcPropName: 'FunctionalSystem', idPropName: 'OBJECTID', outFields: ['OBJECTID', 'FunctionalSystem', 'RouteID'], roadTypeMap: { Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6], St: [7] }, maxRecordCount: 1000, supportsPagination: false },
  905. { layerID: 1, fcPropName: 'FunctionalSystem', idPropName: 'OBJECTID', outFields: ['OBJECTID', 'FunctionalSystem', 'RouteID'], roadTypeMap: { Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6], St: [7] }, maxRecordCount: 1000, supportsPagination: false },
  906. { layerID: 2, fcPropName: 'FunctionalSystem', idPropName: 'OBJECTID', outFields: ['OBJECTID', 'FunctionalSystem', 'RouteID'], roadTypeMap: { Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6], St: [7] }, maxRecordCount: 1000, supportsPagination: false },
  907. { layerID: 3, fcPropName: 'FunctionalSystem', idPropName: 'OBJECTID', outFields: ['OBJECTID', 'FunctionalSystem', 'RouteID'], roadTypeMap: { Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6], St: [7] }, maxRecordCount: 1000, supportsPagination: false },
  908. { layerID: 4, fcPropName: 'FunctionalSystem', idPropName: 'OBJECTID', outFields: ['OBJECTID', 'FunctionalSystem', 'RouteID'], roadTypeMap: { Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6], St: [7] }, maxRecordCount: 1000, supportsPagination: false },
  909. { layerID: 5, fcPropName: 'FunctionalSystem', idPropName: 'OBJECTID', outFields: ['OBJECTID', 'FunctionalSystem', 'RouteID'], roadTypeMap: { Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6], St: [7] }, maxRecordCount: 1000, supportsPagination: false },
  910. { layerID: 6, fcPropName: 'FunctionalSystem', idPropName: 'OBJECTID', outFields: ['OBJECTID', 'FunctionalSystem', 'RouteID'], roadTypeMap: { Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6], St: [7] }, maxRecordCount: 1000, supportsPagination: false }
  911. ],
  912. /* eslint-enable object-curly-newline */
  913. information: { Source: 'LaDOTD', Permission: 'Visible to R4+ or R3-AM' },
  914. getWhereClause(context) {
  915. if (context.mapContext.zoom < 16) {
  916. return `${context.layer.fcPropName}<>'7'`; // OR State_Route LIKE 'US%' OR State_Route LIKE 'LA%'";
  917. }
  918. return null;
  919. },
  920. getFeatureRoadType(feature, layer) {
  921. let fc = feature.attributes[layer.fcPropName];
  922. if (fc === '2a' || fc === '2b') { fc = 2; }
  923. fc = parseInt(fc, 10);
  924. const route = feature.attributes.RouteID.split('_')[1].trim();
  925. const isUS = /^US \d/.test(route);
  926. const isState = /^LA \d/.test(route);
  927. const isBiz = / BUS$/.test(route);
  928. if (fc > 3 && isUS) fc = isBiz ? 4 : 3;
  929. else if (fc > 4 && isState) fc = isBiz ? 5 : 4;
  930. return STATE_SETTINGS.global.getRoadTypeFromFC(fc, layer);
  931. }
  932. },
  933. ME: {
  934. baseUrl: 'https://arcgisserver.maine.gov/arcgis/rest/services/mdot/MaineDOT_Dynamic/MapServer/',
  935. defaultColors: {
  936. Fw: '#ff00c5', Ew: '#4f33df', MH: '#149ece', mH: '#4ce600', PS: '#cfae0e', St: '#eeeeee'
  937. },
  938. zoomSettings: { maxOffset: [30, 15, 8, 4, 2, 1, 1, 1, 1, 1], excludeRoadTypes: [['St'], ['St'], ['St'], ['St'], [], [], [], [], [], [], []] },
  939. fcMapLayers: [
  940. {
  941. layerID: 1024,
  942. fcPropName: 'fedfunccls',
  943. idPropName: 'objectid',
  944. outFields: ['objectid', 'fedfunccls'],
  945. roadTypeMap: {
  946. Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6], St: [7]
  947. },
  948. maxRecordCount: 1000,
  949. supportsPagination: false
  950. }
  951. ],
  952. information: { Source: 'MaineDOT', Permission: 'Visible to R4+ or R3-AM' },
  953. isPermitted() { return _r >= 4 || (_r === 3 && _isAM); },
  954. getWhereClause(context) {
  955. if (context.mapContext.zoom < 16) {
  956. return `${context.layer.fcPropName}<>'Local'`;
  957. }
  958. return null;
  959. },
  960. getFeatureRoadType(feature, layer) {
  961. const attr = feature.attributes;
  962. let fc = attr[layer.fcPropName];
  963. switch (fc) {
  964. case 'Interstate': fc = 1; break;
  965. case 'Other Freeway or Expressway': fc = 2; break;
  966. case 'Other Principal Arterial': fc = 3; break;
  967. case 'Minor Arterial': fc = 4; break;
  968. case 'Major Collector':
  969. case 'Minor Collector': fc = 5; break;
  970. default: fc = 7;
  971. }
  972. // 2024-6-28 (mapomatic) MaineDOT removed the prirtename field so we can't "upgrade" FC anymore.
  973. // const route = attr.prirtename;
  974. // const isUS = /^US \d/.test(route);
  975. // const isState = /^ST RTE \d/.test(route);
  976. // const isBiz = (isUS && /(1B|1BS)$/.test(route)) || (isState && /(15B|24B|25B|137B)$/.test(route));
  977. // if (fc > 3 && isUS) fc = isBiz ? 4 : 3;
  978. // else if (fc > 4 && isState) fc = isBiz ? 5 : 4;
  979. return STATE_SETTINGS.global.getRoadTypeFromFC(fc, layer);
  980. }
  981. },
  982. MD: {
  983. baseUrl: 'https://services.arcgis.com/njFNhDsUCentVYJW/arcgis/rest/services/MDOT_SHA_Roadway_Functional_Classification/FeatureServer/',
  984. defaultColors: {
  985. Fw: '#ff00c5', Ew: '#4f33df', MH: '#149ece', mH: '#4ce600', PS: '#ffff00', St: '#eeeeee'
  986. },
  987. zoomSettings: { maxOffset: [30, 15, 8, 4, 2, 1, 1, 1, 1, 1], excludeRoadTypes: [['St'], ['St'], ['St'], ['St'], [], [], [], [], [], [], []] },
  988. fcMapLayers: [
  989. {
  990. layerID: 0,
  991. fcPropName: 'FUNCTIONAL_CLASS',
  992. idPropName: 'OBJECTID',
  993. outFields: ['OBJECTID', 'FUNCTIONAL_CLASS', 'ID_PREFIX', 'MP_SUFFIX'],
  994. roadTypeMap: {
  995. Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6], St: [7]
  996. },
  997. maxRecordCount: 1000,
  998. supportsPagination: false
  999. }
  1000. ],
  1001. information: { Source: 'MDOT', Permission: 'Visible to R4+ or R3-AM' },
  1002. getWhereClause(context) {
  1003. if (context.mapContext.zoom < 16) {
  1004. return "(FUNCTIONAL_CLASS < 7 OR ID_PREFIX IN('MD'))";
  1005. }
  1006. return null;
  1007. },
  1008. getFeatureRoadType(feature, layer) {
  1009. const attr = feature.attributes;
  1010. let fc = parseInt(attr.FUNCTIONAL_CLASS, 10);
  1011. const isUS = attr.ID_PREFIX === 'US';
  1012. const isState = attr.ID_PREFIX === 'MD';
  1013. const isBiz = attr.MP_SUFFIX === 'BU';
  1014. if (fc > 3 && isUS) fc = isBiz ? 4 : 3;
  1015. else if (fc > 4 && isState) fc = isBiz ? 5 : 4;
  1016. return STATE_SETTINGS.global.getRoadTypeFromFC(fc, layer);
  1017. }
  1018. },
  1019. MA: {
  1020. baseUrl: 'https://gis.massdot.state.ma.us/arcgis/rest/services/Roads/RoadInventory/MapServer/',
  1021. defaultColors: {
  1022. Fw: '#ff00c5', Ew: '#4f33df', MH: '#149ece', mH: '#4ce600', PS: '#cfae0e', St: '#eeeeee'
  1023. },
  1024. zoomSettings: { maxOffset: [30, 15, 8, 4, 2, 1, 1, 1, 1, 1], excludeRoadTypes: [['St'], ['St'], ['St'], ['St'], [], [], [], [], [], [], []] },
  1025. fcMapLayers: [
  1026. {
  1027. layerID: 0,
  1028. fcPropName: 'F_F_Class',
  1029. idPropName: 'OBJECTID',
  1030. outFields: ['OBJECTID', 'F_F_Class', 'Route_ID'],
  1031. roadTypeMap: {
  1032. Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6], St: [7]
  1033. },
  1034. maxRecordCount: 1000,
  1035. supportsPagination: false
  1036. }
  1037. ],
  1038. information: { Source: 'MDOT', Permission: 'Visible to R2+' },
  1039. isPermitted() { return _r >= 2; },
  1040. getWhereClause(context) {
  1041. if (context.mapContext.zoom < 16) {
  1042. return `${context.layer.fcPropName}<>'7'`;
  1043. }
  1044. return null;
  1045. },
  1046. getFeatureRoadType(feature, layer) {
  1047. const attr = feature.attributes;
  1048. let fc = parseInt(attr[layer.fcPropName], 10);
  1049. const route = attr.Route_ID;
  1050. const isUS = /^US\d/.test(route);
  1051. const isState = /^SR\d/.test(route);
  1052. if (fc > 3 && isUS) fc = 3;
  1053. else if (fc > 4 && isState) fc = 4;
  1054. return STATE_SETTINGS.global.getRoadTypeFromFC(fc, layer);
  1055. }
  1056. },
  1057. MI: {
  1058. baseUrl: 'https://gisp.mcgi.state.mi.us/arcgis/rest/services/MDOT/NFC/MapServer/',
  1059. defaultColors: {
  1060. Fw: '#ff00c5', Ew: '#149ece', MH: '#149ece', mH: '#4ce600', PS: '#cfae0e', St: '#eeeeee'
  1061. },
  1062. zoomSettings: { maxOffset: [30, 15, 8, 4, 2, 1, 1, 1, 1, 1], excludeRoadTypes: [['St'], ['St'], ['St'], ['St'], [], [], [], [], [], [], []] },
  1063. fcMapLayers: [
  1064. {
  1065. layerID: 2,
  1066. idPropName: 'OBJECTID',
  1067. fcPropName: 'NFC',
  1068. outFields: ['NFC'],
  1069. roadTypeMap: {
  1070. Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6], St: [7]
  1071. },
  1072. maxRecordCount: 1000,
  1073. supportsPagination: false
  1074. }
  1075. ],
  1076. isPermitted() { return true; },
  1077. information: { Source: 'MDOT', Description: 'Raw unmodified FC data.' },
  1078. getWhereClause(context) {
  1079. if (context.mapContext.zoom < 16) {
  1080. return `${context.layer.fcPropName}<>7`;
  1081. }
  1082. return null;
  1083. },
  1084. getFeatureRoadType(feature, layer) {
  1085. if (layer.getFeatureRoadType) {
  1086. return layer.getFeatureRoadType(feature);
  1087. }
  1088. return STATE_SETTINGS.global.getFeatureRoadType(feature, layer);
  1089. }
  1090. },
  1091. MN: {
  1092. baseUrl: 'https://dotapp9.dot.state.mn.us/lrs/rest/services/emma/emma_op/MapServer/',
  1093. defaultColors: {
  1094. Fw: '#ff00c5', Ew: '#149ece', MH: '#149ece', mH: '#4ce600', PS: '#cfae0e', St: '#eeeeee'
  1095. },
  1096. zoomSettings: { maxOffset: [30, 15, 8, 4, 2, 1, 1, 1, 1, 1], excludeRoadTypes: [['St'], ['St'], ['St'], ['St'], [], [], [], [], [], [], []] },
  1097. fcMapLayers: [
  1098. {
  1099. layerID: 13,
  1100. idPropName: 'OBJECTID',
  1101. fcPropName: 'FUNCTIONAL_CLASS',
  1102. outFields: ['FUNCTIONAL_CLASS', 'ROUTE_ID'],
  1103. roadTypeMap: {
  1104. Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6], St: [7]
  1105. },
  1106. maxRecordCount: 1000,
  1107. supportsPagination: false
  1108. }
  1109. ],
  1110. isPermitted() { return true; },
  1111. information: { Source: 'MnDOT', Description: 'Raw unmodified FC data.' },
  1112. getWhereClause(context) {
  1113. if (context.mapContext.zoom < 16) {
  1114. return `${context.layer.fcPropName}<>7`;
  1115. }
  1116. return null;
  1117. },
  1118. getFeatureRoadType(feature, layer) {
  1119. if (layer.getFeatureRoadType) {
  1120. return layer.getFeatureRoadType(feature);
  1121. }
  1122. return STATE_SETTINGS.global.getFeatureRoadType(feature, layer);
  1123. }
  1124. },
  1125. MO: {
  1126. baseUrl: 'http://mapping.modot.org/external/rest/services/BaseMap/TmsUtility/MapServer/',
  1127. defaultColors: {
  1128. Fw: '#ff00c5', Ew: '#4f33df', MH: '#149ece', mH: '#4ce600', PS: '#cfae0e', St: '#eeeeee'
  1129. },
  1130. zoomSettings: { maxOffset: [30, 15, 8, 4, 2, 1, 1, 1, 1, 1], excludeRoadTypes: [['St'], ['St'], ['St'], ['St'], [], [], [], [], [], [], []] },
  1131. fcMapLayers: [
  1132. {
  1133. layerID: 5,
  1134. fcPropName: 'FUNC_CLASS_NAME',
  1135. idPropName: 'SS_PAVEMENT_ID',
  1136. outFields: ['SS_PAVEMENT_ID', 'FUNC_CLASS_NAME', 'TRAVELWAY_DESG', 'TRAVELWAY_NAME', 'ACCESS_CAT_NAME'],
  1137. roadTypeMap: {
  1138. Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6], St: [7]
  1139. },
  1140. maxRecordCount: 1000,
  1141. supportsPagination: false
  1142. }
  1143. ],
  1144. isPermitted() { return _r >= 3 || (_r >= 2 && _isAM); },
  1145. information: { Source: 'MoDOT', Permission: 'Visible to R3+ or R2-AM' },
  1146. getWhereClause(context) {
  1147. if (context.mapContext.zoom < 13) {
  1148. return '1=0'; // WME very laggy at zoom 0
  1149. }
  1150. // Remove duplicate rows, but suss out interstate business loops
  1151. return "FUNC_CLASS_NAME <> ' ' AND (TRAVELWAY_ID = CNTL_TW_ID OR (TRAVELWAY_ID <> CNTL_TW_ID AND TRAVELWAY_DESG = 'LP'))";
  1152. },
  1153. getFeatureRoadType(feature, layer) {
  1154. const attr = feature.attributes;
  1155. let fc = attr[layer.fcPropName];
  1156. const rtType = attr.TRAVELWAY_DESG;
  1157. const route = attr.TRAVELWAY_NAME;
  1158. switch (fc) {
  1159. case 'INTERSTATE': fc = 1; break;
  1160. case 'FREEWAY': fc = 2; break;
  1161. case 'PRINCIPAL ARTERIAL': fc = 3; break;
  1162. case 'MINOR ARTERIAL': fc = 4; break;
  1163. case 'MAJOR COLLECTOR': fc = 5; break;
  1164. case 'MINOR COLLECTOR': fc = 6; break;
  1165. default: fc = 8; // not a typo
  1166. }
  1167. const usHwys = ['24', '36', '40', '50', '54', '56', '59', '60', '61', '62', '63', '65', '67', '69', '71', '136', '159', '160', '166', '169', '275', '400', '412'];
  1168. const isUS = ['US', 'LP'].includes(rtType); // is US or interstate biz
  1169. const isState = ['MO', 'AL'].includes(rtType);
  1170. const isSup = rtType === 'RT';
  1171. const isBiz = ['BU', 'SP'].includes(rtType) || /BUSINESS .+ \d/.test(route);
  1172. const isUSBiz = isBiz && usHwys.includes(route);
  1173. if ((fc === 2 && attr.ACCESS_CAT_NAME !== 'FULL') || (fc > 3 && isUS)) fc = 3;
  1174. else if (fc > 4 && (isState || isUSBiz)) fc = 4;
  1175. else if (fc > 6 && (isSup || isBiz)) fc = 6;
  1176. return STATE_SETTINGS.global.getRoadTypeFromFC(fc, layer);
  1177. }
  1178. },
  1179. MT: {
  1180. baseUrl: 'https://app.mdt.mt.gov/arcgis/rest/services/Standard/FUNCTIONAL_CLASS/MapServer/',
  1181. defaultColors: {
  1182. Fw: '#ff00c5', Ew: '#4f33df', MH: '#149ece', mH: '#4ce600', PS: '#cfae0e', St: '#eeeeee'
  1183. },
  1184. zoomSettings: { maxOffset: [30, 15, 8, 4, 2, 1, 1, 1, 1, 1], excludeRoadTypes: [['St'], ['St'], ['St'], ['St'], [], [], [], [], [], [], []] },
  1185. fcMapLayers: [
  1186. {
  1187. layerID: 0,
  1188. fcPropName: 'FUNC_CLASS',
  1189. idPropName: 'OBJECTID',
  1190. outFields: ['OBJECTID', 'FUNC_CLASS', 'SIGN_ROUTE', 'ROUTE_NAME'],
  1191. roadTypeMap: {
  1192. Fw: ['1-Interstate']
  1193. },
  1194. maxRecordCount: 1000,
  1195. supportsPagination: false
  1196. },
  1197. {
  1198. layerID: 1,
  1199. fcPropName: 'FUNC_CLASS',
  1200. idPropName: 'OBJECTID',
  1201. outFields: ['OBJECTID', 'FUNC_CLASS', 'SIGN_ROUTE', 'ROUTE_NAME'],
  1202. roadTypeMap: {
  1203. MH: ['3-Principal Arterial - Other']
  1204. },
  1205. maxRecordCount: 1000,
  1206. supportsPagination: false
  1207. },
  1208. {
  1209. layerID: 2,
  1210. fcPropName: 'FUNC_CLASS',
  1211. idPropName: 'OBJECTID',
  1212. outFields: ['OBJECTID', 'FUNC_CLASS', 'SIGN_ROUTE', 'ROUTE_NAME'],
  1213. roadTypeMap: {
  1214. mH: ['4-Minor Arterial']
  1215. },
  1216. maxRecordCount: 1000,
  1217. supportsPagination: false
  1218. },
  1219. {
  1220. layerID: 3,
  1221. fcPropName: 'FUNC_CLASS',
  1222. idPropName: 'OBJECTID',
  1223. outFields: ['OBJECTID', 'FUNC_CLASS', 'SIGN_ROUTE', 'ROUTE_NAME'],
  1224. roadTypeMap: {
  1225. PS: ['5-Major Collector']
  1226. },
  1227. maxRecordCount: 1000,
  1228. supportsPagination: false
  1229. },
  1230. {
  1231. layerID: 4,
  1232. fcPropName: 'FUNC_CLASS',
  1233. idPropName: 'OBJECTID',
  1234. outFields: ['OBJECTID', 'FUNC_CLASS', 'SIGN_ROUTE', 'ROUTE_NAME'],
  1235. roadTypeMap: {
  1236. PS: ['6-Minor Collector']
  1237. },
  1238. maxRecordCount: 1000,
  1239. supportsPagination: false
  1240. },
  1241. {
  1242. layerID: 5,
  1243. fcPropName: 'FUNC_CLASS',
  1244. idPropName: 'OBJECTID',
  1245. outFields: ['OBJECTID', 'FUNC_CLASS', 'SIGN_ROUTE', 'ROUTE_NAME'],
  1246. roadTypeMap: {
  1247. St: ['7-Local']
  1248. },
  1249. maxRecordCount: 1000,
  1250. supportsPagination: false
  1251. }
  1252. ],
  1253. isPermitted() { /* return _r >= 3; */ return ['mapomatic', 'bobc455'].includes(_uName.toLowerCase()); },
  1254. information: { Source: 'MDT', Permission: 'Visible to R3+' },
  1255. getWhereClause(context) {
  1256. if (context.mapContext.zoom < 16) {
  1257. return `${context.layer.fcPropName}<>'LOCAL'`;
  1258. }
  1259. return null;
  1260. },
  1261. getFeatureRoadType(feature, layer) {
  1262. let rt = STATE_SETTINGS.global.getFeatureRoadType(feature, layer);
  1263. const roadID = feature.attributes.SIGN_ROUTE || feature.attributes.ROUTE_NAME;
  1264. const isUS = /^US[ -]?\d+/.test(roadID);
  1265. const isState = /^MONTANA \d+|ROUTE \d+|S-\d{3}\b/.test(roadID);
  1266. if (isUS && ['St', 'PS', 'mH'].includes(rt)) {
  1267. log(`FC UPGRADE: ${roadID} from ${rt} to MH`); // TODO - remove this when testing is finished (9/10/2022)
  1268. rt = 'MH';
  1269. } else if (isState && ['St', 'PS'].includes(rt)) {
  1270. log(`FC UPGRADE: ${roadID} from ${rt} to mH`); // TODO - remove this when testing is finished (9/10/2022)
  1271. rt = 'mH';
  1272. }
  1273. return rt;
  1274. }
  1275. },
  1276. NV: {
  1277. baseUrl: 'https://gis.dot.nv.gov/rhgis/rest/services/GeoHub/FSystem/MapServer/',
  1278. defaultColors: {
  1279. Fw: '#ff00c5', Ew: '#4f33df', MH: '#149ece', mH: '#4ce600', PS: '#cfae0e', St: '#eeeeee'
  1280. },
  1281. zoomSettings: { maxOffset: [30, 15, 8, 4, 2, 1, 1, 1, 1, 1], excludeRoadTypes: [[], [], [], [], [], [], [], [], [], [], []] },
  1282. fcMapLayers: [
  1283. {
  1284. layerID: 0,
  1285. fcPropName: 'FSystem',
  1286. idPropName: 'OBJECTID',
  1287. outFields: ['OBJECTID', 'FSystem'],
  1288. roadTypeMap: {
  1289. Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6], St: [7]
  1290. },
  1291. maxRecordCount: 1000,
  1292. supportsPagination: false
  1293. }
  1294. ],
  1295. isPermitted() { return ['mapomatic', 'turbomkt', 'tonestertm', 'geopgeop', 'ojlaw'].includes(_uName.toLowerCase()); },
  1296. information: { Source: 'NDOT', Permission: '?' },
  1297. getWhereClause(context) {
  1298. if (context.mapContext.zoom < 16) {
  1299. return `${context.layer.fcPropName}<>7`;
  1300. }
  1301. return null;
  1302. },
  1303. getFeatureRoadType(feature, layer) {
  1304. const fc = parseInt(feature.attributes[layer.fcPropName], 10);
  1305. return STATE_SETTINGS.global.getRoadTypeFromFC(fc, layer);
  1306. }
  1307. },
  1308. NH: {
  1309. baseUrl: 'https://nhgeodata.unh.edu/nhgeodata/rest/services/TN/RoadsForDOTViewer/MapServer/',
  1310. defaultColors: {
  1311. Fw: '#ff00c5', Ew: '#4f33df', MH: '#149ece', mH: '#4ce600', PS: '#cfae0e', St: '#eeeeee'
  1312. },
  1313. zoomSettings: { maxOffset: [30, 15, 8, 4, 2, 1, 1, 1, 1, 1], excludeRoadTypes: [[], [], [], [], [], [], [], [], [], [], []] },
  1314. fcMapLayers: [
  1315. {
  1316. layerID: 0,
  1317. fcPropName: 'FUNCT_SYSTEM',
  1318. idPropName: 'OBJECTID',
  1319. outFields: ['OBJECTID', 'FUNCT_SYSTEM', 'STREET_ALIASES', 'TIER'],
  1320. roadTypeMap: {
  1321. Fw: [1], Ew: [2], MH: [2, 3], mH: [4], PS: [5, 6], St: [7, 0]
  1322. },
  1323. maxRecordCount: 1000,
  1324. supportsPagination: false
  1325. }
  1326. ],
  1327. isPermitted() { return _r >= 2; },
  1328. information: { Source: 'NH GRANIT', Permission: 'Visible to R2+' },
  1329. getWhereClause(context) {
  1330. if (context.mapContext.zoom < 16) {
  1331. return `${context.layer.fcPropName}<>7 AND ${context.layer.fcPropName}<>0`;
  1332. }
  1333. return null;
  1334. },
  1335. getFeatureRoadType(feature, layer) {
  1336. let fc = parseInt(feature.attributes[layer.fcPropName], 10);
  1337. if (!(fc > 0)) { fc = 7; }
  1338. const route = feature.attributes.STREET_ALIASES;
  1339. const isUS = /US /.test(route);
  1340. const isState = /NH /.test(route);
  1341. if (fc === 2) fc = feature.attributes.TIER === 1 ? 1 : 3;
  1342. else if (fc > 3 && isUS) fc = /US 3B/.test(route) ? 4 : 3;
  1343. else if (fc > 4 && isState) fc = 4;
  1344. return STATE_SETTINGS.global.getRoadTypeFromFC(fc, layer);
  1345. }
  1346. },
  1347. NM: {
  1348. baseUrl: 'https://services.arcgis.com/hOpd7wfnKm16p9D9/ArcGIS/rest/services/NMDOT_Functional_Class/FeatureServer/',
  1349. defaultColors: {
  1350. Fw: '#ff00c5', Ew: '#ff00c5', MH: '#149ece', mH: '#4ce600', PS: '#cfae0e', St: '#eeeeee'
  1351. },
  1352. zoomSettings: { maxOffset: [30, 15, 8, 4, 2, 1, 1, 1, 1, 1] },
  1353. fcMapLayers: [
  1354. {
  1355. layerID: 0,
  1356. fcPropName: 'Func_Class',
  1357. idPropName: 'OBJECTID_1',
  1358. maxRecordCount: 1000,
  1359. supportsPagination: false,
  1360. outFields: ['OBJECTID_1', 'Func_Class', 'D_RT_ROUTE'],
  1361. roadTypeMap: {
  1362. Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6], St: [7]
  1363. }
  1364. }
  1365. ],
  1366. isPermitted() { return true; },
  1367. information: { Source: 'NMDOT' },
  1368. getWhereClause() {
  1369. return null;
  1370. },
  1371. getFeatureRoadType(feature, layer) {
  1372. let fc = parseInt(feature.attributes[layer.fcPropName], 10);
  1373. const roadType = feature.attributes.D_RT_ROUTE.split('-', 1).shift();
  1374. const isBiz = roadType === 'BL'; // Interstate Business Loop
  1375. const isUS = roadType === 'US';
  1376. const isState = roadType === 'NM';
  1377. if (roadType === 'IX') fc = 0;
  1378. else if (fc > 3 && (isBiz || isUS)) fc = 3;
  1379. else if (fc > 4 && isState) fc = 4;
  1380. return STATE_SETTINGS.global.getRoadTypeFromFC(fc, layer);
  1381. }
  1382. },
  1383. NY: { // https://gis.dot.ny.gov/hostingny/rest/services/Basemap/MapServer/21
  1384. baseUrl: 'https://gis.dot.ny.gov/hostingny/rest/services',
  1385. defaultColors: {
  1386. Fw: '#ff00c5', Ew: '#5f33df', MH: '#149ece', mH: '#4ce600', PS: '#cfae0e', St: '#eeeeee'
  1387. },
  1388. zoomSettings: { maxOffset: [30, 15, 8, 4, 2, 1, 1, 1, 1, 1] },
  1389. fcMapLayers: [
  1390. {
  1391. layerID: '/Geocortex/FC/MapServer/1',
  1392. fcPropName: 'FUNC_CLASS',
  1393. idPropName: 'OBJECTID',
  1394. outFields: ['OBJECTID', 'FUNC_CLASS', 'SEGMENT_NAME', 'ROUTE_NO'],
  1395. roadTypeMap: {
  1396. Fw: [1, 11], Ew: [2, 12], MH: [4, 14], mH: [6, 16], PS: [7, 8, 17, 18], St: [9, 19]
  1397. },
  1398. maxRecordCount: 1000,
  1399. supportsPagination: false
  1400. },
  1401. {
  1402. layerID: 'Basemap/MapServer/21',
  1403. idPropName: 'OBJECTID',
  1404. outFields: ['OBJECTID', 'SHIELD'],
  1405. maxRecordCount: 1000,
  1406. supportsPagination: false
  1407. }
  1408. ],
  1409. information: { Source: 'NYSDOT', Permission: 'Visible to R4+ or R3-AM' },
  1410. getWhereClause(context) {
  1411. if (context.layer.layerID === 'Basemap/MapServer/21') {
  1412. return ("SHIELD IN ('C','CT')");
  1413. }
  1414. return null;
  1415. },
  1416. getFeatureRoadType(feature, layer) {
  1417. let roadType;
  1418. if (layer.layerID === 'Basemap/MapServer/21') {
  1419. roadType = 'PS';
  1420. } else {
  1421. roadType = STATE_SETTINGS.global.getFeatureRoadType(feature, layer);
  1422. const routeNo = feature.attributes.ROUTE_NO;
  1423. if (/^NY.*/.test(routeNo)) {
  1424. if (roadType === 'PS') roadType = 'mH';
  1425. } else if (/^US.*/.test(routeNo)) {
  1426. if (roadType === 'PS' || roadType === 'mH') roadType = 'MH';
  1427. }
  1428. }
  1429. return roadType;
  1430. }
  1431. },
  1432. NC: {
  1433. baseUrl: 'https://gis11.services.ncdot.gov/arcgis/rest/services/NCDOT_FunctionalClassQtr/MapServer/',
  1434. defaultColors: {
  1435. Fw: '#ff00c5', Rmp: '#999999', Ew: '#5f33df', MH: '#149ece', mH: '#4ce600', PS: '#cfae0e', St: '#eeeeee'
  1436. },
  1437. zoomSettings: { maxOffset: [30, 15, 8, 4, 2, 1, 1, 1, 1, 1], excludeRoadTypes: [['St'], ['St'], ['St'], ['St'], [], [], [], [], [], [], []] },
  1438. fcMapLayers: [
  1439. {
  1440. layerID: 0,
  1441. fcPropName: 'FuncClass',
  1442. idPropName: 'OBJECTID',
  1443. outFields: ['OBJECTID', 'FuncClass', 'RouteClass', 'RouteQualifier'],
  1444. roadTypeMap: {
  1445. Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6], St: [7]
  1446. },
  1447. zoomLevels: [3, 4, 5, 6, 7, 8, 9, 10],
  1448. maxRecordCount: 1000,
  1449. supportsPagination: false
  1450. }
  1451. ],
  1452. isPermitted() { return _r >= 3; },
  1453. information: { Source: 'NCDOT', Permission: 'Visible to R3+' },
  1454. getWhereClause(context) {
  1455. if (context.mapContext.zoom < 16) {
  1456. const clause = `(${context.layer.fcPropName} < 7 OR RouteClass IN ('I','FED','NC','RMP','US'))`;
  1457. return clause;
  1458. }
  1459. return null;
  1460. },
  1461. getFeatureRoadType(feature, layer) {
  1462. const fc = feature.attributes[layer.fcPropName];
  1463. let roadType;
  1464. switch (this.getHwySys(feature)) {
  1465. case 'interstate':
  1466. if (fc <= 2 || !this.isBusinessRoute(feature)) roadType = 'Fw';
  1467. else roadType = 'MH';
  1468. break;
  1469. case 'us':
  1470. if (fc <= 2) roadType = 'Ew';
  1471. else if (fc === 3 || !this.isBusinessRoute(feature)) roadType = 'MH';
  1472. else roadType = 'mH';
  1473. break;
  1474. case 'state':
  1475. if (fc <= 2) roadType = 'Ew';
  1476. else if (fc === 3) roadType = 'MH';
  1477. else if (fc === 4 || !this.isBusinessRoute(feature)) roadType = 'mH';
  1478. else roadType = 'PS';
  1479. break;
  1480. case 'ramp':
  1481. roadType = 'Rmp';
  1482. break;
  1483. default:
  1484. if (fc === 2) roadType = 'Ew';
  1485. else if (fc === 3) roadType = 'MH';
  1486. else if (fc === 4) roadType = 'mH';
  1487. else if (fc <= 6) roadType = 'PS';
  1488. else roadType = 'St';
  1489. // roadType = fc === 2 ? 'Ew' : (fc === 3 ? 'MH' : (fc === 4 ? 'mH' : (fc <= 6 ? 'PS' : 'St')));
  1490. }
  1491. return roadType;
  1492. },
  1493. getHwySys(feature) {
  1494. let hwySys;
  1495. switch (feature.attributes.RouteClass.toString()) {
  1496. case '1':
  1497. hwySys = 'interstate';
  1498. break;
  1499. case '2':
  1500. hwySys = 'us';
  1501. break;
  1502. case '3':
  1503. hwySys = 'state';
  1504. break;
  1505. case '80':
  1506. hwySys = 'ramp';
  1507. break;
  1508. default:
  1509. hwySys = 'local';
  1510. }
  1511. return hwySys;
  1512. },
  1513. isBusinessRoute(feature) {
  1514. const qual = feature.attributes.RouteQualifier.toString();
  1515. return qual === '9';
  1516. }
  1517. },
  1518. ND: {
  1519. baseUrl: 'https://gis.dot.nd.gov/arcgis/rest/services/external/transinfo/MapServer/',
  1520. defaultColors: {
  1521. Fw: '#ff00c5', Ew: '#149ece', MH: '#149ece', mH: '#4ce600', PS: '#cfae0e', St: '#eeeeee'
  1522. },
  1523. zoomSettings: { maxOffset: [30, 15, 8, 4, 2, 1, 1, 1, 1, 1], excludeRoadTypes: [['St'], ['St'], ['St'], ['St'], [], [], [], [], [], [], []] },
  1524. fcMapLayers: [
  1525. {
  1526. layerID: 10,
  1527. fcPropName: 'FUNCTION_CLASS',
  1528. idPropName: 'OBJECTID',
  1529. outFields: ['OBJECTID', 'FUNCTION_CLASS'],
  1530. roadTypeMap: {
  1531. Fw: ['Interstate'], MH: ['Principal Arterial'], mH: ['Minor Arterial'], PS: ['Major Collector', 'Collector'], St: ['Local']
  1532. },
  1533. maxRecordCount: 1000,
  1534. supportsPagination: false
  1535. },
  1536. {
  1537. layerID: 11,
  1538. fcPropName: 'FUNCTION_CLASS',
  1539. idPropName: 'OBJECTID',
  1540. outFields: ['OBJECTID', 'FUNCTION_CLASS'],
  1541. roadTypeMap: {
  1542. Fw: ['Interstate'], MH: ['Principal Arterial'], mH: ['Minor Arterial'], PS: ['Major Collector', 'Collector'], St: ['Local']
  1543. },
  1544. maxRecordCount: 1000,
  1545. supportsPagination: false
  1546. },
  1547. {
  1548. layerID: 12,
  1549. fcPropName: 'FUNCTION_CLASS',
  1550. idPropName: 'OBJECTID',
  1551. outFields: ['OBJECTID', 'FUNCTION_CLASS'],
  1552. roadTypeMap: { PS: ['Major Collector', 'Collector'] },
  1553. maxRecordCount: 1000,
  1554. supportsPagination: false
  1555. },
  1556. {
  1557. layerID: 16,
  1558. fcPropName: 'SYSTEM_CD',
  1559. idPropName: 'OBJECTID',
  1560. outFields: ['OBJECTID', 'SYSTEM_CD', 'SYSTEM_DESC', 'HIGHWAY', 'HWY_SUFFIX'],
  1561. roadTypeMap: { Fw: [1, 11], MH: [2, 14], mH: [6, 7, 16, 19] },
  1562. maxRecordCount: 1000,
  1563. supportsPagination: false
  1564. }
  1565. ],
  1566. information: { Source: 'NDDOT', Permission: 'Visible to R4+ or R3-AM' },
  1567. getWhereClause(context) {
  1568. if (context.mapContext.zoom < 16) {
  1569. if (context.layer.layerID !== 16) return `${context.layer.fcPropName}<>'Local'`;
  1570. }
  1571. return null;
  1572. },
  1573. getFeatureRoadType(feature, layer) {
  1574. return STATE_SETTINGS.global.getFeatureRoadType(feature, layer);
  1575. }
  1576. },
  1577. OH: {
  1578. baseUrl: 'https://gis.dot.state.oh.us/arcgis/rest/services/TIMS/Roadway_Information/MapServer/',
  1579. defaultColors: {
  1580. Fw: '#ff00c5', Ew: '#4f33df', MH: '#149ece', mH: '#4ce600', PS: '#cfae0e', St: '#eeeeee'
  1581. },
  1582. zoomSettings: { maxOffset: [30, 15, 8, 4, 2, 1, 1, 1, 1, 1], excludeRoadTypes: [['St'], ['St'], ['St'], ['St'], [], [], [], [], [], [], []] },
  1583.  
  1584. fcMapLayers: [
  1585. {
  1586. layerID: 8,
  1587. fcPropName: 'FUNCTION_CLASS_CD',
  1588. idPropName: 'ObjectID',
  1589. outFields: ['FUNCTION_CLASS_CD', 'ROUTE_TYPE', 'ROUTE_NBR', 'ObjectID'],
  1590. maxRecordCount: 1000,
  1591. supportsPagination: false,
  1592. roadTypeMap: {
  1593. Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6], St: [7]
  1594. }
  1595. }
  1596. ],
  1597. isPermitted() { return true; },
  1598. information: { Source: 'ODOT' },
  1599. getWhereClause(context) {
  1600. if (context.mapContext.zoom < 16) {
  1601. const clause = `(${context.layer.fcPropName} < 7 OR ROUTE_TYPE IN ('CR','SR','US'))`;
  1602. return clause;
  1603. }
  1604. return null;
  1605. },
  1606. getFeatureRoadType(feature, layer) {
  1607. let fc = feature.attributes[layer.fcPropName];
  1608. const prefix = feature.attributes.ROUTE_TYPE;
  1609. const isUS = prefix === 'US';
  1610. const isState = prefix === 'SR';
  1611. const isCounty = prefix === 'CR';
  1612. if (isUS && fc > 3) { fc = 3; }
  1613. if (isState && fc > 4) { fc = 4; }
  1614. if (isCounty && fc > 6) { fc = 6; }
  1615. return STATE_SETTINGS.global.getRoadTypeFromFC(fc, layer);
  1616. }
  1617. },
  1618. OK: {
  1619. baseUrl: 'https://services6.arcgis.com/RBtoEUQ2lmN0K3GY/arcgis/rest/services/Roadways/FeatureServer/',
  1620. defaultColors: {
  1621. Fw: '#ff00c5', Ew: '#4f33df', MH: '#149ece', mH: '#4ce600', PS: '#cfae0e', St: '#eeeeee'
  1622. },
  1623. zoomSettings: { maxOffset: [30, 15, 8, 4, 2, 1, 1, 1, 1, 1], excludeRoadTypes: [['St'], ['St'], ['St'], ['St'], [], [], [], [], [], [], []] },
  1624. fcMapLayers: [
  1625. {
  1626. layerID: 0,
  1627. fcPropName: 'FUNCTIONALCLASS',
  1628. idPropName: 'OBJECTID',
  1629. outFields: ['OBJECTID', 'FUNCTIONALCLASS', 'FHWAPRIMARYROUTE', 'ODOTROUTECLASS', 'ACCESSCONTROL'],
  1630. maxRecordCount: 1000,
  1631. supportsPagination: false,
  1632. roadTypeMap: {
  1633. Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6], St: [7]
  1634. }
  1635. }
  1636. ],
  1637. information: { Source: 'ODOT', Permission: 'Visible to R4+ or R3-AM' },
  1638. getWhereClause(context) {
  1639. if (context.mapContext.zoom < 16) {
  1640. return `${context.layer.fcPropName} < 7 OR ODOTROUTECLASS IN ('U','S','I')`;
  1641. }
  1642. return null;
  1643. },
  1644. getFeatureRoadType(feature, layer) {
  1645. let fc = feature.attributes[layer.fcPropName];
  1646. const route = (feature.attributes.FHWAPRIMARYROUTE || '').trim();
  1647. const isBusinessOrSpur = /BUS$|SPR$/i.test(route);
  1648. const prefix = isBusinessOrSpur ? route.substring(0, 1) : feature.attributes.ODOTROUTECLASS;
  1649. const isFw = parseInt(feature.attributes.ACCESSCONTROL, 10) === 1;
  1650. const isInterstate = prefix === 'I';
  1651. const isUS = prefix === 'U';
  1652. const isState = prefix === 'S';
  1653. if (isFw) fc = 1;
  1654. else if (fc > 3 && ((isUS && !isBusinessOrSpur) || (isInterstate && isBusinessOrSpur))) fc = 3;
  1655. else if (fc > 4 && ((isUS && isBusinessOrSpur) || (isState && !isBusinessOrSpur))) fc = 4;
  1656. else if (fc > 5 && isState && isBusinessOrSpur) fc = 5;
  1657. return STATE_SETTINGS.global.getRoadTypeFromFC(fc, layer);
  1658. }
  1659. },
  1660. OR: {
  1661. baseUrl: 'https://gis.odot.state.or.us/arcgis/rest/services/transgis/data_catalog_display/Mapserver/',
  1662. defaultColors: {
  1663. Fw: '#ff00c5', Ew: '#4f33df', MH: '#149ece', mH: '#4ce600', PS: '#cfae0e', St: '#eeeeee'
  1664. },
  1665. zoomSettings: { maxOffset: [30, 15, 8, 4, 2, 1, 1, 1, 1, 1], excludeRoadTypes: [['St'], ['St'], ['St'], ['St'], [], [], [], [], [], [], []] },
  1666. fcMapLayers: [
  1667. {
  1668. layerID: 78,
  1669. fcPropName: 'NEW_FC_CD',
  1670. idPropName: 'OBJECTID',
  1671. outFields: ['OBJECTID', 'NEW_FC_CD'],
  1672. roadTypeMap: {
  1673. Fw: ['1'], Ew: ['2'], MH: ['3'], mH: ['4'], PS: ['5', '6'], St: ['7']
  1674. },
  1675. maxRecordCount: 1000,
  1676. supportsPagination: false
  1677. },
  1678. {
  1679. layerID: 80,
  1680. fcPropName: 'NEW_FC_CD',
  1681. idPropName: 'OBJECTID',
  1682. outFields: ['OBJECTID', 'NEW_FC_CD'],
  1683. roadTypeMap: {
  1684. Fw: ['1'], Ew: ['2'], MH: ['3'], mH: ['4'], PS: ['5', '6'], St: ['7']
  1685. },
  1686. maxRecordCount: 1000,
  1687. supportsPagination: false
  1688. }
  1689. ],
  1690. information: { Source: 'ODOT', Permission: 'Visible to R4+ or R3-AM', Description: 'Raw unmodified FC data.' },
  1691. getWhereClause(context) {
  1692. if (context.mapContext.zoom < 16) {
  1693. return `${context.layer.fcPropName} <> '7'`;
  1694. }
  1695. return null;
  1696. },
  1697. getFeatureRoadType(feature, layer) {
  1698. if (layer.getFeatureRoadType) {
  1699. return layer.getFeatureRoadType(feature);
  1700. }
  1701. return STATE_SETTINGS.global.getFeatureRoadType(feature, layer);
  1702. }
  1703. },
  1704. PA: {
  1705. baseUrl: 'https://gis.penndot.gov/arcgis/rest/services/opendata/roadwayadmin/MapServer/',
  1706. supportsPagination: false,
  1707. defaultColors: {
  1708. Fw: '#ff00c5', Ew: '#4f33df', MH: '#149ece', mH: '#4ce600', PS: '#cfae0e', St: '#eeeeee'
  1709. },
  1710. zoomSettings: { maxOffset: [30, 15, 8, 4, 2, 1, 1, 1, 1, 1], excludeRoadTypes: [['St'], ['St'], ['St'], ['St'], [], [], [], [], [], [], []] },
  1711. fcMapLayers: [
  1712. {
  1713. layerID: 0,
  1714. features: new Map(),
  1715. fcPropName: 'FUNC_CLS',
  1716. idPropName: 'MSLINK',
  1717. outFields: ['MSLINK', 'FUNC_CLS'],
  1718. maxRecordCount: 1000,
  1719. supportsPagination: false,
  1720. roadTypeMap: {
  1721. Fw: ['01', '11'], Ew: ['12'], MH: ['02', '14'], mH: ['06', '16'], PS: ['07', '08', '17'], St: ['09', '19']
  1722. }
  1723. }
  1724. ],
  1725. isPermitted() { return _r >= 4; },
  1726. information: { Source: 'PennDOT', Permission: 'Visible to R4+', Description: 'Raw unmodified FC data.' },
  1727. getWhereClause(context) {
  1728. return (context.mapContext.zoom < 16) ? `${context.layer.fcPropName} NOT IN ('09','19')` : null;
  1729. },
  1730. getFeatureRoadType(feature, layer) {
  1731. if (layer.getFeatureRoadType) {
  1732. return layer.getFeatureRoadType(feature);
  1733. }
  1734. const fc = feature.attributes[layer.fcPropName];
  1735. return STATE_SETTINGS.global.getRoadTypeFromFC(fc, layer);
  1736. }
  1737. },
  1738. RI: {
  1739. baseUrl: 'https://services2.arcgis.com/S8zZg9pg23JUEexQ/arcgis/rest/services/RIDOT_Roads_2016/FeatureServer/',
  1740. defaultColors: {
  1741. Fw: '#ff00c5', Ew: '#4f33df', MH: '#149ece', mH: '#4ce600', PS: '#cfae0e', St: '#eeeeee'
  1742. },
  1743. zoomSettings: { maxOffset: [30, 15, 8, 4, 2, 1, 1, 1, 1, 1], excludeRoadTypes: [[], [], [], [], [], [], [], [], [], [], []] },
  1744. fcMapLayers: [
  1745. {
  1746. layerID: 0,
  1747. fcPropName: 'F_SYSTEM',
  1748. idPropName: 'OBJECTID',
  1749. outFields: ['OBJECTID', 'F_SYSTEM', 'ROADTYPE', 'RTNO'],
  1750. roadTypeMap: {
  1751. Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6], St: [7, 0]
  1752. },
  1753. maxRecordCount: 1000,
  1754. supportsPagination: false
  1755. }
  1756. ],
  1757. isPermitted() { return _r >= 2; },
  1758. information: { Source: 'RIDOT', Permission: 'Visible to R2+' },
  1759. getWhereClause(context) {
  1760. return (context.mapContext.zoom < 16) ? `${context.layer.fcPropName} NOT IN (7,0)` : null;
  1761. },
  1762. getFeatureRoadType(feature, layer) {
  1763. let fc = parseInt(feature.attributes[layer.fcPropName], 10);
  1764. const type = feature.attributes.ROADTYPE;
  1765. const rtnum = feature.attributes.RTNO;
  1766. if (fc === 2 && ['10', '24', '37', '78', '99', '138', '403'].includes(rtnum)) fc = 1; // isFW
  1767. else if ((fc > 3 && type === 'US') || rtnum === '1') fc = 3; // isUS
  1768. else if (fc > 4 && rtnum.trim() !== '') fc = 4; // isState
  1769. return STATE_SETTINGS.global.getRoadTypeFromFC(fc, layer);
  1770. }
  1771. },
  1772. SC: {
  1773. baseUrl: 'https://services1.arcgis.com/VaY7cY9pvUYUP1Lf/arcgis/rest/services/Functional_Class/FeatureServer/',
  1774. defaultColors: {
  1775. Fw: '#ff00c5', Ew: '#4f33df', MH: '#149ece', mH: '#4ce600', PS: '#cfae0e', St: '#eeeeee'
  1776. },
  1777. zoomSettings: { maxOffset: [30, 15, 8, 4, 2, 1, 1, 1, 1, 1], excludeRoadTypes: [['St'], ['St'], ['St'], ['St'], [], [], [], [], [], [], []] },
  1778. fcMapLayers: [
  1779. {
  1780. layerID: 0,
  1781. fcPropName: 'FC_GIS',
  1782. idPropName: 'FID',
  1783. outFields: ['FID', 'FC_GIS', 'ROUTE_LRS'],
  1784. maxRecordCount: 1000,
  1785. supportsPagination: false,
  1786. roadTypeMap: {
  1787. Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6], St: [7]
  1788. }
  1789. }
  1790. ],
  1791. isPermitted() { return _r >= 4; },
  1792. information: { Source: 'SCDOT', Permission: 'Visible to R4+' },
  1793. getWhereClause() {
  1794. return null;
  1795. },
  1796. getFeatureRoadType(feature, layer) {
  1797. const roadID = feature.attributes.ROUTE_LRS;
  1798. const roadType = parseInt(roadID.slice(3, 4), 10);
  1799. const isFw = roadType === 1;
  1800. const isUS = roadType === 2;
  1801. const isState = roadType === 4;
  1802. const isBiz = parseInt(roadID.slice(-2, -1), 10) === 7;
  1803. let fc = 7;
  1804. switch (feature.attributes[layer.fcPropName]) {
  1805. case 'INT': fc = 1; break;
  1806. case 'EXP': fc = 2; break;
  1807. case 'PRA': fc = 3; break;
  1808. case 'MIA': fc = 4; break;
  1809. case 'MAC':
  1810. case 'MIC': fc = 5; break;
  1811. default: throw new Error(`FC Layer: unexpected fc value: ${fc}`);
  1812. }
  1813. if (fc > 1 && isFw) fc = 1;
  1814. else if (fc > 3 && isUS) fc = isBiz ? 4 : 3;
  1815. else if (fc > 4 && isState) fc = (isBiz ? 5 : 4);
  1816. if (layer.getFeatureRoadType) {
  1817. return layer.getFeatureRoadType(feature);
  1818. }
  1819. return STATE_SETTINGS.global.getRoadTypeFromFC(fc, layer);
  1820. }
  1821. },
  1822. SD: {
  1823. baseUrl: 'https://arcgis.sd.gov/arcgis/rest/services/DOT/LocalRoads/MapServer/',
  1824. defaultColors: {
  1825. Fw: '#ff00c5', Ew: '#149ece', MH: '#149ece', mH: '#4ce600', PS: '#cfae0e', St: '#eeeeee', PSGr: '#cc6533', StGr: '#e99cb6'
  1826. },
  1827. zoomSettings: { maxOffset: [30, 15, 8, 4, 2, 1, 1, 1, 1, 1], excludeRoadTypes: [['St'], ['St'], ['St'], ['St'], [], [], [], [], [], [], []] },
  1828. fcMapLayers: [{
  1829. layerID: 1,
  1830. fcPropName: 'FUNC_CLASS',
  1831. idPropName: 'OBJECTID',
  1832. maxRecordCount: 1000,
  1833. supportsPagination: false,
  1834. outFields: ['OBJECTID', 'FUNC_CLASS', 'SURFACE_TYPE', 'ROADNAME'],
  1835. roadTypeMap: {
  1836. Fw: [1, 11], Ew: [2, 12], MH: [4, 14], mH: [6, 16], PS: [7, 8, 17], St: [9, 19]
  1837. }
  1838. }],
  1839. information: { Source: 'SDDOT', Permission: 'Visible to R4+ or R3-AM', Description: 'Additional colors denote unpaved PS and LS segements.' },
  1840. getWhereClause(context) {
  1841. if (context.mapContext.zoom < 16) {
  1842. return `${context.layer.fcPropName} NOT IN (9,19)`;
  1843. }
  1844. return null;
  1845. },
  1846. getFeatureRoadType(feature, layer) {
  1847. const attr = feature.attributes;
  1848. let fc = parseInt(attr[layer.fcPropName], 10) % 10;
  1849. const isFw = attr.ACCESS_CONTROL === 1;
  1850. const isUS = /^US HWY /i.test(attr.ROADNAME);
  1851. const isState = /^SD HWY /i.test(attr.ROADNAME);
  1852. const isBiz = /^(US|SD) HWY .* (E|W)?(B|L)$/i.test(attr.ROADNAME);
  1853. const isPaved = parseInt(attr.SURFACE_TYPE, 10) > 5;
  1854. if (isFw) fc = 1;
  1855. else if (fc > 4 && isUS) fc = (isBiz ? 6 : 4);
  1856. else if (fc > 6 && isState) fc = (isBiz ? 7 : 6);
  1857. if (fc > 6 && !isPaved) {
  1858. return fc < 9 ? 'PSGr' : 'StGr';
  1859. }
  1860. return STATE_SETTINGS.global.getRoadTypeFromFC(fc, layer.fcPropName);
  1861. }
  1862. },
  1863. TN: {
  1864. baseUrl: 'https://',
  1865. defaultColors: {
  1866. Fw: '#ff00c5', Ew: '#4f33df', MH: '#149ece', mH: '#4ce600', PS: '#cfae0e', PS2: '#cfae0e', St: '#eeeeee'
  1867. },
  1868. zoomSettings: { maxOffset: [30, 15, 8, 4, 2, 1, 1, 1, 1, 1] },
  1869. fcMapLayers: [
  1870. {
  1871. layerPath: 'services2.arcgis.com/nf3p7v7Zy4fTOh6M/ArcGIS/rest/services/Road_Segment/FeatureServer/',
  1872. maxRecordCount: 1000,
  1873. supportsPagination: false,
  1874. layerID: 0,
  1875. fcPropName: 'FUNC_CLASS',
  1876. idPropName: 'OBJECTID',
  1877. outFields: ['OBJECTID', 'FUNC_CLASS', 'NBR_RTE', 'NBR_US_RTE'],
  1878. getWhereClause(context) {
  1879. if (context.mapContext.zoom < 16) {
  1880. return `${context.layer.fcPropName} NOT LIKE '%Local'`;
  1881. }
  1882. return null;
  1883. },
  1884. roadTypeMap: {
  1885. Fw: ['Urban Interstate', 'Rural Interstate'],
  1886. Ew: ['Urban Freeway or Expressway', 'Rural Freeway or Expressway'],
  1887. MH: ['Urban Other Principal Arterial', 'Rural Other Principal Arterial'],
  1888. mH: ['Urban Minor Arterial', 'Rural Minor Arterial'],
  1889. PS: ['Urban Major Collector', 'Rural Major Collector'],
  1890. PS2: ['Urban Minor Collector', 'Rural Minor Collector'],
  1891. St: ['Urban Local', 'Rural Local']
  1892. }
  1893. }
  1894. ],
  1895. information: {
  1896. Source: 'Memphis, Nashville Area MPO',
  1897. Permission: 'Visible to R4+ or R3-AM',
  1898. Description: 'Raw unmodified FC data for the Memphis and Nashville regions only.'
  1899. },
  1900. getWhereClause(context) {
  1901. if (context.layer.getWhereClause) {
  1902. return context.layer.getWhereClause(context);
  1903. }
  1904. return null;
  1905. },
  1906. getFeatureRoadType(feature, layer) {
  1907. if (layer.getFeatureRoadType) {
  1908. return layer.getFeatureRoadType(feature);
  1909. }
  1910. let fc = STATE_SETTINGS.global.getRoadTypeFromFC(feature.attributes.FUNC_CLASS, layer);
  1911. if ((fc === 'PS' || fc === 'mH') && feature.attributes.NBR_US_RTE != null) {
  1912. fc = feature.attributes.NBR_US_RTE.endsWith('BR') ? 'mH' : 'MH';
  1913. } else if (fc === 'PS' && (feature.attributes.NBR_RTE.startsWith('SR') || feature.attributes.NBR_RTE.startsWith('TN'))) {
  1914. fc = 'mH';
  1915. }
  1916. return fc;
  1917. }
  1918. },
  1919. TX: {
  1920. baseUrl: 'https://services.arcgis.com/KTcxiTD9dsQw4r7Z/ArcGIS/rest/services/TxDOT_Functional_Classification/FeatureServer/',
  1921. defaultColors: {
  1922. Fw: '#ff00c5', Ew: '#4f33df', MH: '#149ece', mH: '#4ce600', PS: '#cfae0e', St: '#eeeeee'
  1923. },
  1924. zoomSettings: { maxOffset: [30, 15, 8, 4, 2, 1, 1, 1, 1, 1] },
  1925. fcMapLayers: [
  1926. {
  1927. layerID: 0,
  1928. fcPropName: 'F_SYSTEM',
  1929. idPropName: 'OBJECTID',
  1930. outFields: ['OBJECTID', 'F_SYSTEM', 'RTE_PRFX'],
  1931. maxRecordCount: 1000,
  1932. supportsPagination: false,
  1933. roadTypeMap: {
  1934. Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6], St: [7]
  1935. }
  1936. }
  1937. ],
  1938. isPermitted() { return _r >= 2; },
  1939. information: { Source: 'TxDOT', Permission: 'Visible to R2+' },
  1940. getWhereClause(context) {
  1941. let where = ' F_SYSTEM IS NOT NULL AND RTE_PRFX IS NOT NULL';
  1942. if (context.mapContext.zoom < 16) {
  1943. where += ` AND ${context.layer.fcPropName} <> 7`;
  1944. }
  1945. return where;
  1946. },
  1947. getFeatureRoadType(feature, layer) {
  1948. // On-System:
  1949. // IH=Interstate BF=Business FM
  1950. // US=US Highway FM=Farm to Mkt
  1951. // UA=US Alt. RM=Ranch to Mkt
  1952. // UP=US Spur RR=Ranch Road
  1953. // SH=State Highway PR=Park Road
  1954. // SA=State Alt. RE=Rec Road
  1955. // SL=State Loop RP=Rec Rd Spur
  1956. // SS=State Spur FS=FM Spur
  1957. // BI=Business IH RS=RM Spur
  1958. // BU=Business US RU=RR Spur
  1959. // BS=Business State PA=Principal Arterial
  1960. // Off-System:
  1961. // TL=Off-System Tollroad CR=County Road
  1962. // FC=Func. Classified St. LS=Local Street
  1963. if (layer.getFeatureRoadType) {
  1964. return layer.getFeatureRoadType(feature);
  1965. }
  1966. let fc = feature.attributes[layer.fcPropName];
  1967. const type = feature.attributes.RTE_PRFX.substring(0, 2).toUpperCase();
  1968. if (type === 'IH' && fc > 1) {
  1969. fc = 1;
  1970. } else if ((type === 'US' || type === 'BI' || type === 'UA') && fc > 3) {
  1971. fc = 3;
  1972. } else if ((type === 'UP' || type === 'BU' || type === 'SH' || type === 'SA') && fc > 4) {
  1973. fc = 4;
  1974. } else if ((type === 'SL' || type === 'SS' || type === 'BS') && fc > 6) {
  1975. fc = 6;
  1976. }
  1977. return STATE_SETTINGS.global.getRoadTypeFromFC(fc, layer);
  1978. }
  1979. },
  1980. UT: {
  1981. baseUrl: 'https://roads.udot.utah.gov/server/rest/services/Public/Functional_Class/MapServer/0',
  1982. defaultColors: {
  1983. Fw: '#ff00c5', Ew: '#4f33df', MH: '#149ece', mH: '#4ce600', PS: '#cfae0e', St: '#eeeeee'
  1984. },
  1985. zoomSettings: { maxOffset: [30, 15, 8, 4, 2, 1, 1, 1, 1, 1], excludeRoadTypes: [['St'], ['St'], ['St'], ['St'], [], [], [], [], [], [], []] },
  1986. fcMapLayers: [
  1987. {
  1988. layerID: 0,
  1989. fcPropName: 'FUNCTIONAL_CLASS',
  1990. idPropName: 'OBJECTID',
  1991. outFields: ['OBJECTID', 'FUNCTIONAL_CLASS', 'route_id'],
  1992. roadTypeMap: {
  1993. Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6], St: [7]
  1994. },
  1995. maxRecordCount: 1000,
  1996. supportsPagination: false
  1997. }
  1998. ],
  1999. information: { Source: 'UDOT', Permission: 'Visible to R4+ or R3-AM' },
  2000. getWhereClause(context) {
  2001. return `${context.layer.fcPropName} NOT LIKE 'Proposed%'`;
  2002. },
  2003. getFeatureRoadType(feature, layer) {
  2004. const attr = feature.attributes;
  2005. let fc = attr[layer.fcPropName];
  2006. const routeID = attr.route_id;
  2007. const roadNum = parseInt(routeID.substring(0, 4), 10);
  2008. switch (fc) {
  2009. case 'Interstate': fc = 1; break;
  2010. case 'Other Freeways and Expressways': fc = 2; break;
  2011. case 'Other Principal Arterial': fc = 3; break;
  2012. case 'Minor Arterial': fc = 4; break;
  2013. case 'Major Collector': fc = 5; break;
  2014. case 'Minor Collector': fc = 6; break;
  2015. default: fc = 7;
  2016. }
  2017. const re = /^(6|40|50|89|91|163|189|191|491)$/;
  2018. if (re.test(roadNum) && fc > 3) {
  2019. // US highway
  2020. fc = 3;
  2021. } else if (roadNum <= 491 && fc > 4) {
  2022. // State highway
  2023. fc = 4;
  2024. }
  2025. return STATE_SETTINGS.global.getRoadTypeFromFC(fc, layer);
  2026. }
  2027. },
  2028. VT: {
  2029. baseUrl: 'https://maps.vtrans.vermont.gov/arcgis/rest/services/Master/General/FeatureServer/',
  2030. defaultColors: {
  2031. Fw: '#ff00c5', Ew: '#4f33df', MH: '#149ece', mH: '#4ce600', PS: '#cfae0e', St: '#eeeeee'
  2032. },
  2033. zoomSettings: { maxOffset: [30, 15, 8, 4, 2, 1, 1, 1, 1, 1], excludeRoadTypes: [['St'], ['St'], ['St'], ['St'], [], [], [], [], [], [], []] },
  2034. fcMapLayers: [
  2035. {
  2036. layerID: 39,
  2037. fcPropName: 'FUNCL',
  2038. idPropName: 'OBJECTID',
  2039. outFields: ['OBJECTID', 'FUNCL', 'HWYSIGN'],
  2040. roadTypeMap: {
  2041. Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6], St: [7]
  2042. },
  2043. maxRecordCount: 1000,
  2044. supportsPagination: false
  2045. }
  2046. ],
  2047. information: { Source: 'VTrans', Permission: 'Visible to R2+' },
  2048. isPermitted() { return _r >= 2; },
  2049. getWhereClause(context) {
  2050. if (context.mapContext.zoom < 16) {
  2051. return `${context.layer.fcPropName}<>7 AND ${context.layer.fcPropName}<>0`;
  2052. }
  2053. return null;
  2054. },
  2055. getFeatureRoadType(feature, layer) {
  2056. const roadID = feature.attributes.HWYSIGN;
  2057. let fc = feature.attributes[layer.fcPropName];
  2058. if (!(fc > 0)) { fc = 7; }
  2059. const isUS = /^U/.test(roadID);
  2060. const isState = /^V/.test(roadID);
  2061. const isUSBiz = /^B/.test(roadID);
  2062. if (fc > 3 && isUS) fc = 3;
  2063. else if (fc > 4 && (isUSBiz || isState)) fc = 4;
  2064. return STATE_SETTINGS.global.getRoadTypeFromFC(fc, layer);
  2065. }
  2066. },
  2067. VA: {
  2068. baseUrl: 'https://services.arcgis.com/p5v98VHDX9Atv3l7/arcgis/rest/services/FC_2014_FHWA_Submittal1/FeatureServer/',
  2069. defaultColors: {
  2070. Fw: '#ff00c5', Ew: '#ff00c5', MH: '#149ece', mH: '#4ce600', PS: '#cfae0e', St: '#eeeeee'
  2071. },
  2072. zoomSettings: { maxOffset: [30, 15, 8, 4, 2, 1, 1, 1, 1, 1], excludeRoadTypes: [['St'], ['St'], ['St'], ['St'], [], [], [], [], [], [], []] },
  2073. fcMapLayers: [
  2074. {
  2075. layerID: 0,
  2076. fcPropName: 'STATE_FUNCT_CLASS_ID',
  2077. idPropName: 'OBJECTID',
  2078. outFields: ['OBJECTID', 'STATE_FUNCT_CLASS_ID', 'RTE_NM'],
  2079. maxRecordCount: 2000,
  2080. supportsPagination: true,
  2081. roadTypeMap: {
  2082. Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6], St: [7]
  2083. }
  2084. }, {
  2085. layerID: 1,
  2086. fcPropName: 'STATE_FUNCT_CLASS_ID',
  2087. idPropName: 'OBJECTID',
  2088. outFields: ['OBJECTID', 'STATE_FUNCT_CLASS_ID', 'RTE_NM', 'ROUTE_NO'],
  2089. maxRecordCount: 2000,
  2090. supportsPagination: true,
  2091. roadTypeMap: {
  2092. Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6], St: [7]
  2093. }
  2094. }, {
  2095. layerID: 3,
  2096. fcPropName: 'TMPD_FC',
  2097. idPropName: 'OBJECTID',
  2098. outFields: ['OBJECTID', 'TMPD_FC', 'RTE_NM'],
  2099. maxRecordCount: 2000,
  2100. supportsPagination: true,
  2101. roadTypeMap: {
  2102. Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6], St: [7]
  2103. }
  2104. }
  2105. ],
  2106. information: { Source: 'VDOT', Permission: 'Visible to R4+ or R3-AM' },
  2107. srExceptions: [217, 302, 303, 305, 308, 310, 313, 314, 315, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328,
  2108. 329, 330, 331, 332, 333, 334, 335, 336, 339, 341, 342, 343, 344, 345, 346, 347, 348, 350, 353, 355, 357, 358, 361,
  2109. 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 382, 383, 384, 385, 386,
  2110. 387, 388, 389, 390, 391, 392, 393, 394, 396, 397, 398, 399, 785, 895],
  2111. getWhereClause(context) {
  2112. if (context.mapContext.zoom < 16) {
  2113. return `${context.layer.fcPropName}<>7`;
  2114. }
  2115. // NOTE: As of 9/14/2016 there does not appear to be any US/SR/VA labeled routes with FC = 7.
  2116. return null;
  2117. },
  2118. getFeatureRoadType(feature, layer) {
  2119. if (layer.getFeatureRoadType) {
  2120. return layer.getFeatureRoadType(feature);
  2121. }
  2122. let fc = parseInt(feature.attributes[layer.fcPropName], 10);
  2123. const rtName = feature.attributes.RTE_NM;
  2124. const match = /^R-VA\s*(US|VA|SR)(\d{5})..(BUS)?/.exec(rtName);
  2125. const isBusiness = (match && (match !== null) && (match[3] === 'BUS'));
  2126. const isState = (match && (match !== null) && (match[1] === 'VA' || match[1] === 'SR'));
  2127. let rtNumText;
  2128. if (layer.layerID === 1) {
  2129. rtNumText = feature.attributes.ROUTE_NO;
  2130. } else if (match) {
  2131. // eslint-disable-next-line prefer-destructuring
  2132. rtNumText = match[2];
  2133. } else {
  2134. rtNumText = '99999';
  2135. }
  2136. const rtNum = parseInt(rtNumText, 10);
  2137. const rtPrefix = match && match[1];
  2138. if (fc > 3 && rtPrefix === 'US') {
  2139. fc = isBusiness ? 4 : 3;
  2140. } else if (isState && fc > 4 && this.srExceptions.indexOf(rtNum) === -1 && rtNum < 600) {
  2141. fc = isBusiness ? 5 : 4;
  2142. }
  2143. return STATE_SETTINGS.global.getRoadTypeFromFC(fc, layer);
  2144. }
  2145. },
  2146. WA: {
  2147. baseUrl: 'https://data.wsdot.wa.gov/arcgis/rest/services/FunctionalClass/WSDOTFunctionalClassMap/MapServer/',
  2148. defaultColors: {
  2149. Fw: '#ff00c5', Ew: '#4f33df', MH: '#149ece', mH: '#4ce600', PS: '#cfae0e', St: '#eeeeee'
  2150. },
  2151. zoomSettings: { maxOffset: [30, 15, 8, 4, 2, 1, 1, 1, 1, 1], excludeRoadTypes: [['St'], ['St'], ['St'], ['St'], [], [], [], [], [], [], []] },
  2152. fcMapLayers: [
  2153. {
  2154. layerID: 2,
  2155. fcPropName: 'FederalFunctionalClassCode',
  2156. idPropName: 'OBJECTID',
  2157. outFields: ['OBJECTID', 'FederalFunctionalClassCode'],
  2158. roadTypeMap: {
  2159. Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6], St: [7]
  2160. },
  2161. maxRecordCount: 1000,
  2162. supportsPagination: false
  2163. }, {
  2164. layerID: 1,
  2165. fcPropName: 'FederalFunctionalClassCode',
  2166. idPropName: 'OBJECTID',
  2167. outFields: ['OBJECTID', 'FederalFunctionalClassCode'],
  2168. roadTypeMap: {
  2169. Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6], St: [7]
  2170. },
  2171. maxRecordCount: 1000,
  2172. supportsPagination: false
  2173. }, {
  2174. layerID: 4,
  2175. fcPropName: 'FederalFunctionalClassCode',
  2176. idPropName: 'OBJECTID',
  2177. outFields: ['OBJECTID', 'FederalFunctionalClassCode'],
  2178. roadTypeMap: {
  2179. Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6], St: [7]
  2180. },
  2181. maxRecordCount: 1000,
  2182. supportsPagination: false
  2183. }
  2184. ],
  2185. information: { Source: 'WSDOT', Permission: 'Visible to R4+ or R3-AM', Description: 'Raw unmodified FC data.' },
  2186. getWhereClause(context) {
  2187. if (context.mapContext.zoom < 16) {
  2188. return `${context.layer.fcPropName} <> 7`;
  2189. }
  2190. return null;
  2191. },
  2192. getFeatureRoadType(feature, layer) {
  2193. if (layer.getFeatureRoadType) {
  2194. return layer.getFeatureRoadType(feature);
  2195. }
  2196. return STATE_SETTINGS.global.getFeatureRoadType(feature, layer);
  2197. }
  2198. },
  2199. WV: {
  2200. baseUrl: 'https://gis.transportation.wv.gov/arcgis/rest/services/Routes/MapServer/',
  2201. defaultColors: {
  2202. Fw: '#ff00c5', Ew: '#ff00c5', MH: '#149ece', mH: '#4ce600', PS: '#cfae0e', St: '#eeeeee'
  2203. },
  2204. zoomSettings: { maxOffset: [30, 15, 8, 4, 2, 1, 1, 1, 1, 1], excludeRoadTypes: [['St'], ['St'], ['St'], ['St'], [], [], [], [], [], [], []] },
  2205. fcMapLayers: [
  2206. {
  2207. layerID: 2,
  2208. fcPropName: 'NAT_FUNCTIONAL_CLASS',
  2209. idPropName: 'OBJECTID',
  2210. outFields: ['OBJECTID', 'NAT_FUNCTIONAL_CLASS', 'ROUTE_ID'],
  2211. maxRecordCount: 1000,
  2212. supportsPagination: true,
  2213. roadTypeMap: {
  2214. Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6], St: [7]
  2215. }
  2216. }
  2217. ],
  2218. information: { Source: 'WV DOT' },
  2219. isPermitted() { return true; },
  2220. getWhereClause(context) {
  2221. if (context.mapContext.zoom < 16) {
  2222. return `${context.layer.fcPropName} NOT IN (9,19)`;
  2223. }
  2224. return null;
  2225. },
  2226. getFeatureRoadType(feature, layer) {
  2227. if (layer.getFeatureRoadType) {
  2228. return layer.getFeatureRoadType(feature);
  2229. }
  2230. const fcCode = feature.attributes[layer.fcPropName];
  2231. let fc = fcCode;
  2232. if (fcCode === 11) fc = 1;
  2233. else if (fcCode === 4 || fcCode === 12) fc = 2;
  2234. else if (fcCode === 2 || fcCode === 14) fc = 3;
  2235. else if (fcCode === 6 || fcCode === 16) fc = 4;
  2236. else if (fcCode === 7 || fcCode === 17 || fcCode === 8 || fcCode === 18) fc = 5;
  2237. else fc = 7;
  2238. const id = feature.attributes.ROUTE_ID;
  2239. const prefix = id.substr(2, 1);
  2240. const isInterstate = prefix === '1';
  2241. const isUS = prefix === '2';
  2242. const isState = prefix === '3';
  2243. if (fc > 1 && isInterstate) fc = 1;
  2244. else if (fc > 3 && isUS) fc = 3;
  2245. else if (fc > 4 && isState) fc = 4;
  2246. return STATE_SETTINGS.global.getRoadTypeFromFC(fc, layer);
  2247. }
  2248. },
  2249. WY: {
  2250. baseUrl: 'https://gisservices.wyoroad.info/arcgis/rest/services/ITSM/LAYERS/MapServer/',
  2251. defaultColors: {
  2252. Fw: '#ff00c5', Ew: '#4f33df', MH: '#149ece', mH: '#4ce600', PS: '#cfae0e', St: '#eeeeee'
  2253. },
  2254. zoomSettings: { maxOffset: [30, 15, 8, 4, 2, 1, 1, 1, 1, 1], excludeRoadTypes: [['St'], ['St'], ['St'], ['St'], [], [], [], [], [], [], []] },
  2255. fcMapLayers: [
  2256. {
  2257. layerID: 20,
  2258. fcPropName: 'CLASSIFICATION',
  2259. idPropName: 'OBJECTID',
  2260. outFields: ['OBJECTID', 'CLASSIFICATION', 'COMMON_ROUTE_NAME'],
  2261. roadTypeMap: {
  2262. Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6], St: [7]
  2263. },
  2264. maxRecordCount: 1000,
  2265. supportsPagination: false
  2266. }, {
  2267. layerID: 21,
  2268. fcPropName: 'CLASSIFICATION',
  2269. idPropName: 'OBJECTID',
  2270. outFields: ['OBJECTID', 'CLASSIFICATION', 'COMMON_ROUTE_NAME'],
  2271. roadTypeMap: {
  2272. Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6], St: [7]
  2273. },
  2274. maxRecordCount: 1000,
  2275. supportsPagination: false
  2276. }, {
  2277. layerID: 22,
  2278. fcPropName: 'CLASSIFICATION',
  2279. idPropName: 'OBJECTID',
  2280. outFields: ['OBJECTID', 'CLASSIFICATION', 'COMMON_ROUTE_NAME'],
  2281. roadTypeMap: {
  2282. Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6], St: [7]
  2283. },
  2284. maxRecordCount: 1000,
  2285. supportsPagination: false
  2286. }, {
  2287. layerID: 23,
  2288. fcPropName: 'CLASSIFICATION',
  2289. idPropName: 'OBJECTID',
  2290. outFields: ['OBJECTID', 'CLASSIFICATION', 'COMMON_ROUTE_NAME'],
  2291. roadTypeMap: {
  2292. Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6], St: [7]
  2293. },
  2294. maxRecordCount: 1000,
  2295. supportsPagination: false
  2296. }, {
  2297. layerID: 24,
  2298. fcPropName: 'CLASSIFICATION',
  2299. idPropName: 'OBJECTID',
  2300. outFields: ['OBJECTID', 'CLASSIFICATION', 'COMMON_ROUTE_NAME'],
  2301. roadTypeMap: {
  2302. Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6], St: [7]
  2303. },
  2304. maxRecordCount: 1000,
  2305. supportsPagination: false
  2306. }, {
  2307. layerID: 25,
  2308. fcPropName: 'CLASSIFICATION',
  2309. idPropName: 'OBJECTID',
  2310. outFields: ['OBJECTID', 'CLASSIFICATION', 'COMMON_ROUTE_NAME'],
  2311. roadTypeMap: {
  2312. Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6], St: [7]
  2313. },
  2314. maxRecordCount: 1000,
  2315. supportsPagination: false
  2316. }, {
  2317. layerID: 26,
  2318. fcPropName: 'CLASSIFICATION',
  2319. idPropName: 'OBJECTID',
  2320. outFields: ['OBJECTID', 'CLASSIFICATION', 'COMMON_ROUTE_NAME'],
  2321. roadTypeMap: {
  2322. Fw: [1], Ew: [2], MH: [3], mH: [4], PS: [5, 6], St: [7]
  2323. },
  2324. maxRecordCount: 1000,
  2325. supportsPagination: false
  2326. }
  2327. ],
  2328. information: { Source: 'WYDOT', Permission: 'Visible to R4+ or R3-AM', Description: 'Minimum suggested FC.' },
  2329. getWhereClause(context) {
  2330. if (context.mapContext.zoom < 16) {
  2331. return `${context.layer.fcPropName} <> 'Local'`;
  2332. }
  2333. return null;
  2334. },
  2335. getFeatureRoadType(feature, layer) {
  2336. const attr = feature.attributes;
  2337. let fc = attr[layer.fcPropName];
  2338. const route = attr.COMMON_ROUTE_NAME;
  2339. switch (fc) {
  2340. case 'Interstate': fc = 1; break;
  2341. case 'Expressway': fc = 2; break;
  2342. case 'Principal Arterial': fc = 3; break;
  2343. case 'Minor Arterial': fc = 4; break;
  2344. case 'Major Collector': fc = 5; break;
  2345. case 'Minor Collector': fc = 6; break;
  2346. default: fc = 7;
  2347. }
  2348. const isIntBiz = /I (25|80) BUS/.test(route);
  2349. const isUS = /US \d+/.test(route);
  2350. const isUSBiz = /US \d+ BUS/.test(route);
  2351. const isState = /WY \d+/.test(route);
  2352. const isStateBiz = /WY \d+ BUS/.test(route);
  2353. if (fc > 3 && (isUS || isIntBiz)) fc = isUSBiz ? 4 : 3;
  2354. else if (fc > 4 && isState) fc = isStateBiz ? 5 : 4;
  2355. return STATE_SETTINGS.global.getRoadTypeFromFC(fc, layer);
  2356. }
  2357. }
  2358. };
  2359.  
  2360. function log(message) {
  2361. console.log('FC Layer: ', message);
  2362. }
  2363. function debugLog(message) {
  2364. console.debug('FC Layer: ', message);
  2365. }
  2366. function errorLog(message) {
  2367. console.error('FC Layer: ', message);
  2368. }
  2369.  
  2370. function loadSettingsFromStorage() {
  2371. const loadedSettings = $.parseJSON(localStorage.getItem(SETTINGS_STORE_NAME));
  2372. const defaultSettings = {
  2373. lastVersion: null,
  2374. layerVisible: true,
  2375. activeStateAbbr: 'ALL',
  2376. hideStreet: false
  2377. };
  2378. _settings = loadedSettings || defaultSettings;
  2379. Object.keys(defaultSettings).filter(prop => !_settings.hasOwnProperty(prop)).forEach(prop => {
  2380. _settings[prop] = defaultSettings[prop];
  2381. });
  2382. }
  2383.  
  2384. function saveSettingsToStorage() {
  2385. if (localStorage) {
  2386. _settings.lastVersion = SCRIPT_VERSION;
  2387. _settings.layerVisible = _mapLayer.visibility;
  2388. localStorage.setItem(SETTINGS_STORE_NAME, JSON.stringify(_settings));
  2389. // debugLog('Settings saved');
  2390. }
  2391. }
  2392.  
  2393. function getLineWidth() {
  2394. return 12 * (1.15 ** (W.map.getZoom() - 13));
  2395. }
  2396.  
  2397. function sortArray(array) {
  2398. array.sort((a, b) => { if (a < b) return -1; if (a > b) return 1; return 0; });
  2399. }
  2400.  
  2401. function getVisibleStateAbbrs() {
  2402. const visibleStates = [];
  2403. W.model.states.getObjectArray().forEach(state => {
  2404. const stateAbbr = STATES_HASH[state.attributes.name];
  2405. const { activeStateAbbr } = _settings;
  2406. if (STATE_SETTINGS[stateAbbr] && STATE_SETTINGS.global.isPermitted(stateAbbr) && (!activeStateAbbr || activeStateAbbr === 'ALL' || activeStateAbbr === stateAbbr)) {
  2407. visibleStates.push(stateAbbr);
  2408. }
  2409. });
  2410. return visibleStates;
  2411. }
  2412.  
  2413. function getAsync(url, context) {
  2414. return new Promise((resolve, reject) => {
  2415. GM_xmlhttpRequest({
  2416. context,
  2417. method: 'GET',
  2418. url,
  2419. onload(res) {
  2420. if (res.status.toString() === '200') {
  2421. resolve({ responseText: res.responseText, context });
  2422. } else {
  2423. reject(new Error({ responseText: res.responseText, context }));
  2424. }
  2425. },
  2426. onerror() {
  2427. reject(Error('Network Error'));
  2428. }
  2429. });
  2430. });
  2431. }
  2432.  
  2433. function getUrl(context, queryType, queryParams) {
  2434. const { extent } = context.mapContext;
  2435. const { zoom } = context.mapContext;
  2436. const { layer } = context;
  2437. const { state } = context;
  2438.  
  2439. const whereParts = [];
  2440. const geometry = {
  2441. xmin: extent.left, ymin: extent.bottom, xmax: extent.right, ymax: extent.top, spatialReference: { wkid: 102100, latestWkid: 3857 }
  2442. };
  2443. const geometryStr = JSON.stringify(geometry);
  2444. const stateWhereClause = state.getWhereClause(context);
  2445. const layerPath = layer.layerPath || '';
  2446. let url = `${state.baseUrl + layerPath + layer.layerID}/query?geometry=${encodeURIComponent(geometryStr)}`;
  2447.  
  2448. if (queryType === 'countOnly') {
  2449. url += '&returnCountOnly=true';
  2450. } else if (queryType === 'idsOnly') {
  2451. url += '&returnIdsOnly=true';
  2452. } else if (queryType === 'paged') {
  2453. // TODO
  2454. } else {
  2455. url += `&returnGeometry=true&maxAllowableOffset=${state.zoomSettings.maxOffset[zoom - 12]}`;
  2456. url += `&outFields=${encodeURIComponent(layer.outFields.join(','))}`;
  2457. if (queryType === 'idRange') {
  2458. whereParts.push(`(${queryParams.idFieldName}>=${queryParams.range[0]} AND ${queryParams.idFieldName}<=${queryParams.range[1]})`);
  2459. }
  2460. }
  2461. if (stateWhereClause) whereParts.push(stateWhereClause);
  2462. if (whereParts.length > 0) url += `&where=${encodeURIComponent(whereParts.join(' AND '))}`;
  2463. url += '&spatialRel=esriSpatialRelIntersects&geometryType=esriGeometryEnvelope&inSR=102100&outSR=3857&f=json';
  2464. console.log(url);
  2465. return url;
  2466. }
  2467.  
  2468. function convertFcToRoadTypeVectors(feature, context) {
  2469. const { state, stateAbbr, layer } = context;
  2470. const roadType = state.getFeatureRoadType(feature, layer);
  2471. // debugLog(feature);
  2472. const zIndex = STATE_SETTINGS.global.roadTypes.indexOf(roadType) * 100;
  2473. const attr = {
  2474. state: stateAbbr,
  2475. layerID: layer.layerID,
  2476. roadType,
  2477. dotAttributes: $.extend({}, feature.attributes),
  2478. color: state.defaultColors[roadType],
  2479. strokeWidth: getLineWidth,
  2480. zIndex
  2481. };
  2482. const vectors = feature.geometry.paths.map(path => {
  2483. const pointList = path.map(pt => new OpenLayers.Geometry.Point(pt[0], pt[1]));
  2484. return new OpenLayers.Feature.Vector(new OpenLayers.Geometry.LineString(pointList), attr);
  2485. });
  2486.  
  2487. return vectors;
  2488. }
  2489.  
  2490. function fetchLayerFC(context) {
  2491. const url = getUrl(context, 'idsOnly');
  2492. debugLog(url);
  2493. if (!context.parentContext.cancel) {
  2494. return getAsync(url, context).bind(context).then(res => {
  2495. const ids = $.parseJSON(res.responseText);
  2496. if (!ids.objectIds) ids.objectIds = [];
  2497. sortArray(ids.objectIds);
  2498. // debugLog(ids);
  2499. return ids;
  2500. }).then(res => {
  2501. const idRanges = [];
  2502. if (res.objectIds) {
  2503. const len = res.objectIds ? res.objectIds.length : 0;
  2504. let currentIndex = 0;
  2505. const offset = Math.min(context.layer.maxRecordCount, 1000);
  2506. while (currentIndex < len) {
  2507. let nextIndex = currentIndex + offset;
  2508. if (nextIndex >= len) nextIndex = len - 1;
  2509. idRanges.push({ range: [res.objectIds[currentIndex], res.objectIds[nextIndex]], idFieldName: res.objectIdFieldName });
  2510. currentIndex = nextIndex + 1;
  2511. }
  2512. // debugLog(context.layer.layerID);
  2513. // debugLog(idRanges);
  2514. }
  2515. return idRanges;
  2516. }).map(idRange => {
  2517. if (!context.parentContext.cancel) {
  2518. const newUrl = getUrl(context, 'idRange', idRange);
  2519. debugLog(url);
  2520. return getAsync(newUrl, context).then(res => {
  2521. if (!context.parentContext.cancel) {
  2522. let { features } = $.parseJSON(res.responseText);
  2523. context.parentContext.callCount++;
  2524. // debugLog('Feature Count=' + (features ? features.length : 0));
  2525. features = features || [];
  2526. return features.map(feature => convertFcToRoadTypeVectors(feature, context))
  2527. .filter(vector => !(vector[0].attributes.roadType === 'St' && _settings.hideStreet));
  2528. }
  2529. return null;
  2530. });
  2531. }
  2532. // debugLog('Async call cancelled');
  2533. return null;
  2534. });
  2535. }
  2536. return null;
  2537. }
  2538.  
  2539. function fetchStateFC(context) {
  2540. const state = STATE_SETTINGS[context.stateAbbr];
  2541. const contexts = state.fcMapLayers.map(layer => ({
  2542. parentContext: context.parentContext, layer, state, stateAbbr: context.stateAbbr, mapContext: context.mapContext
  2543. }));
  2544.  
  2545. return Promise.map(contexts, ctx => fetchLayerFC(ctx));
  2546. }
  2547.  
  2548. let _lastPromise = null;
  2549. let _lastContext = null;
  2550. let _fcCallCount = 0;
  2551. function fetchAllFC() {
  2552. if (!_mapLayer.visibility) return;
  2553.  
  2554. if (_lastPromise) { _lastPromise.cancel(); }
  2555. $('#fc-loading-indicator').text('Loading FC...');
  2556.  
  2557. const mapContext = { zoom: W.map.getZoom(), extent: getOLMapExtent() };
  2558. if (mapContext.zoom > MIN_ZOOM_LEVEL) {
  2559. const parentContext = { callCount: 0, startTime: Date.now() };
  2560.  
  2561. if (_lastContext) _lastContext.cancel = true;
  2562. _lastContext = parentContext;
  2563. const contexts = getVisibleStateAbbrs().map(stateAbbr => ({ parentContext, stateAbbr, mapContext }));
  2564. const map = Promise.map(contexts, ctx => fetchStateFC(ctx)).then(statesVectorArrays => {
  2565. if (!parentContext.cancel) {
  2566. _mapLayer.removeAllFeatures();
  2567. statesVectorArrays.forEach(vectorsArray => {
  2568. vectorsArray.forEach(vectors => {
  2569. vectors.forEach(vector => {
  2570. vector.forEach(vectorFeature => {
  2571. _mapLayer.addFeatures(vectorFeature);
  2572. });
  2573. });
  2574. });
  2575. });
  2576. }
  2577. return statesVectorArrays;
  2578. }).catch(e => {
  2579. $('#fc-loading-indicator').text('FC Error! (check console for details)');
  2580. errorLog(e);
  2581. }).finally(() => {
  2582. _fcCallCount -= 1;
  2583. if (_fcCallCount === 0) {
  2584. $('#fc-loading-indicator').text('');
  2585. }
  2586. });
  2587.  
  2588. _fcCallCount += 1;
  2589. _lastPromise = map;
  2590. } else {
  2591. // if zoomed out too far, clear the layer
  2592. _mapLayer.removeAllFeatures();
  2593. }
  2594. }
  2595.  
  2596. function getOLMapExtent() {
  2597. let extent = W.map.getExtent();
  2598. if (Array.isArray(extent)) {
  2599. extent = new OpenLayers.Bounds(extent);
  2600. extent.transform('EPSG:4326', 'EPSG:3857');
  2601. }
  2602. return extent;
  2603. }
  2604.  
  2605. function onLayerCheckboxChanged(checked) {
  2606. setEnabled(checked);
  2607. }
  2608.  
  2609. function onLayerVisibilityChanged() {
  2610. setEnabled(_mapLayer.visibility);
  2611. // _settings.layerVisible = _mapLayer.visibility;
  2612. // saveSettingsToStorage();
  2613. // if (_mapLayer.visibility) {
  2614. // fetchAllFC();
  2615. // }
  2616. }
  2617.  
  2618. function checkLayerZIndex() {
  2619. if (_mapLayer.getZIndex() !== MAP_LAYER_Z_INDEX) {
  2620. // ("ADJUSTED FC LAYER Z-INDEX " + _mapLayerZIndex + ', ' + _mapLayer.getZIndex());
  2621. _mapLayer.setZIndex(MAP_LAYER_Z_INDEX);
  2622. }
  2623. }
  2624.  
  2625. function initLayer() {
  2626. const defaultStyle = new OpenLayers.Style({
  2627. strokeColor: '${color}', // '#00aaff',
  2628. strokeDashstyle: 'solid',
  2629. strokeOpacity: 1.0,
  2630. strokeWidth: '${strokeWidth}',
  2631. graphicZIndex: '${zIndex}'
  2632. });
  2633.  
  2634. const selectStyle = new OpenLayers.Style({
  2635. // strokeOpacity: 1.0,
  2636. strokeColor: '#000000'
  2637. });
  2638.  
  2639. _mapLayer = new OpenLayers.Layer.Vector('FC Layer', {
  2640. uniqueName: '__FCLayer',
  2641. displayInLayerSwitcher: false,
  2642. rendererOptions: { zIndexing: true },
  2643. styleMap: new OpenLayers.StyleMap({
  2644. default: defaultStyle,
  2645. select: selectStyle
  2646. })
  2647. });
  2648.  
  2649. _mapLayer.setOpacity(0.5);
  2650.  
  2651. I18n.translations[I18n.locale].layers.name.__FCLayer = 'FC Layer';
  2652.  
  2653. _mapLayer.displayInLayerSwitcher = true;
  2654. _mapLayer.events.register('visibilitychanged', null, onLayerVisibilityChanged);
  2655. _mapLayer.setVisibility(_settings.layerVisible);
  2656.  
  2657. W.map.addLayer(_mapLayer);
  2658. MAP_LAYER_Z_INDEX = W.map.roadLayer.getZIndex() - 3;
  2659. _mapLayer.setZIndex(MAP_LAYER_Z_INDEX);
  2660. WazeWrap.Interface.AddLayerCheckbox('Display', 'FC Layer', _settings.layerVisible, onLayerCheckboxChanged);
  2661. // Hack to fix layer zIndex. Some other code is changing it sometimes but I have not been able to figure out why.
  2662. // It may be that the FC layer is added to the map before some Waze code loads the base layers and forces other layers higher. (?)
  2663.  
  2664. setInterval(checkLayerZIndex, 200);
  2665.  
  2666. W.map.events.register('moveend', W.map, () => {
  2667. fetchAllFC();
  2668. return true;
  2669. }, true);
  2670. }
  2671.  
  2672. function onHideStreetsClicked() {
  2673. _settings.hideStreet = $(this).is(':checked');
  2674. saveSettingsToStorage();
  2675. _mapLayer.removeAllFeatures();
  2676. fetchAllFC();
  2677. }
  2678.  
  2679. function onStateSelectionChanged() {
  2680. _settings.activeStateAbbr = this.value;
  2681. saveSettingsToStorage();
  2682. loadStateFCInfo();
  2683. fetchAllFC();
  2684. }
  2685.  
  2686. function setEnabled(value) {
  2687. _settings.layerVisible = value;
  2688. saveSettingsToStorage();
  2689. _mapLayer.setVisibility(value);
  2690. const color = value ? '#00bd00' : '#ccc';
  2691. $('span#fc-layer-power-btn').css({ color });
  2692. if (value) fetchAllFC();
  2693. $('#layer-switcher-item_fc_layer').prop('checked', value);
  2694. }
  2695.  
  2696. function initUserPanel() {
  2697. const $tab = $('<li>').append($('<a>', { 'data-toggle': 'tab', href: '#sidepanel-fc-layer' }).text('FC'));
  2698. const $panel = $('<div>', { class: 'tab-pane', id: 'sidepanel-fc-layer' });
  2699. const $stateSelect = $('<select>', { id: 'fcl-state-select', class: 'form-control disabled', style: 'disabled' }).append($('<option>', { value: 'ALL' }).text('All'));
  2700. // $stateSelect.change(function(evt) {
  2701. // _settings.activeStateAbbr = evt.target.value;
  2702. // saveSettingsToStorage();
  2703. // _mapLayer.removeAllFeatures();
  2704. // fetchAllFC();
  2705. // });
  2706. Object.keys(STATE_SETTINGS).forEach(stateAbbr => {
  2707. if (stateAbbr !== 'global') {
  2708. $stateSelect.append($('<option>', { value: stateAbbr }).text(reverseStatesHash(stateAbbr)));
  2709. }
  2710. });
  2711.  
  2712. const $hideStreet = $('<div>', { id: 'fcl-hide-street-container', class: 'controls-container' })
  2713. .append($('<input>', { type: 'checkbox', name: 'fcl-hide-street', id: 'fcl-hide-street' }).prop('checked', _settings.hideStreet).click(onHideStreetsClicked))
  2714. .append($('<label>', { for: 'fcl-hide-street' }).text('Hide local street highlights'));
  2715.  
  2716. $stateSelect.val(_settings.activeStateAbbr ? _settings.activeStateAbbr : 'ALL');
  2717.  
  2718. $panel.append(
  2719. $('<div>', { class: 'form-group' }).append(
  2720. $('<label>', { class: 'control-label' }).text('Select a state')
  2721. ).append(
  2722. $('<div>', { class: 'controls', id: 'fcl-state-select-container' }).append(
  2723. $('<div>').append($stateSelect)
  2724. )
  2725. ),
  2726. $hideStreet,
  2727. $('<div>', { id: 'fcl-table-container' })
  2728. );
  2729.  
  2730. $panel.append($('<div>', { id: 'fcl-state-info' }));
  2731.  
  2732. $panel.append(
  2733. $('<div>', { style: 'margin-top:10px;font-size:10px;color:#999999;' })
  2734. .append($('<div>').text(`version ${SCRIPT_VERSION}`))
  2735. .append(
  2736. $('<div>').append(
  2737. $('<a>', { href: '#' /* , target:'__blank' */ }).text('Discussion Forum (currently n/a)')
  2738. )
  2739. )
  2740. );
  2741.  
  2742. $('#user-tabs > .nav-tabs').append($tab);
  2743.  
  2744. // append the power button
  2745. if (!$('#fc-layer-power-btn').length) {
  2746. const color = _settings.layerVisible ? '#00bd00' : '#ccc';
  2747. $('a[href="#sidepanel-fc-layer"]').prepend(
  2748. $('<span>', {
  2749. class: 'fa fa-power-off',
  2750. id: 'fc-layer-power-btn',
  2751. style: `margin-right: 5px;cursor: pointer;color: ${color};font-size: 13px;`,
  2752. title: 'Toggle FC Layer'
  2753. }).click(evt => {
  2754. evt.stopPropagation();
  2755. setEnabled(!_settings.layerVisible);
  2756. })
  2757. );
  2758. }
  2759.  
  2760. $('#user-info > .flex-parent > .tab-content').append($panel);
  2761. $('#fcl-state-select').change(onStateSelectionChanged);
  2762. loadStateFCInfo();
  2763. }
  2764.  
  2765. function loadStateFCInfo() {
  2766. $('#fcl-state-info').empty();
  2767. if (STATE_SETTINGS[_settings.activeStateAbbr]) {
  2768. const stateInfo = STATE_SETTINGS[_settings.activeStateAbbr].information;
  2769. const $panelStateInfo = $('<dl>');
  2770. Object.keys(stateInfo).forEach(propertyName => {
  2771. $panelStateInfo.append($('<dt>', { style: 'margin-top:1em;color:#777777' }).text(propertyName))
  2772. .append($('<dd>').text(stateInfo[propertyName]));
  2773. });
  2774. $('#fcl-state-info').append($panelStateInfo);
  2775. }
  2776. }
  2777.  
  2778. function addLoadingIndicator() {
  2779. $('.loading-indicator').after($('<div class="loading-indicator" style="margin-right:10px" id="fc-loading-indicator">'));
  2780. }
  2781.  
  2782. function initGui() {
  2783. addLoadingIndicator();
  2784. initLayer();
  2785. initUserPanel();
  2786. }
  2787.  
  2788. function loadScriptUpdateMonitor() {
  2789. try {
  2790. const updateMonitor = new WazeWrap.Alerts.ScriptUpdateMonitor(SCRIPT_NAME, SCRIPT_VERSION, DOWNLOAD_URL, GM_xmlhttpRequest);
  2791. updateMonitor.start();
  2792. } catch (ex) {
  2793. // Report, but don't stop if ScriptUpdateMonitor fails.
  2794. console.error(`${SCRIPT_NAME}:`, ex);
  2795. }
  2796. }
  2797.  
  2798. function init() {
  2799. loadScriptUpdateMonitor();
  2800.  
  2801. if (DEBUG && Promise.config) {
  2802. Promise.config({
  2803. warnings: true,
  2804. longStackTraces: true,
  2805. cancellation: true,
  2806. monitoring: false
  2807. });
  2808. } else {
  2809. Promise.config({
  2810. warnings: false,
  2811. longStackTraces: false,
  2812. cancellation: true,
  2813. monitoring: false
  2814. });
  2815. }
  2816.  
  2817. const u = W.loginManager.user;
  2818. _uid = u.getID();
  2819. _r = u.getRank() + 1;
  2820. _isAM = u.attributes.isAreaManager;
  2821. _uName = u.getUsername();
  2822.  
  2823. loadSettingsFromStorage();
  2824. initGui();
  2825. fetchAllFC();
  2826. log('Initialized.');
  2827. }
  2828.  
  2829. function bootstrap() {
  2830. if (WazeWrap.Ready) {
  2831. log('Initializing...');
  2832. init();
  2833. } else {
  2834. log('Bootstrap failed. Trying again...');
  2835. unsafeWindow.setTimeout(bootstrap, 1000);
  2836. }
  2837. }
  2838.  
  2839. log('Bootstrap...');
  2840. bootstrap();
  2841. })();

QingJ © 2025

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