@cdc/map 4.25.7 → 4.25.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/.claude/settings.local.json +30 -0
  2. package/CLAUDE.local.md +0 -0
  3. package/dist/cdcmap.js +54785 -53159
  4. package/examples/private/c.json +290 -0
  5. package/examples/private/canvas-city-hover.json +787 -0
  6. package/examples/private/d.json +345 -0
  7. package/examples/private/filter-map.json +909 -0
  8. package/examples/private/g.json +1 -0
  9. package/examples/private/h.json +105911 -0
  10. package/examples/private/measles-data.json +378 -0
  11. package/examples/private/measles.json +211 -0
  12. package/examples/private/north-dakota.json +1132 -0
  13. package/examples/private/rsv-data.json +532 -0
  14. package/examples/private/state-with-pattern.json +883 -0
  15. package/examples/private/test.json +222 -640
  16. package/index.html +1 -1
  17. package/package.json +26 -5
  18. package/src/CdcMap.tsx +28 -8
  19. package/src/CdcMapComponent.tsx +230 -306
  20. package/src/_stories/CdcMap.Filters.stories.tsx +2 -2
  21. package/src/_stories/CdcMap.Legend.Gradient.stories.tsx +3 -3
  22. package/src/_stories/CdcMap.Legend.stories.tsx +7 -4
  23. package/src/_stories/CdcMap.Patterns.stories.tsx +2 -2
  24. package/src/_stories/CdcMap.Table.stories.tsx +2 -2
  25. package/src/_stories/CdcMap.stories.tsx +18 -11
  26. package/src/_stories/GoogleMap.stories.tsx +2 -2
  27. package/src/_stories/UsaMap.NoData.stories.tsx +2 -2
  28. package/src/_stories/_mock/equal-number.json +1109 -0
  29. package/src/_stories/_mock/multi-state.json +21389 -0
  30. package/src/_stories/_mock/us-bubble-cities.json +306 -0
  31. package/src/components/BubbleList.tsx +16 -12
  32. package/src/components/CityList.tsx +88 -110
  33. package/src/components/DataTable.tsx +44 -12
  34. package/src/components/EditorPanel/components/EditorPanel.tsx +201 -203
  35. package/src/components/EditorPanel/components/HexShapeSettings.tsx +3 -2
  36. package/src/components/EditorPanel/components/Panels/Panel.PatternSettings.tsx +7 -5
  37. package/src/components/Geo.tsx +2 -0
  38. package/src/components/Legend/components/Legend.tsx +117 -93
  39. package/src/components/Legend/components/LegendGroup/Legend.Group.tsx +10 -7
  40. package/src/components/MapContainer.tsx +52 -0
  41. package/src/components/MapControls.tsx +44 -0
  42. package/src/components/Modal.tsx +2 -8
  43. package/src/components/NavigationMenu.tsx +13 -1
  44. package/src/components/UsaMap/components/SingleState/SingleState.CountyOutput.tsx +24 -7
  45. package/src/components/UsaMap/components/SingleState/SingleState.StateOutput.tsx +21 -15
  46. package/src/components/UsaMap/components/TerritoriesSection.tsx +2 -2
  47. package/src/components/UsaMap/components/UsaMap.County.tsx +112 -33
  48. package/src/components/UsaMap/components/UsaMap.Region.tsx +23 -5
  49. package/src/components/UsaMap/components/UsaMap.SingleState.tsx +38 -26
  50. package/src/components/UsaMap/components/UsaMap.State.tsx +28 -10
  51. package/src/components/UsaMap/helpers/map.ts +16 -8
  52. package/src/components/WorldMap/WorldMap.tsx +116 -11
  53. package/src/components/ZoomControls.tsx +6 -9
  54. package/src/context/LegendMemoContext.tsx +30 -0
  55. package/src/context.ts +1 -39
  56. package/src/data/initial-state.js +143 -128
  57. package/src/data/supported-geos.js +202 -4
  58. package/src/helpers/addUIDs.ts +8 -8
  59. package/src/helpers/applyColorToLegend.ts +122 -45
  60. package/src/helpers/applyLegendToRow.ts +15 -13
  61. package/src/helpers/componentHelpers.ts +8 -0
  62. package/src/helpers/constants.ts +12 -0
  63. package/src/helpers/dataTableHelpers.ts +6 -0
  64. package/src/helpers/displayGeoName.ts +12 -7
  65. package/src/helpers/formatLegendLocation.ts +1 -3
  66. package/src/helpers/generateRuntimeLegend.ts +192 -340
  67. package/src/helpers/generateRuntimeLegendHash.ts +4 -2
  68. package/src/helpers/getColumnNames.ts +1 -1
  69. package/src/helpers/getPatternForRow.ts +36 -0
  70. package/src/helpers/getStatesPicked.ts +14 -0
  71. package/src/helpers/handleMapAriaLabels.ts +2 -2
  72. package/src/helpers/index.ts +11 -3
  73. package/src/helpers/isLegendItemDisabled.ts +16 -0
  74. package/src/helpers/mapObserverHelpers.ts +40 -0
  75. package/src/helpers/resetLegendToggles.ts +3 -2
  76. package/src/helpers/toggleLegendActive.ts +6 -11
  77. package/src/helpers/urlDataHelpers.ts +70 -0
  78. package/src/hooks/useGeoClickHandler.ts +35 -1
  79. package/src/hooks/useLegendMemo.ts +17 -0
  80. package/src/hooks/useMapLayers.tsx +5 -4
  81. package/src/hooks/useStateZoom.tsx +137 -88
  82. package/src/hooks/useTooltip.ts +1 -2
  83. package/src/index.jsx +6 -3
  84. package/src/scss/main.scss +23 -12
  85. package/src/store/map.actions.ts +2 -2
  86. package/src/store/map.reducer.ts +21 -10
  87. package/src/test/CdcMap.test.jsx +11 -0
  88. package/src/types/MapConfig.ts +25 -17
  89. package/src/types/MapContext.ts +2 -8
  90. package/src/types/runtimeLegend.ts +12 -10
  91. package/vite.config.js +2 -7
  92. package/vitest.config.ts +16 -0
  93. package/src/_stories/_mock/floating-point.json +0 -427
  94. package/src/coreStyles_map.scss +0 -3
  95. package/src/helpers/colorDistributions.ts +0 -12
  96. package/src/helpers/generateColorsArray.ts +0 -14
  97. package/src/helpers/getStatePicked.ts +0 -8
  98. package/src/helpers/tests/generateColorsArray.test.ts +0 -18
  99. package/src/helpers/tests/generateRuntimeLegendHash.test.ts +0 -11
@@ -1,133 +1,148 @@
1
- export default {
2
- annotations: [],
3
- general: {
4
- navigationTarget: '_self',
5
- noStateFoundMessage: 'Map Unavailable',
6
- annotationDropdownText: 'Annotations',
7
- geoBorderColor: 'darkGray',
8
- headerColor: 'theme-blue',
9
- title: '',
10
- showTitle: true,
11
- showSidebar: true,
12
- showDownloadMediaButton: false,
13
- displayAsHex: false,
14
- displayStateLabels: true,
15
- territoriesAlwaysShow: false,
16
- language: 'en',
17
- geoType: 'single-state',
18
- geoLabelOverride: '',
19
- hasRegions: false,
20
- fullBorder: false,
21
- type: 'data',
22
- convertFipsCodes: true,
23
- palette: {
24
- isReversed: false
1
+ import { USE_V2_MIGRATION } from '@cdc/core/helpers/constants'
2
+
3
+ // Dynamic initial state based on migration flag
4
+ const createInitialState = () => {
5
+ const paletteDefaults = USE_V2_MIGRATION
6
+ ? {
7
+ isReversed: true,
8
+ name: 'sequential_bluereverse',
9
+ version: '2.0'
10
+ }
11
+ : {
12
+ isReversed: true,
13
+ name: 'bluegreen',
14
+ version: '1.0'
15
+ }
16
+
17
+ return {
18
+ annotations: [],
19
+ general: {
20
+ navigationTarget: '_self',
21
+ noDataMessage: 'No State Selected',
22
+ annotationDropdownText: 'Annotations',
23
+ geoBorderColor: 'darkGray',
24
+ headerColor: 'theme-blue',
25
+ title: '',
26
+ showTitle: true,
27
+ showSidebar: true,
28
+ showDownloadMediaButton: false,
29
+ displayAsHex: false,
30
+ displayStateLabels: true,
31
+ territoriesAlwaysShow: false,
32
+ language: 'en',
33
+ geoType: 'single-state',
34
+ geoLabelOverride: '',
35
+ hasRegions: false,
36
+ fullBorder: false,
37
+ type: 'data',
38
+ convertFipsCodes: true,
39
+ palette: paletteDefaults,
40
+ allowMapZoom: true,
41
+ hideGeoColumnInTooltip: false,
42
+ hidePrimaryColumnInTooltip: false,
43
+ statesPicked: []
25
44
  },
26
- allowMapZoom: true,
27
- hideGeoColumnInTooltip: false,
28
- hidePrimaryColumnInTooltip: false,
29
- statePicked: {
30
- fipsCode: '01',
31
- stateName: 'Alabama'
32
- }
33
- },
34
- type: 'map',
35
- color: 'pinkpurple',
36
- columns: {
37
- geo: {
38
- name: 'FIPS Codes',
39
- label: 'Location',
40
- tooltip: false,
41
- dataTable: true
45
+ type: 'map',
46
+ columns: {
47
+ geo: {
48
+ name: 'FIPS Codes',
49
+ label: 'Location',
50
+ tooltip: false,
51
+ dataTable: true
52
+ },
53
+ primary: {
54
+ dataTable: true,
55
+ tooltip: true,
56
+ prefix: '',
57
+ suffix: '',
58
+ name: '',
59
+ label: '',
60
+ roundToPlace: 0
61
+ },
62
+ navigate: {
63
+ name: ''
64
+ },
65
+ latitude: { name: '' },
66
+ longitude: { name: '' }
42
67
  },
43
- primary: {
44
- dataTable: true,
45
- tooltip: true,
46
- prefix: '',
47
- suffix: '',
48
- name: '',
49
- label: '',
50
- roundToPlace: 0
68
+ legend: {
69
+ descriptions: {},
70
+ specialClasses: [],
71
+ unified: false,
72
+ singleColumn: false,
73
+ singleRow: false,
74
+ verticalSorted: false,
75
+ showSpecialClassesLast: false,
76
+ dynamicDescription: false,
77
+ type: 'equalnumber',
78
+ numberOfItems: 3,
79
+ position: 'side',
80
+ title: '',
81
+ style: 'circles',
82
+ subStyle: 'linear blocks',
83
+ tickRotation: '',
84
+ singleColumnLegend: false,
85
+ hideBorder: false,
86
+ groupBy: ''
51
87
  },
52
- navigate: {
53
- name: ''
88
+ filters: [],
89
+ data: [],
90
+ table: {
91
+ wrapColumns: false,
92
+ label: 'Data Table',
93
+ expanded: false,
94
+ limitHeight: false,
95
+ height: '',
96
+ caption: '',
97
+ showDownloadUrl: false,
98
+ showDataTableLink: true,
99
+ showDownloadLinkBelow: true,
100
+ showFullGeoNameInCSV: false,
101
+ forceDisplay: true,
102
+ download: false,
103
+ indexLabel: '',
104
+ cellMinWidth: '0',
105
+ collapsible: true
54
106
  },
55
- latitude: { name: '' },
56
- longitude: { name: '' }
57
- },
58
- legend: {
59
- descriptions: {},
60
- specialClasses: [],
61
- unified: false,
62
- singleColumn: false,
63
- singleRow: false,
64
- verticalSorted: false,
65
- showSpecialClassesLast: false,
66
- dynamicDescription: false,
67
- type: 'equalnumber',
68
- numberOfItems: 3,
69
- position: 'side',
70
- title: '',
71
- style: 'circles',
72
- subStyle: 'linear blocks',
73
- tickRotation: '',
74
- singleColumnLegend: false,
75
- hideBorder: false,
76
- groupBy: ''
77
- },
78
- filters: [],
79
- data: [],
80
- table: {
81
- wrapColumns: false,
82
- label: 'Data Table',
83
- expanded: false,
84
- limitHeight: false,
85
- height: '',
86
- caption: '',
87
- showDownloadUrl: false,
88
- showDataTableLink: true,
89
- showDownloadLinkBelow: true,
90
- showFullGeoNameInCSV: false,
91
- forceDisplay: true,
92
- download: false,
93
- indexLabel: '',
94
- cellMinWidth: '0'
95
- },
96
- tooltips: {
97
- appearanceType: 'hover',
98
- linkLabel: 'Learn More',
99
- capitalizeLabels: true,
100
- opacity: 90
101
- },
102
- runtime: {
103
- editorErrorMessage: []
104
- },
105
- visual: {
106
- minBubbleSize: 1,
107
- maxBubbleSize: 20,
108
- extraBubbleBorder: false,
109
- cityStyle: 'circle',
110
- cityStyleLabel: '',
111
- showBubbleZeros: false,
112
- additionalCityStyles: [],
113
- geoCodeCircleSize: 8,
114
- showBubbleZeros: false
115
- },
116
- mapPosition: { coordinates: [0, 30], zoom: 1 },
117
- map: {
118
- layers: [],
119
- patterns: []
120
- },
121
- hexMap: {
122
- type: '',
123
- shapeGroups: [
124
- {
125
- legendTitle: '',
126
- legendDescription: '',
127
- items: [{ key: '', shape: 'Arrow Up', column: '', operator: '=', value: '' }]
128
- }
129
- ]
130
- },
131
- filterBehavior: 'Filter Change',
132
- filterIntro: ''
107
+ tooltips: {
108
+ appearanceType: 'hover',
109
+ linkLabel: 'Learn More',
110
+ opacity: 90
111
+ },
112
+ runtime: {
113
+ editorErrorMessage: []
114
+ },
115
+ visual: {
116
+ minBubbleSize: 1,
117
+ maxBubbleSize: 20,
118
+ extraBubbleBorder: false,
119
+ cityStyle: 'circle',
120
+ cityStyleLabel: '',
121
+ showBubbleZeros: false,
122
+ additionalCityStyles: [],
123
+ geoCodeCircleSize: 8,
124
+ showBubbleZeros: false
125
+ },
126
+ mapPosition: { coordinates: [0, 30], zoom: 1 },
127
+ map: {
128
+ layers: [],
129
+ patterns: []
130
+ },
131
+ hexMap: {
132
+ type: '',
133
+ shapeGroups: [
134
+ {
135
+ legendTitle: '',
136
+ legendDescription: '',
137
+ items: [{ key: '', shape: 'Arrow Up', column: '', operator: '=', value: '' }]
138
+ }
139
+ ]
140
+ },
141
+ filterBehavior: 'Filter Change',
142
+ filterIntro: '',
143
+ markupVariables: [],
144
+ enableMarkupVariables: false
145
+ }
133
146
  }
147
+
148
+ export default createInitialState()
@@ -1,5 +1,21 @@
1
1
  import supportedCountiesJSON from './supported-counties.json'
2
2
 
3
+ /**
4
+ * US States Lookup Table
5
+ *
6
+ * Maps ISO 3166-2 state codes to arrays of supported name variations.
7
+ * Used for normalizing US state data and converting between different naming formats.
8
+ *
9
+ * Structure: { 'US-XX': ['FULL_NAME', 'XX'] }
10
+ * - Key: ISO 3166-2 state code (e.g., 'US-CA')
11
+ * - Value: [0] = Full uppercase state name, [1] = Two-letter abbreviation
12
+ *
13
+ * Used in:
14
+ * - addUIDs.ts: Match user state data to standardized UIDs
15
+ * - displayGeoName.ts: Convert state codes to display names
16
+ * - UsaMap.State.tsx: State-level map rendering
17
+ * - EditorPanel.tsx: Geography selection interface
18
+ */
3
19
  export const supportedStates = {
4
20
  // States
5
21
  'US-AL': ['ALABAMA', 'AL'],
@@ -55,6 +71,20 @@ export const supportedStates = {
55
71
  'US-WY': ['WYOMING', 'WY']
56
72
  }
57
73
 
74
+ /**
75
+ * US Regions Lookup Table
76
+ *
77
+ * Maps US federal regions (HHS regions) to supported name variations.
78
+ * Used for regional-level data visualization and aggregation.
79
+ *
80
+ * Structure: { 'region N': ['REGION N', 'RN'] }
81
+ * - Key: Lowercase region identifier
82
+ * - Value: [0] = Uppercase region name, [1] = Region abbreviation
83
+ *
84
+ * Used in:
85
+ * - addUIDs.ts: Match regional data to region identifiers
86
+ * - Regional map visualizations
87
+ */
58
88
  export const supportedRegions = {
59
89
  'region 1': ['REGION 1', 'R1'],
60
90
  'region 2': ['REGION 2', 'R2'],
@@ -68,6 +98,20 @@ export const supportedRegions = {
68
98
  'region 10': ['REGION 10', 'R10']
69
99
  }
70
100
 
101
+ /**
102
+ * State Name to ISO Code Mapping
103
+ *
104
+ * Maps proper case state names to their corresponding ISO 3166-2 codes.
105
+ * Provides reverse lookup capability for the supportedStates table.
106
+ *
107
+ * Structure: { 'State Name': 'US-XX' }
108
+ * - Key: Proper case state name (e.g., 'California')
109
+ * - Value: ISO 3166-2 state code (e.g., 'US-CA')
110
+ *
111
+ * Used in:
112
+ * - Data processing when state names need to be converted to ISO codes
113
+ * - Validation and normalization of state data
114
+ */
71
115
  export const stateToIso = {
72
116
  // States
73
117
  Alabama: 'US-AL',
@@ -122,6 +166,22 @@ export const stateToIso = {
122
166
  Wyoming: 'US-WY'
123
167
  }
124
168
 
169
+ /**
170
+ * State FIPS Code to Two-Letter Abbreviation Mapping
171
+ *
172
+ * Maps FIPS (Federal Information Processing Standards) state codes to two-letter abbreviations.
173
+ * FIPS codes are numeric identifiers used by the US Census Bureau and other federal agencies.
174
+ *
175
+ * Structure: { 'XX': 'YY' } or { XX: 'YY' }
176
+ * - Key: FIPS code as string or number (e.g., '06' or 6)
177
+ * - Value: Two-letter state/territory abbreviation (e.g., 'CA')
178
+ *
179
+ * Note: Includes US territories (AS, GU, MP, PR, VI) with FIPS codes 60+
180
+ *
181
+ * Used in:
182
+ * - formatLegendLocation.ts: Convert county FIPS codes to state abbreviations
183
+ * - County-level data processing where state context is needed
184
+ */
125
185
  export const stateFipsToTwoDigit = {
126
186
  ['01']: 'AL', // eslint-disable-line
127
187
  ['02']: 'AK', // eslint-disable-line
@@ -181,6 +241,22 @@ export const stateFipsToTwoDigit = {
181
241
  78: 'VI'
182
242
  }
183
243
 
244
+ /**
245
+ * State FIPS Code to Full Name Mapping
246
+ *
247
+ * Maps FIPS state codes to their full proper case names.
248
+ * Comprehensive lookup including all 50 states, DC, and US territories.
249
+ *
250
+ * Structure: { 'XX': 'Full State Name' } or { XX: 'Full State Name' }
251
+ * - Key: FIPS code as string or number
252
+ * - Value: Full proper case state/territory name
253
+ *
254
+ * Used in:
255
+ * - useStateZoom.tsx: State identification for zoom functionality
256
+ * - getStatesPicked.ts: State selection processing
257
+ * - useApplyTooltipsToGeo.tsx: Tooltip content generation
258
+ * - EditorPanel.tsx: Geographic selection interfaces
259
+ */
184
260
  export const supportedStatesFipsCodes = {
185
261
  '01': 'Alabama',
186
262
  '02': 'Alaska',
@@ -240,6 +316,28 @@ export const supportedStatesFipsCodes = {
240
316
  78: 'United States Virgin Islands'
241
317
  }
242
318
 
319
+ /**
320
+ * World Countries Lookup Table
321
+ *
322
+ * Maps ISO 3166-1 alpha-3 country codes to arrays of supported name variations.
323
+ * Comprehensive international geography support for world maps.
324
+ *
325
+ * Structure: { 'XXX': ['Name Variation 1', 'Name Variation 2', ...] }
326
+ * - Key: ISO 3166-1 alpha-3 country code (e.g., 'USA', 'GBR', 'CHN')
327
+ * - Value: Array of alternative country names and common variations
328
+ *
329
+ * Features:
330
+ * - Multiple name variations per country (official names, common names, abbreviations)
331
+ * - Special territories and dependencies included
332
+ * - Handles disputed territories and special cases
333
+ * - Supports historical and alternative country names
334
+ *
335
+ * Used in:
336
+ * - WorldMap.tsx: International map rendering and interaction
337
+ * - addUIDs.ts: Match international geographic data
338
+ * - displayGeoName.ts: Convert country codes to display names
339
+ * - generateRuntimeLegend.ts: Legend generation for world maps
340
+ */
243
341
  export const supportedCountries = {
244
342
  AFG: ['Afghanistan'],
245
343
  ALA: ['Åland', 'Åland Islands'],
@@ -414,7 +512,14 @@ export const supportedCountries = {
414
512
  NIU: ['Niue', 'Niue (New Zealand)'],
415
513
  NFK: ['Norfolk Island', 'Norfolk Island (Australia)'],
416
514
  MKD: ['North Macedonia', 'Republic of North Macedonia', 'Macedonia'],
417
- MNP: ['Northern Mariana Islands', 'N. Mariana Is.', 'Northern Mariana Islands (U.S.)'],
515
+ MNP: [
516
+ 'Northern Mariana Islands',
517
+ 'N. Mariana Is.',
518
+ 'Northern Mariana Islands (U.S.)',
519
+ 'Commonwealth of Northern Mariana Islands',
520
+ 'Commonwealth of the Northern Mariana Islands',
521
+ 'Commonwealth of the Northern Mariana Islands (CNMI)'
522
+ ],
418
523
  NOR: ['Norway'],
419
524
  OMN: ['Oman'],
420
525
  PAK: ['Pakistan'],
@@ -521,19 +626,69 @@ export const supportedCountries = {
521
626
  'US-HI': ['Hawaii']
522
627
  }
523
628
 
629
+ /**
630
+ * US Territories Lookup Table
631
+ *
632
+ * Maps US territory identifiers to arrays of supported name variations.
633
+ * Covers US territories, freely associated states, and commonwealths.
634
+ *
635
+ * Structure: { 'US-XX': ['FULL_NAME', 'XX', ...] }
636
+ * - Key: ISO-style territory identifier (following US-XX pattern)
637
+ * - Value: [0] = Full uppercase territory name, [1] = Abbreviation, [...] = Variations
638
+ *
639
+ * Note: Some keys (US-FM, US-PW, US-MH) are not official ISO codes but follow
640
+ * the pattern for consistency with the Freely Associated States.
641
+ *
642
+ * Used in:
643
+ * - addUIDs.ts: Match territory data to identifiers
644
+ * - displayGeoName.ts: Convert territory codes to display names
645
+ * - UsaMap.Region.tsx: Territory rendering on regional maps
646
+ * - UsaMap.State.tsx: Territory handling in state-level maps
647
+ */
524
648
  export const supportedTerritories = {
525
649
  'US-AS': ['AMERICAN SAMOA', 'AS'],
526
650
  'US-GU': ['GUAM', 'GU'],
527
651
  'US-PR': ['PUERTO RICO', 'PR'],
528
652
  'US-VI': ['U.S. VIRGIN ISLANDS', 'VI', 'US VIRGIN ISLANDS', 'VIRGIN ISLANDS'],
529
- 'US-MP': ['NORTHERN MARIANAS', 'MP', 'CNMI'],
653
+ 'US-MP': [
654
+ 'NORTHERN MARIANA ISLANDS',
655
+ 'MP',
656
+ 'CNMI',
657
+ 'NORTHERN MARIANAS',
658
+ 'COMMONWEALTH OF NORTHERN MARIANA ISLANDS',
659
+ 'COMMONWEALTH OF THE NORTHERN MARIANA ISLANDS',
660
+ 'COMMONWEALTH OF THE NORTHERN MARIANA ISLANDS (CNMI)'
661
+ ],
530
662
  'US-FM': ['MICRONESIA', 'FM', 'Federated States of Micronesia'], // Note: Key is not an official ISO code
531
663
  'US-PW': ['PALAU', 'PW'], // Note: Key is not an official ISO code
532
664
  'US-MH': ['MARSHALL ISLANDS', 'MH', 'RMI'] // Note: Key is not an official ISO code
533
665
  }
534
666
 
535
- // ! INFO: coordinates are [negative longitude, latitude]
536
- // ie. Albuquerque coordinates are actually [35, 106]
667
+ /**
668
+ * US Cities Coordinate Lookup Table
669
+ *
670
+ * Maps city names to their geographic coordinates for location-based mapping.
671
+ * Includes cities, tribal health organizations, and other geographic entities.
672
+ *
673
+ * Structure: { 'CITY_NAME': [longitude, latitude] }
674
+ * - Key: Uppercase city name, often with state (e.g., 'ALBANY, NEW YORK')
675
+ * - Value: [longitude, latitude] coordinate pair
676
+ *
677
+ * Coordinate Format:
678
+ * - Longitude: Negative values for locations west of Prime Meridian
679
+ * - Latitude: Positive values for locations north of Equator
680
+ * - Format: [longitude, latitude] (NOTE: longitude comes first, opposite of lat/lng)
681
+ *
682
+ * Special Entries:
683
+ * - Tribal health organizations and consortiums
684
+ * - Multi-state metropolitan areas
685
+ * - Federal districts and territories
686
+ *
687
+ * Used in:
688
+ * - addUIDs.ts: Match city-based geographic data
689
+ * - CityList.tsx: City selection and display functionality
690
+ * - Location-based map features requiring precise coordinates
691
+ */
537
692
  // prettier-ignore
538
693
  export const supportedCities = {
539
694
  'ALASKA NATIVE TRIBAL HEALTH CONSORTIUM': [-149.8067, 61.1827],
@@ -724,4 +879,47 @@ export const supportedCities = {
724
879
  'YUKON-KUSKOKWIM HEALTH CORPORATION': [-161.7849, 60.7881]
725
880
  };
726
881
 
882
+ /**
883
+ * US Counties Lookup Table
884
+ *
885
+ * Maps 5-digit FIPS county codes to county names.
886
+ * Imported from external JSON file for maintainability and size management.
887
+ *
888
+ * Structure: { 'SSCCC': 'County Name' }
889
+ * - Key: 5-digit FIPS code where SS = state FIPS, CCC = county FIPS
890
+ * - Value: County name in proper case
891
+ *
892
+ * Coverage:
893
+ * - All 3,143+ US counties and county-equivalents
894
+ * - Includes parishes (Louisiana), boroughs (Alaska), independent cities (Virginia)
895
+ * - Census areas, municipalities, and other county-level entities
896
+ *
897
+ * Used in:
898
+ * - addUIDs.ts: Match county FIPS codes to identifiers
899
+ * - formatLegendLocation.ts: Display county names in legends with state context
900
+ * - displayGeoName.ts: Convert county codes to display names
901
+ * - County-level map rendering and data processing
902
+ */
727
903
  export const supportedCounties = supportedCountiesJSON
904
+
905
+ /**
906
+ * Pre-computed Key Arrays
907
+ *
908
+ * Performance optimization: Pre-compute key arrays to avoid repeated Object.keys() calls
909
+ * in performance-critical functions like displayGeoName() and addUIDs().
910
+ *
911
+ * Used by:
912
+ * - displayGeoName.ts: Geographic name resolution
913
+ * - addUIDs.ts: Geographic data processing
914
+ * - generateRuntimeLegend.ts: Legend generation
915
+ * - formatLegendLocation.ts: Legend formatting
916
+ */
917
+ export const stateKeys = Object.keys(supportedStates)
918
+ export const territoryKeys = Object.keys(supportedTerritories)
919
+ export const regionKeys = Object.keys(supportedRegions)
920
+ export const countryKeys = Object.keys(supportedCountries)
921
+ export const countyKeys = Object.keys(supportedCounties)
922
+ export const cityKeys = Object.keys(supportedCities)
923
+
924
+ // Pre-computed Sets for O(1) lookup performance
925
+ export const countyKeySet = new Set(countyKeys)
@@ -4,19 +4,19 @@ import {
4
4
  supportedCountries,
5
5
  supportedRegions,
6
6
  supportedStates,
7
- supportedTerritories
7
+ supportedTerritories,
8
+ stateKeys,
9
+ territoryKeys,
10
+ regionKeys,
11
+ countryKeys,
12
+ countyKeys,
13
+ cityKeys
8
14
  } from './../data/supported-geos'
9
15
 
10
16
  import { SUPPORTED_DC_NAMES, GEO_TYPES, GEOCODE_TYPES } from './constants'
11
17
  import { DataRow, MapConfig } from '../types/MapConfig'
12
18
 
13
- // Data props
14
- const stateKeys = Object.keys(supportedStates)
15
- const territoryKeys = Object.keys(supportedTerritories)
16
- const regionKeys = Object.keys(supportedRegions)
17
- const countryKeys = Object.keys(supportedCountries)
18
- const countyKeys = Object.keys(supportedCounties)
19
- const cityKeys = Object.keys(supportedCities)
19
+ // Note: Key arrays are now imported from supported-geos for better performance
20
20
 
21
21
  const geoLookups: Record<string, GeoLookup> = {
22
22
  state: { keys: stateKeys, data: supportedStates },