|
@@ -14,21 +14,27 @@ class IntersectionService {
|
|
|
this.intersectionsMap = new Map()
|
|
|
}
|
|
|
|
|
|
- // @param {[]} intersections
|
|
|
- // @calledby ./app/components/intersection-component/drawers/intersection-drawer.js
|
|
|
- addIntersections (intersections) { try { //D //leo
|
|
|
- //D console.log("intersection-service.js: addIntersections(" + intersections + ")");
|
|
|
- const key = intersections.map((intersection) => {
|
|
|
- return `og1_${intersection.og1.id}_og2_${intersection.og2.id}`;
|
|
|
- });
|
|
|
- if (this.intersectionsMap.has(key)) {
|
|
|
- this.intersectionsMap.get(key).forEach((x, i) => intersections[i] = x.id);
|
|
|
- delete this.intersectionsMap.get(key);
|
|
|
- this.intersectionsMap.delete(key);
|
|
|
+ // @param {[], aggregator.genericObject, aggregator.genericObject} intersections between 2 aggregator.genericObject
|
|
|
+ // @calledby app/components/intersection-component/drawers/intersection-drawer.js!drawPoint(): intersectionPoints=intersectionService.addIntersections(intersectionOg1Og2,og1,og2);
|
|
|
+ addIntersections (intersections, og1, og2) {
|
|
|
+ try { //D //leo
|
|
|
+ console.log("intersection-service.js: addIntersections(" + intersections + "," + og1 + "," + og2 + ")\n" + msgED);
|
|
|
+ // if (intersections.og1 == undefined) then og1 is an existent point
|
|
|
+ const key = intersections.map((intersection) => {
|
|
|
+ // return `og1_${intersection.og1.id}_og2_${intersection.og2.id}`;
|
|
|
+ return `og1_${og1.id}_og2_${og2.id}`;
|
|
|
+ });
|
|
|
+ if (this.intersectionsMap.has(key)) {
|
|
|
+ this.intersectionsMap.get(key).forEach((x, i) => intersections[i] = x.id);
|
|
|
+ delete this.intersectionsMap.get(key);
|
|
|
+ this.intersectionsMap.delete(key);
|
|
|
+ }
|
|
|
+ this.intersectionsMap.set(key, intersections);
|
|
|
+ return intersections;
|
|
|
+ } catch (e) {
|
|
|
+ var msgED = "intersection between og1 and og2: og1.id=" + (og1.id?og1.id:"<>") + ", og2.id=" + (og2.id?og2.id:"<>");
|
|
|
+ console.log("app/components/intersection-component/services/intersection-service.js: addIntersections(.): error " + e + "!\n" + msgED + "\n" + e.stack);
|
|
|
}
|
|
|
- this.intersectionsMap.set(key, intersections);
|
|
|
- return intersections;
|
|
|
- } catch (e) { console.log("app/components/intersection-component/services/intersection-service.js: addIntersections(.): erro!\n" + e.stack); }
|
|
|
}
|
|
|
|
|
|
}
|