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

Beakerboy / OSMBuilding / 14734484374

29 Apr 2025 02:58PM UTC coverage: 53.644% (-0.4%) from 54.091%
14734484374

Pull #84

github

web-flow
Merge 5a219ba1e into 2eb5d502d
Pull Request #84: Make data preprocessing more error-tolerant, rewrite combineWays

93 of 141 branches covered (65.96%)

Branch coverage included in aggregate %.

105 of 150 new or added lines in 4 files covered. (70.0%)

23 existing lines in 2 files now uncovered.

908 of 1725 relevant lines covered (52.64%)

2.99 hits per line

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

69.51
/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
  /**
4✔
11
   * Create the shape of the outer relation.
4✔
12
   *
4✔
13
   * @return {THREE.Shape} shape - the shape
4✔
14
   */
4✔
15
  buildShape() {
4✔
16
    this.type = 'multipolygon';
4✔
17
    const innerMembers = this.way.querySelectorAll('member[role="inner"][type="way"]');
4✔
18
    const outerMembers = this.way.querySelectorAll('member[role="outer"][type="way"]');
4✔
19
    const innerShapes = [];
4✔
20
    const shapes = [];
4✔
21
    for (let i = 0; i < innerMembers.length; i++) {
4✔
22
      const wayID = innerMembers[i].getAttribute('ref');
4✔
23
      const way = this.fullXmlData.getElementById(wayID);
2✔
24
      if (way) {
2✔
25
        innerShapes.push(BuildingShapeUtils.createShape(way, this.nodelist, this.augmentedNodelist));
2✔
26
      } else {
2!
NEW
27
        window.printError(`Missing way ${wayID} for relation ${this.id} for inner members`);
×
NEW
28
        innerShapes.push(BuildingShapeUtils.createShape(this.augmentedWays[wayID], this.nodelist, this.augmentedNodelist));
×
NEW
29
      }
×
30
    }
2✔
31
    const ways = [];
4✔
32
    for (let j = 0; j < outerMembers.length; j++) {
4✔
33
      const wayID = outerMembers[j].getAttribute('ref');
4✔
34
      const way = this.fullXmlData.getElementById(wayID);
5✔
35
      if (way) {
5✔
36
        ways.push(way);
5✔
37
      } else {
5!
NEW
38
        window.printError(`Missing way ${wayID} for relation ${this.id}`);
×
NEW
39
        ways.push(this.augmentedWays[wayID]);
×
NEW
40
      }
×
41
    }
5✔
42
    const closedWays = BuildingShapeUtils.combineWays(ways);
4✔
43
    for (let k = 0; k < closedWays.length; k++) {
4✔
44
      const shape = BuildingShapeUtils.createShape(closedWays[k], this.nodelist, this.augmentedNodelist);
4✔
45
      shape.holes.push(...innerShapes);
3✔
46
      shapes.push(shape);
3✔
47
    }
3✔
48
    if (closedWays.length === 1) {
4✔
49
      return shapes[0];
4✔
50
    }
3✔
51
    // Multiple outer members
4✔
52
    return shapes;
1✔
53
  }
1✔
54

1✔
55
  getWidth() {
4✔
56
    var xy = [[], []];
×
57
    for (let i = 0; i < this.shape.length; i++){
×
58
      const shape = this.shape[i];
×
59
      const newXy = BuildingShapeUtils.combineCoordinates(shape);
×
60
      xy[0] = xy[0].concat(newXy[0]);
×
61
      xy[1] = xy[1].concat(newXy[1]);
×
62
    }
×
63

×
64
    const x = xy[0];
×
65
    const y = xy[1];
×
66
    window.printError('Multibuilding x: ' + x);
×
67
    window.printError('Multibuilding y: ' + y);
×
68
    const widths = Math.max(Math.max(...x) - Math.min(...x), Math.max(...y) - Math.min(...y));
×
69
    window.printError('Multibuilding Width: ' + widths);
×
70
    return widths;
×
71
  }
×
72
}
×
73
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

© 2025 Coveralls, Inc