@smartnet360/svelte-components 0.0.54 → 0.0.55

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 (79) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/index.js +2 -2
  3. package/dist/map-v2/core/controls/MapStyleControl.svelte +289 -0
  4. package/dist/map-v2/core/controls/MapStyleControl.svelte.d.ts +24 -0
  5. package/dist/{map → map-v2/core}/hooks/useMapbox.d.ts +1 -1
  6. package/dist/{map → map-v2/core}/hooks/useMapbox.js +1 -1
  7. package/dist/map-v2/core/index.d.ts +11 -0
  8. package/dist/map-v2/core/index.js +14 -0
  9. package/dist/map-v2/core/providers/MapboxProvider.svelte +140 -0
  10. package/dist/map-v2/core/providers/MapboxProvider.svelte.d.ts +33 -0
  11. package/dist/{map → map-v2/core}/stores/mapStore.d.ts +2 -2
  12. package/dist/{map → map-v2/core}/stores/mapStore.js +2 -2
  13. package/dist/map-v2/core/types.d.ts +13 -0
  14. package/dist/map-v2/core/types.js +7 -0
  15. package/dist/map-v2/demo/DemoMap.svelte +63 -0
  16. package/dist/{map → map-v2}/demo/DemoMap.svelte.d.ts +3 -4
  17. package/dist/map-v2/demo/demo-data.d.ts +8 -0
  18. package/dist/map-v2/demo/demo-data.js +128 -0
  19. package/dist/map-v2/demo/index.d.ts +7 -0
  20. package/dist/map-v2/demo/index.js +9 -0
  21. package/dist/{map → map-v2/features/sites}/controls/SiteFilterControl.svelte +26 -40
  22. package/dist/{map → map-v2/features/sites}/controls/SiteFilterControl.svelte.d.ts +4 -6
  23. package/dist/map-v2/features/sites/controls/SiteSizeSlider.svelte +185 -0
  24. package/dist/map-v2/features/sites/controls/SiteSizeSlider.svelte.d.ts +20 -0
  25. package/dist/map-v2/features/sites/index.d.ts +14 -0
  26. package/dist/map-v2/features/sites/index.js +16 -0
  27. package/dist/map-v2/features/sites/layers/SitesLayer.svelte +277 -0
  28. package/dist/map-v2/features/sites/layers/SitesLayer.svelte.d.ts +12 -0
  29. package/dist/map-v2/features/sites/stores/siteStore.d.ts +18 -0
  30. package/dist/map-v2/features/sites/stores/siteStore.js +36 -0
  31. package/dist/map-v2/features/sites/stores/siteStoreContext.svelte.d.ts +29 -0
  32. package/dist/map-v2/features/sites/stores/siteStoreContext.svelte.js +73 -0
  33. package/dist/map-v2/features/sites/types.d.ts +36 -0
  34. package/dist/map-v2/features/sites/types.js +4 -0
  35. package/dist/map-v2/features/sites/utils/siteGeoJSON.d.ts +31 -0
  36. package/dist/map-v2/features/sites/utils/siteGeoJSON.js +34 -0
  37. package/dist/map-v2/features/sites/utils/siteTreeUtils.d.ts +14 -0
  38. package/dist/{map → map-v2/features/sites}/utils/siteTreeUtils.js +3 -50
  39. package/dist/map-v2/index.d.ts +10 -0
  40. package/dist/map-v2/index.js +22 -0
  41. package/dist/{map → map-v2/shared}/controls/MapControl.svelte +1 -1
  42. package/dist/map-v2/shared/index.d.ts +7 -0
  43. package/dist/map-v2/shared/index.js +9 -0
  44. package/package.json +1 -1
  45. package/dist/map/demo/DemoMap.svelte +0 -98
  46. package/dist/map/demo/demo-data.d.ts +0 -12
  47. package/dist/map/demo/demo-data.js +0 -220
  48. package/dist/map/hooks/useCellData.d.ts +0 -14
  49. package/dist/map/hooks/useCellData.js +0 -29
  50. package/dist/map/index.d.ts +0 -27
  51. package/dist/map/index.js +0 -47
  52. package/dist/map/layers/CellsLayer.svelte +0 -242
  53. package/dist/map/layers/CellsLayer.svelte.d.ts +0 -21
  54. package/dist/map/layers/CoverageLayer.svelte +0 -37
  55. package/dist/map/layers/CoverageLayer.svelte.d.ts +0 -9
  56. package/dist/map/layers/LayerBase.d.ts +0 -42
  57. package/dist/map/layers/LayerBase.js +0 -58
  58. package/dist/map/layers/SitesLayer.svelte +0 -282
  59. package/dist/map/layers/SitesLayer.svelte.d.ts +0 -19
  60. package/dist/map/providers/CellDataProvider.svelte +0 -43
  61. package/dist/map/providers/CellDataProvider.svelte.d.ts +0 -12
  62. package/dist/map/providers/MapboxProvider.svelte +0 -38
  63. package/dist/map/providers/MapboxProvider.svelte.d.ts +0 -9
  64. package/dist/map/providers/providerHelpers.d.ts +0 -17
  65. package/dist/map/providers/providerHelpers.js +0 -26
  66. package/dist/map/stores/cellDataStore.d.ts +0 -21
  67. package/dist/map/stores/cellDataStore.js +0 -53
  68. package/dist/map/stores/interactions.d.ts +0 -20
  69. package/dist/map/stores/interactions.js +0 -33
  70. package/dist/map/types.d.ts +0 -115
  71. package/dist/map/types.js +0 -10
  72. package/dist/map/utils/geojson.d.ts +0 -20
  73. package/dist/map/utils/geojson.js +0 -78
  74. package/dist/map/utils/math.d.ts +0 -40
  75. package/dist/map/utils/math.js +0 -95
  76. package/dist/map/utils/siteTreeUtils.d.ts +0 -27
  77. /package/dist/{map → map-v2/shared}/controls/MapControl.svelte.d.ts +0 -0
  78. /package/dist/{map → map-v2/shared}/utils/mapboxHelpers.d.ts +0 -0
  79. /package/dist/{map → map-v2/shared}/utils/mapboxHelpers.js +0 -0
@@ -1,19 +0,0 @@
1
- interface Props {
2
- /** Namespace for layer IDs (default: 'cellular') */
3
- namespace?: string;
4
- /** Enable click to select sites (default: true) */
5
- clickable?: boolean;
6
- /** Show popup on click (default: true) */
7
- showPopup?: boolean;
8
- /** Site circle radius (default: 8) */
9
- circleRadius?: number;
10
- /** Site circle color (default: '#3b82f6') */
11
- circleColor?: string;
12
- /** Selected site color (default: '#ef4444') */
13
- selectedColor?: string;
14
- /** Hovered site color (default: '#8b5cf6') */
15
- hoverColor?: string;
16
- }
17
- declare const SitesLayer: import("svelte").Component<Props, {}, "">;
18
- type SitesLayer = ReturnType<typeof SitesLayer>;
19
- export default SitesLayer;
@@ -1,43 +0,0 @@
1
- <script lang="ts">
2
- /**
3
- * CellDataProvider - Provides cellular data (sites, cells) and interaction state to child components
4
- *
5
- * Usage:
6
- * <CellDataProvider {sites} {cells}>
7
- * <SitesLayer />
8
- * <CellsLayer />
9
- * </CellDataProvider>
10
- */
11
- import { setContext } from 'svelte';
12
- import type { Site, Cell } from '../types';
13
- import { CELL_DATA_CONTEXT_KEY } from '../types';
14
- import { createCellDataStores } from '../stores/cellDataStore';
15
-
16
- interface Props {
17
- /** Array of cellular sites */
18
- sites?: Site[];
19
- /** Array of cellular cells/sectors */
20
- cells?: Cell[];
21
- /** Optional child content */
22
- children?: import('svelte').Snippet;
23
- }
24
-
25
- let { sites = [], cells = [], children }: Props = $props();
26
-
27
- // Create and set the cell data context in context
28
- const cellDataContext = createCellDataStores(sites, cells);
29
- setContext(CELL_DATA_CONTEXT_KEY, cellDataContext);
30
-
31
- // Update stores when props change
32
- $effect(() => {
33
- cellDataContext.sites.set(sites);
34
- });
35
-
36
- $effect(() => {
37
- cellDataContext.cells.set(cells);
38
- });
39
- </script>
40
-
41
- {#if children}
42
- {@render children()}
43
- {/if}
@@ -1,12 +0,0 @@
1
- import type { Site, Cell } from '../types';
2
- interface Props {
3
- /** Array of cellular sites */
4
- sites?: Site[];
5
- /** Array of cellular cells/sectors */
6
- cells?: Cell[];
7
- /** Optional child content */
8
- children?: import('svelte').Snippet;
9
- }
10
- declare const CellDataProvider: import("svelte").Component<Props, {}, "">;
11
- type CellDataProvider = ReturnType<typeof CellDataProvider>;
12
- export default CellDataProvider;
@@ -1,38 +0,0 @@
1
- <script lang="ts">
2
- /**
3
- * MapboxProvider - Provides Mapbox GL JS map instance to child components via context
4
- *
5
- * Usage:
6
- * <MapboxProvider {mapInstance}>
7
- * <SitesLayer />
8
- * <CellsLayer />
9
- * </MapboxProvider>
10
- */
11
- import { setContext } from 'svelte';
12
- import type mapboxgl from 'mapbox-gl';
13
- import { MAP_CONTEXT_KEY } from '../types';
14
- import { createMapStore } from '../stores/mapStore';
15
-
16
- interface Props {
17
- /** The Mapbox GL JS map instance */
18
- mapInstance: mapboxgl.Map;
19
- /** Optional child content */
20
- children?: import('svelte').Snippet;
21
- }
22
-
23
- let { mapInstance, children }: Props = $props();
24
-
25
- // Create and set the map store in context
26
- const mapStore = createMapStore();
27
- setContext(MAP_CONTEXT_KEY, mapStore);
28
-
29
- // Update the store whenever the map instance changes
30
- $effect(() => {
31
- console.log('MapboxProvider: Setting map instance', mapInstance);
32
- mapStore.set(mapInstance);
33
- });
34
- </script>
35
-
36
- {#if children}
37
- {@render children()}
38
- {/if}
@@ -1,9 +0,0 @@
1
- interface Props {
2
- /** The Mapbox GL JS map instance */
3
- mapInstance: mapboxgl.Map;
4
- /** Optional child content */
5
- children?: import('svelte').Snippet;
6
- }
7
- declare const MapboxProvider: import("svelte").Component<Props, {}, "">;
8
- type MapboxProvider = ReturnType<typeof MapboxProvider>;
9
- export default MapboxProvider;
@@ -1,17 +0,0 @@
1
- /**
2
- * Provider helper utilities
3
- */
4
- import type { MapStore } from '../types';
5
- import type { Site, Cell, CellDataContext } from '../types';
6
- /**
7
- * Creates a new map store instance
8
- */
9
- export declare function createMap(): MapStore;
10
- /**
11
- * Creates a new cell data context
12
- */
13
- export declare function createCellContext(sites?: Site[], cells?: Cell[]): CellDataContext;
14
- /**
15
- * Validates that a map instance is ready for use
16
- */
17
- export declare function isMapReady(map: unknown): boolean;
@@ -1,26 +0,0 @@
1
- /**
2
- * Provider helper utilities
3
- */
4
- import { createMapStore } from '../stores/mapStore';
5
- import { createCellDataStores } from '../stores/cellDataStore';
6
- /**
7
- * Creates a new map store instance
8
- */
9
- export function createMap() {
10
- return createMapStore();
11
- }
12
- /**
13
- * Creates a new cell data context
14
- */
15
- export function createCellContext(sites = [], cells = []) {
16
- return createCellDataStores(sites, cells);
17
- }
18
- /**
19
- * Validates that a map instance is ready for use
20
- */
21
- export function isMapReady(map) {
22
- if (!map)
23
- return false;
24
- // Check if it has the basic Mapbox GL Map interface
25
- return typeof map.getStyle === 'function';
26
- }
@@ -1,21 +0,0 @@
1
- /**
2
- * Store factory and utilities for cellular data
3
- */
4
- import type { Writable, Readable } from 'svelte/store';
5
- import type { Site, Cell, CellDataContext } from '../types';
6
- /**
7
- * Creates a complete cell data context with all required stores
8
- */
9
- export declare function createCellDataStores(initialSites?: Site[], initialCells?: Cell[]): CellDataContext;
10
- /**
11
- * Creates a derived store that filters cells by site ID
12
- */
13
- export declare function createCellsBySiteStore(cells: Writable<Cell[]>, siteId: Writable<string | null>): Readable<Cell[]>;
14
- /**
15
- * Creates a derived store for the currently selected site
16
- */
17
- export declare function createSelectedSiteStore(sites: Writable<Site[]>, selectedSiteId: Writable<string | null>): Readable<Site | null>;
18
- /**
19
- * Creates a derived store for the currently selected cell
20
- */
21
- export declare function createSelectedCellStore(cells: Writable<Cell[]>, selectedCellId: Writable<string | null>): Readable<Cell | null>;
@@ -1,53 +0,0 @@
1
- /**
2
- * Store factory and utilities for cellular data
3
- */
4
- import { writable, derived } from 'svelte/store';
5
- /**
6
- * Creates a complete cell data context with all required stores
7
- */
8
- export function createCellDataStores(initialSites = [], initialCells = []) {
9
- const sites = writable(initialSites);
10
- const cells = writable(initialCells);
11
- const selectedSiteId = writable(null);
12
- const selectedCellId = writable(null);
13
- const hoveredSiteId = writable(null);
14
- const hoveredCellId = writable(null);
15
- return {
16
- sites,
17
- cells,
18
- selectedSiteId,
19
- selectedCellId,
20
- hoveredSiteId,
21
- hoveredCellId
22
- };
23
- }
24
- /**
25
- * Creates a derived store that filters cells by site ID
26
- */
27
- export function createCellsBySiteStore(cells, siteId) {
28
- return derived([cells, siteId], ([$cells, $siteId]) => {
29
- if (!$siteId)
30
- return [];
31
- return $cells.filter((cell) => cell.siteId === $siteId);
32
- });
33
- }
34
- /**
35
- * Creates a derived store for the currently selected site
36
- */
37
- export function createSelectedSiteStore(sites, selectedSiteId) {
38
- return derived([sites, selectedSiteId], ([$sites, $selectedSiteId]) => {
39
- if (!$selectedSiteId)
40
- return null;
41
- return $sites.find((site) => site.id === $selectedSiteId) ?? null;
42
- });
43
- }
44
- /**
45
- * Creates a derived store for the currently selected cell
46
- */
47
- export function createSelectedCellStore(cells, selectedCellId) {
48
- return derived([cells, selectedCellId], ([$cells, $selectedCellId]) => {
49
- if (!$selectedCellId)
50
- return null;
51
- return $cells.find((cell) => cell.id === $selectedCellId) ?? null;
52
- });
53
- }
@@ -1,20 +0,0 @@
1
- /**
2
- * Interaction state utilities and helpers
3
- */
4
- import type { Writable } from 'svelte/store';
5
- /**
6
- * Helper to clear all selections
7
- */
8
- export declare function clearSelections(selectedSiteId: Writable<string | null>, selectedCellId: Writable<string | null>): void;
9
- /**
10
- * Helper to clear all hover states
11
- */
12
- export declare function clearHovers(hoveredSiteId: Writable<string | null>, hoveredCellId: Writable<string | null>): void;
13
- /**
14
- * Helper to select a site and clear cell selection
15
- */
16
- export declare function selectSite(siteId: string | null, selectedSiteId: Writable<string | null>, selectedCellId: Writable<string | null>): void;
17
- /**
18
- * Helper to select a cell (and optionally its parent site)
19
- */
20
- export declare function selectCell(cellId: string | null, selectedCellId: Writable<string | null>, parentSiteId?: string | null, selectedSiteId?: Writable<string | null>): void;
@@ -1,33 +0,0 @@
1
- /**
2
- * Interaction state utilities and helpers
3
- */
4
- /**
5
- * Helper to clear all selections
6
- */
7
- export function clearSelections(selectedSiteId, selectedCellId) {
8
- selectedSiteId.set(null);
9
- selectedCellId.set(null);
10
- }
11
- /**
12
- * Helper to clear all hover states
13
- */
14
- export function clearHovers(hoveredSiteId, hoveredCellId) {
15
- hoveredSiteId.set(null);
16
- hoveredCellId.set(null);
17
- }
18
- /**
19
- * Helper to select a site and clear cell selection
20
- */
21
- export function selectSite(siteId, selectedSiteId, selectedCellId) {
22
- selectedSiteId.set(siteId);
23
- selectedCellId.set(null);
24
- }
25
- /**
26
- * Helper to select a cell (and optionally its parent site)
27
- */
28
- export function selectCell(cellId, selectedCellId, parentSiteId, selectedSiteId) {
29
- selectedCellId.set(cellId);
30
- if (selectedSiteId && parentSiteId !== undefined) {
31
- selectedSiteId.set(parentSiteId);
32
- }
33
- }
@@ -1,115 +0,0 @@
1
- /**
2
- * Core types for Mapbox cellular visualization components
3
- */
4
- import type { Writable } from 'svelte/store';
5
- /** Context key for the Mapbox instance store */
6
- export declare const MAP_CONTEXT_KEY: unique symbol;
7
- /** Context key for the cell data stores */
8
- export declare const CELL_DATA_CONTEXT_KEY: unique symbol;
9
- /**
10
- * Represents a cellular site/tower location
11
- */
12
- export interface Site {
13
- /** Unique identifier for the site */
14
- id: string;
15
- /** Human-readable site name */
16
- name: string;
17
- /** Latitude (WGS84) */
18
- latitude: number;
19
- /** Longitude (WGS84) */
20
- longitude: number;
21
- /** Frequency bands */
22
- fbands?: string[];
23
- /** Technology (e.g., '4G', '5G', 'LTE') */
24
- technology: string;
25
- /** Additional properties */
26
- properties: Record<string, any>;
27
- /** Array of cell names at this site */
28
- cellNames: string[];
29
- /** Source or owning organization (e.g. 'Vodafone', 'France Telecom') */
30
- provider: string;
31
- /** Sub-classification used for TreeView grouping for level2 grouping */
32
- featureGroup: string;
33
- }
34
- /**
35
- * Represents a cellular sector/cell with coverage area
36
- */
37
- export interface Cell {
38
- /** Unique identifier for the cell */
39
- id: string;
40
- /** ID of the parent site */
41
- siteId: string;
42
- /** Sector number (e.g., 1, 2, 3) */
43
- sector?: number;
44
- /** Azimuth/bearing in degrees (0-360, where 0 is North) */
45
- azimuth: number;
46
- /** Beamwidth/aperture in degrees (e.g., 65, 120) */
47
- beamwidth: number;
48
- /** Coverage radius in meters (default: 500) */
49
- radius?: number;
50
- /** Optional additional properties (band, technology, etc.) */
51
- properties?: Record<string, unknown>;
52
- }
53
- /**
54
- * User interaction state (selection, hover)
55
- */
56
- export interface InteractionState {
57
- /** Currently selected site ID */
58
- selectedSiteId: string | null;
59
- /** Currently selected cell ID */
60
- selectedCellId: string | null;
61
- /** Currently hovered site ID */
62
- hoveredSiteId: string | null;
63
- /** Currently hovered cell ID */
64
- hoveredCellId: string | null;
65
- }
66
- /**
67
- * Map instance store provided by MapboxProvider
68
- */
69
- export type MapStore = Writable<mapboxgl.Map | null>;
70
- /**
71
- * Cell data context stores provided by CellDataProvider
72
- */
73
- export interface CellDataContext {
74
- /** Store containing all sites */
75
- sites: Writable<Site[]>;
76
- /** Store containing all cells */
77
- cells: Writable<Cell[]>;
78
- /** Store for selected site ID */
79
- selectedSiteId: Writable<string | null>;
80
- /** Store for selected cell ID */
81
- selectedCellId: Writable<string | null>;
82
- /** Store for hovered site ID */
83
- hoveredSiteId: Writable<string | null>;
84
- /** Store for hovered cell ID */
85
- hoveredCellId: Writable<string | null>;
86
- }
87
- /**
88
- * GeoJSON Point Feature for a site
89
- */
90
- export interface SiteFeature {
91
- type: 'Feature';
92
- geometry: {
93
- type: 'Point';
94
- coordinates: [number, number];
95
- };
96
- properties: Site;
97
- }
98
- /**
99
- * GeoJSON Polygon Feature for a cell sector
100
- */
101
- export interface CellFeature {
102
- type: 'Feature';
103
- geometry: {
104
- type: 'Polygon';
105
- coordinates: number[][][];
106
- };
107
- properties: Cell;
108
- }
109
- /**
110
- * GeoJSON FeatureCollection
111
- */
112
- export interface FeatureCollection<T> {
113
- type: 'FeatureCollection';
114
- features: T[];
115
- }
package/dist/map/types.js DELETED
@@ -1,10 +0,0 @@
1
- /**
2
- * Core types for Mapbox cellular visualization components
3
- */
4
- // ============================================================================
5
- // Context Keys
6
- // ============================================================================
7
- /** Context key for the Mapbox instance store */
8
- export const MAP_CONTEXT_KEY = Symbol('mapbox-instance');
9
- /** Context key for the cell data stores */
10
- export const CELL_DATA_CONTEXT_KEY = Symbol('cell-data');
@@ -1,20 +0,0 @@
1
- /**
2
- * GeoJSON conversion utilities for sites and cells
3
- */
4
- import type { Site, Cell, SiteFeature, CellFeature, FeatureCollection } from '../types';
5
- /**
6
- * Converts an array of sites to a GeoJSON FeatureCollection
7
- */
8
- export declare function sitesToGeoJSON(sites: Site[]): FeatureCollection<SiteFeature>;
9
- /**
10
- * Converts an array of cells to a GeoJSON FeatureCollection of polygons
11
- */
12
- export declare function cellsToGeoJSON(cells: Cell[], sites: Site[], defaultRadius?: number): FeatureCollection<CellFeature>;
13
- /**
14
- * Converts a single site to a GeoJSON Feature
15
- */
16
- export declare function siteToFeature(site: Site): SiteFeature;
17
- /**
18
- * Converts a single cell to a GeoJSON Feature (requires parent site for location)
19
- */
20
- export declare function cellToFeature(cell: Cell, site: Site, defaultRadius?: number): CellFeature | null;
@@ -1,78 +0,0 @@
1
- /**
2
- * GeoJSON conversion utilities for sites and cells
3
- */
4
- import { createSectorPolygon } from './math';
5
- /**
6
- * Converts an array of sites to a GeoJSON FeatureCollection
7
- */
8
- export function sitesToGeoJSON(sites) {
9
- const features = sites.map((site) => ({
10
- type: 'Feature',
11
- geometry: {
12
- type: 'Point',
13
- coordinates: [site.longitude, site.latitude]
14
- },
15
- properties: site
16
- }));
17
- return {
18
- type: 'FeatureCollection',
19
- features
20
- };
21
- }
22
- /**
23
- * Converts an array of cells to a GeoJSON FeatureCollection of polygons
24
- */
25
- export function cellsToGeoJSON(cells, sites, defaultRadius = 500) {
26
- // Create a map for fast site lookup
27
- const siteMap = new Map(sites.map((site) => [site.id, site]));
28
- const features = [];
29
- for (const cell of cells) {
30
- const site = siteMap.get(cell.siteId);
31
- if (!site) {
32
- console.warn(`Cell ${cell.id} references unknown site ${cell.siteId}`);
33
- continue;
34
- }
35
- const radius = cell.radius ?? defaultRadius;
36
- const coordinates = createSectorPolygon(site.longitude, site.latitude, cell.azimuth, cell.beamwidth, radius);
37
- features.push({
38
- type: 'Feature',
39
- geometry: {
40
- type: 'Polygon',
41
- coordinates: [coordinates]
42
- },
43
- properties: cell
44
- });
45
- }
46
- return {
47
- type: 'FeatureCollection',
48
- features
49
- };
50
- }
51
- /**
52
- * Converts a single site to a GeoJSON Feature
53
- */
54
- export function siteToFeature(site) {
55
- return {
56
- type: 'Feature',
57
- geometry: {
58
- type: 'Point',
59
- coordinates: [site.longitude, site.latitude]
60
- },
61
- properties: site
62
- };
63
- }
64
- /**
65
- * Converts a single cell to a GeoJSON Feature (requires parent site for location)
66
- */
67
- export function cellToFeature(cell, site, defaultRadius = 500) {
68
- const radius = cell.radius ?? defaultRadius;
69
- const coordinates = createSectorPolygon(site.longitude, site.latitude, cell.azimuth, cell.beamwidth, radius);
70
- return {
71
- type: 'Feature',
72
- geometry: {
73
- type: 'Polygon',
74
- coordinates: [coordinates]
75
- },
76
- properties: cell
77
- };
78
- }
@@ -1,40 +0,0 @@
1
- /**
2
- * Mathematical utilities for cellular sector geometry
3
- */
4
- /**
5
- * Calculates the destination point given start point, bearing, and distance
6
- * Uses Haversine formula
7
- *
8
- * @param lon - Starting longitude
9
- * @param lat - Starting latitude
10
- * @param bearing - Bearing in degrees (0 = North, 90 = East)
11
- * @param distance - Distance in meters
12
- * @returns [lon, lat] of destination point
13
- */
14
- export declare function destinationPoint(lon: number, lat: number, bearing: number, distance: number): [number, number];
15
- /**
16
- * Creates a polygon representing a cellular sector
17
- *
18
- * @param centerLon - Center point longitude
19
- * @param centerLat - Center point latitude
20
- * @param azimuth - Sector azimuth/bearing in degrees (0-360, where 0 is North)
21
- * @param beamwidth - Sector beamwidth in degrees (e.g., 65, 120)
22
- * @param radius - Sector radius in meters
23
- * @param arcPoints - Number of points to use for the arc (default: 32)
24
- * @returns Array of [lon, lat] coordinates forming a closed polygon
25
- */
26
- export declare function createSectorPolygon(centerLon: number, centerLat: number, azimuth: number, beamwidth: number, radius: number, arcPoints?: number): [number, number][];
27
- /**
28
- * Creates a circle polygon (360-degree sector)
29
- *
30
- * @param centerLon - Center point longitude
31
- * @param centerLat - Center point latitude
32
- * @param radius - Circle radius in meters
33
- * @param points - Number of points to use for the circle (default: 64)
34
- * @returns Array of [lon, lat] coordinates forming a closed polygon
35
- */
36
- export declare function createCirclePolygon(centerLon: number, centerLat: number, radius: number, points?: number): [number, number][];
37
- /**
38
- * Normalizes an azimuth to 0-360 range
39
- */
40
- export declare function normalizeAzimuth(azimuth: number): number;
@@ -1,95 +0,0 @@
1
- /**
2
- * Mathematical utilities for cellular sector geometry
3
- */
4
- /**
5
- * Converts degrees to radians
6
- */
7
- function toRadians(degrees) {
8
- return (degrees * Math.PI) / 180;
9
- }
10
- /**
11
- * Converts radians to degrees
12
- */
13
- function toDegrees(radians) {
14
- return (radians * 180) / Math.PI;
15
- }
16
- /**
17
- * Calculates the destination point given start point, bearing, and distance
18
- * Uses Haversine formula
19
- *
20
- * @param lon - Starting longitude
21
- * @param lat - Starting latitude
22
- * @param bearing - Bearing in degrees (0 = North, 90 = East)
23
- * @param distance - Distance in meters
24
- * @returns [lon, lat] of destination point
25
- */
26
- export function destinationPoint(lon, lat, bearing, distance) {
27
- const R = 6371e3; // Earth radius in meters
28
- const δ = distance / R; // Angular distance
29
- const θ = toRadians(bearing);
30
- const φ1 = toRadians(lat);
31
- const λ1 = toRadians(lon);
32
- const φ2 = Math.asin(Math.sin(φ1) * Math.cos(δ) + Math.cos(φ1) * Math.sin(δ) * Math.cos(θ));
33
- const λ2 = λ1 +
34
- Math.atan2(Math.sin(θ) * Math.sin(δ) * Math.cos(φ1), Math.cos(δ) - Math.sin(φ1) * Math.sin(φ2));
35
- return [toDegrees(λ2), toDegrees(φ2)];
36
- }
37
- /**
38
- * Creates a polygon representing a cellular sector
39
- *
40
- * @param centerLon - Center point longitude
41
- * @param centerLat - Center point latitude
42
- * @param azimuth - Sector azimuth/bearing in degrees (0-360, where 0 is North)
43
- * @param beamwidth - Sector beamwidth in degrees (e.g., 65, 120)
44
- * @param radius - Sector radius in meters
45
- * @param arcPoints - Number of points to use for the arc (default: 32)
46
- * @returns Array of [lon, lat] coordinates forming a closed polygon
47
- */
48
- export function createSectorPolygon(centerLon, centerLat, azimuth, beamwidth, radius, arcPoints = 32) {
49
- const coordinates = [];
50
- // Start at the center point
51
- coordinates.push([centerLon, centerLat]);
52
- // Calculate start and end bearings
53
- const startBearing = azimuth - beamwidth / 2;
54
- const endBearing = azimuth + beamwidth / 2;
55
- // Generate arc points
56
- const angleStep = beamwidth / (arcPoints - 1);
57
- for (let i = 0; i < arcPoints; i++) {
58
- const bearing = startBearing + angleStep * i;
59
- const point = destinationPoint(centerLon, centerLat, bearing, radius);
60
- coordinates.push(point);
61
- }
62
- // Close the polygon by returning to center
63
- coordinates.push([centerLon, centerLat]);
64
- return coordinates;
65
- }
66
- /**
67
- * Creates a circle polygon (360-degree sector)
68
- *
69
- * @param centerLon - Center point longitude
70
- * @param centerLat - Center point latitude
71
- * @param radius - Circle radius in meters
72
- * @param points - Number of points to use for the circle (default: 64)
73
- * @returns Array of [lon, lat] coordinates forming a closed polygon
74
- */
75
- export function createCirclePolygon(centerLon, centerLat, radius, points = 64) {
76
- const coordinates = [];
77
- const angleStep = 360 / points;
78
- for (let i = 0; i < points; i++) {
79
- const bearing = angleStep * i;
80
- const point = destinationPoint(centerLon, centerLat, bearing, radius);
81
- coordinates.push(point);
82
- }
83
- // Close the polygon
84
- coordinates.push(coordinates[0]);
85
- return coordinates;
86
- }
87
- /**
88
- * Normalizes an azimuth to 0-360 range
89
- */
90
- export function normalizeAzimuth(azimuth) {
91
- let normalized = azimuth % 360;
92
- if (normalized < 0)
93
- normalized += 360;
94
- return normalized;
95
- }