* withAllRelatedEntities * Returns an expanded set of `entityIDs` that need to also be validated alongside the given `entityIDs` * - Entities involved in the same issues * - Entities connected to the given entities * - Entities involved in nearby connectivity issues (impossible oneway, d
(entityIDs = [])
| 932 | * @return {Set} entityIDs related to the given entityIDs |
| 933 | */ |
| 934 | withAllRelatedEntities(entityIDs = []) { |
| 935 | const graph = this.graph; |
| 936 | const results = new Set(entityIDs); // include original entityIDs |
| 937 | if (!graph || !results.size) return results; // nothing to do |
| 938 | |
| 939 | const relatedIssueIDs = new Set(); |
| 940 | |
| 941 | for (const entityID of entityIDs) { |
| 942 | const entity = graph.hasEntity(entityID); |
| 943 | if (!entity) continue; |
| 944 | |
| 945 | // Gather Issues this Entity is involved in.. |
| 946 | const issueIDs = this.entityIssueIDs.get(entityID) ?? []; |
| 947 | for (const issueID of issueIDs) { |
| 948 | relatedIssueIDs.add(issueID); |
| 949 | } |
| 950 | |
| 951 | if (entity.type === 'way' || entity.type === 'node') { |
| 952 | // Gather nearby connectivity Issues (impossible oneway, disconnected way) |
| 953 | const extent = entity.extent(graph); |
| 954 | const boxes = this.recheckRBush.search(extent.bbox()) ?? []; |
| 955 | for (const box of boxes) { |
| 956 | relatedIssueIDs.add(box.issueID); |
| 957 | } |
| 958 | |
| 959 | // Gather other Entities connected to this Entity.. |
| 960 | const checkNodes = entity.type === 'way' ? graph.childNodes(entity) : entity.type === 'node' ? [entity] : []; |
| 961 | for (const node of checkNodes) { |
| 962 | for (const parentWay of graph.parentWays(node)) { |
| 963 | results.add(parentWay.id); |
| 964 | } |
| 965 | } |
| 966 | } |
| 967 | } |
| 968 | |
| 969 | for (const issueID of relatedIssueIDs) { |
| 970 | const issue = this.issues.get(issueID); |
| 971 | const relatedEntityIDs = issue?.entityIds ?? []; |
| 972 | for (const relatedEntityID of relatedEntityIDs) { |
| 973 | results.add(relatedEntityID); |
| 974 | } |
| 975 | } |
| 976 | |
| 977 | return results; |
| 978 | } |
| 979 | |
| 980 | } |
no test coverage detected