diff --git a/src/buildingpart.js b/src/buildingpart.js index 84160dc..3f642ce 100644 --- a/src/buildingpart.js +++ b/src/buildingpart.js @@ -270,7 +270,7 @@ class BuildingPart { const options = { center: center, angle: angle / 180 * Math.PI, - depth: this.options.roof.height, + depth: this.options.roof.height ?? 3, }; const geometry = new WedgeGeometry(this.shape, options); @@ -434,7 +434,7 @@ class BuildingPart { /** * OSM compass degrees are 0-360 clockwise. - * + * 0 degrees is North. * @return {number} degrees */ static atanRadToCompassDeg(rad) { diff --git a/src/extras/BuildingShapeUtils.js b/src/extras/BuildingShapeUtils.js index 6dedcf8..091f533 100644 --- a/src/extras/BuildingShapeUtils.js +++ b/src/extras/BuildingShapeUtils.js @@ -287,7 +287,6 @@ class BuildingShapeUtils extends ShapeUtils { */ static combineCoordinates(shape) { const points = shape.extractPoints().shape; - points.pop(); var x = []; var y = []; var vec; @@ -337,7 +336,6 @@ class BuildingShapeUtils extends ShapeUtils { */ static edgeLength(shape) { const points = shape.extractPoints().shape; - points.pop(); const lengths = []; var p1; var p2; @@ -359,7 +357,6 @@ class BuildingShapeUtils extends ShapeUtils { */ static vertexAngle(shape) { const points = shape.extractPoints().shape; - points.pop(); const angles = []; var p0; var p1; @@ -394,7 +391,6 @@ class BuildingShapeUtils extends ShapeUtils { */ static edgeDirection(shape) { const points = shape.extractPoints().shape; - points.pop(); const angles = []; var p1; var p2; @@ -418,7 +414,6 @@ class BuildingShapeUtils extends ShapeUtils { static surrounds(shape, point) { var count = 0; const vecs = shape.extractPoints().shape; - vecs.pop(); var vec; var nextvec; for (let i = 0; i < vecs.length; i++) { @@ -468,7 +463,7 @@ class BuildingShapeUtils extends ShapeUtils { * Return the angle of the longest side of a shape with 90° vertices. * * @param {THREE.Shape} shape - the shape - * @return {number} + * @return {number} in radians from Pi > x > -Pi */ static longestSideAngle(shape) { const lengths = BuildingShapeUtils.edgeLength(shape); diff --git a/test/building.test.js b/test/building.test.js index 1bc9167..96f75a2 100644 --- a/test/building.test.js +++ b/test/building.test.js @@ -309,6 +309,10 @@ test('Test downloading type=building with multipolygon outline and multiple inne const building = new Building('42', innerData); expect(building.id).toBe('42'); expect(building.outerElement.shape.holes.length).toBe(1); + const urlBase = 'https://api.openstreetmap.org/api/0.6/'; + expect(global.fetch.mock.calls[0][0]).toBe(urlBase + 'relation/42/full'); + expect(global.fetch.mock.calls[1][0]).toBe(urlBase + 'relation/40/full'); + expect(global.fetch.mock.calls[2][0]).toBe(urlBase + 'map?bbox=30.4980057,59.9380365,30.4993839,59.9385087'); }); window.printError = printError; diff --git a/test/buildingpart.test.js b/test/buildingpart.test.js index f368452..16f6c55 100644 --- a/test/buildingpart.test.js +++ b/test/buildingpart.test.js @@ -61,6 +61,8 @@ test('Constructor', () => { expect(part.options.roof.orientation).toBe('along'); // toDo: Mock BuildingShapeUtils and test options + expect(BuildingShapeUtils.edgeDirection(part.shape)).toStrictEqual([1.5707963267948966, 0, -1.5707963267948966, 3.141592653589793]); + expect(BuildingShapeUtils.longestSideAngle(part.shape)).toBe(1.5707963267948966); expect(part.options.roof.direction).toBe(90); expect(errors.length).toBe(0); }); diff --git a/test/utils.test.js b/test/utils.test.js index b673c85..b71d8c5 100644 --- a/test/utils.test.js +++ b/test/utils.test.js @@ -115,20 +115,17 @@ const rightTriangle = new Shape(); rightTriangle.moveTo(1, 1); rightTriangle.lineTo(1, -1); rightTriangle.lineTo(-1, 1); -rightTriangle.lineTo(1, 1); const rightTriangle2 = new Shape(); rightTriangle2.moveTo(1, 1); rightTriangle2.lineTo(-1, 1); rightTriangle2.lineTo(1, -1); -rightTriangle2.lineTo(1, 1); const rectangle = new Shape(); rectangle.moveTo(-4.332738077015795, -5.882209888874915); rectangle.lineTo(-4.332738077015795, 5.88221335051411); rectangle.lineTo(4.332747472106493, 5.88221335051411); rectangle.lineTo(4.332747472106493, -5.882209888874915); -rectangle.lineTo(-4.332738077015795, -5.882209888874915); test('Extents no Rotation', () => { expect(BuildingShapeUtils.extents(rightTriangle)).toStrictEqual([-1, -1, 1, 1]);