Skip to content
Merged

Dev #137

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/buildingpart.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -434,7 +434,7 @@ class BuildingPart {

/**
* OSM compass degrees are 0-360 clockwise.
*
* 0 degrees is North.
* @return {number} degrees
*/
static atanRadToCompassDeg(rad) {
Expand Down
7 changes: 1 addition & 6 deletions src/extras/BuildingShapeUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,6 @@ class BuildingShapeUtils extends ShapeUtils {
*/
static combineCoordinates(shape) {
const points = shape.extractPoints().shape;
points.pop();
var x = [];
var y = [];
var vec;
Expand Down Expand Up @@ -337,7 +336,6 @@ class BuildingShapeUtils extends ShapeUtils {
*/
static edgeLength(shape) {
const points = shape.extractPoints().shape;
points.pop();
const lengths = [];
var p1;
var p2;
Expand All @@ -359,7 +357,6 @@ class BuildingShapeUtils extends ShapeUtils {
*/
static vertexAngle(shape) {
const points = shape.extractPoints().shape;
points.pop();
const angles = [];
var p0;
var p1;
Expand Down Expand Up @@ -394,7 +391,6 @@ class BuildingShapeUtils extends ShapeUtils {
*/
static edgeDirection(shape) {
const points = shape.extractPoints().shape;
points.pop();
const angles = [];
var p1;
var p2;
Expand All @@ -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++) {
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions test/building.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions test/buildingpart.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
3 changes: 0 additions & 3 deletions test/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down