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

Beakerboy / OSMBuilding / 14742065167

29 Apr 2025 09:53PM UTC coverage: 55.088% (-3.7%) from 58.753%
14742065167

Pull #89

github

web-flow
Merge 0e38145ea into aefdd5e06
Pull Request #89: #86 Support render from .osm, support multiple ways in holes

116 of 159 branches covered (72.96%)

Branch coverage included in aggregate %.

28 of 177 new or added lines in 3 files covered. (15.82%)

2 existing lines in 1 file now uncovered.

983 of 1836 relevant lines covered (53.54%)

3.13 hits per line

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

72.37
/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 = [];
8✔
12
    for (let j = 0; j < members.length; j++) {
8✔
13
      const wayID = members[j].getAttribute('ref');
8✔
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);
8✔
23
  }
8✔
24

8✔
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';
4✔
32
    const innerMembers = this.way.querySelectorAll('member[role="inner"][type="way"]');
4✔
33
    const outerMembers = this.way.querySelectorAll('member[role="outer"][type="way"]');
4✔
34
    const shapes = [];
4✔
35
    const innerShapes = this.makeRings(innerMembers).map(ring => BuildingShapeUtils.createShape(ring, this.nodelist, this.augmentedNodelist));
4✔
36
    const closedOuterWays = this.makeRings(outerMembers);
4✔
37
    for (let k = 0; k < closedOuterWays.length; k++) {
4✔
38
      const shape = BuildingShapeUtils.createShape(closedOuterWays[k], this.nodelist, this.augmentedNodelist);
4✔
39
      shape.holes.push(...innerShapes);
3✔
40
      shapes.push(shape);
3✔
41
    }
3✔
42
    if (closedOuterWays.length === 1) {
4✔
43
      return shapes[0];
4✔
44
    }
3✔
45
    // Multiple outer members
4✔
46
    return shapes;
1✔
47
  }
1✔
48

1✔
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