|
| 1 | +/** |
| 2 | + * @jest-environment jsdom |
| 3 | + */ |
| 4 | + |
| 5 | +import { Shape, Mesh } from 'three'; |
| 6 | +import { TextEncoder } from 'node:util'; |
| 7 | +import {expect, test, beforeEach, describe} from '@jest/globals'; |
| 8 | +global.TextEncoder = TextEncoder; |
| 9 | + |
| 10 | +import {apis} from '../src/apis.js'; |
| 11 | +global.apis = apis; |
| 12 | + |
| 13 | +import { Building } from '../src/building.js'; |
| 14 | + |
| 15 | +import fetchMock from 'jest-fetch-mock'; |
| 16 | +fetchMock.enableMocks(); |
| 17 | + |
| 18 | +// Step 1: get the full data for the buiding from the API |
| 19 | +const initialData = ` |
| 20 | +`; |
| 21 | + |
| 22 | +// Step 2: get the bounding box data for the buiding from the API |
| 23 | +const mapData = ` |
| 24 | +`; |
| 25 | + |
| 26 | +// Describe Issue |
| 27 | +test('Diagnose Skillion Issue', async() => { |
| 28 | + fetch.mockResponses( |
| 29 | + [initialData], // /way/1426868383/full |
| 30 | + [mapData], // /map call |
| 31 | + ); |
| 32 | + let way_id = '1426868383'; |
| 33 | + const innerData = await Building.downloadDataAroundBuilding('way', way_id); |
| 34 | + const building = new Building(way_id, innerData); |
| 35 | + expect(building.id).toBe(way_id); |
| 36 | + const urlBase = 'https://api.openstreetmap.org/api/0.6/'; |
| 37 | + expect(global.fetch.mock.calls[0][0]).toBe(urlBase + 'way/' + way_id + '/full'); |
| 38 | + expect(global.fetch.mock.calls[1][0]).toBe(urlBase + 'map?bbox=125.7416897,39.0269534,125.7420811,39.0272423'); |
| 39 | + // get building part |
| 40 | + const parts = building.parts; |
| 41 | + // let found = false; |
| 42 | + for (const part of parts){ |
| 43 | + // Get the building part |
| 44 | + if (part.id === '1426868384'){ |
| 45 | + const shape = part.shape; |
| 46 | + const points = shape.extractPoints().shape; |
| 47 | + //const options = { |
| 48 | + // angle: (360 - part.options.roof.direction) / 360 * 2 * Math.PI, |
| 49 | + // depth: part.options.roof.height, |
| 50 | + // pitch: part.options.roof.angle / 180 * Math.PI, |
| 51 | + //}; |
| 52 | + //expect(options).toBe({}); |
| 53 | + expect(points).toBe([]); |
| 54 | + //expect(shape.toJSON()).toBe(''); |
| 55 | + // found = true; |
| 56 | + } |
| 57 | + } |
| 58 | + // expect(found).toBeTrue(); |
| 59 | + // dump outer shape |
| 60 | +}); |
| 61 | + |
| 62 | +window.printError = printError; |
| 63 | + |
| 64 | +var errors = []; |
| 65 | + |
| 66 | +function printError(txt) { |
| 67 | + errors.push[txt]; |
| 68 | +} |
0 commit comments