• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Beakerboy / OSMBuilding / 14810936089

03 May 2025 12:37PM UTC coverage: 57.393% (-3.8%) from 61.229%
14810936089

Pull #89

github

web-flow
Merge 6800a6036 into 426908675
Pull Request #89: #86 Support render from .osm, support multiple ways in holes

149 of 184 branches covered (80.98%)

Branch coverage included in aggregate %.

22 of 149 new or added lines in 3 files covered. (14.77%)

9 existing lines in 1 file now uncovered.

1031 of 1872 relevant lines covered (55.07%)

5.14 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

66.22
/src/multibuildingpart.js
1
import {BuildingShapeUtils} from './extras/BuildingShapeUtils.js';
4✔
2
import {BuildingPart} from './buildingpart.js';
4✔
3
/**
4✔
4
 * An OSM Building Part
4✔
5
 *
4✔
6
 * A building part includes a main building and a roof.
4✔
7
 */
4✔
8
class MultiBuildingPart extends BuildingPart {
4✔
9

4✔
10
  makeRings(members) {
4✔
11
    const ways = [];
6✔
12
    for (let j = 0; j < members.length; j++) {
6✔
13
      const wayID = members[j].getAttribute('ref');
6✔
14
      const way = this.fullXmlData.getElementById(wayID);
7✔
15
      if (way) {
7✔
16
        ways.push(way.cloneNode(true));
7✔
17
      } else {
7!
NEW
18
        window.printError(`Missing way ${wayID} for relation ${this.id}`);
×
NEW
19
        ways.push(this.augmentedWays[wayID].cloneNode(true));
×
NEW
20
      }
×
21
    }
7✔
22
    return BuildingShapeUtils.combineWays(ways);
6✔
23
  }
6✔
24

6✔
25
  /**
4✔
26
   * Create the shape of the outer relation.
4✔
27
   *
4✔
28
   * @return {THREE.Shape} shape - the shape
4✔
29
   */
4✔
30
  buildShape() {
4✔
31
    this.type = 'multipolygon';
3✔
32
    const innerMembers = this.way.querySelectorAll('member[role="inner"][type="way"]');
3✔
33
    const outerMembers = this.way.querySelectorAll('member[role="outer"][type="way"]');
3✔
34
    const shapes = [];
3✔
35
    const innerShapes = this.makeRings(innerMembers).map(ring => BuildingShapeUtils.createShape(ring, this.nodelist, this.augmentedNodelist));
3✔
36
    const closedOuterWays = this.makeRings(outerMembers);
3✔
37
    for (let k = 0; k < closedOuterWays.length; k++) {
3✔
38
      const shape = BuildingShapeUtils.createShape(closedOuterWays[k], this.nodelist, this.augmentedNodelist);
3✔
39
      shape.holes.push(...innerShapes);
3✔
40
      shapes.push(shape);
3✔
41
    }
3✔
42
    if (closedOuterWays.length === 1) {
3✔
43
      return shapes[0];
3✔
44
    }
3✔
45
    // Multiple outer members
3!
46
    return shapes;
×
47
  }
×
48

×
49
  getWidth() {
4✔
50
    var xy = [[], []];
×
51
    for (let i = 0; i < this.shape.length; i++){
×
52
      const shape = this.shape[i];
×
53
      const newXy = BuildingShapeUtils.combineCoordinates(shape);
×
54
      xy[0] = xy[0].concat(newXy[0]);
×
55
      xy[1] = xy[1].concat(newXy[1]);
×
56
    }
×
57

×
58
    const x = xy[0];
×
59
    const y = xy[1];
×
60
    window.printError('Multibuilding x: ' + x);
×
61
    window.printError('Multibuilding y: ' + y);
×
62
    const widths = Math.max(Math.max(...x) - Math.min(...x), Math.max(...y) - Math.min(...y));
×
63
    window.printError('Multibuilding Width: ' + widths);
×
64
    return widths;
×
65
  }
×
66
}
×
67
export {MultiBuildingPart};
4✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc