|
| 1 | +/** |
| 2 | + * @jest-environment jsdom |
| 3 | + */ |
| 4 | + |
| 5 | +import { Shape, Mesh } from 'three'; |
| 6 | +import { TextEncoder } from 'node:util'; |
| 7 | +global.TextEncoder = TextEncoder; |
| 8 | + |
| 9 | +import { Building } from '../src/building.js'; |
| 10 | +import { MultiBuildingPart } from '../src/multibuildingpart.js'; |
| 11 | +// ways 1 and 3 are tip-to-tip. |
| 12 | +const data = ` |
| 13 | +<osm> |
| 14 | + <node id="12" lat="4" lon="4"/> |
| 15 | + <node id="11" lat="4" lon="4.001"/> |
| 16 | + <node id="6" lat="4.001" lon="4.001"/> |
| 17 | + <node id="7" lat="4.001" lon="4"/> |
| 18 | + <node id="8" lat="4.00025" lon="4.00025"/> |
| 19 | + <node id="9" lat="4.00025" lon="4.00075"/> |
| 20 | + <node id="10" lat="4.00075" lon="4.0005"/> |
| 21 | + <relation id="5"> |
| 22 | + <member ref="1" role="outer"/> |
| 23 | + <member ref="3" role="outer"/> |
| 24 | + <member ref="2" role="inner"/> |
| 25 | + <tag k="type" v="multipolygon"/> |
| 26 | + <tag k="building" v="yes"/> |
| 27 | + <tag k="roof:shape" v="skillion"/> |
| 28 | + <tag k="roof:direction" v="0"/> |
| 29 | + <tag k="roof:angle" v="45"/> |
| 30 | + </relation> |
| 31 | + <way id="1"> |
| 32 | + <nd ref="12"/> |
| 33 | + <nd ref="11"/> |
| 34 | + <nd ref="6"/> |
| 35 | + </way> |
| 36 | + <way id="2"> |
| 37 | + <nd ref="8"/> |
| 38 | + <nd ref="9"/> |
| 39 | + <nd ref="10"/> |
| 40 | + <nd ref="8"/> |
| 41 | + </way> |
| 42 | + <way id="3"> |
| 43 | + <nd ref="12"/> |
| 44 | + <nd ref="7"/> |
| 45 | + <nd ref="6"/> |
| 46 | + </way> |
| 47 | +</osm>`; |
| 48 | + |
| 49 | +beforeEach(() => { |
| 50 | + errors = []; |
| 51 | +}); |
| 52 | + |
| 53 | +test('Test Simple Multipolygon', () => { |
| 54 | + let xmlData = new window.DOMParser().parseFromString(data, 'text/xml'); |
| 55 | + const nodelist = Building.buildNodeList(xmlData); |
| 56 | + const shape = new MultiBuildingPart('5', xmlData, nodelist); |
| 57 | + expect(shape.id).toBe('5'); |
| 58 | + expect(shape.shape).toBeInstanceOf(Shape); |
| 59 | + // expect(shape.roof).toBeInstanceOf(Mesh); |
| 60 | + expect(errors.length).toBe(0); |
| 61 | +}); |
| 62 | + |
| 63 | +window.printError = printError; |
| 64 | + |
| 65 | +var errors = []; |
| 66 | + |
| 67 | +function printError(txt) { |
| 68 | + errors.push[txt]; |
| 69 | +} |
0 commit comments