@nextgis/geocoder 1.19.1 → 2.0.0-alpha.0
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/README.md +1 -1
- package/lib/geocoder.cjs.js +345 -315
- package/lib/geocoder.cjs.js.map +1 -1
- package/lib/geocoder.cjs.prod.js +1 -1
- package/lib/geocoder.cjs.prod.js.map +1 -1
- package/lib/geocoder.esm-browser.js +2475 -2348
- package/lib/geocoder.esm-browser.js.map +1 -1
- package/lib/geocoder.esm-browser.prod.js +1 -1
- package/lib/geocoder.esm-browser.prod.js.map +1 -1
- package/lib/geocoder.esm-bundler.js +505 -309
- package/lib/geocoder.esm-bundler.js.map +1 -1
- package/lib/geocoder.esm-bundler.prod.js +1 -1
- package/lib/geocoder.esm-bundler.prod.js.map +1 -1
- package/lib/geocoder.global.js +2768 -3112
- package/lib/geocoder.global.js.map +1 -1
- package/lib/geocoder.global.prod.js +1 -1
- package/lib/geocoder.global.prod.js.map +1 -1
- package/lib/index.d.ts +226 -241
- package/package.json +8 -8
package/lib/index.d.ts
CHANGED
|
@@ -1,241 +1,226 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
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
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* Defines the structure for a rendered search item.
|
|
173
|
-
*/
|
|
174
|
-
|
|
175
|
-
/** The specific feature item */
|
|
176
|
-
item: FeatureItem;
|
|
177
|
-
/** The NGW resource item */
|
|
178
|
-
resourceItem: ResourceItem;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
*/
|
|
228
|
-
result?: () => CancelablePromise<ResultItem>;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
* Options for searching within a NGW resource.
|
|
233
|
-
*/
|
|
234
|
-
declare interface SearchResource extends FetchNgwItemsOptions {
|
|
235
|
-
/** The search method used ('ilike' is case-insensitive) */
|
|
236
|
-
searchMethod?: 'ilike' | 'like';
|
|
237
|
-
/** Custom rendering function for search results */
|
|
238
|
-
renderSearch?: (item: RenderSearchItem) => string | HTMLElement;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
export { }
|
|
1
|
+
import CancelablePromise from '@nextgis/cancelable-promise';
|
|
2
|
+
import { LngLatBoundsArray, LngLatArray } from '@nextgis/utils';
|
|
3
|
+
import { GeoJsonObject } from 'geojson';
|
|
4
|
+
import NgwConnector, { FeatureItem, ResourceItem, NgwConnectorOptions } from '@nextgis/ngw-connector';
|
|
5
|
+
import { FetchNgwItemsOptions } from '@nextgis/ngw-kit';
|
|
6
|
+
|
|
7
|
+
interface ResultItem {
|
|
8
|
+
/**
|
|
9
|
+
* Display text of the result item.
|
|
10
|
+
*/
|
|
11
|
+
text: string;
|
|
12
|
+
/**
|
|
13
|
+
* Bounding box of the result item in [west, south, east, north] format.
|
|
14
|
+
*/
|
|
15
|
+
extent: LngLatBoundsArray;
|
|
16
|
+
/**
|
|
17
|
+
* Optional GeoJSON geometry associated with this result item.
|
|
18
|
+
*/
|
|
19
|
+
geom?: GeoJsonObject;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Options for initializing a basic search provider.
|
|
24
|
+
*/
|
|
25
|
+
interface BaseProviderOptions {
|
|
26
|
+
/**
|
|
27
|
+
* URL endpoint for the search service.
|
|
28
|
+
* This is where queries will be sent to obtain search results.
|
|
29
|
+
*/
|
|
30
|
+
searchUrl?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Label to represent the provider.
|
|
33
|
+
* This could be used for user interfaces to display the source of search results.
|
|
34
|
+
*/
|
|
35
|
+
label?: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Abstract base class representing a search provider.
|
|
40
|
+
* It builds upon the BaseGeocoder functionalities with provider-specific properties.
|
|
41
|
+
* @template O - Options type which extends BaseProviderOptions.
|
|
42
|
+
*/
|
|
43
|
+
declare abstract class BaseProvider<O extends BaseProviderOptions = BaseProviderOptions> extends BaseGeocoder<O> {
|
|
44
|
+
/**
|
|
45
|
+
* URL endpoint for the search service.
|
|
46
|
+
* This is where queries will be sent to obtain search results.
|
|
47
|
+
*/
|
|
48
|
+
searchUrl?: string;
|
|
49
|
+
/**
|
|
50
|
+
* Label to represent the provider.
|
|
51
|
+
* Useful for user interfaces to display the source of search results.
|
|
52
|
+
*/
|
|
53
|
+
label?: string;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
interface SearchItem {
|
|
57
|
+
/**
|
|
58
|
+
* A dynamic property bucket for the `SearchItem`.
|
|
59
|
+
*/
|
|
60
|
+
[prop: string]: any;
|
|
61
|
+
/**
|
|
62
|
+
* An optional unique identifier for the search result.
|
|
63
|
+
*/
|
|
64
|
+
_id?: number | string;
|
|
65
|
+
/**
|
|
66
|
+
* Display text of the search result.
|
|
67
|
+
*/
|
|
68
|
+
text: string;
|
|
69
|
+
/**
|
|
70
|
+
* The original query string that resulted in this search result.
|
|
71
|
+
*/
|
|
72
|
+
query: string;
|
|
73
|
+
/**
|
|
74
|
+
* An optional bounding box of the search result in [west, south, east, north] format.
|
|
75
|
+
*/
|
|
76
|
+
extent?: LngLatBoundsArray;
|
|
77
|
+
/**
|
|
78
|
+
* The provider that sourced this search result.
|
|
79
|
+
*/
|
|
80
|
+
provider?: BaseProvider;
|
|
81
|
+
/**
|
|
82
|
+
* Optional GeoJSON geometry associated with this search result.
|
|
83
|
+
*/
|
|
84
|
+
geom?: GeoJsonObject;
|
|
85
|
+
/**
|
|
86
|
+
* An optional function that can be called to retrieve detailed result for this search item.
|
|
87
|
+
*/
|
|
88
|
+
result?: () => CancelablePromise<ResultItem>;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Represents the base class for a geocoder.
|
|
93
|
+
* This abstract class provides the basic methods that every geocoder should implement.
|
|
94
|
+
*
|
|
95
|
+
* @template O - The type of options that can be passed to the geocoder.
|
|
96
|
+
*/
|
|
97
|
+
declare abstract class BaseGeocoder<O extends Record<string, any> = Record<string, any>> {
|
|
98
|
+
constructor(options?: O);
|
|
99
|
+
/**
|
|
100
|
+
* Search method to retrieve geocoding results.
|
|
101
|
+
*
|
|
102
|
+
* @abstract
|
|
103
|
+
* @param query - The search string to geocode.
|
|
104
|
+
* @yields An async generator that yields search results.
|
|
105
|
+
*/
|
|
106
|
+
abstract search(query: string): AsyncGenerator<SearchItem>;
|
|
107
|
+
/**
|
|
108
|
+
* Method to retrieve detailed result for a specific search item.
|
|
109
|
+
*
|
|
110
|
+
* @abstract
|
|
111
|
+
* @param item - The search item to get detailed result for.
|
|
112
|
+
* @returns A promise that resolves to the detailed result.
|
|
113
|
+
*/
|
|
114
|
+
abstract result(item: SearchItem): CancelablePromise<any>;
|
|
115
|
+
/**
|
|
116
|
+
* Method for reverse geocoding.
|
|
117
|
+
* Takes coordinates and returns the corresponding address or location information.
|
|
118
|
+
*
|
|
119
|
+
* @abstract
|
|
120
|
+
* @param coordinates - The longitude and latitude values.
|
|
121
|
+
* @returns An async generator that yields reverse geocoding results.
|
|
122
|
+
*/
|
|
123
|
+
abstract reverse(coordinates: LngLatArray): AsyncGenerator<SearchItem>;
|
|
124
|
+
/**
|
|
125
|
+
* Optional method to abort any ongoing geocoding requests.
|
|
126
|
+
*
|
|
127
|
+
* @abstract
|
|
128
|
+
*/
|
|
129
|
+
abstract abort?(): void;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Defines the options for creating a Geocoder instance.
|
|
134
|
+
*/
|
|
135
|
+
interface GeocoderOptions {
|
|
136
|
+
/**
|
|
137
|
+
* An array of providers to be used for geocoding.
|
|
138
|
+
*/
|
|
139
|
+
providers: BaseProvider[];
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
declare class Geocoder extends BaseGeocoder<GeocoderOptions> {
|
|
143
|
+
providers: BaseProvider[];
|
|
144
|
+
constructor(options: GeocoderOptions);
|
|
145
|
+
abort(): void;
|
|
146
|
+
search(query: string): AsyncGenerator<SearchItem, void, unknown>;
|
|
147
|
+
result(item: SearchItem): CancelablePromise<any>;
|
|
148
|
+
reverse(coordinates: LngLatArray): AsyncGenerator<SearchItem, void, unknown>;
|
|
149
|
+
/**
|
|
150
|
+
* Returns the first reverse geocoding result for given coordinates from any provider.
|
|
151
|
+
*
|
|
152
|
+
* @param coordinates - The longitude and latitude values.
|
|
153
|
+
* @returns A promise that resolves to the first reverse geocoding result, or undefined if no results are found.
|
|
154
|
+
*/
|
|
155
|
+
reverseGeocodeFirstResult(coordinates: LngLatArray): Promise<SearchItem | undefined>;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Extends the basic search item with NGW-specific properties.
|
|
160
|
+
*/
|
|
161
|
+
interface NgwSearchItem extends SearchItem {
|
|
162
|
+
/** ID of the NGW resource */
|
|
163
|
+
resourceId: number;
|
|
164
|
+
/** ID of the feature in the NGW resource */
|
|
165
|
+
featureId: number;
|
|
166
|
+
/** The specific feature item from NGW */
|
|
167
|
+
item: FeatureItem;
|
|
168
|
+
/** The NGW resource item */
|
|
169
|
+
resourceItem: ResourceItem;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Defines the structure for a rendered search item.
|
|
173
|
+
*/
|
|
174
|
+
interface RenderSearchItem {
|
|
175
|
+
/** The specific feature item */
|
|
176
|
+
item: FeatureItem;
|
|
177
|
+
/** The NGW resource item */
|
|
178
|
+
resourceItem: ResourceItem;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Options for searching within a NGW resource.
|
|
182
|
+
*/
|
|
183
|
+
interface SearchResource extends FetchNgwItemsOptions {
|
|
184
|
+
/** The search method used ('ilike' is case-insensitive) */
|
|
185
|
+
searchMethod?: 'ilike' | 'like';
|
|
186
|
+
/** Custom rendering function for search results */
|
|
187
|
+
renderSearch?: (item: RenderSearchItem) => string | HTMLElement;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Options required to initialize an NGW provider.
|
|
191
|
+
*/
|
|
192
|
+
interface NgwProviderOptions extends BaseProviderOptions {
|
|
193
|
+
/** Connector instance for NGW. If not provided, will be created internally */
|
|
194
|
+
connector?: NgwConnector;
|
|
195
|
+
/** List of NGW resources to search within */
|
|
196
|
+
searchResources: SearchResource[];
|
|
197
|
+
/** Options for the internal NgwConnector (if one needs to be created) */
|
|
198
|
+
connectorOptions?: NgwConnectorOptions;
|
|
199
|
+
}
|
|
200
|
+
declare class NgwProvider extends BaseProvider<NgwProviderOptions> {
|
|
201
|
+
static limit: number;
|
|
202
|
+
searchResources: SearchResource[];
|
|
203
|
+
private connector;
|
|
204
|
+
private _abortControllers;
|
|
205
|
+
constructor(options: NgwProviderOptions);
|
|
206
|
+
abort(): void;
|
|
207
|
+
search(query: string): AsyncGenerator<NgwSearchItem, void, unknown>;
|
|
208
|
+
result(item: NgwSearchItem): CancelablePromise<ResultItem>;
|
|
209
|
+
reverse(coordinates: LngLatArray): AsyncGenerator<SearchItem, void, unknown>;
|
|
210
|
+
private _makeSignal;
|
|
211
|
+
private _items;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
declare class NominatimProvider extends BaseProvider {
|
|
215
|
+
searchUrl: string;
|
|
216
|
+
private _requests;
|
|
217
|
+
constructor(options?: BaseProviderOptions);
|
|
218
|
+
abort(): void;
|
|
219
|
+
search(val: string): AsyncGenerator<SearchItem, void, unknown>;
|
|
220
|
+
result(model: SearchItem): CancelablePromise<ResultItem>;
|
|
221
|
+
reverse(coordinates: LngLatArray): AsyncGenerator<SearchItem, void, unknown>;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
declare function create(options: GeocoderOptions): Geocoder;
|
|
225
|
+
|
|
226
|
+
export { BaseProvider, type BaseProviderOptions, Geocoder, type GeocoderOptions, NgwProvider, NominatimProvider, type ResultItem, type SearchItem, create };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nextgis/geocoder",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-alpha.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "lib/geocoder.esm-bundler.js",
|
|
@@ -8,16 +8,16 @@
|
|
|
8
8
|
"jsdelivr": "lib/geocoder.global.prod.js",
|
|
9
9
|
"types": "lib/index.d.ts",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@nextgis/cancelable-promise": "^
|
|
12
|
-
"@nextgis/ngw-connector": "^
|
|
13
|
-
"@nextgis/ngw-kit": "^
|
|
14
|
-
"@nextgis/utils": "^
|
|
11
|
+
"@nextgis/cancelable-promise": "^2.0.0-alpha.0",
|
|
12
|
+
"@nextgis/ngw-connector": "^2.0.0-alpha.0",
|
|
13
|
+
"@nextgis/ngw-kit": "^2.0.0-alpha.0",
|
|
14
|
+
"@nextgis/utils": "^2.0.0-alpha.0",
|
|
15
15
|
"@types/events": "^3.0.0",
|
|
16
16
|
"@types/geojson": "^7946.0.8",
|
|
17
|
-
"events": "
|
|
17
|
+
"events": "*"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@nextgis/build-tools": "^
|
|
20
|
+
"@nextgis/build-tools": "^2.0.0-alpha.0"
|
|
21
21
|
},
|
|
22
22
|
"buildOptions": {
|
|
23
23
|
"name": "Geocoder",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"bugs": {
|
|
54
54
|
"url": "https://github.com/nextgis/nextgis_frontend/issues"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "6a4a43d17a08e468d2362f1ae9590094e39aa6cc"
|
|
57
57
|
}
|