WME FC Layer

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

目前為 2023-05-31 提交的版本,檢視 最新版本

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

QingJ © 2025

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