|
1 |
| -import test from 'flug'; |
2 |
| -import fetch from 'cross-fetch'; |
3 |
| -import load from '../load'; |
4 |
| -import max from './max.module'; |
5 |
| - |
6 |
| -const url = 'http://localhost:3000/data/test.tiff'; |
7 |
| - |
8 |
| -const bbox = [80.63, 7.42, 84.21, 10.10]; |
9 |
| -const expectedBboxValue = 5166.70; |
10 |
| - |
11 |
| -const polygon = [[ |
12 |
| - [83.12255859375, 22.49225722008518], [82.96875, 21.57571893245848], [81.58447265624999, 1.207458730482642], |
13 |
| - [83.07861328125, 20.34462694382967], [83.8037109375, 19.497664168139053], [84.814453125, 19.766703551716976], |
14 |
| - [85.078125, 21.166483858206583], [86.044921875, 20.838277806058933], [86.98974609375, 22.49225722008518], |
15 |
| - [85.58349609375, 24.54712317973075], [84.6826171875, 23.36242859340884], [83.12255859375, 22.49225722008518] |
16 |
| -]]; |
17 |
| -const expectedPolygonValue = 7807.40; |
18 |
| - |
19 |
| -test('Got Correct Get Max from Bounding Box', async ({ eq }) => { |
20 |
| - const georaster = await fetch(url).then(r => r.arrayBuffer()).then(load); |
| 1 | +/** |
| 2 | + * @prettier |
| 3 | + */ |
| 4 | +import test from "flug"; |
| 5 | +import { serve } from "srvd"; |
| 6 | +import load from "../load"; |
| 7 | +import max from "./max.module"; |
| 8 | + |
| 9 | +if (require.main === module) serve({ debug: true, port: 3000, wait: 60 }); |
| 10 | + |
| 11 | +const url = "http://localhost:3000/data/test.tiff"; |
| 12 | + |
| 13 | +const bbox = [80.63, 7.42, 84.21, 10.1]; |
| 14 | +const expectedBboxValue = 5166.7; |
| 15 | + |
| 16 | +const polygon = [ |
| 17 | + [ |
| 18 | + [83.12255859375, 22.49225722008518], |
| 19 | + [82.96875, 21.57571893245848], |
| 20 | + [81.58447265624999, 1.207458730482642], |
| 21 | + [83.07861328125, 20.34462694382967], |
| 22 | + [83.8037109375, 19.497664168139053], |
| 23 | + [84.814453125, 19.766703551716976], |
| 24 | + [85.078125, 21.166483858206583], |
| 25 | + [86.044921875, 20.838277806058933], |
| 26 | + [86.98974609375, 22.49225722008518], |
| 27 | + [85.58349609375, 24.54712317973075], |
| 28 | + [84.6826171875, 23.36242859340884], |
| 29 | + [83.12255859375, 22.49225722008518] |
| 30 | + ] |
| 31 | +]; |
| 32 | +const expectedPolygonValue = 7807.4; |
| 33 | + |
| 34 | +test("(Legacy) Max without Geometry", async ({ eq }) => { |
| 35 | + const georaster = await load(url); |
| 36 | + const value = max(georaster)[0]; |
| 37 | + eq(value, 8131.2); |
| 38 | +}); |
| 39 | + |
| 40 | +test("(Legacy) Max with Bounding Box", async ({ eq }) => { |
| 41 | + const georaster = await load(url); |
21 | 42 | const value = Number(max(georaster, bbox)[0].toFixed(2));
|
22 | 43 | eq(value, expectedBboxValue);
|
23 | 44 | });
|
24 | 45 |
|
25 |
| -test('Get Max from Polygon', async ({ eq }) => { |
26 |
| - const georaster = await fetch(url).then(r => r.arrayBuffer()).then(load); |
| 46 | +test("(Legacy) Max with Polygon", async ({ eq }) => { |
| 47 | + const georaster = await load(url); |
27 | 48 | const value = Number(max(georaster, polygon)[0].toFixed(2));
|
28 | 49 | eq(value, expectedPolygonValue);
|
29 | 50 | });
|
30 | 51 |
|
31 |
| -test('Get Max from Raster without polygon', async ({ eq }) => { |
32 |
| - const georaster = await fetch(url).then(r => r.arrayBuffer()).then(load); |
33 |
| - const value = max(georaster)[0]; |
34 |
| - eq(value, 8131.2); |
| 52 | +test("(Modern) Max without Geometry", async ({ eq }) => { |
| 53 | + eq(await max(url), [8131.2]); |
35 | 54 | });
|
36 | 55 |
|
37 |
| - |
38 |
| -// async |
39 |
| -test('Got Correct Get Max from Bounding Box', async ({ eq }) => { |
40 |
| - const georaster = await load(url); |
41 |
| - const result = await max(georaster, bbox); |
| 56 | +test("(Modern) Got Correct Get Max from Bounding Box", async ({ eq }) => { |
| 57 | + const result = await max(url, bbox); |
42 | 58 | const value = Number(result[0].toFixed(2));
|
43 | 59 | eq(value, expectedBboxValue);
|
44 | 60 | });
|
45 | 61 |
|
46 |
| -test('Get Max from Polygon', async ({ eq }) => { |
| 62 | +test("(Modern) Get Max from Polygon", async ({ eq }) => { |
47 | 63 | const result = await max(url, polygon);
|
48 | 64 | const value = Number(result[0].toFixed(2));
|
49 | 65 | eq(value, expectedPolygonValue);
|
50 | 66 | });
|
51 |
| - |
52 |
| -test('Get Max from Raster without polygon from async obj', async ({ eq }) => { |
53 |
| - const georaster = await load(url); |
54 |
| - const value = await max(georaster); |
55 |
| - eq(value[0], 8131.2); |
56 |
| -}); |
57 |
| - |
58 |
| -test('Get Max from Raster without polygon directly from url', async ({ eq }) => { |
59 |
| - const value = await max(url); |
60 |
| - eq(value[0], 8131.2); |
61 |
| -}); |
|
0 commit comments