@mapbox/mcp-server 0.2.1-dev.0 → 0.2.1-dev.2
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/tools/MapboxApiBasedTool.d.ts +7 -0
- package/dist/tools/MapboxApiBasedTool.d.ts.map +1 -1
- package/dist/tools/MapboxApiBasedTool.js +24 -2
- package/dist/tools/MapboxApiBasedTool.js.map +1 -1
- package/dist/tools/MapboxApiBasedTool.test.d.ts +2 -0
- package/dist/tools/MapboxApiBasedTool.test.d.ts.map +1 -0
- package/dist/tools/MapboxApiBasedTool.test.js +143 -0
- package/dist/tools/MapboxApiBasedTool.test.js.map +1 -0
- package/dist/tools/category-search-tool/CategorySearchTool.d.ts +55 -6
- package/dist/tools/category-search-tool/CategorySearchTool.d.ts.map +1 -1
- package/dist/tools/category-search-tool/CategorySearchTool.js +47 -19
- package/dist/tools/category-search-tool/CategorySearchTool.js.map +1 -1
- package/dist/tools/category-search-tool/CategorySearchTool.test.js +90 -10
- package/dist/tools/category-search-tool/CategorySearchTool.test.js.map +1 -1
- package/dist/tools/directions-tool/DirectionsTool.d.ts +18 -3
- package/dist/tools/directions-tool/DirectionsTool.d.ts.map +1 -1
- package/dist/tools/directions-tool/DirectionsTool.js +6 -6
- package/dist/tools/directions-tool/DirectionsTool.js.map +1 -1
- package/dist/tools/directions-tool/DirectionsTool.test.js +122 -118
- package/dist/tools/directions-tool/DirectionsTool.test.js.map +1 -1
- package/dist/tools/forward-geocode-tool/ForwardGeocodeTool.d.ts +54 -8
- package/dist/tools/forward-geocode-tool/ForwardGeocodeTool.d.ts.map +1 -1
- package/dist/tools/forward-geocode-tool/ForwardGeocodeTool.js +33 -15
- package/dist/tools/forward-geocode-tool/ForwardGeocodeTool.js.map +1 -1
- package/dist/tools/forward-geocode-tool/ForwardGeocodeTool.test.js +33 -9
- package/dist/tools/forward-geocode-tool/ForwardGeocodeTool.test.js.map +1 -1
- package/dist/tools/isochrone-tool/IsochroneTool.d.ts +18 -3
- package/dist/tools/isochrone-tool/IsochroneTool.d.ts.map +1 -1
- package/dist/tools/isochrone-tool/IsochroneTool.js +6 -3
- package/dist/tools/isochrone-tool/IsochroneTool.js.map +1 -1
- package/dist/tools/isochrone-tool/IsochroneTool.test.js +8 -7
- package/dist/tools/isochrone-tool/IsochroneTool.test.js.map +1 -1
- package/dist/tools/matrix-tool/MatrixTool.d.ts +18 -3
- package/dist/tools/matrix-tool/MatrixTool.d.ts.map +1 -1
- package/dist/tools/matrix-tool/MatrixTool.js +6 -6
- package/dist/tools/matrix-tool/MatrixTool.js.map +1 -1
- package/dist/tools/matrix-tool/MatrixTool.test.js +128 -115
- package/dist/tools/matrix-tool/MatrixTool.test.js.map +1 -1
- package/dist/tools/poi-search-tool/PoiSearchTool.d.ts +70 -9
- package/dist/tools/poi-search-tool/PoiSearchTool.d.ts.map +1 -1
- package/dist/tools/poi-search-tool/PoiSearchTool.js +41 -20
- package/dist/tools/poi-search-tool/PoiSearchTool.js.map +1 -1
- package/dist/tools/poi-search-tool/PoiSearchTool.test.js +34 -10
- package/dist/tools/poi-search-tool/PoiSearchTool.test.js.map +1 -1
- package/dist/tools/reverse-geocode-tool/ReverseGeocodeTool.d.ts +2 -2
- package/dist/tools/reverse-geocode-tool/ReverseGeocodeTool.test.js +12 -7
- package/dist/tools/reverse-geocode-tool/ReverseGeocodeTool.test.js.map +1 -1
- package/dist/tools/static-map-image-tool/StaticMapImageTool.d.ts +36 -6
- package/dist/tools/static-map-image-tool/StaticMapImageTool.d.ts.map +1 -1
- package/dist/tools/static-map-image-tool/StaticMapImageTool.js +12 -9
- package/dist/tools/static-map-image-tool/StaticMapImageTool.js.map +1 -1
- package/dist/tools/static-map-image-tool/StaticMapImageTool.test.js +48 -47
- package/dist/tools/static-map-image-tool/StaticMapImageTool.test.js.map +1 -1
- package/dist/version.json +4 -4
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
process.env.MAPBOX_ACCESS_TOKEN =
|
|
1
|
+
process.env.MAPBOX_ACCESS_TOKEN =
|
|
2
|
+
'eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ0ZXN0In0.signature';
|
|
2
3
|
import { cleanup } from '../../utils/requestUtils.js';
|
|
3
4
|
import { setupFetch, assertHeadersSent } from '../../utils/requestUtils.test-helpers.js';
|
|
4
5
|
import { MatrixTool } from './MatrixTool.js';
|
|
@@ -61,8 +62,8 @@ describe('MatrixTool', () => {
|
|
|
61
62
|
const mockFetch = setupFetch();
|
|
62
63
|
await new MatrixTool().run({
|
|
63
64
|
coordinates: [
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
{ longitude: -74.102094, latitude: 40.692815 },
|
|
66
|
+
{ longitude: -74.1022094, latitude: 40.792815 }
|
|
66
67
|
],
|
|
67
68
|
profile: 'walking'
|
|
68
69
|
});
|
|
@@ -75,9 +76,9 @@ describe('MatrixTool', () => {
|
|
|
75
76
|
const tool = new MatrixTool();
|
|
76
77
|
const result = await tool.run({
|
|
77
78
|
coordinates: [
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
{ longitude: -122.42, latitude: 37.78 },
|
|
80
|
+
{ longitude: -122.45, latitude: 37.91 },
|
|
81
|
+
{ longitude: -122.48, latitude: 37.73 }
|
|
81
82
|
],
|
|
82
83
|
profile: 'driving'
|
|
83
84
|
});
|
|
@@ -86,7 +87,7 @@ describe('MatrixTool', () => {
|
|
|
86
87
|
// Check that URL contains correct profile and coordinates
|
|
87
88
|
const url = mockFetch.mock.calls[0][0];
|
|
88
89
|
expect(url).toContain('directions-matrix/v1/mapbox/driving/-122.42,37.78;-122.45,37.91;-122.48,37.73');
|
|
89
|
-
expect(url).toContain('access_token=
|
|
90
|
+
expect(url).toContain('access_token=eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ0ZXN0In0.signature');
|
|
90
91
|
assertHeadersSent(mockFetch);
|
|
91
92
|
});
|
|
92
93
|
it('properly includes annotations parameter when specified', async () => {
|
|
@@ -96,8 +97,8 @@ describe('MatrixTool', () => {
|
|
|
96
97
|
const tool = new MatrixTool();
|
|
97
98
|
await tool.run({
|
|
98
99
|
coordinates: [
|
|
99
|
-
|
|
100
|
-
|
|
100
|
+
{ longitude: -122.42, latitude: 37.78 },
|
|
101
|
+
{ longitude: -122.45, latitude: 37.91 }
|
|
101
102
|
],
|
|
102
103
|
profile: 'driving',
|
|
103
104
|
annotations: 'duration,distance'
|
|
@@ -112,9 +113,9 @@ describe('MatrixTool', () => {
|
|
|
112
113
|
const tool = new MatrixTool();
|
|
113
114
|
await tool.run({
|
|
114
115
|
coordinates: [
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
{ longitude: -122.42, latitude: 37.78 },
|
|
117
|
+
{ longitude: -122.45, latitude: 37.91 },
|
|
118
|
+
{ longitude: -122.48, latitude: 37.73 }
|
|
118
119
|
],
|
|
119
120
|
profile: 'driving',
|
|
120
121
|
approaches: 'curb;unrestricted;curb'
|
|
@@ -129,8 +130,8 @@ describe('MatrixTool', () => {
|
|
|
129
130
|
const tool = new MatrixTool();
|
|
130
131
|
await tool.run({
|
|
131
132
|
coordinates: [
|
|
132
|
-
|
|
133
|
-
|
|
133
|
+
{ longitude: -122.42, latitude: 37.78 },
|
|
134
|
+
{ longitude: -122.45, latitude: 37.91 }
|
|
134
135
|
],
|
|
135
136
|
profile: 'driving',
|
|
136
137
|
bearings: '45,90;120,45'
|
|
@@ -145,9 +146,9 @@ describe('MatrixTool', () => {
|
|
|
145
146
|
const tool = new MatrixTool();
|
|
146
147
|
await tool.run({
|
|
147
148
|
coordinates: [
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
149
|
+
{ longitude: -122.42, latitude: 37.78 },
|
|
150
|
+
{ longitude: -122.45, latitude: 37.91 },
|
|
151
|
+
{ longitude: -122.48, latitude: 37.73 }
|
|
151
152
|
],
|
|
152
153
|
profile: 'cycling',
|
|
153
154
|
destinations: '0;2'
|
|
@@ -162,9 +163,9 @@ describe('MatrixTool', () => {
|
|
|
162
163
|
const tool = new MatrixTool();
|
|
163
164
|
await tool.run({
|
|
164
165
|
coordinates: [
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
166
|
+
{ longitude: -122.42, latitude: 37.78 },
|
|
167
|
+
{ longitude: -122.45, latitude: 37.91 },
|
|
168
|
+
{ longitude: -122.48, latitude: 37.73 }
|
|
168
169
|
],
|
|
169
170
|
profile: 'walking',
|
|
170
171
|
sources: '1'
|
|
@@ -179,9 +180,9 @@ describe('MatrixTool', () => {
|
|
|
179
180
|
const tool = new MatrixTool();
|
|
180
181
|
const result = await tool.run({
|
|
181
182
|
coordinates: [
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
183
|
+
{ longitude: -122.42, latitude: 37.78 },
|
|
184
|
+
{ longitude: -122.45, latitude: 37.91 },
|
|
185
|
+
{ longitude: -122.48, latitude: 37.73 }
|
|
185
186
|
],
|
|
186
187
|
profile: 'driving',
|
|
187
188
|
annotations: 'distance,duration',
|
|
@@ -207,8 +208,8 @@ describe('MatrixTool', () => {
|
|
|
207
208
|
const tool = new MatrixTool();
|
|
208
209
|
const result = await tool.run({
|
|
209
210
|
coordinates: [
|
|
210
|
-
|
|
211
|
-
|
|
211
|
+
{ longitude: -122.42, latitude: 37.78 },
|
|
212
|
+
{ longitude: -122.45, latitude: 37.91 }
|
|
212
213
|
],
|
|
213
214
|
profile: 'walking'
|
|
214
215
|
});
|
|
@@ -222,7 +223,7 @@ describe('MatrixTool', () => {
|
|
|
222
223
|
it('validates driving-traffic profile coordinate limit', async () => {
|
|
223
224
|
const mockFetch = setupFetch();
|
|
224
225
|
const tool = new MatrixTool();
|
|
225
|
-
const coordinates = Array(11).fill(
|
|
226
|
+
const coordinates = Array(11).fill({ longitude: -122.42, latitude: 37.78 });
|
|
226
227
|
const result = await tool.run({
|
|
227
228
|
coordinates,
|
|
228
229
|
profile: 'driving-traffic'
|
|
@@ -246,20 +247,23 @@ describe('MatrixTool', () => {
|
|
|
246
247
|
});
|
|
247
248
|
it('validates coordinates - minimum count', async () => {
|
|
248
249
|
const result = await tool.run({
|
|
249
|
-
coordinates: [
|
|
250
|
+
coordinates: [{ longitude: -122.42, latitude: 37.78 }],
|
|
250
251
|
profile: 'driving'
|
|
251
252
|
});
|
|
252
253
|
expect(result.is_error).toBe(true);
|
|
253
254
|
// Test direct error message using Zod validation from schema
|
|
254
255
|
await expect(async () => {
|
|
255
256
|
await tool['inputSchema'].parseAsync({
|
|
256
|
-
coordinates: [
|
|
257
|
+
coordinates: [{ longitude: -122.42, latitude: 37.78 }],
|
|
257
258
|
profile: 'driving'
|
|
258
259
|
});
|
|
259
260
|
}).rejects.toThrow('At least two coordinate pairs are required.');
|
|
260
261
|
});
|
|
261
262
|
it('validates coordinates - maximum count for regular profiles', async () => {
|
|
262
|
-
const coordinates = Array(26).fill(
|
|
263
|
+
const coordinates = Array(26).fill({
|
|
264
|
+
longitude: -122.42,
|
|
265
|
+
latitude: 37.78
|
|
266
|
+
});
|
|
263
267
|
const result = await tool.run({
|
|
264
268
|
coordinates,
|
|
265
269
|
profile: 'driving'
|
|
@@ -276,8 +280,8 @@ describe('MatrixTool', () => {
|
|
|
276
280
|
it('validates coordinate bounds', async () => {
|
|
277
281
|
const invalidLongitude = await tool.run({
|
|
278
282
|
coordinates: [
|
|
279
|
-
|
|
280
|
-
|
|
283
|
+
{ longitude: -190, latitude: 37.78 },
|
|
284
|
+
{ longitude: -122.45, latitude: 37.91 }
|
|
281
285
|
],
|
|
282
286
|
profile: 'driving'
|
|
283
287
|
});
|
|
@@ -286,16 +290,16 @@ describe('MatrixTool', () => {
|
|
|
286
290
|
await expect(async () => {
|
|
287
291
|
await tool['inputSchema'].parseAsync({
|
|
288
292
|
coordinates: [
|
|
289
|
-
|
|
290
|
-
|
|
293
|
+
{ longitude: -190, latitude: 37.78 },
|
|
294
|
+
{ longitude: -122.45, latitude: 37.91 }
|
|
291
295
|
],
|
|
292
296
|
profile: 'driving'
|
|
293
297
|
});
|
|
294
298
|
}).rejects.toThrow('Longitude must be between -180 and 180 degrees');
|
|
295
299
|
const invalidLatitude = await tool.run({
|
|
296
300
|
coordinates: [
|
|
297
|
-
|
|
298
|
-
|
|
301
|
+
{ longitude: -122.42, latitude: 37.78 },
|
|
302
|
+
{ longitude: -122.45, latitude: 95 }
|
|
299
303
|
],
|
|
300
304
|
profile: 'driving'
|
|
301
305
|
});
|
|
@@ -304,8 +308,8 @@ describe('MatrixTool', () => {
|
|
|
304
308
|
await expect(async () => {
|
|
305
309
|
await tool['inputSchema'].parseAsync({
|
|
306
310
|
coordinates: [
|
|
307
|
-
|
|
308
|
-
|
|
311
|
+
{ longitude: -122.42, latitude: 37.78 },
|
|
312
|
+
{ longitude: -122.45, latitude: 95 }
|
|
309
313
|
],
|
|
310
314
|
profile: 'driving'
|
|
311
315
|
});
|
|
@@ -314,9 +318,9 @@ describe('MatrixTool', () => {
|
|
|
314
318
|
it('validates approaches parameter length', async () => {
|
|
315
319
|
const result = await tool.run({
|
|
316
320
|
coordinates: [
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
321
|
+
{ longitude: -122.42, latitude: 37.78 },
|
|
322
|
+
{ longitude: -122.45, latitude: 37.91 },
|
|
323
|
+
{ longitude: -122.48, latitude: 37.73 }
|
|
320
324
|
],
|
|
321
325
|
profile: 'driving',
|
|
322
326
|
approaches: 'curb;unrestricted' // Only 2 for 3 coordinates
|
|
@@ -326,9 +330,9 @@ describe('MatrixTool', () => {
|
|
|
326
330
|
await expect(async () => {
|
|
327
331
|
await tool['execute']({
|
|
328
332
|
coordinates: [
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
333
|
+
{ longitude: -122.42, latitude: 37.78 },
|
|
334
|
+
{ longitude: -122.45, latitude: 37.91 },
|
|
335
|
+
{ longitude: -122.48, latitude: 37.73 }
|
|
332
336
|
],
|
|
333
337
|
profile: 'driving',
|
|
334
338
|
approaches: 'curb;unrestricted'
|
|
@@ -338,8 +342,8 @@ describe('MatrixTool', () => {
|
|
|
338
342
|
it('validates approaches parameter values', async () => {
|
|
339
343
|
const result = await tool.run({
|
|
340
344
|
coordinates: [
|
|
341
|
-
|
|
342
|
-
|
|
345
|
+
{ longitude: -122.42, latitude: 37.78 },
|
|
346
|
+
{ longitude: -122.45, latitude: 37.91 }
|
|
343
347
|
],
|
|
344
348
|
profile: 'driving',
|
|
345
349
|
approaches: 'curb;invalid' // 'invalid' is not allowed
|
|
@@ -349,8 +353,8 @@ describe('MatrixTool', () => {
|
|
|
349
353
|
await expect(async () => {
|
|
350
354
|
await tool['execute']({
|
|
351
355
|
coordinates: [
|
|
352
|
-
|
|
353
|
-
|
|
356
|
+
{ longitude: -122.42, latitude: 37.78 },
|
|
357
|
+
{ longitude: -122.45, latitude: 37.91 }
|
|
354
358
|
],
|
|
355
359
|
profile: 'driving',
|
|
356
360
|
approaches: 'curb;invalid'
|
|
@@ -360,9 +364,9 @@ describe('MatrixTool', () => {
|
|
|
360
364
|
it('validates bearings parameter length', async () => {
|
|
361
365
|
const result = await tool.run({
|
|
362
366
|
coordinates: [
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
367
|
+
{ longitude: -122.42, latitude: 37.78 },
|
|
368
|
+
{ longitude: -122.45, latitude: 37.91 },
|
|
369
|
+
{ longitude: -122.48, latitude: 37.73 }
|
|
366
370
|
],
|
|
367
371
|
profile: 'driving',
|
|
368
372
|
bearings: '45,90;120,45' // Only 2 for 3 coordinates
|
|
@@ -372,9 +376,9 @@ describe('MatrixTool', () => {
|
|
|
372
376
|
await expect(async () => {
|
|
373
377
|
await tool['execute']({
|
|
374
378
|
coordinates: [
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
379
|
+
{ longitude: -122.42, latitude: 37.78 },
|
|
380
|
+
{ longitude: -122.45, latitude: 37.91 },
|
|
381
|
+
{ longitude: -122.48, latitude: 37.73 }
|
|
378
382
|
],
|
|
379
383
|
profile: 'driving',
|
|
380
384
|
bearings: '45,90;120,45'
|
|
@@ -384,8 +388,8 @@ describe('MatrixTool', () => {
|
|
|
384
388
|
it('validates bearings parameter format', async () => {
|
|
385
389
|
const result = await tool.run({
|
|
386
390
|
coordinates: [
|
|
387
|
-
|
|
388
|
-
|
|
391
|
+
{ longitude: -122.42, latitude: 37.78 },
|
|
392
|
+
{ longitude: -122.45, latitude: 37.91 }
|
|
389
393
|
],
|
|
390
394
|
profile: 'driving',
|
|
391
395
|
bearings: '45,90;invalid'
|
|
@@ -395,8 +399,8 @@ describe('MatrixTool', () => {
|
|
|
395
399
|
await expect(async () => {
|
|
396
400
|
await tool['execute']({
|
|
397
401
|
coordinates: [
|
|
398
|
-
|
|
399
|
-
|
|
402
|
+
{ longitude: -122.42, latitude: 37.78 },
|
|
403
|
+
{ longitude: -122.45, latitude: 37.91 }
|
|
400
404
|
],
|
|
401
405
|
profile: 'driving',
|
|
402
406
|
bearings: '45,90;invalid'
|
|
@@ -406,8 +410,8 @@ describe('MatrixTool', () => {
|
|
|
406
410
|
it('validates bearings parameter angle range', async () => {
|
|
407
411
|
const result = await tool.run({
|
|
408
412
|
coordinates: [
|
|
409
|
-
|
|
410
|
-
|
|
413
|
+
{ longitude: -122.42, latitude: 37.78 },
|
|
414
|
+
{ longitude: -122.45, latitude: 37.91 }
|
|
411
415
|
],
|
|
412
416
|
profile: 'driving',
|
|
413
417
|
bearings: '400,90;120,45' // 400 is > 360
|
|
@@ -417,8 +421,8 @@ describe('MatrixTool', () => {
|
|
|
417
421
|
await expect(async () => {
|
|
418
422
|
await tool['execute']({
|
|
419
423
|
coordinates: [
|
|
420
|
-
|
|
421
|
-
|
|
424
|
+
{ longitude: -122.42, latitude: 37.78 },
|
|
425
|
+
{ longitude: -122.45, latitude: 37.91 }
|
|
422
426
|
],
|
|
423
427
|
profile: 'driving',
|
|
424
428
|
bearings: '400,90;120,45'
|
|
@@ -428,8 +432,8 @@ describe('MatrixTool', () => {
|
|
|
428
432
|
it('validates bearings parameter degrees range', async () => {
|
|
429
433
|
const result = await tool.run({
|
|
430
434
|
coordinates: [
|
|
431
|
-
|
|
432
|
-
|
|
435
|
+
{ longitude: -122.42, latitude: 37.78 },
|
|
436
|
+
{ longitude: -122.45, latitude: 37.91 }
|
|
433
437
|
],
|
|
434
438
|
profile: 'driving',
|
|
435
439
|
bearings: '45,200;120,45' // 200 is > 180
|
|
@@ -439,8 +443,8 @@ describe('MatrixTool', () => {
|
|
|
439
443
|
await expect(async () => {
|
|
440
444
|
await tool['execute']({
|
|
441
445
|
coordinates: [
|
|
442
|
-
|
|
443
|
-
|
|
446
|
+
{ longitude: -122.42, latitude: 37.78 },
|
|
447
|
+
{ longitude: -122.45, latitude: 37.91 }
|
|
444
448
|
],
|
|
445
449
|
profile: 'driving',
|
|
446
450
|
bearings: '45,200;120,45'
|
|
@@ -450,8 +454,8 @@ describe('MatrixTool', () => {
|
|
|
450
454
|
it('validates sources parameter indices', async () => {
|
|
451
455
|
const result = await tool.run({
|
|
452
456
|
coordinates: [
|
|
453
|
-
|
|
454
|
-
|
|
457
|
+
{ longitude: -122.42, latitude: 37.78 },
|
|
458
|
+
{ longitude: -122.45, latitude: 37.91 }
|
|
455
459
|
],
|
|
456
460
|
profile: 'driving',
|
|
457
461
|
sources: '0;2' // 2 is out of bounds
|
|
@@ -461,8 +465,8 @@ describe('MatrixTool', () => {
|
|
|
461
465
|
await expect(async () => {
|
|
462
466
|
await tool['execute']({
|
|
463
467
|
coordinates: [
|
|
464
|
-
|
|
465
|
-
|
|
468
|
+
{ longitude: -122.42, latitude: 37.78 },
|
|
469
|
+
{ longitude: -122.45, latitude: 37.91 }
|
|
466
470
|
],
|
|
467
471
|
profile: 'driving',
|
|
468
472
|
sources: '0;2'
|
|
@@ -472,8 +476,8 @@ describe('MatrixTool', () => {
|
|
|
472
476
|
it('validates destinations parameter indices', async () => {
|
|
473
477
|
const result = await tool.run({
|
|
474
478
|
coordinates: [
|
|
475
|
-
|
|
476
|
-
|
|
479
|
+
{ longitude: -122.42, latitude: 37.78 },
|
|
480
|
+
{ longitude: -122.45, latitude: 37.91 }
|
|
477
481
|
],
|
|
478
482
|
profile: 'driving',
|
|
479
483
|
destinations: '3' // 3 is out of bounds
|
|
@@ -483,8 +487,8 @@ describe('MatrixTool', () => {
|
|
|
483
487
|
await expect(async () => {
|
|
484
488
|
await tool['execute']({
|
|
485
489
|
coordinates: [
|
|
486
|
-
|
|
487
|
-
|
|
490
|
+
{ longitude: -122.42, latitude: 37.78 },
|
|
491
|
+
{ longitude: -122.45, latitude: 37.91 }
|
|
488
492
|
],
|
|
489
493
|
profile: 'driving',
|
|
490
494
|
destinations: '3'
|
|
@@ -494,8 +498,8 @@ describe('MatrixTool', () => {
|
|
|
494
498
|
it('validates destinations parameter index negative', async () => {
|
|
495
499
|
const result = await tool.run({
|
|
496
500
|
coordinates: [
|
|
497
|
-
|
|
498
|
-
|
|
501
|
+
{ longitude: -122.42, latitude: 37.78 },
|
|
502
|
+
{ longitude: -122.45, latitude: 37.91 }
|
|
499
503
|
],
|
|
500
504
|
profile: 'driving',
|
|
501
505
|
destinations: '-1'
|
|
@@ -505,8 +509,8 @@ describe('MatrixTool', () => {
|
|
|
505
509
|
await expect(async () => {
|
|
506
510
|
await tool['execute']({
|
|
507
511
|
coordinates: [
|
|
508
|
-
|
|
509
|
-
|
|
512
|
+
{ longitude: -122.42, latitude: 37.78 },
|
|
513
|
+
{ longitude: -122.45, latitude: 37.91 }
|
|
510
514
|
],
|
|
511
515
|
profile: 'driving',
|
|
512
516
|
destinations: '-1'
|
|
@@ -519,8 +523,8 @@ describe('MatrixTool', () => {
|
|
|
519
523
|
});
|
|
520
524
|
await tool.run({
|
|
521
525
|
coordinates: [
|
|
522
|
-
|
|
523
|
-
|
|
526
|
+
{ longitude: -122.42, latitude: 37.78 },
|
|
527
|
+
{ longitude: -122.45, latitude: 37.91 }
|
|
524
528
|
],
|
|
525
529
|
profile: 'driving',
|
|
526
530
|
sources: 'all'
|
|
@@ -534,8 +538,8 @@ describe('MatrixTool', () => {
|
|
|
534
538
|
});
|
|
535
539
|
await tool.run({
|
|
536
540
|
coordinates: [
|
|
537
|
-
|
|
538
|
-
|
|
541
|
+
{ longitude: -122.42, latitude: 37.78 },
|
|
542
|
+
{ longitude: -122.45, latitude: 37.91 }
|
|
539
543
|
],
|
|
540
544
|
profile: 'driving',
|
|
541
545
|
destinations: 'all'
|
|
@@ -556,9 +560,9 @@ describe('MatrixTool', () => {
|
|
|
556
560
|
});
|
|
557
561
|
const result = await tool.run({
|
|
558
562
|
coordinates: [
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
563
|
+
{ longitude: -122.42, latitude: 37.78 },
|
|
564
|
+
{ longitude: -122.46, latitude: 37.9 },
|
|
565
|
+
{ longitude: -122.48, latitude: 37.73 }
|
|
562
566
|
],
|
|
563
567
|
profile: 'driving',
|
|
564
568
|
approaches: 'curb;;unrestricted'
|
|
@@ -573,9 +577,9 @@ describe('MatrixTool', () => {
|
|
|
573
577
|
});
|
|
574
578
|
const result = await tool.run({
|
|
575
579
|
coordinates: [
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
580
|
+
{ longitude: -122.42, latitude: 37.78 },
|
|
581
|
+
{ longitude: -122.46, latitude: 37.9 },
|
|
582
|
+
{ longitude: -122.45, latitude: 37.91 }
|
|
579
583
|
],
|
|
580
584
|
profile: 'driving',
|
|
581
585
|
bearings: '45,90;;120,45'
|
|
@@ -590,9 +594,9 @@ describe('MatrixTool', () => {
|
|
|
590
594
|
});
|
|
591
595
|
const resultWithSuccess1 = await tool.run({
|
|
592
596
|
coordinates: [
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
597
|
+
{ longitude: -122.42, latitude: 37.78 },
|
|
598
|
+
{ longitude: -122.45, latitude: 37.91 },
|
|
599
|
+
{ longitude: -122.48, latitude: 37.73 }
|
|
596
600
|
],
|
|
597
601
|
profile: 'driving',
|
|
598
602
|
approaches: 'curb;;unrestricted'
|
|
@@ -600,8 +604,8 @@ describe('MatrixTool', () => {
|
|
|
600
604
|
expect(resultWithSuccess1.is_error).toBe(false);
|
|
601
605
|
const resultWithSuccess2 = await tool.run({
|
|
602
606
|
coordinates: [
|
|
603
|
-
|
|
604
|
-
|
|
607
|
+
{ longitude: -122.42, latitude: 37.78 },
|
|
608
|
+
{ longitude: -122.45, latitude: 37.91 }
|
|
605
609
|
],
|
|
606
610
|
profile: 'driving',
|
|
607
611
|
approaches: 'curb;'
|
|
@@ -614,9 +618,9 @@ describe('MatrixTool', () => {
|
|
|
614
618
|
});
|
|
615
619
|
const result = await tool.run({
|
|
616
620
|
coordinates: [
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
621
|
+
{ longitude: -122.42, latitude: 37.78 },
|
|
622
|
+
{ longitude: -122.45, latitude: 37.91 },
|
|
623
|
+
{ longitude: -122.48, latitude: 37.73 }
|
|
620
624
|
],
|
|
621
625
|
profile: 'driving',
|
|
622
626
|
sources: '1',
|
|
@@ -628,9 +632,9 @@ describe('MatrixTool', () => {
|
|
|
628
632
|
await expect(async () => {
|
|
629
633
|
await tool['execute']({
|
|
630
634
|
coordinates: [
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
635
|
+
{ longitude: -122.42, latitude: 37.78 },
|
|
636
|
+
{ longitude: -122.45, latitude: 37.91 },
|
|
637
|
+
{ longitude: -122.48, latitude: 37.73 }
|
|
634
638
|
],
|
|
635
639
|
profile: 'driving',
|
|
636
640
|
sources: '1',
|
|
@@ -644,8 +648,8 @@ describe('MatrixTool', () => {
|
|
|
644
648
|
});
|
|
645
649
|
await tool.run({
|
|
646
650
|
coordinates: [
|
|
647
|
-
|
|
648
|
-
|
|
651
|
+
{ longitude: -122.42, latitude: 37.78 },
|
|
652
|
+
{ longitude: -122.45, latitude: 37.91 }
|
|
649
653
|
],
|
|
650
654
|
profile: 'driving',
|
|
651
655
|
sources: '0',
|
|
@@ -661,8 +665,8 @@ describe('MatrixTool', () => {
|
|
|
661
665
|
});
|
|
662
666
|
await tool.run({
|
|
663
667
|
coordinates: [
|
|
664
|
-
|
|
665
|
-
|
|
668
|
+
{ longitude: -122.42, latitude: 37.78 },
|
|
669
|
+
{ longitude: -122.45, latitude: 37.91 }
|
|
666
670
|
],
|
|
667
671
|
profile: 'driving',
|
|
668
672
|
annotations: 'duration,distance'
|
|
@@ -674,8 +678,8 @@ describe('MatrixTool', () => {
|
|
|
674
678
|
});
|
|
675
679
|
await tool.run({
|
|
676
680
|
coordinates: [
|
|
677
|
-
|
|
678
|
-
|
|
681
|
+
{ longitude: -122.42, latitude: 37.78 },
|
|
682
|
+
{ longitude: -122.45, latitude: 37.91 }
|
|
679
683
|
],
|
|
680
684
|
profile: 'driving',
|
|
681
685
|
annotations: 'distance,duration'
|
|
@@ -694,7 +698,10 @@ describe('MatrixTool', () => {
|
|
|
694
698
|
const mockFetch = setupFetch({
|
|
695
699
|
json: () => Promise.resolve(sampleMatrixResponse)
|
|
696
700
|
});
|
|
697
|
-
const coordinates = Array.from({ length: 25 }, (_, i) =>
|
|
701
|
+
const coordinates = Array.from({ length: 25 }, (_, i) => ({
|
|
702
|
+
longitude: -122.42 + i * 0.01,
|
|
703
|
+
latitude: 37.78 + i * 0.01
|
|
704
|
+
}));
|
|
698
705
|
const result = await tool.run({
|
|
699
706
|
coordinates,
|
|
700
707
|
profile: 'driving'
|
|
@@ -706,7 +713,10 @@ describe('MatrixTool', () => {
|
|
|
706
713
|
const mockFetch = setupFetch({
|
|
707
714
|
json: () => Promise.resolve(sampleMatrixResponse)
|
|
708
715
|
});
|
|
709
|
-
const coordinates = Array.from({ length: 10 }, (_, i) =>
|
|
716
|
+
const coordinates = Array.from({ length: 10 }, (_, i) => ({
|
|
717
|
+
longitude: -122.42 + i * 0.01,
|
|
718
|
+
latitude: 37.78 + i * 0.01
|
|
719
|
+
}));
|
|
710
720
|
const result = await tool.run({
|
|
711
721
|
coordinates,
|
|
712
722
|
profile: 'driving-traffic'
|
|
@@ -716,7 +726,10 @@ describe('MatrixTool', () => {
|
|
|
716
726
|
});
|
|
717
727
|
it('rejects 11 coordinates for driving-traffic profile', async () => {
|
|
718
728
|
const mockFetch = setupFetch();
|
|
719
|
-
const coordinates = Array.from({ length: 11 }, (_, i) =>
|
|
729
|
+
const coordinates = Array.from({ length: 11 }, (_, i) => ({
|
|
730
|
+
longitude: -122.42 + i * 0.01,
|
|
731
|
+
latitude: 37.78 + i * 0.01
|
|
732
|
+
}));
|
|
720
733
|
const result = await tool.run({
|
|
721
734
|
coordinates,
|
|
722
735
|
profile: 'driving-traffic'
|
|
@@ -744,8 +757,8 @@ describe('MatrixTool', () => {
|
|
|
744
757
|
});
|
|
745
758
|
const result = await tool.run({
|
|
746
759
|
coordinates: [
|
|
747
|
-
|
|
748
|
-
|
|
760
|
+
{ longitude: -122.42, latitude: 37.78 },
|
|
761
|
+
{ longitude: -122.45, latitude: 37.91 }
|
|
749
762
|
],
|
|
750
763
|
profile: 'driving-traffic'
|
|
751
764
|
});
|
|
@@ -759,8 +772,8 @@ describe('MatrixTool', () => {
|
|
|
759
772
|
});
|
|
760
773
|
const result = await tool.run({
|
|
761
774
|
coordinates: [
|
|
762
|
-
|
|
763
|
-
|
|
775
|
+
{ longitude: -122.42, latitude: 37.78 },
|
|
776
|
+
{ longitude: -122.45, latitude: 37.91 }
|
|
764
777
|
],
|
|
765
778
|
profile: 'driving'
|
|
766
779
|
});
|
|
@@ -774,8 +787,8 @@ describe('MatrixTool', () => {
|
|
|
774
787
|
});
|
|
775
788
|
const result = await tool.run({
|
|
776
789
|
coordinates: [
|
|
777
|
-
|
|
778
|
-
|
|
790
|
+
{ longitude: -122.42, latitude: 37.78 },
|
|
791
|
+
{ longitude: -122.45, latitude: 37.91 }
|
|
779
792
|
],
|
|
780
793
|
profile: 'walking'
|
|
781
794
|
});
|
|
@@ -789,8 +802,8 @@ describe('MatrixTool', () => {
|
|
|
789
802
|
});
|
|
790
803
|
const result = await tool.run({
|
|
791
804
|
coordinates: [
|
|
792
|
-
|
|
793
|
-
|
|
805
|
+
{ longitude: -122.42, latitude: 37.78 },
|
|
806
|
+
{ longitude: -122.45, latitude: 37.91 }
|
|
794
807
|
],
|
|
795
808
|
profile: 'cycling'
|
|
796
809
|
});
|