|
1 |
| -import test from 'flug'; |
2 |
| -import fetch from 'cross-fetch'; |
3 |
| -import load from '../load'; |
4 |
| -import get from './get.module'; |
| 1 | +/** |
| 2 | + * @prettier |
| 3 | + */ |
| 4 | +import test from "flug"; |
| 5 | +import { serve } from "srvd"; |
| 6 | +import load from "../load"; |
| 7 | +import parse from "../parse"; |
| 8 | +import get from "./get.module"; |
5 | 9 |
|
6 |
| -const urlRwanda = 'http://localhost:3000/data/RWA_MNH_ANC.tif'; |
7 |
| -const bboxRwanda = require('../../data/RwandaBufferedBoundingBox.json'); |
| 10 | +const urlRwanda = "http://localhost:3000/data/RWA_MNH_ANC.tif"; |
| 11 | +const bboxRwanda = require("../../data/RwandaBufferedBoundingBox.json"); |
8 | 12 |
|
9 |
| -test('Got Correct Flat Values when Geom bigger than Raster', async ({ eq }) => { |
10 |
| - const georaster = await fetch(urlRwanda).then(r => r.arrayBuffer()).then(load); |
| 13 | +const EXPECTED_HEIGHT = 712; |
| 14 | +const EXPECTED_WIDTH = 995; |
| 15 | +const EXPECTED_AREA = 708440; |
| 16 | + |
| 17 | +if (require.main === module) serve({ debug: true, port: 3000, wait: 15 }); |
| 18 | + |
| 19 | +test("(Legacy) Got Correct Flat Values when Geom bigger than Raster", async ({ eq }) => { |
| 20 | + const georaster = await load(urlRwanda); |
11 | 21 | const actualValues = get(georaster, bboxRwanda, true);
|
12 | 22 | eq(actualValues.length, 1);
|
13 |
| - console.log(actualValues[0].filter(it => it === undefined).length); |
14 |
| - eq(actualValues[0].length, georaster.height * georaster.width); |
| 23 | + eq(actualValues[0].length, EXPECTED_AREA); |
15 | 24 | });
|
16 | 25 |
|
17 |
| -test('Got Correct 2-D Values when Geom bigger than Raster', async ({ eq }) => { |
18 |
| - const georaster = await fetch(urlRwanda).then(r => r.arrayBuffer()).then(load); |
| 26 | +test("(Legacy) Got Correct 2-D Values when Geom bigger than Raster", async ({ eq }) => { |
| 27 | + const georaster = await load(urlRwanda); |
19 | 28 | const actualValues = get(georaster, bboxRwanda, false);
|
20 | 29 | eq(actualValues.length, 1);
|
21 |
| - eq(actualValues[0].length, georaster.height); |
22 |
| - eq(actualValues[0][0].length, georaster.width); |
| 30 | + eq(actualValues[0].length, EXPECTED_HEIGHT); |
| 31 | + eq(actualValues[0][0].length, EXPECTED_WIDTH); |
23 | 32 | });
|
24 | 33 |
|
25 |
| -test('Got Correct flat values for whole raster', async ({ eq }) => { |
26 |
| - const georaster = await fetch(urlRwanda).then(r => r.arrayBuffer()).then(load); |
| 34 | +test("(Legacy) Got Correct flat values for whole raster", async ({ eq }) => { |
| 35 | + const georaster = await load(urlRwanda); |
27 | 36 | const flat = true;
|
28 | 37 | const actualValues = get(georaster, null, flat);
|
29 | 38 | eq(actualValues.length, 1);
|
30 |
| - eq(actualValues[0].length, georaster.height * georaster.width); |
| 39 | + eq(actualValues[0].length, EXPECTED_AREA); |
31 | 40 | });
|
32 | 41 |
|
| 42 | +test("(Legacy) Got Correct Flat Values when Geom bigger than Raster (from URL)", async ({ eq }) => { |
| 43 | + const georaster = await load(urlRwanda); |
| 44 | + const actualValues = get(georaster, bboxRwanda, true); |
| 45 | + eq(actualValues.length, 1); |
| 46 | + eq(actualValues[0].length, EXPECTED_AREA); |
| 47 | +}); |
33 | 48 |
|
34 |
| -test('Got Correct Flat Values when Geom bigger than Raster (from URL)', async ({ eq }) => { |
| 49 | +test("(Legacy) Got Correct 2-D Values when Geom bigger than Raster (from URL)", async ({ eq }) => { |
35 | 50 | const georaster = await load(urlRwanda);
|
36 |
| - const actualValues = await get(georaster, bboxRwanda, true); |
| 51 | + const actualValues = get(georaster, bboxRwanda, false); |
37 | 52 | eq(actualValues.length, 1);
|
38 |
| - eq(actualValues[0].length, georaster.height * georaster.width); |
| 53 | + eq(actualValues[0].length, EXPECTED_HEIGHT); |
| 54 | + eq(actualValues[0][0].length, EXPECTED_WIDTH); |
39 | 55 | });
|
40 | 56 |
|
41 |
| -test('Got Correct 2-D Values when Geom bigger than Raster (from URL)', async ({ eq }) => { |
| 57 | +test("(Legacy) Got Correct flat values for whole raster (from URL)", async ({ eq }) => { |
42 | 58 | const georaster = await load(urlRwanda);
|
| 59 | + const flat = true; |
| 60 | + const actualValues = get(georaster, null, flat); |
| 61 | + eq(actualValues.length, 1); |
| 62 | + eq(actualValues[0].length, EXPECTED_AREA); |
| 63 | +}); |
| 64 | + |
| 65 | +// modern |
| 66 | +test("(Modern) Got Correct Flat Values when Geom bigger than Raster", async ({ eq }) => { |
| 67 | + const georaster = await parse(urlRwanda); |
| 68 | + const actualValues = await get(georaster, bboxRwanda, true); |
| 69 | + eq(actualValues.length, 1); |
| 70 | + eq(actualValues[0].length, EXPECTED_AREA); |
| 71 | +}); |
| 72 | + |
| 73 | +test("(Modern) Got Correct 2-D Values when Geom bigger than Raster", async ({ eq }) => { |
| 74 | + const georaster = await parse(urlRwanda); |
43 | 75 | const actualValues = await get(georaster, bboxRwanda, false);
|
44 | 76 | eq(actualValues.length, 1);
|
45 |
| - eq(actualValues[0].length, georaster.height); |
46 |
| - eq(actualValues[0][0].length, georaster.width); |
| 77 | + eq(actualValues[0].length, EXPECTED_HEIGHT); |
| 78 | + eq(actualValues[0][0].length, EXPECTED_WIDTH); |
47 | 79 | });
|
48 | 80 |
|
49 |
| -test('Got Correct flat values for whole raster (from URL)', async ({ eq }) => { |
| 81 | +test("(Modern) Got Correct flat values for whole raster", async ({ eq }) => { |
| 82 | + const georaster = await parse(urlRwanda); |
| 83 | + const flat = true; |
| 84 | + const actualValues = await get(georaster, null, flat); |
| 85 | + eq(actualValues.length, 1); |
| 86 | + eq(actualValues[0].length, EXPECTED_AREA); |
| 87 | +}); |
| 88 | + |
| 89 | +test("(Modern) Got Correct Flat Values when Geom bigger than Raster (from URL)", async ({ eq }) => { |
| 90 | + const georaster = await parse(urlRwanda); |
| 91 | + const actualValues = await get(georaster, bboxRwanda, true); |
| 92 | + eq(actualValues.length, 1); |
| 93 | + eq(actualValues[0].length, EXPECTED_AREA); |
| 94 | +}); |
| 95 | + |
| 96 | +test("(Modern) Got Correct 2-D Values when Geom bigger than Raster (from URL)", async ({ eq }) => { |
| 97 | + const georaster = await parse(urlRwanda); |
| 98 | + const actualValues = await get(georaster, bboxRwanda, false); |
| 99 | + eq(actualValues.length, 1); |
| 100 | + eq(actualValues[0].length, EXPECTED_HEIGHT); |
| 101 | + eq(actualValues[0][0].length, EXPECTED_WIDTH); |
| 102 | +}); |
| 103 | + |
| 104 | +test("(Modern) Got Correct flat values for whole raster (from URL)", async ({ eq }) => { |
50 | 105 | const georaster = await load(urlRwanda);
|
51 | 106 | const flat = true;
|
52 | 107 | const actualValues = await get(georaster, null, flat);
|
53 | 108 | eq(actualValues.length, 1);
|
54 |
| - eq(actualValues[0].length, georaster.height * georaster.width); |
| 109 | + eq(actualValues[0].length, EXPECTED_AREA); |
| 110 | +}); |
| 111 | + |
| 112 | +// GeoRaster URL |
| 113 | +test("(Modern) Got Correct Flat Values when Geom bigger than Raster [url source]", async ({ eq }) => { |
| 114 | + const actualValues = await get(urlRwanda, bboxRwanda, true); |
| 115 | + eq(actualValues.length, 1); |
| 116 | + eq(actualValues[0].length, EXPECTED_AREA); |
| 117 | +}); |
| 118 | + |
| 119 | +test("(Modern) Got Correct 2-D Values when Geom bigger than Raster [url source]", async ({ eq }) => { |
| 120 | + const actualValues = await get(urlRwanda, bboxRwanda, false); |
| 121 | + eq(actualValues.length, 1); |
| 122 | + eq(actualValues[0].length, EXPECTED_HEIGHT); |
| 123 | + eq(actualValues[0][0].length, EXPECTED_WIDTH); |
| 124 | +}); |
| 125 | + |
| 126 | +test("(Modern) Got Correct flat values for whole raster [url source]", async ({ eq }) => { |
| 127 | + const flat = true; |
| 128 | + const actualValues = await get(urlRwanda, null, flat); |
| 129 | + eq(actualValues.length, 1); |
| 130 | + eq(actualValues[0].length, EXPECTED_AREA); |
| 131 | +}); |
| 132 | + |
| 133 | +test("(Modern) Got Correct Flat Values when Geom bigger than Raster [url source]", async ({ eq }) => { |
| 134 | + const actualValues = await get(urlRwanda, bboxRwanda, true); |
| 135 | + eq(actualValues.length, 1); |
| 136 | + eq(actualValues[0].length, EXPECTED_AREA); |
| 137 | +}); |
| 138 | + |
| 139 | +test("(Modern) Got Correct 2-D Values when Geom bigger than Raster [url source]", async ({ eq }) => { |
| 140 | + const actualValues = await get(urlRwanda, bboxRwanda, false); |
| 141 | + eq(actualValues.length, 1); |
| 142 | + eq(actualValues[0].length, EXPECTED_HEIGHT); |
| 143 | + eq(actualValues[0][0].length, EXPECTED_WIDTH); |
| 144 | +}); |
| 145 | + |
| 146 | +test("(Modern) Got Correct flat values for whole raster [url source]", async ({ eq }) => { |
| 147 | + const flat = true; |
| 148 | + const actualValues = await get(urlRwanda, null, flat); |
| 149 | + eq(actualValues.length, 1); |
| 150 | + eq(actualValues[0].length, EXPECTED_AREA); |
55 | 151 | });
|
0 commit comments