@happyvertical/smrt-places 0.51.32 → 0.51.34
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/__smrt-register__.d.ts +2 -0
- package/dist/__smrt-register__.d.ts.map +1 -0
- package/dist/collections/PlaceAssetCollection.d.ts +17 -0
- package/dist/collections/PlaceAssetCollection.d.ts.map +1 -0
- package/dist/collections/PlaceCollection.d.ts +211 -0
- package/dist/collections/PlaceCollection.d.ts.map +1 -0
- package/dist/collections/PlaceTypeCollection.d.ts +41 -0
- package/dist/collections/PlaceTypeCollection.d.ts.map +1 -0
- package/dist/index.d.ts +18 -613
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -1
- package/dist/manifest.json +1 -1
- package/dist/models/Place.d.ts +76 -0
- package/dist/models/Place.d.ts.map +1 -0
- package/dist/models/PlaceAsset.d.ts +18 -0
- package/dist/models/PlaceAsset.d.ts.map +1 -0
- package/dist/models/PlaceType.d.ts +22 -0
- package/dist/models/PlaceType.d.ts.map +1 -0
- package/dist/smrt-knowledge.json +4 -4
- package/dist/types.d.ts +166 -253
- package/dist/types.d.ts.map +1 -0
- package/dist/utils.d.ts +90 -113
- package/dist/utils.d.ts.map +1 -0
- package/package.json +6 -6
package/dist/types.d.ts
CHANGED
|
@@ -1,253 +1,166 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { SmrtObjectOptions } from '@happyvertical/smrt-core';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
parentId?: string | null;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
*
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
postalCode?: string;
|
|
168
|
-
countryCode?: string;
|
|
169
|
-
timezone?: string;
|
|
170
|
-
externalId?: string;
|
|
171
|
-
source?: string;
|
|
172
|
-
metadata?: Record<string, unknown> | string;
|
|
173
|
-
createdAt?: Date;
|
|
174
|
-
updatedAt?: Date;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
declare class PlaceType extends SmrtObject {
|
|
178
|
-
name: string;
|
|
179
|
-
description?: string;
|
|
180
|
-
createdAt: Date;
|
|
181
|
-
updatedAt: Date;
|
|
182
|
-
constructor(options?: PlaceTypeOptions);
|
|
183
|
-
/**
|
|
184
|
-
* Convenience method for slug-based lookup
|
|
185
|
-
*
|
|
186
|
-
* @param slug - The slug to search for
|
|
187
|
-
* @returns PlaceType instance or null if not found
|
|
188
|
-
*/
|
|
189
|
-
static getBySlug(_slug: string): Promise<PlaceType | null>;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* Options for creating/updating a PlaceType
|
|
194
|
-
*/
|
|
195
|
-
export declare interface PlaceTypeOptions extends SmrtObjectOptions {
|
|
196
|
-
id?: string;
|
|
197
|
-
slug?: string;
|
|
198
|
-
name?: string;
|
|
199
|
-
description?: string;
|
|
200
|
-
createdAt?: Date;
|
|
201
|
-
updatedAt?: Date;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* Options for `PlaceCollection.resolveTrackPlaces`. Extends
|
|
206
|
-
* `DiscoverNearbyOptions` with per-track knobs that control how the track
|
|
207
|
-
* is bucketed + throttled before hitting the geo provider.
|
|
208
|
-
*/
|
|
209
|
-
export declare interface ResolveTrackPlacesOptions extends DiscoverNearbyOptions {
|
|
210
|
-
/**
|
|
211
|
-
* Per-point POI search radius in meters. Default 50.
|
|
212
|
-
*/
|
|
213
|
-
radiusMeters?: number;
|
|
214
|
-
/**
|
|
215
|
-
* Collapse points within this distance (m) into a single bucket so we
|
|
216
|
-
* don't re-query the same ~50m area dozens of times for a slow drive-by.
|
|
217
|
-
* Default 50.
|
|
218
|
-
*/
|
|
219
|
-
bucketMeters?: number;
|
|
220
|
-
/**
|
|
221
|
-
* Minimum delay between provider requests. Default 1100ms — safely above
|
|
222
|
-
* OSM's 1 req/sec community limit. Google can usually handle faster; set
|
|
223
|
-
* to 100ms or less for paid tiers.
|
|
224
|
-
*/
|
|
225
|
-
throttleMs?: number;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* Result of `PlaceCollection.resolveTrackPlaces`. Tracks are typically
|
|
230
|
-
* long-running operations so the return payload includes counters that let
|
|
231
|
-
* callers surface progress or estimate cost without re-walking.
|
|
232
|
-
*/
|
|
233
|
-
export declare interface TrackPlacesResult {
|
|
234
|
-
/** De-duplicated Place rows touched during resolution. */
|
|
235
|
-
places: Place[];
|
|
236
|
-
/** Number of provider requests issued. */
|
|
237
|
-
requestCount: number;
|
|
238
|
-
/** Number of bucketed points that reused existing Place rows. */
|
|
239
|
-
cacheHitCount: number;
|
|
240
|
-
/** Number of distinct geographic buckets walked. */
|
|
241
|
-
bucketCount: number;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* A single point along a track. Matches the `{ lat, lng }` convention used
|
|
246
|
-
* by `LookupOrCreateOptions.coords` so callers don't have to shuffle shapes.
|
|
247
|
-
*/
|
|
248
|
-
export declare interface TrackPoint {
|
|
249
|
-
lat: number;
|
|
250
|
-
lng: number;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
export { }
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for @have/places package
|
|
3
|
+
*/
|
|
4
|
+
import type { SmrtObjectOptions } from '@happyvertical/smrt-core';
|
|
5
|
+
import type { Place } from './models/Place';
|
|
6
|
+
/**
|
|
7
|
+
* Geographic data structure
|
|
8
|
+
* All fields optional to support both real-world and abstract places
|
|
9
|
+
*/
|
|
10
|
+
export interface GeoData {
|
|
11
|
+
latitude: number | null;
|
|
12
|
+
longitude: number | null;
|
|
13
|
+
streetNumber?: string;
|
|
14
|
+
streetName?: string;
|
|
15
|
+
city?: string;
|
|
16
|
+
region?: string;
|
|
17
|
+
country?: string;
|
|
18
|
+
postalCode?: string;
|
|
19
|
+
countryCode?: string;
|
|
20
|
+
timezone?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Options for creating/updating a Place
|
|
24
|
+
*/
|
|
25
|
+
export interface PlaceOptions extends SmrtObjectOptions {
|
|
26
|
+
id?: string;
|
|
27
|
+
tenantId?: string | null;
|
|
28
|
+
typeId?: string;
|
|
29
|
+
parentId?: string | null;
|
|
30
|
+
name?: string;
|
|
31
|
+
description?: string;
|
|
32
|
+
latitude?: number | null;
|
|
33
|
+
longitude?: number | null;
|
|
34
|
+
streetNumber?: string;
|
|
35
|
+
streetName?: string;
|
|
36
|
+
city?: string;
|
|
37
|
+
region?: string;
|
|
38
|
+
country?: string;
|
|
39
|
+
postalCode?: string;
|
|
40
|
+
countryCode?: string;
|
|
41
|
+
timezone?: string;
|
|
42
|
+
externalId?: string;
|
|
43
|
+
source?: string;
|
|
44
|
+
metadata?: Record<string, unknown> | string;
|
|
45
|
+
createdAt?: Date;
|
|
46
|
+
updatedAt?: Date;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Options for creating/updating a PlaceType
|
|
50
|
+
*/
|
|
51
|
+
export interface PlaceTypeOptions extends SmrtObjectOptions {
|
|
52
|
+
id?: string;
|
|
53
|
+
slug?: string;
|
|
54
|
+
name?: string;
|
|
55
|
+
description?: string;
|
|
56
|
+
createdAt?: Date;
|
|
57
|
+
updatedAt?: Date;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Options for lookupOrCreate method
|
|
61
|
+
*/
|
|
62
|
+
export interface LookupOrCreateOptions {
|
|
63
|
+
/**
|
|
64
|
+
* Which geo provider to use for lookups
|
|
65
|
+
*/
|
|
66
|
+
geoProvider?: 'google' | 'openstreetmap';
|
|
67
|
+
/**
|
|
68
|
+
* Force a specific place type
|
|
69
|
+
*/
|
|
70
|
+
typeSlug?: string;
|
|
71
|
+
/**
|
|
72
|
+
* Set parent place if known
|
|
73
|
+
*/
|
|
74
|
+
parentId?: string | null;
|
|
75
|
+
/**
|
|
76
|
+
* Whether to create if not found (default: true)
|
|
77
|
+
*/
|
|
78
|
+
createIfNotFound?: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Coordinates for reverse geocoding
|
|
81
|
+
*/
|
|
82
|
+
coords?: {
|
|
83
|
+
lat: number;
|
|
84
|
+
lng: number;
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Place hierarchy structure
|
|
89
|
+
*/
|
|
90
|
+
export interface PlaceHierarchy {
|
|
91
|
+
ancestors: Place[];
|
|
92
|
+
current: Place;
|
|
93
|
+
descendants: Place[];
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Options for `PlaceCollection.discoverNearby`. Mirrors the inputs to
|
|
97
|
+
* `@happyvertical/geo`'s `findPoisNear` plus a couple of persistence knobs
|
|
98
|
+
* (PlaceType override, parent linkage) to match `lookupOrCreate`'s shape.
|
|
99
|
+
*/
|
|
100
|
+
export interface DiscoverNearbyOptions {
|
|
101
|
+
/** Which geo provider to use. Defaults to openstreetmap. */
|
|
102
|
+
geoProvider?: 'google' | 'openstreetmap';
|
|
103
|
+
/**
|
|
104
|
+
* POI category filter, forwarded to the provider. See
|
|
105
|
+
* `@happyvertical/geo`'s `PoiSearchOptions.types` for provider-specific
|
|
106
|
+
* interpretation.
|
|
107
|
+
*/
|
|
108
|
+
types?: string[];
|
|
109
|
+
/** Free-text keyword filter (provider-dependent; Google only). */
|
|
110
|
+
keyword?: string;
|
|
111
|
+
/** Max results per provider call. Default 20. */
|
|
112
|
+
limit?: number;
|
|
113
|
+
/** Preferred language for place names (Google only). */
|
|
114
|
+
language?: string;
|
|
115
|
+
/** Override the PlaceType slug assigned to created rows. */
|
|
116
|
+
typeSlug?: string;
|
|
117
|
+
/** Set parent place on created rows. */
|
|
118
|
+
parentId?: string | null;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* A single point along a track. Matches the `{ lat, lng }` convention used
|
|
122
|
+
* by `LookupOrCreateOptions.coords` so callers don't have to shuffle shapes.
|
|
123
|
+
*/
|
|
124
|
+
export interface TrackPoint {
|
|
125
|
+
lat: number;
|
|
126
|
+
lng: number;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Options for `PlaceCollection.resolveTrackPlaces`. Extends
|
|
130
|
+
* `DiscoverNearbyOptions` with per-track knobs that control how the track
|
|
131
|
+
* is bucketed + throttled before hitting the geo provider.
|
|
132
|
+
*/
|
|
133
|
+
export interface ResolveTrackPlacesOptions extends DiscoverNearbyOptions {
|
|
134
|
+
/**
|
|
135
|
+
* Per-point POI search radius in meters. Default 50.
|
|
136
|
+
*/
|
|
137
|
+
radiusMeters?: number;
|
|
138
|
+
/**
|
|
139
|
+
* Collapse points within this distance (m) into a single bucket so we
|
|
140
|
+
* don't re-query the same ~50m area dozens of times for a slow drive-by.
|
|
141
|
+
* Default 50.
|
|
142
|
+
*/
|
|
143
|
+
bucketMeters?: number;
|
|
144
|
+
/**
|
|
145
|
+
* Minimum delay between provider requests. Default 1100ms — safely above
|
|
146
|
+
* OSM's 1 req/sec community limit. Google can usually handle faster; set
|
|
147
|
+
* to 100ms or less for paid tiers.
|
|
148
|
+
*/
|
|
149
|
+
throttleMs?: number;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Result of `PlaceCollection.resolveTrackPlaces`. Tracks are typically
|
|
153
|
+
* long-running operations so the return payload includes counters that let
|
|
154
|
+
* callers surface progress or estimate cost without re-walking.
|
|
155
|
+
*/
|
|
156
|
+
export interface TrackPlacesResult {
|
|
157
|
+
/** De-duplicated Place rows touched during resolution. */
|
|
158
|
+
places: Place[];
|
|
159
|
+
/** Number of provider requests issued. */
|
|
160
|
+
requestCount: number;
|
|
161
|
+
/** Number of bucketed points that reused existing Place rows. */
|
|
162
|
+
cacheHitCount: number;
|
|
163
|
+
/** Number of distinct geographic buckets walked. */
|
|
164
|
+
bucketCount: number;
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAE5C;;;GAGG;AACH,MAAM,WAAW,OAAO;IACtB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAA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
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
* - "lat lng"
|
|
92
|
-
*
|
|
93
|
-
* @param coordString - Coordinate string
|
|
94
|
-
* @returns Object with lat and lng, or null if invalid
|
|
95
|
-
*/
|
|
96
|
-
export declare function parseCoordinates(coordString: string): {
|
|
97
|
-
lat: number;
|
|
98
|
-
lng: number;
|
|
99
|
-
} | null;
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Validate geographic coordinates
|
|
103
|
-
*
|
|
104
|
-
* @param latitude - Latitude value
|
|
105
|
-
* @param longitude - Longitude value
|
|
106
|
-
* @returns Object with valid flag and optional error message
|
|
107
|
-
*/
|
|
108
|
-
export declare function validateCoordinates(latitude: number, longitude: number): {
|
|
109
|
-
valid: boolean;
|
|
110
|
-
error?: string;
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
export { }
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions for @have/places package
|
|
3
|
+
*/
|
|
4
|
+
import type { Location } from '@happyvertical/geo';
|
|
5
|
+
import type { GeoData } from './types';
|
|
6
|
+
/**
|
|
7
|
+
* Map Location type from @happyvertical/geo to PlaceType slug
|
|
8
|
+
*
|
|
9
|
+
* @param locationType - Location type from geocoding provider
|
|
10
|
+
* @returns PlaceType slug
|
|
11
|
+
*/
|
|
12
|
+
export declare function mapLocationTypeToPlaceType(locationType: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Convert Location from @happyvertical/geo to GeoData
|
|
15
|
+
*
|
|
16
|
+
* @param location - Location from geocoding
|
|
17
|
+
* @returns GeoData object
|
|
18
|
+
*/
|
|
19
|
+
export declare function locationToGeoData(location: Location): GeoData;
|
|
20
|
+
/**
|
|
21
|
+
* Validate geographic coordinates
|
|
22
|
+
*
|
|
23
|
+
* @param latitude - Latitude value
|
|
24
|
+
* @param longitude - Longitude value
|
|
25
|
+
* @returns Object with valid flag and optional error message
|
|
26
|
+
*/
|
|
27
|
+
export declare function validateCoordinates(latitude: number, longitude: number): {
|
|
28
|
+
valid: boolean;
|
|
29
|
+
error?: string;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Calculate distance between two coordinates using Haversine formula
|
|
33
|
+
*
|
|
34
|
+
* @param lat1 - First latitude
|
|
35
|
+
* @param lng1 - First longitude
|
|
36
|
+
* @param lat2 - Second latitude
|
|
37
|
+
* @param lng2 - Second longitude
|
|
38
|
+
* @returns Distance in kilometers
|
|
39
|
+
*/
|
|
40
|
+
export declare function calculateDistance(lat1: number, lng1: number, lat2: number, lng2: number): number;
|
|
41
|
+
/**
|
|
42
|
+
* Format coordinates as string
|
|
43
|
+
*
|
|
44
|
+
* @param latitude - Latitude value
|
|
45
|
+
* @param longitude - Longitude value
|
|
46
|
+
* @param precision - Number of decimal places (default: 6)
|
|
47
|
+
* @returns Formatted coordinate string
|
|
48
|
+
*/
|
|
49
|
+
export declare function formatCoordinates(latitude: number, longitude: number, precision?: number): string;
|
|
50
|
+
/**
|
|
51
|
+
* Parse coordinate string to lat/lng
|
|
52
|
+
*
|
|
53
|
+
* Supports formats:
|
|
54
|
+
* - "lat, lng"
|
|
55
|
+
* - "lat,lng"
|
|
56
|
+
* - "lat lng"
|
|
57
|
+
*
|
|
58
|
+
* @param coordString - Coordinate string
|
|
59
|
+
* @returns Object with lat and lng, or null if invalid
|
|
60
|
+
*/
|
|
61
|
+
export declare function parseCoordinates(coordString: string): {
|
|
62
|
+
lat: number;
|
|
63
|
+
lng: number;
|
|
64
|
+
} | null;
|
|
65
|
+
/**
|
|
66
|
+
* Normalize address components by trimming and removing empty values
|
|
67
|
+
*
|
|
68
|
+
* @param components - Address components
|
|
69
|
+
* @returns Normalized components
|
|
70
|
+
*/
|
|
71
|
+
export declare function normalizeAddressComponents(components: Partial<GeoData>): Partial<GeoData>;
|
|
72
|
+
/**
|
|
73
|
+
* Generate a display name from address components
|
|
74
|
+
*
|
|
75
|
+
* @param components - Address components
|
|
76
|
+
* @returns Formatted display name
|
|
77
|
+
*/
|
|
78
|
+
export declare function generateDisplayName(components: Partial<GeoData>): string;
|
|
79
|
+
/**
|
|
80
|
+
* Check if two coordinates are within a threshold distance
|
|
81
|
+
*
|
|
82
|
+
* @param lat1 - First latitude
|
|
83
|
+
* @param lng1 - First longitude
|
|
84
|
+
* @param lat2 - Second latitude
|
|
85
|
+
* @param lng2 - Second longitude
|
|
86
|
+
* @param thresholdKm - Distance threshold in kilometers
|
|
87
|
+
* @returns True if coordinates are within threshold
|
|
88
|
+
*/
|
|
89
|
+
export declare function areCoordinatesNear(lat1: number, lng1: number, lat2: number, lng2: number, thresholdKm?: number): boolean;
|
|
90
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAEvC;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAoBvE;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAe7D;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,GAChB;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAUpC;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EAC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