forked from Maps4HTML/MapML.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqueryGeoJSON.test.js
More file actions
92 lines (91 loc) · 3.44 KB
/
queryGeoJSON.test.js
File metadata and controls
92 lines (91 loc) · 3.44 KB
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
import { test, expect, chromium } from '@playwright/test';
test.describe('GeoJSON Query Response', () => {
let page;
let context;
test.beforeAll(async function () {
context = await chromium.launchPersistentContext('', {
headless: true,
slowMo: 250
});
page = await context.newPage();
await page.goto('queryGeoJSON.html');
await page.waitForTimeout(1000);
});
test.afterAll(async function () {
await context.close();
});
test('Query returns features from all three GeoJSON extents', async () => {
await page.click('mapml-viewer');
const popupContainer = page.locator('.mapml-popup-content > iframe');
await expect(popupContainer).toBeVisible();
const popupFeatureCount = page.locator('.mapml-feature-count');
await expect(popupFeatureCount).toHaveText('1/3', { useInnerText: true });
});
test('Standard CRS:84 GeoJSON feature has cs meta set to gcrs', async () => {
// The first feature comes from the CRS:84 extent (geojsonFeature)
// Its meta should have cs=gcrs since coordinates are standard lon/lat
let csMeta = await page.evaluate(() => {
let layer =
document.querySelector('mapml-viewer').layers[0]._layer;
let features = layer._mapmlFeatures;
// find the feature from CRS:84 response (the polygon from geojsonFeature)
let f = features.find(
(feat) => feat.querySelector('map-polygon') !== null
);
if (f && f.meta) {
let cs = f.meta.find(
(m) => m.getAttribute('name') === 'cs'
);
return cs ? cs.getAttribute('content') : null;
}
return null;
});
expect(csMeta).toBe('gcrs');
});
test('GeoJSON with explicit crs member has cs meta set to pcrs', async () => {
// The feature from geojsonProjectedWithCrs has a "crs" member
// Its meta should have cs=pcrs
let csMeta = await page.evaluate(() => {
let layer =
document.querySelector('mapml-viewer').layers[0]._layer;
let features = layer._mapmlFeatures;
// find the feature with properties containing "Test Point with CRS"
let f = features.find((feat) => {
let props = feat.querySelector('map-properties');
return props && props.innerHTML.includes('Test Point with CRS');
});
if (f && f.meta) {
let cs = f.meta.find(
(m) => m.getAttribute('name') === 'cs'
);
return cs ? cs.getAttribute('content') : null;
}
return null;
});
expect(csMeta).toBe('pcrs');
});
test('GeoJSON with projected coordinates but no crs member has cs meta set to pcrs via magnitude heuristic', async () => {
// The feature from geojsonProjectedNoCrs has large coordinate values
// but no "crs" member — the magnitude heuristic should detect this
let csMeta = await page.evaluate(() => {
let layer =
document.querySelector('mapml-viewer').layers[0]._layer;
let features = layer._mapmlFeatures;
// find the feature with properties containing "Test Point projected no CRS"
let f = features.find((feat) => {
let props = feat.querySelector('map-properties');
return (
props && props.innerHTML.includes('Test Point projected no CRS')
);
});
if (f && f.meta) {
let cs = f.meta.find(
(m) => m.getAttribute('name') === 'cs'
);
return cs ? cs.getAttribute('content') : null;
}
return null;
});
expect(csMeta).toBe('pcrs');
});
});