@smartnet360/svelte-components 0.0.101 → 0.0.103
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.
- package/dist/apps/antenna-pattern/index.d.ts +1 -0
- package/dist/apps/antenna-pattern/index.js +1 -0
- package/dist/apps/antenna-pattern/utils/load-static-antennas.d.ts +17 -0
- package/dist/apps/antenna-pattern/utils/load-static-antennas.js +83 -0
- package/dist/apps/site-check/SiteCheck.svelte +4 -6
- package/dist/core/Charts/ChartCard.svelte +122 -12
- package/dist/core/Charts/ChartCard.svelte.d.ts +2 -0
- package/dist/core/Charts/ChartComponent.svelte +8 -6
- package/dist/core/CoverageMap/ai/AITools.d.ts +117 -0
- package/dist/core/CoverageMap/ai/AITools.js +380 -0
- package/dist/core/CoverageMap/core/CoverageCalculator.d.ts +138 -0
- package/dist/core/CoverageMap/core/CoverageCalculator.js +375 -0
- package/dist/core/CoverageMap/core/GridCalculator.d.ts +115 -0
- package/dist/core/CoverageMap/core/GridCalculator.js +484 -0
- package/dist/core/CoverageMap/core/PathLossModels.d.ts +253 -0
- package/dist/core/CoverageMap/core/PathLossModels.js +380 -0
- package/dist/core/CoverageMap/core/SignalProcessor.d.ts +288 -0
- package/dist/core/CoverageMap/core/SignalProcessor.js +424 -0
- package/dist/core/CoverageMap/data/AntennaStore.d.ts +165 -0
- package/dist/core/CoverageMap/data/AntennaStore.js +327 -0
- package/dist/core/CoverageMap/data/SiteStore.d.ts +155 -0
- package/dist/core/CoverageMap/data/SiteStore.js +355 -0
- package/dist/core/CoverageMap/index.d.ts +74 -0
- package/dist/core/CoverageMap/index.js +103 -0
- package/dist/core/CoverageMap/types.d.ts +252 -0
- package/dist/core/CoverageMap/types.js +7 -0
- package/dist/core/CoverageMap/utils/geoUtils.d.ts +223 -0
- package/dist/core/CoverageMap/utils/geoUtils.js +374 -0
- package/dist/core/CoverageMap/utils/rfUtils.d.ts +329 -0
- package/dist/core/CoverageMap/utils/rfUtils.js +434 -0
- package/dist/core/CoverageMap/visualization/ColorSchemes.d.ts +149 -0
- package/dist/core/CoverageMap/visualization/ColorSchemes.js +377 -0
- package/dist/core/TreeView/index.d.ts +4 -4
- package/dist/core/TreeView/index.js +5 -5
- package/dist/core/TreeView/tree-utils.d.ts +12 -0
- package/dist/core/TreeView/tree-utils.js +115 -6
- package/dist/core/TreeView/tree.store.svelte.d.ts +94 -0
- package/dist/core/TreeView/tree.store.svelte.js +274 -0
- package/dist/map-v2/features/cells/controls/CellFilterControl.svelte +16 -27
- package/dist/map-v2/features/cells/utils/cellGeoJSON.js +1 -0
- package/dist/map-v2/features/repeaters/controls/RepeaterFilterControl.svelte +33 -42
- package/dist/map-v2/features/sites/controls/SiteFilterControl.svelte +12 -19
- package/dist/map-v3/core/components/Map.svelte +4 -0
- package/dist/map-v3/core/stores/map.store.svelte.js +2 -0
- package/dist/map-v3/demo/DemoMap.svelte +31 -5
- package/dist/map-v3/demo/demo-cells.js +51 -22
- package/dist/map-v3/features/cells/components/CellFilterControl.svelte +24 -30
- package/dist/map-v3/features/cells/layers/CellsLayer.svelte +29 -9
- package/dist/map-v3/features/cells/logic/geometry.js +3 -0
- package/dist/map-v3/features/cells/stores/cell.data.svelte.d.ts +27 -0
- package/dist/map-v3/features/cells/stores/cell.data.svelte.js +65 -0
- package/dist/map-v3/features/coverage/index.d.ts +12 -0
- package/dist/map-v3/features/coverage/index.js +16 -0
- package/dist/map-v3/features/coverage/layers/CoverageLayer.svelte +198 -0
- package/dist/map-v3/features/coverage/layers/CoverageLayer.svelte.d.ts +10 -0
- package/dist/map-v3/features/coverage/logic/coloring.d.ts +28 -0
- package/dist/map-v3/features/coverage/logic/coloring.js +77 -0
- package/dist/map-v3/features/coverage/logic/geometry.d.ts +33 -0
- package/dist/map-v3/features/coverage/logic/geometry.js +112 -0
- package/dist/map-v3/features/coverage/stores/coverage.data.svelte.d.ts +46 -0
- package/dist/map-v3/features/coverage/stores/coverage.data.svelte.js +95 -0
- package/dist/map-v3/features/coverage/stores/coverage.display.svelte.d.ts +33 -0
- package/dist/map-v3/features/coverage/stores/coverage.display.svelte.js +90 -0
- package/dist/map-v3/features/coverage/types.d.ts +52 -0
- package/dist/map-v3/features/coverage/types.js +7 -0
- package/dist/map-v3/features/repeaters/components/RepeaterFilterControl.svelte +14 -20
- package/dist/map-v3/features/selection/components/FeatureSelectionControl.svelte +82 -65
- package/dist/map-v3/features/selection/components/FeatureSelectionControl.svelte.d.ts +5 -9
- package/dist/map-v3/features/selection/index.d.ts +1 -2
- package/dist/map-v3/features/selection/index.js +0 -1
- package/dist/map-v3/features/selection/stores/selection.store.svelte.d.ts +44 -15
- package/dist/map-v3/features/selection/stores/selection.store.svelte.js +163 -40
- package/dist/map-v3/features/selection/types.d.ts +4 -2
- package/dist/map-v3/features/sites/components/SiteFilterControl.svelte +23 -33
- package/dist/map-v3/index.d.ts +4 -0
- package/dist/map-v3/index.js +5 -0
- package/package.json +2 -2
- package/dist/core/TreeView/tree.store.d.ts +0 -10
- package/dist/core/TreeView/tree.store.js +0 -320
- package/dist/map-v3/features/selection/layers/SelectionHighlightLayers.svelte +0 -209
- package/dist/map-v3/features/selection/layers/SelectionHighlightLayers.svelte.d.ts +0 -13
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Path Loss Models
|
|
3
|
+
*
|
|
4
|
+
* This module implements various RF propagation path loss models.
|
|
5
|
+
* Path loss describes how signal strength decreases with distance.
|
|
6
|
+
*
|
|
7
|
+
* Models implemented:
|
|
8
|
+
* 1. Free Space Path Loss (FSPL) - Ideal conditions, line of sight
|
|
9
|
+
* 2. Hata Model - Urban/Suburban/Rural environments
|
|
10
|
+
* 3. COST-231 Hata - Extended Hata for higher frequencies
|
|
11
|
+
*
|
|
12
|
+
* All models return path loss in dB (positive value).
|
|
13
|
+
* Higher values = more loss = weaker signal.
|
|
14
|
+
*/
|
|
15
|
+
import type { PathLossModel } from '../types';
|
|
16
|
+
/**
|
|
17
|
+
* Calculate Free Space Path Loss (FSPL)
|
|
18
|
+
*
|
|
19
|
+
* FSPL represents signal attenuation in ideal conditions:
|
|
20
|
+
* - Perfect line of sight
|
|
21
|
+
* - No obstacles
|
|
22
|
+
* - No ground reflections
|
|
23
|
+
* - No atmospheric absorption
|
|
24
|
+
*
|
|
25
|
+
* This is the MINIMUM possible path loss. Real-world loss is always higher.
|
|
26
|
+
*
|
|
27
|
+
* Formula:
|
|
28
|
+
* FSPL(dB) = 32.45 + 20×log₁₀(d_km) + 20×log₁₀(f_MHz)
|
|
29
|
+
*
|
|
30
|
+
* Breaking down the formula:
|
|
31
|
+
*
|
|
32
|
+
* 1. Constant term (32.45):
|
|
33
|
+
* - Derived from (4π/c)² where c = speed of light
|
|
34
|
+
* - Accounts for wave spreading in free space
|
|
35
|
+
* - Unit conversion factor (km, MHz → dB)
|
|
36
|
+
*
|
|
37
|
+
* 2. Distance term: 20×log₁₀(d_km)
|
|
38
|
+
* - Signal spreads over spherical wavefront
|
|
39
|
+
* - Area increases as r² (doubling distance = -6 dB)
|
|
40
|
+
* - Why 20 log? Because power ∝ 1/r², and 10×log₁₀(r²) = 20×log₁₀(r)
|
|
41
|
+
*
|
|
42
|
+
* 3. Frequency term: 20×log₁₀(f_MHz)
|
|
43
|
+
* - Higher frequency = shorter wavelength
|
|
44
|
+
* - Smaller antenna aperture (capture area)
|
|
45
|
+
* - Doubling frequency = +6 dB loss
|
|
46
|
+
*
|
|
47
|
+
* Physical intuition:
|
|
48
|
+
* - Imagine signal energy spreading over expanding sphere
|
|
49
|
+
* - Surface area = 4πr²
|
|
50
|
+
* - Power density = Power / (4πr²)
|
|
51
|
+
* - As distance doubles, density drops to 1/4 (-6 dB)
|
|
52
|
+
*
|
|
53
|
+
* Frequency dependency:
|
|
54
|
+
* - 700 MHz: Less loss, better penetration, longer range
|
|
55
|
+
* - 2600 MHz: More loss, worse penetration, shorter range
|
|
56
|
+
* - Difference at 1 km: ~11 dB (2600 MHz has 11 dB more loss)
|
|
57
|
+
*
|
|
58
|
+
* Typical FSPL values:
|
|
59
|
+
* Distance | 700 MHz | 1800 MHz | 2600 MHz
|
|
60
|
+
* ---------|---------|----------|----------
|
|
61
|
+
* 0.1 km | 77 dB | 85 dB | 89 dB
|
|
62
|
+
* 1 km | 97 dB | 105 dB | 109 dB
|
|
63
|
+
* 5 km | 111 dB | 119 dB | 123 dB
|
|
64
|
+
* 10 km | 117 dB | 125 dB | 129 dB
|
|
65
|
+
*
|
|
66
|
+
* Use cases:
|
|
67
|
+
* - Microwave links (actual line of sight)
|
|
68
|
+
* - Satellite communications
|
|
69
|
+
* - Initial planning estimates
|
|
70
|
+
* - Best-case scenario calculations
|
|
71
|
+
*
|
|
72
|
+
* Limitations:
|
|
73
|
+
* ❌ Ignores buildings, trees, terrain
|
|
74
|
+
* ❌ Ignores ground reflections
|
|
75
|
+
* ❌ Only valid for far-field (d >> wavelength)
|
|
76
|
+
* ❌ Real cellular networks experience 20-40 dB additional loss
|
|
77
|
+
*
|
|
78
|
+
* @param distanceKm - Distance between transmitter and receiver (km)
|
|
79
|
+
* @param frequencyMHz - Operating frequency (MHz)
|
|
80
|
+
* @returns Path loss in dB (positive value)
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* const loss = calculateFSPL(1.0, 1800); // 1 km at 1800 MHz
|
|
84
|
+
* // Returns: ~105 dB
|
|
85
|
+
* // Interpretation: Signal is 105 dB weaker than transmitted
|
|
86
|
+
*/
|
|
87
|
+
export declare function calculateFSPL(distanceKm: number, frequencyMHz: number): number;
|
|
88
|
+
/**
|
|
89
|
+
* Calculate path loss using Hata Model
|
|
90
|
+
*
|
|
91
|
+
* The Hata model is an empirical formula derived from Okumura's measurements
|
|
92
|
+
* in Tokyo. It's widely used for cellular network planning in various environments.
|
|
93
|
+
*
|
|
94
|
+
* Valid ranges:
|
|
95
|
+
* - Frequency: 150 - 1500 MHz (original), extended to 2000 MHz
|
|
96
|
+
* - Distance: 1 - 20 km
|
|
97
|
+
* - Base station height: 30 - 200 m
|
|
98
|
+
* - Mobile height: 1 - 10 m
|
|
99
|
+
*
|
|
100
|
+
* Formula (Urban):
|
|
101
|
+
* L = 69.55 + 26.16×log₁₀(f) - 13.82×log₁₀(h_b) - a(h_m)
|
|
102
|
+
* + (44.9 - 6.55×log₁₀(h_b))×log₁₀(d)
|
|
103
|
+
*
|
|
104
|
+
* Where:
|
|
105
|
+
* - f = frequency in MHz
|
|
106
|
+
* - h_b = base station (antenna) height in meters
|
|
107
|
+
* - h_m = mobile station height in meters
|
|
108
|
+
* - d = distance in km
|
|
109
|
+
* - a(h_m) = mobile antenna height correction factor
|
|
110
|
+
*
|
|
111
|
+
* For small/medium city:
|
|
112
|
+
* a(h_m) = (1.1×log₁₀(f) - 0.7)×h_m - (1.56×log₁₀(f) - 0.8)
|
|
113
|
+
*
|
|
114
|
+
* For large city (f ≤ 200 MHz):
|
|
115
|
+
* a(h_m) = 8.29×(log₁₀(1.54×h_m))² - 1.1
|
|
116
|
+
*
|
|
117
|
+
* For large city (f ≥ 400 MHz):
|
|
118
|
+
* a(h_m) = 3.2×(log₁₀(11.75×h_m))² - 4.97
|
|
119
|
+
*
|
|
120
|
+
* Environment adjustments:
|
|
121
|
+
*
|
|
122
|
+
* Suburban:
|
|
123
|
+
* L_suburban = L_urban - 2×(log₁₀(f/28))² - 5.4
|
|
124
|
+
* Typically 10-20 dB less loss than urban
|
|
125
|
+
*
|
|
126
|
+
* Rural (open):
|
|
127
|
+
* L_rural = L_urban - 4.78×(log₁₀(f))² + 18.33×log₁₀(f) - 40.94
|
|
128
|
+
* Typically 20-30 dB less loss than urban
|
|
129
|
+
*
|
|
130
|
+
* Physical meaning:
|
|
131
|
+
* - Accounts for buildings, street canyons, clutter
|
|
132
|
+
* - Based on actual measurements in real cities
|
|
133
|
+
* - More realistic than FSPL for cellular networks
|
|
134
|
+
* - Still doesn't account for specific terrain/buildings
|
|
135
|
+
*
|
|
136
|
+
* Typical Hata values vs FSPL (1800 MHz, 30m antenna, 1.5m mobile):
|
|
137
|
+
* Distance | FSPL | Hata Urban | Hata Suburban | Hata Rural
|
|
138
|
+
* ---------|--------|------------|---------------|------------
|
|
139
|
+
* 1 km | 105 dB | 127 dB | 115 dB | 105 dB
|
|
140
|
+
* 5 km | 119 dB | 141 dB | 129 dB | 119 dB
|
|
141
|
+
* 10 km | 125 dB | 147 dB | 135 dB | 125 dB
|
|
142
|
+
*
|
|
143
|
+
* Note: Hata adds 20-40 dB loss compared to FSPL in urban areas!
|
|
144
|
+
*
|
|
145
|
+
* @param distanceKm - Distance (1-20 km)
|
|
146
|
+
* @param frequencyMHz - Frequency (150-2000 MHz)
|
|
147
|
+
* @param antennaHeightM - Base station antenna height (30-200 m)
|
|
148
|
+
* @param mobileHeightM - Mobile height (1-10 m, default: 1.5m)
|
|
149
|
+
* @param environment - 'urban' | 'suburban' | 'rural'
|
|
150
|
+
* @param citySize - 'small' | 'medium' | 'large' (for urban only)
|
|
151
|
+
* @returns Path loss in dB
|
|
152
|
+
*/
|
|
153
|
+
export declare function calculateHata(distanceKm: number, frequencyMHz: number, antennaHeightM: number, mobileHeightM?: number, environment?: 'urban' | 'suburban' | 'rural', citySize?: 'small' | 'medium' | 'large'): number;
|
|
154
|
+
/**
|
|
155
|
+
* Calculate path loss using COST-231 Hata Model
|
|
156
|
+
*
|
|
157
|
+
* COST-231 is an extension of the Hata model for higher frequencies.
|
|
158
|
+
* It extends the valid frequency range from 1500 MHz to 2000 MHz,
|
|
159
|
+
* making it suitable for modern cellular networks (1800 MHz, 1900 MHz, 2100 MHz).
|
|
160
|
+
*
|
|
161
|
+
* Valid ranges:
|
|
162
|
+
* - Frequency: 1500 - 2000 MHz (extended range)
|
|
163
|
+
* - Distance: 1 - 20 km
|
|
164
|
+
* - Base station height: 30 - 200 m
|
|
165
|
+
* - Mobile height: 1 - 10 m
|
|
166
|
+
*
|
|
167
|
+
* Formula:
|
|
168
|
+
* L = 46.3 + 33.9×log₁₀(f) - 13.82×log₁₀(h_b) - a(h_m)
|
|
169
|
+
* + (44.9 - 6.55×log₁₀(h_b))×log₁₀(d) + C_m
|
|
170
|
+
*
|
|
171
|
+
* Where C_m is the environment correction:
|
|
172
|
+
* - C_m = 0 dB for suburban/rural (medium city)
|
|
173
|
+
* - C_m = 3 dB for metropolitan centers (urban)
|
|
174
|
+
*
|
|
175
|
+
* Differences from Hata:
|
|
176
|
+
* - Different constant terms (46.3 vs 69.55)
|
|
177
|
+
* - Different frequency coefficient (33.9 vs 26.16)
|
|
178
|
+
* - Addition of C_m term
|
|
179
|
+
* - Valid for higher frequencies
|
|
180
|
+
*
|
|
181
|
+
* Use this model for:
|
|
182
|
+
* ✅ 1800 MHz (LTE Band 3, GSM 1800)
|
|
183
|
+
* ✅ 1900 MHz (PCS, LTE Band 2)
|
|
184
|
+
* ✅ 2100 MHz (UMTS, LTE Band 1)
|
|
185
|
+
* ✅ 2600 MHz (LTE Band 7) - slightly outside range but acceptable
|
|
186
|
+
*
|
|
187
|
+
* @param distanceKm - Distance (1-20 km)
|
|
188
|
+
* @param frequencyMHz - Frequency (1500-2000 MHz)
|
|
189
|
+
* @param antennaHeightM - Base station antenna height (30-200 m)
|
|
190
|
+
* @param mobileHeightM - Mobile height (1-10 m, default: 1.5m)
|
|
191
|
+
* @param isMetropolitan - true for dense urban, false for suburban
|
|
192
|
+
* @returns Path loss in dB
|
|
193
|
+
*/
|
|
194
|
+
export declare function calculateCOST231(distanceKm: number, frequencyMHz: number, antennaHeightM: number, mobileHeightM?: number, isMetropolitan?: boolean): number;
|
|
195
|
+
/**
|
|
196
|
+
* Calculate path loss using specified model
|
|
197
|
+
*
|
|
198
|
+
* This is the main entry point for path loss calculations.
|
|
199
|
+
* It selects the appropriate model and parameters.
|
|
200
|
+
*
|
|
201
|
+
* Model selection guide:
|
|
202
|
+
*
|
|
203
|
+
* 1. Free Space (FSPL):
|
|
204
|
+
* - Best case scenario
|
|
205
|
+
* - Quick calculations
|
|
206
|
+
* - Microwave links
|
|
207
|
+
* - Line of sight paths
|
|
208
|
+
*
|
|
209
|
+
* 2. Hata:
|
|
210
|
+
* - Frequencies 150-1500 MHz
|
|
211
|
+
* - Good for 700 MHz, 850 MHz bands
|
|
212
|
+
* - Mature, well-tested model
|
|
213
|
+
*
|
|
214
|
+
* 3. COST-231:
|
|
215
|
+
* - Frequencies 1500-2000 MHz
|
|
216
|
+
* - Best for 1800 MHz, 1900 MHz, 2100 MHz
|
|
217
|
+
* - Modern cellular networks
|
|
218
|
+
*
|
|
219
|
+
* Default parameters:
|
|
220
|
+
* - Mobile height: 1.5m (typical phone height)
|
|
221
|
+
* - Environment: urban (conservative estimate)
|
|
222
|
+
*
|
|
223
|
+
* @param model - Path loss model to use
|
|
224
|
+
* @param distanceKm - Distance in km
|
|
225
|
+
* @param frequencyMHz - Frequency in MHz
|
|
226
|
+
* @param antennaHeightM - Antenna height in meters
|
|
227
|
+
* @param options - Additional options for specific models
|
|
228
|
+
* @returns Path loss in dB
|
|
229
|
+
*/
|
|
230
|
+
export declare function calculatePathLoss(model: PathLossModel, distanceKm: number, frequencyMHz: number, antennaHeightM: number, options?: {
|
|
231
|
+
mobileHeightM?: number;
|
|
232
|
+
environment?: 'urban' | 'suburban' | 'rural';
|
|
233
|
+
citySize?: 'small' | 'medium' | 'large';
|
|
234
|
+
isMetropolitan?: boolean;
|
|
235
|
+
}): number;
|
|
236
|
+
/**
|
|
237
|
+
* Get recommended path loss model for given frequency
|
|
238
|
+
*
|
|
239
|
+
* @param frequencyMHz - Operating frequency in MHz
|
|
240
|
+
* @returns Recommended path loss model
|
|
241
|
+
*/
|
|
242
|
+
export declare function getRecommendedModel(frequencyMHz: number): PathLossModel;
|
|
243
|
+
/**
|
|
244
|
+
* Compare path loss across different models
|
|
245
|
+
*
|
|
246
|
+
* Useful for understanding model differences and uncertainty ranges.
|
|
247
|
+
*
|
|
248
|
+
* @param distanceKm - Distance
|
|
249
|
+
* @param frequencyMHz - Frequency
|
|
250
|
+
* @param antennaHeightM - Antenna height
|
|
251
|
+
* @returns Object with loss values for each model
|
|
252
|
+
*/
|
|
253
|
+
export declare function compareModels(distanceKm: number, frequencyMHz: number, antennaHeightM: number): Record<string, number>;
|
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Path Loss Models
|
|
3
|
+
*
|
|
4
|
+
* This module implements various RF propagation path loss models.
|
|
5
|
+
* Path loss describes how signal strength decreases with distance.
|
|
6
|
+
*
|
|
7
|
+
* Models implemented:
|
|
8
|
+
* 1. Free Space Path Loss (FSPL) - Ideal conditions, line of sight
|
|
9
|
+
* 2. Hata Model - Urban/Suburban/Rural environments
|
|
10
|
+
* 3. COST-231 Hata - Extended Hata for higher frequencies
|
|
11
|
+
*
|
|
12
|
+
* All models return path loss in dB (positive value).
|
|
13
|
+
* Higher values = more loss = weaker signal.
|
|
14
|
+
*/
|
|
15
|
+
// ============================================================================
|
|
16
|
+
// FREE SPACE PATH LOSS (FSPL)
|
|
17
|
+
// ============================================================================
|
|
18
|
+
/**
|
|
19
|
+
* Calculate Free Space Path Loss (FSPL)
|
|
20
|
+
*
|
|
21
|
+
* FSPL represents signal attenuation in ideal conditions:
|
|
22
|
+
* - Perfect line of sight
|
|
23
|
+
* - No obstacles
|
|
24
|
+
* - No ground reflections
|
|
25
|
+
* - No atmospheric absorption
|
|
26
|
+
*
|
|
27
|
+
* This is the MINIMUM possible path loss. Real-world loss is always higher.
|
|
28
|
+
*
|
|
29
|
+
* Formula:
|
|
30
|
+
* FSPL(dB) = 32.45 + 20×log₁₀(d_km) + 20×log₁₀(f_MHz)
|
|
31
|
+
*
|
|
32
|
+
* Breaking down the formula:
|
|
33
|
+
*
|
|
34
|
+
* 1. Constant term (32.45):
|
|
35
|
+
* - Derived from (4π/c)² where c = speed of light
|
|
36
|
+
* - Accounts for wave spreading in free space
|
|
37
|
+
* - Unit conversion factor (km, MHz → dB)
|
|
38
|
+
*
|
|
39
|
+
* 2. Distance term: 20×log₁₀(d_km)
|
|
40
|
+
* - Signal spreads over spherical wavefront
|
|
41
|
+
* - Area increases as r² (doubling distance = -6 dB)
|
|
42
|
+
* - Why 20 log? Because power ∝ 1/r², and 10×log₁₀(r²) = 20×log₁₀(r)
|
|
43
|
+
*
|
|
44
|
+
* 3. Frequency term: 20×log₁₀(f_MHz)
|
|
45
|
+
* - Higher frequency = shorter wavelength
|
|
46
|
+
* - Smaller antenna aperture (capture area)
|
|
47
|
+
* - Doubling frequency = +6 dB loss
|
|
48
|
+
*
|
|
49
|
+
* Physical intuition:
|
|
50
|
+
* - Imagine signal energy spreading over expanding sphere
|
|
51
|
+
* - Surface area = 4πr²
|
|
52
|
+
* - Power density = Power / (4πr²)
|
|
53
|
+
* - As distance doubles, density drops to 1/4 (-6 dB)
|
|
54
|
+
*
|
|
55
|
+
* Frequency dependency:
|
|
56
|
+
* - 700 MHz: Less loss, better penetration, longer range
|
|
57
|
+
* - 2600 MHz: More loss, worse penetration, shorter range
|
|
58
|
+
* - Difference at 1 km: ~11 dB (2600 MHz has 11 dB more loss)
|
|
59
|
+
*
|
|
60
|
+
* Typical FSPL values:
|
|
61
|
+
* Distance | 700 MHz | 1800 MHz | 2600 MHz
|
|
62
|
+
* ---------|---------|----------|----------
|
|
63
|
+
* 0.1 km | 77 dB | 85 dB | 89 dB
|
|
64
|
+
* 1 km | 97 dB | 105 dB | 109 dB
|
|
65
|
+
* 5 km | 111 dB | 119 dB | 123 dB
|
|
66
|
+
* 10 km | 117 dB | 125 dB | 129 dB
|
|
67
|
+
*
|
|
68
|
+
* Use cases:
|
|
69
|
+
* - Microwave links (actual line of sight)
|
|
70
|
+
* - Satellite communications
|
|
71
|
+
* - Initial planning estimates
|
|
72
|
+
* - Best-case scenario calculations
|
|
73
|
+
*
|
|
74
|
+
* Limitations:
|
|
75
|
+
* ❌ Ignores buildings, trees, terrain
|
|
76
|
+
* ❌ Ignores ground reflections
|
|
77
|
+
* ❌ Only valid for far-field (d >> wavelength)
|
|
78
|
+
* ❌ Real cellular networks experience 20-40 dB additional loss
|
|
79
|
+
*
|
|
80
|
+
* @param distanceKm - Distance between transmitter and receiver (km)
|
|
81
|
+
* @param frequencyMHz - Operating frequency (MHz)
|
|
82
|
+
* @returns Path loss in dB (positive value)
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* const loss = calculateFSPL(1.0, 1800); // 1 km at 1800 MHz
|
|
86
|
+
* // Returns: ~105 dB
|
|
87
|
+
* // Interpretation: Signal is 105 dB weaker than transmitted
|
|
88
|
+
*/
|
|
89
|
+
export function calculateFSPL(distanceKm, frequencyMHz) {
|
|
90
|
+
// Validate inputs
|
|
91
|
+
if (distanceKm <= 0) {
|
|
92
|
+
throw new Error(`Invalid distance: ${distanceKm} km. Must be positive.`);
|
|
93
|
+
}
|
|
94
|
+
if (frequencyMHz <= 0) {
|
|
95
|
+
throw new Error(`Invalid frequency: ${frequencyMHz} MHz. Must be positive.`);
|
|
96
|
+
}
|
|
97
|
+
// Calculate each term separately for clarity
|
|
98
|
+
const constantTerm = 32.45;
|
|
99
|
+
const distanceTerm = 20 * Math.log10(distanceKm);
|
|
100
|
+
const frequencyTerm = 20 * Math.log10(frequencyMHz);
|
|
101
|
+
// Combine terms
|
|
102
|
+
const fspl = constantTerm + distanceTerm + frequencyTerm;
|
|
103
|
+
return fspl;
|
|
104
|
+
}
|
|
105
|
+
// ============================================================================
|
|
106
|
+
// HATA MODEL (OKUMURA-HATA)
|
|
107
|
+
// ============================================================================
|
|
108
|
+
/**
|
|
109
|
+
* Calculate path loss using Hata Model
|
|
110
|
+
*
|
|
111
|
+
* The Hata model is an empirical formula derived from Okumura's measurements
|
|
112
|
+
* in Tokyo. It's widely used for cellular network planning in various environments.
|
|
113
|
+
*
|
|
114
|
+
* Valid ranges:
|
|
115
|
+
* - Frequency: 150 - 1500 MHz (original), extended to 2000 MHz
|
|
116
|
+
* - Distance: 1 - 20 km
|
|
117
|
+
* - Base station height: 30 - 200 m
|
|
118
|
+
* - Mobile height: 1 - 10 m
|
|
119
|
+
*
|
|
120
|
+
* Formula (Urban):
|
|
121
|
+
* L = 69.55 + 26.16×log₁₀(f) - 13.82×log₁₀(h_b) - a(h_m)
|
|
122
|
+
* + (44.9 - 6.55×log₁₀(h_b))×log₁₀(d)
|
|
123
|
+
*
|
|
124
|
+
* Where:
|
|
125
|
+
* - f = frequency in MHz
|
|
126
|
+
* - h_b = base station (antenna) height in meters
|
|
127
|
+
* - h_m = mobile station height in meters
|
|
128
|
+
* - d = distance in km
|
|
129
|
+
* - a(h_m) = mobile antenna height correction factor
|
|
130
|
+
*
|
|
131
|
+
* For small/medium city:
|
|
132
|
+
* a(h_m) = (1.1×log₁₀(f) - 0.7)×h_m - (1.56×log₁₀(f) - 0.8)
|
|
133
|
+
*
|
|
134
|
+
* For large city (f ≤ 200 MHz):
|
|
135
|
+
* a(h_m) = 8.29×(log₁₀(1.54×h_m))² - 1.1
|
|
136
|
+
*
|
|
137
|
+
* For large city (f ≥ 400 MHz):
|
|
138
|
+
* a(h_m) = 3.2×(log₁₀(11.75×h_m))² - 4.97
|
|
139
|
+
*
|
|
140
|
+
* Environment adjustments:
|
|
141
|
+
*
|
|
142
|
+
* Suburban:
|
|
143
|
+
* L_suburban = L_urban - 2×(log₁₀(f/28))² - 5.4
|
|
144
|
+
* Typically 10-20 dB less loss than urban
|
|
145
|
+
*
|
|
146
|
+
* Rural (open):
|
|
147
|
+
* L_rural = L_urban - 4.78×(log₁₀(f))² + 18.33×log₁₀(f) - 40.94
|
|
148
|
+
* Typically 20-30 dB less loss than urban
|
|
149
|
+
*
|
|
150
|
+
* Physical meaning:
|
|
151
|
+
* - Accounts for buildings, street canyons, clutter
|
|
152
|
+
* - Based on actual measurements in real cities
|
|
153
|
+
* - More realistic than FSPL for cellular networks
|
|
154
|
+
* - Still doesn't account for specific terrain/buildings
|
|
155
|
+
*
|
|
156
|
+
* Typical Hata values vs FSPL (1800 MHz, 30m antenna, 1.5m mobile):
|
|
157
|
+
* Distance | FSPL | Hata Urban | Hata Suburban | Hata Rural
|
|
158
|
+
* ---------|--------|------------|---------------|------------
|
|
159
|
+
* 1 km | 105 dB | 127 dB | 115 dB | 105 dB
|
|
160
|
+
* 5 km | 119 dB | 141 dB | 129 dB | 119 dB
|
|
161
|
+
* 10 km | 125 dB | 147 dB | 135 dB | 125 dB
|
|
162
|
+
*
|
|
163
|
+
* Note: Hata adds 20-40 dB loss compared to FSPL in urban areas!
|
|
164
|
+
*
|
|
165
|
+
* @param distanceKm - Distance (1-20 km)
|
|
166
|
+
* @param frequencyMHz - Frequency (150-2000 MHz)
|
|
167
|
+
* @param antennaHeightM - Base station antenna height (30-200 m)
|
|
168
|
+
* @param mobileHeightM - Mobile height (1-10 m, default: 1.5m)
|
|
169
|
+
* @param environment - 'urban' | 'suburban' | 'rural'
|
|
170
|
+
* @param citySize - 'small' | 'medium' | 'large' (for urban only)
|
|
171
|
+
* @returns Path loss in dB
|
|
172
|
+
*/
|
|
173
|
+
export function calculateHata(distanceKm, frequencyMHz, antennaHeightM, mobileHeightM = 1.5, environment = 'urban', citySize = 'medium') {
|
|
174
|
+
// Validate inputs against Hata model valid ranges
|
|
175
|
+
if (distanceKm < 1 || distanceKm > 20) {
|
|
176
|
+
console.warn(`Hata model: distance ${distanceKm} km outside valid range (1-20 km)`);
|
|
177
|
+
}
|
|
178
|
+
if (frequencyMHz < 150 || frequencyMHz > 2000) {
|
|
179
|
+
console.warn(`Hata model: frequency ${frequencyMHz} MHz outside valid range (150-2000 MHz)`);
|
|
180
|
+
}
|
|
181
|
+
if (antennaHeightM < 30 || antennaHeightM > 200) {
|
|
182
|
+
console.warn(`Hata model: antenna height ${antennaHeightM} m outside valid range (30-200 m)`);
|
|
183
|
+
}
|
|
184
|
+
// Calculate mobile antenna height correction factor a(h_m)
|
|
185
|
+
let a_hm;
|
|
186
|
+
if (citySize === 'large') {
|
|
187
|
+
// Large city correction
|
|
188
|
+
if (frequencyMHz <= 200) {
|
|
189
|
+
// Low frequency formula
|
|
190
|
+
const term = Math.log10(1.54 * mobileHeightM);
|
|
191
|
+
a_hm = 8.29 * term * term - 1.1;
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
// High frequency formula (≥ 400 MHz)
|
|
195
|
+
const term = Math.log10(11.75 * mobileHeightM);
|
|
196
|
+
a_hm = 3.2 * term * term - 4.97;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
// Small/medium city correction
|
|
201
|
+
a_hm =
|
|
202
|
+
(1.1 * Math.log10(frequencyMHz) - 0.7) * mobileHeightM -
|
|
203
|
+
(1.56 * Math.log10(frequencyMHz) - 0.8);
|
|
204
|
+
}
|
|
205
|
+
// Calculate urban path loss (base formula)
|
|
206
|
+
const term1 = 69.55;
|
|
207
|
+
const term2 = 26.16 * Math.log10(frequencyMHz);
|
|
208
|
+
const term3 = 13.82 * Math.log10(antennaHeightM);
|
|
209
|
+
const term4 = (44.9 - 6.55 * Math.log10(antennaHeightM)) * Math.log10(distanceKm);
|
|
210
|
+
const urbanLoss = term1 + term2 - term3 - a_hm + term4;
|
|
211
|
+
// Apply environment correction
|
|
212
|
+
if (environment === 'suburban') {
|
|
213
|
+
// Suburban correction (less loss than urban)
|
|
214
|
+
const correction = 2 * Math.pow(Math.log10(frequencyMHz / 28), 2) + 5.4;
|
|
215
|
+
return urbanLoss - correction;
|
|
216
|
+
}
|
|
217
|
+
else if (environment === 'rural') {
|
|
218
|
+
// Rural/open area correction (much less loss)
|
|
219
|
+
const correction = 4.78 * Math.pow(Math.log10(frequencyMHz), 2) +
|
|
220
|
+
18.33 * Math.log10(frequencyMHz) -
|
|
221
|
+
40.94;
|
|
222
|
+
return urbanLoss - correction;
|
|
223
|
+
}
|
|
224
|
+
// Urban environment (no correction)
|
|
225
|
+
return urbanLoss;
|
|
226
|
+
}
|
|
227
|
+
// ============================================================================
|
|
228
|
+
// COST-231 HATA MODEL (EXTENDED)
|
|
229
|
+
// ============================================================================
|
|
230
|
+
/**
|
|
231
|
+
* Calculate path loss using COST-231 Hata Model
|
|
232
|
+
*
|
|
233
|
+
* COST-231 is an extension of the Hata model for higher frequencies.
|
|
234
|
+
* It extends the valid frequency range from 1500 MHz to 2000 MHz,
|
|
235
|
+
* making it suitable for modern cellular networks (1800 MHz, 1900 MHz, 2100 MHz).
|
|
236
|
+
*
|
|
237
|
+
* Valid ranges:
|
|
238
|
+
* - Frequency: 1500 - 2000 MHz (extended range)
|
|
239
|
+
* - Distance: 1 - 20 km
|
|
240
|
+
* - Base station height: 30 - 200 m
|
|
241
|
+
* - Mobile height: 1 - 10 m
|
|
242
|
+
*
|
|
243
|
+
* Formula:
|
|
244
|
+
* L = 46.3 + 33.9×log₁₀(f) - 13.82×log₁₀(h_b) - a(h_m)
|
|
245
|
+
* + (44.9 - 6.55×log₁₀(h_b))×log₁₀(d) + C_m
|
|
246
|
+
*
|
|
247
|
+
* Where C_m is the environment correction:
|
|
248
|
+
* - C_m = 0 dB for suburban/rural (medium city)
|
|
249
|
+
* - C_m = 3 dB for metropolitan centers (urban)
|
|
250
|
+
*
|
|
251
|
+
* Differences from Hata:
|
|
252
|
+
* - Different constant terms (46.3 vs 69.55)
|
|
253
|
+
* - Different frequency coefficient (33.9 vs 26.16)
|
|
254
|
+
* - Addition of C_m term
|
|
255
|
+
* - Valid for higher frequencies
|
|
256
|
+
*
|
|
257
|
+
* Use this model for:
|
|
258
|
+
* ✅ 1800 MHz (LTE Band 3, GSM 1800)
|
|
259
|
+
* ✅ 1900 MHz (PCS, LTE Band 2)
|
|
260
|
+
* ✅ 2100 MHz (UMTS, LTE Band 1)
|
|
261
|
+
* ✅ 2600 MHz (LTE Band 7) - slightly outside range but acceptable
|
|
262
|
+
*
|
|
263
|
+
* @param distanceKm - Distance (1-20 km)
|
|
264
|
+
* @param frequencyMHz - Frequency (1500-2000 MHz)
|
|
265
|
+
* @param antennaHeightM - Base station antenna height (30-200 m)
|
|
266
|
+
* @param mobileHeightM - Mobile height (1-10 m, default: 1.5m)
|
|
267
|
+
* @param isMetropolitan - true for dense urban, false for suburban
|
|
268
|
+
* @returns Path loss in dB
|
|
269
|
+
*/
|
|
270
|
+
export function calculateCOST231(distanceKm, frequencyMHz, antennaHeightM, mobileHeightM = 1.5, isMetropolitan = false) {
|
|
271
|
+
// Validate inputs
|
|
272
|
+
if (distanceKm < 1 || distanceKm > 20) {
|
|
273
|
+
console.warn(`COST-231: distance ${distanceKm} km outside valid range (1-20 km)`);
|
|
274
|
+
}
|
|
275
|
+
if (frequencyMHz < 1500 || frequencyMHz > 2000) {
|
|
276
|
+
console.warn(`COST-231: frequency ${frequencyMHz} MHz outside valid range (1500-2000 MHz)`);
|
|
277
|
+
}
|
|
278
|
+
// Calculate mobile antenna height correction factor
|
|
279
|
+
// Using medium city formula (most common)
|
|
280
|
+
const a_hm = (1.1 * Math.log10(frequencyMHz) - 0.7) * mobileHeightM -
|
|
281
|
+
(1.56 * Math.log10(frequencyMHz) - 0.8);
|
|
282
|
+
// Environment correction factor
|
|
283
|
+
const C_m = isMetropolitan ? 3 : 0;
|
|
284
|
+
// COST-231 formula
|
|
285
|
+
const term1 = 46.3;
|
|
286
|
+
const term2 = 33.9 * Math.log10(frequencyMHz);
|
|
287
|
+
const term3 = 13.82 * Math.log10(antennaHeightM);
|
|
288
|
+
const term4 = (44.9 - 6.55 * Math.log10(antennaHeightM)) * Math.log10(distanceKm);
|
|
289
|
+
const pathLoss = term1 + term2 - term3 - a_hm + term4 + C_m;
|
|
290
|
+
return pathLoss;
|
|
291
|
+
}
|
|
292
|
+
// ============================================================================
|
|
293
|
+
// MODEL SELECTOR
|
|
294
|
+
// ============================================================================
|
|
295
|
+
/**
|
|
296
|
+
* Calculate path loss using specified model
|
|
297
|
+
*
|
|
298
|
+
* This is the main entry point for path loss calculations.
|
|
299
|
+
* It selects the appropriate model and parameters.
|
|
300
|
+
*
|
|
301
|
+
* Model selection guide:
|
|
302
|
+
*
|
|
303
|
+
* 1. Free Space (FSPL):
|
|
304
|
+
* - Best case scenario
|
|
305
|
+
* - Quick calculations
|
|
306
|
+
* - Microwave links
|
|
307
|
+
* - Line of sight paths
|
|
308
|
+
*
|
|
309
|
+
* 2. Hata:
|
|
310
|
+
* - Frequencies 150-1500 MHz
|
|
311
|
+
* - Good for 700 MHz, 850 MHz bands
|
|
312
|
+
* - Mature, well-tested model
|
|
313
|
+
*
|
|
314
|
+
* 3. COST-231:
|
|
315
|
+
* - Frequencies 1500-2000 MHz
|
|
316
|
+
* - Best for 1800 MHz, 1900 MHz, 2100 MHz
|
|
317
|
+
* - Modern cellular networks
|
|
318
|
+
*
|
|
319
|
+
* Default parameters:
|
|
320
|
+
* - Mobile height: 1.5m (typical phone height)
|
|
321
|
+
* - Environment: urban (conservative estimate)
|
|
322
|
+
*
|
|
323
|
+
* @param model - Path loss model to use
|
|
324
|
+
* @param distanceKm - Distance in km
|
|
325
|
+
* @param frequencyMHz - Frequency in MHz
|
|
326
|
+
* @param antennaHeightM - Antenna height in meters
|
|
327
|
+
* @param options - Additional options for specific models
|
|
328
|
+
* @returns Path loss in dB
|
|
329
|
+
*/
|
|
330
|
+
export function calculatePathLoss(model, distanceKm, frequencyMHz, antennaHeightM, options) {
|
|
331
|
+
switch (model) {
|
|
332
|
+
case 'free-space':
|
|
333
|
+
return calculateFSPL(distanceKm, frequencyMHz);
|
|
334
|
+
case 'hata-urban':
|
|
335
|
+
return calculateHata(distanceKm, frequencyMHz, antennaHeightM, options?.mobileHeightM || 1.5, 'urban', options?.citySize || 'medium');
|
|
336
|
+
case 'hata-suburban':
|
|
337
|
+
return calculateHata(distanceKm, frequencyMHz, antennaHeightM, options?.mobileHeightM || 1.5, 'suburban', options?.citySize || 'medium');
|
|
338
|
+
case 'cost231':
|
|
339
|
+
return calculateCOST231(distanceKm, frequencyMHz, antennaHeightM, options?.mobileHeightM || 1.5, options?.isMetropolitan || false);
|
|
340
|
+
default:
|
|
341
|
+
console.warn(`Unknown path loss model: ${model}, falling back to FSPL`);
|
|
342
|
+
return calculateFSPL(distanceKm, frequencyMHz);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
// ============================================================================
|
|
346
|
+
// UTILITY FUNCTIONS
|
|
347
|
+
// ============================================================================
|
|
348
|
+
/**
|
|
349
|
+
* Get recommended path loss model for given frequency
|
|
350
|
+
*
|
|
351
|
+
* @param frequencyMHz - Operating frequency in MHz
|
|
352
|
+
* @returns Recommended path loss model
|
|
353
|
+
*/
|
|
354
|
+
export function getRecommendedModel(frequencyMHz) {
|
|
355
|
+
if (frequencyMHz < 1500) {
|
|
356
|
+
return 'hata-urban'; // Use Hata for lower frequencies
|
|
357
|
+
}
|
|
358
|
+
else {
|
|
359
|
+
return 'cost231'; // Use COST-231 for higher frequencies
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Compare path loss across different models
|
|
364
|
+
*
|
|
365
|
+
* Useful for understanding model differences and uncertainty ranges.
|
|
366
|
+
*
|
|
367
|
+
* @param distanceKm - Distance
|
|
368
|
+
* @param frequencyMHz - Frequency
|
|
369
|
+
* @param antennaHeightM - Antenna height
|
|
370
|
+
* @returns Object with loss values for each model
|
|
371
|
+
*/
|
|
372
|
+
export function compareModels(distanceKm, frequencyMHz, antennaHeightM) {
|
|
373
|
+
return {
|
|
374
|
+
freeSpace: calculateFSPL(distanceKm, frequencyMHz),
|
|
375
|
+
hataUrban: calculateHata(distanceKm, frequencyMHz, antennaHeightM, 1.5, 'urban', 'medium'),
|
|
376
|
+
hataSuburban: calculateHata(distanceKm, frequencyMHz, antennaHeightM, 1.5, 'suburban', 'medium'),
|
|
377
|
+
hataRural: calculateHata(distanceKm, frequencyMHz, antennaHeightM, 1.5, 'rural', 'medium'),
|
|
378
|
+
cost231: calculateCOST231(distanceKm, frequencyMHz, antennaHeightM, 1.5, false)
|
|
379
|
+
};
|
|
380
|
+
}
|