From e53961450b7573340f9e6c5c78afc11d056eb737 Mon Sep 17 00:00:00 2001 From: Kevin Nowaczyk Date: Tue, 13 Jan 2026 12:06:09 -0500 Subject: [PATCH 01/12] Create diagnose.test.js #146 --- test/diagnose.test.js | 68 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 test/diagnose.test.js diff --git a/test/diagnose.test.js b/test/diagnose.test.js new file mode 100644 index 0000000..1a303a5 --- /dev/null +++ b/test/diagnose.test.js @@ -0,0 +1,68 @@ +/** + * @jest-environment jsdom + */ + +import { Shape, Mesh } from 'three'; +import { TextEncoder } from 'node:util'; +import {expect, test, beforeEach, describe} from '@jest/globals'; +global.TextEncoder = TextEncoder; + +import {apis} from '../src/apis.js'; +global.apis = apis; + +import { Building } from '../src/building.js'; + +import fetchMock from 'jest-fetch-mock'; +fetchMock.enableMocks(); + +// Step 1: get the full data for the buiding from the API +const initialData = ` +`; + +// Step 2: get the bounding box data for the buiding from the API +const mapData = ` +`; + +// Describe Issue +test('Diagnose Skillion Issue', async() => { + fetch.mockResponses( + [initialData], // /way/1426868383/full + [mapData], // /map call + ); + let way_id = '1426868383'; + const innerData = await Building.downloadDataAroundBuilding('way', way_id); + const building = new Building(way_id, innerData); + expect(building.id).toBe(way_id); + const urlBase = 'https://api.openstreetmap.org/api/0.6/'; + expect(global.fetch.mock.calls[0][0]).toBe(urlBase + 'way/' + way_id + '/full'); + expect(global.fetch.mock.calls[1][0]).toBe(urlBase + 'map?bbox=125.7416897,39.0269534,125.7420811,39.0272423'); + // get building part + const parts = building.parts; + // let found = false; + for (const part of parts){ + // Get the building part + if (part.id === '1426868384'){ + const shape = part.shape; + const points = shape.extractPoints().shape; + //const options = { + // angle: (360 - part.options.roof.direction) / 360 * 2 * Math.PI, + // depth: part.options.roof.height, + // pitch: part.options.roof.angle / 180 * Math.PI, + //}; + //expect(options).toBe({}); + expect(points).toBe([]); + //expect(shape.toJSON()).toBe(''); + // found = true; + } + } + // expect(found).toBeTrue(); + // dump outer shape +}); + +window.printError = printError; + +var errors = []; + +function printError(txt) { + errors.push[txt]; +} From 6dcdb7df2dbf31490f301929c6095868dcd922b3 Mon Sep 17 00:00:00 2001 From: Kevin Nowaczyk Date: Tue, 13 Jan 2026 12:08:09 -0500 Subject: [PATCH 02/12] Update diagnose.test.js --- test/diagnose.test.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/diagnose.test.js b/test/diagnose.test.js index 1a303a5..6ecbdb2 100644 --- a/test/diagnose.test.js +++ b/test/diagnose.test.js @@ -29,12 +29,12 @@ test('Diagnose Skillion Issue', async() => { [initialData], // /way/1426868383/full [mapData], // /map call ); - let way_id = '1426868383'; - const innerData = await Building.downloadDataAroundBuilding('way', way_id); - const building = new Building(way_id, innerData); - expect(building.id).toBe(way_id); + let wayId = '1426868383'; + const innerData = await Building.downloadDataAroundBuilding('way', wayId); + const building = new Building(wayId, innerData); + expect(building.id).toBe(wayId); const urlBase = 'https://api.openstreetmap.org/api/0.6/'; - expect(global.fetch.mock.calls[0][0]).toBe(urlBase + 'way/' + way_id + '/full'); + expect(global.fetch.mock.calls[0][0]).toBe(urlBase + 'way/' + wayId + '/full'); expect(global.fetch.mock.calls[1][0]).toBe(urlBase + 'map?bbox=125.7416897,39.0269534,125.7420811,39.0272423'); // get building part const parts = building.parts; From 176b72a1c48125ca6fd1967695fd0f1d9b8d2020 Mon Sep 17 00:00:00 2001 From: Kevin Nowaczyk Date: Tue, 13 Jan 2026 12:12:03 -0500 Subject: [PATCH 03/12] Update diagnose.test.js --- test/diagnose.test.js | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/test/diagnose.test.js b/test/diagnose.test.js index 6ecbdb2..01c5021 100644 --- a/test/diagnose.test.js +++ b/test/diagnose.test.js @@ -16,7 +16,40 @@ import fetchMock from 'jest-fetch-mock'; fetchMock.enableMocks(); // Step 1: get the full data for the buiding from the API -const initialData = ` +const initialData = ` + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + `; // Step 2: get the bounding box data for the buiding from the API From 7e2f622f86d5c71c60f3eaeba6cb0ac6e683dcee Mon Sep 17 00:00:00 2001 From: Kevin Nowaczyk Date: Tue, 13 Jan 2026 12:17:54 -0500 Subject: [PATCH 04/12] Update diagnose.test.js --- test/diagnose.test.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/diagnose.test.js b/test/diagnose.test.js index 01c5021..3afe683 100644 --- a/test/diagnose.test.js +++ b/test/diagnose.test.js @@ -53,7 +53,10 @@ const initialData = ` + + + `; // Describe Issue From 63b5ee987e0978141dfb1e3d49e68eebd8d278bf Mon Sep 17 00:00:00 2001 From: Kevin Nowaczyk Date: Tue, 13 Jan 2026 12:20:01 -0500 Subject: [PATCH 05/12] Update diagnose.test.js --- test/diagnose.test.js | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/test/diagnose.test.js b/test/diagnose.test.js index 3afe683..cff8179 100644 --- a/test/diagnose.test.js +++ b/test/diagnose.test.js @@ -49,13 +49,44 @@ const initialData = ` - -`; +`; // Step 2: get the bounding box data for the buiding from the API const mapData = ` - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + `; From 93e43e0caf33f1f54c4edc536b8ee340108f428a Mon Sep 17 00:00:00 2001 From: Kevin Nowaczyk Date: Tue, 13 Jan 2026 12:22:59 -0500 Subject: [PATCH 06/12] Update diagnose.test.js --- test/diagnose.test.js | 589 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 554 insertions(+), 35 deletions(-) diff --git a/test/diagnose.test.js b/test/diagnose.test.js index cff8179..f20a6af 100644 --- a/test/diagnose.test.js +++ b/test/diagnose.test.js @@ -52,41 +52,560 @@ const initialData = ` - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + `; @@ -102,7 +621,7 @@ test('Diagnose Skillion Issue', async() => { expect(building.id).toBe(wayId); const urlBase = 'https://api.openstreetmap.org/api/0.6/'; expect(global.fetch.mock.calls[0][0]).toBe(urlBase + 'way/' + wayId + '/full'); - expect(global.fetch.mock.calls[1][0]).toBe(urlBase + 'map?bbox=125.7416897,39.0269534,125.7420811,39.0272423'); + expect(global.fetch.mock.calls[1][0]).toBe(urlBase + 'map?bbox=-4.3314236,55.8550736,-4.3312202,55.8551787'); // get building part const parts = building.parts; // let found = false; From ae1e87bc667b7355f6790a672d2af904b6a40874 Mon Sep 17 00:00:00 2001 From: Kevin Nowaczyk Date: Tue, 13 Jan 2026 12:25:40 -0500 Subject: [PATCH 07/12] Update diagnose.test.js --- test/diagnose.test.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/diagnose.test.js b/test/diagnose.test.js index f20a6af..8c2c0fd 100644 --- a/test/diagnose.test.js +++ b/test/diagnose.test.js @@ -624,7 +624,7 @@ test('Diagnose Skillion Issue', async() => { expect(global.fetch.mock.calls[1][0]).toBe(urlBase + 'map?bbox=-4.3314236,55.8550736,-4.3312202,55.8551787'); // get building part const parts = building.parts; - // let found = false; + let found = false; for (const part of parts){ // Get the building part if (part.id === '1426868384'){ @@ -636,12 +636,12 @@ test('Diagnose Skillion Issue', async() => { // pitch: part.options.roof.angle / 180 * Math.PI, //}; //expect(options).toBe({}); - expect(points).toBe([]); + //expect(points).toBe([]); //expect(shape.toJSON()).toBe(''); - // found = true; + found = true; } } - // expect(found).toBeTrue(); + expect(found).toBe(true); // dump outer shape }); From 956e510c60e743e649501d49e65ceb9f66e860fb Mon Sep 17 00:00:00 2001 From: Kevin Nowaczyk Date: Tue, 13 Jan 2026 12:27:10 -0500 Subject: [PATCH 08/12] Update diagnose.test.js --- test/diagnose.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/diagnose.test.js b/test/diagnose.test.js index 8c2c0fd..a3a6af3 100644 --- a/test/diagnose.test.js +++ b/test/diagnose.test.js @@ -635,7 +635,7 @@ test('Diagnose Skillion Issue', async() => { // depth: part.options.roof.height, // pitch: part.options.roof.angle / 180 * Math.PI, //}; - //expect(options).toBe({}); + expect(part.options).toBe({}); //expect(points).toBe([]); //expect(shape.toJSON()).toBe(''); found = true; From 88e6936d6c3c5450973ce109666f622cc58093e3 Mon Sep 17 00:00:00 2001 From: Kevin Nowaczyk Date: Tue, 13 Jan 2026 12:30:26 -0500 Subject: [PATCH 09/12] Update buildingpart.js --- src/buildingpart.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/buildingpart.js b/src/buildingpart.js index 1e7cdd3..25d4838 100644 --- a/src/buildingpart.js +++ b/src/buildingpart.js @@ -162,7 +162,7 @@ class BuildingPart { (calculatedOptions.roof.shape === 'flat' ? 0 : null) ?? (calculatedOptions.roof.shape === 'dome' || calculatedOptions.roof.shape === 'pyramidal' ? BuildingShapeUtils.calculateRadius(this.shape) : null) ?? (calculatedOptions.roof.shape === 'onion' ? BuildingShapeUtils.calculateRadius(this.shape) * 1.5 : null) ?? - (calculatedOptions.roof.shape === 'skillion' ? (calculatedOptions.roof.angle ? Math.cos(calculatedOptions.roof.angle / 360 * 2 * Math.PI) * shapeHeight : 22.5) : null); + (calculatedOptions.roof.shape === 'skillion' ? (calculatedOptions.roof.angle ? Math.cos(calculatedOptions.roof.angle / 360 * 2 * Math.PI) * shapeHeight : Math.cos(22.5 / 360 * 2 * Math.PI) * shapeHeight) : null); calculatedOptions.building.height = this.options.specified.building.height ?? (isNaN(calculatedOptions.building.levels) ? null : (calculatedOptions.building.levels * 3) + calculatedOptions.roof.height) ?? From 6d3882345ff02df93d9c84c4f885e5292b3ee5b5 Mon Sep 17 00:00:00 2001 From: Kevin Nowaczyk Date: Tue, 13 Jan 2026 12:34:56 -0500 Subject: [PATCH 10/12] Update diagnose.test.js --- test/diagnose.test.js | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/test/diagnose.test.js b/test/diagnose.test.js index a3a6af3..2534038 100644 --- a/test/diagnose.test.js +++ b/test/diagnose.test.js @@ -628,21 +628,11 @@ test('Diagnose Skillion Issue', async() => { for (const part of parts){ // Get the building part if (part.id === '1426868384'){ - const shape = part.shape; - const points = shape.extractPoints().shape; - //const options = { - // angle: (360 - part.options.roof.direction) / 360 * 2 * Math.PI, - // depth: part.options.roof.height, - // pitch: part.options.roof.angle / 180 * Math.PI, - //}; - expect(part.options).toBe({}); - //expect(points).toBe([]); - //expect(shape.toJSON()).toBe(''); + expect(part.options.roof.height).toBe(5.284715476364045); found = true; } } expect(found).toBe(true); - // dump outer shape }); window.printError = printError; From 97207e6324ed74d8ab315094d8b8e5899f009c7a Mon Sep 17 00:00:00 2001 From: Kevin Nowaczyk Date: Tue, 13 Jan 2026 12:36:00 -0500 Subject: [PATCH 11/12] Update diagnose.test.js --- test/diagnose.test.js | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/test/diagnose.test.js b/test/diagnose.test.js index 2534038..dfe26d6 100644 --- a/test/diagnose.test.js +++ b/test/diagnose.test.js @@ -31,23 +31,8 @@ const initialData = ` - - - - - - - - - - - - - - - `; @@ -559,23 +544,8 @@ const mapData = ` - - - - - - - - - - - - - - - From 0f419ca1902d966286d0c67396050965b5e195e1 Mon Sep 17 00:00:00 2001 From: Kevin Nowaczyk Date: Tue, 13 Jan 2026 12:36:54 -0500 Subject: [PATCH 12/12] Rename diagnose.test.js to skillion_slope.test.js --- test/{diagnose.test.js => skillion_slope.test.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/{diagnose.test.js => skillion_slope.test.js} (100%) diff --git a/test/diagnose.test.js b/test/skillion_slope.test.js similarity index 100% rename from test/diagnose.test.js rename to test/skillion_slope.test.js