forked from Beakerboy/OSMBuilding
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsplit_way_multipolygon.test.js
More file actions
69 lines (61 loc) · 1.67 KB
/
split_way_multipolygon.test.js
File metadata and controls
69 lines (61 loc) · 1.67 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
/**
* @jest-environment jsdom
*/
import { Shape, Mesh } from 'three';
import { TextEncoder } from 'node:util';
global.TextEncoder = TextEncoder;
import { Building } from '../src/building.js';
import { MultiBuildingPart } from '../src/multibuildingpart.js';
const data = `
<osm>
<node id="12" lat="4" lon="4"/>
<node id="11" lat="4" lon="4.001"/>
<node id="6" lat="4.001" lon="4.001"/>
<node id="7" lat="4.001" lon="4"/>
<node id="8" lat="4.00025" lon="4.00025"/>
<node id="9" lat="4.00025" lon="4.00075"/>
<node id="10" lat="4.00075" lon="4.0005"/>
<relation id="5">
<member ref="1" role="outer" type="way"/>
<member ref="3" role="outer" type="way"/>
<member ref="2" role="inner" type="way"/>
<tag k="type" v="multipolygon"/>
<tag k="building" v="yes"/>
<tag k="roof:shape" v="skillion"/>
<tag k="roof:direction" v="0"/>
<tag k="roof:angle" v="45"/>
</relation>
<way id="1">
<nd ref="12"/>
<nd ref="11"/>
<nd ref="6"/>
</way>
<way id="2">
<nd ref="8"/>
<nd ref="9"/>
<nd ref="10"/>
<nd ref="8"/>
</way>
<way id="3">
<nd ref="6"/>
<nd ref="7"/>
<nd ref="12"/>
</way>
</osm>`;
beforeEach(() => {
errors = [];
});
test('Test Simple Multipolygon', () => {
let xmlData = new window.DOMParser().parseFromString(data, 'text/xml');
const nodelist = Building.buildNodeList(xmlData);
const shape = new MultiBuildingPart('5', xmlData, nodelist);
expect(shape.id).toBe('5');
expect(shape.shape).toBeInstanceOf(Shape);
// expect(shape.roof).toBeInstanceOf(Mesh);
expect(errors.length).toBe(0);
});
window.printError = printError;
var errors = [];
function printError(txt) {
errors.push[txt];
}