public getPotentialEdges()

in src/graph/edge/EdgeCalculator.ts [63:159]


    public getPotentialEdges(node: Image, potentialImages: Image[], fallbackIds: string[]): PotentialEdge[] {
        if (!node.complete) {
            throw new ArgumentMapillaryError("Image has to be full.");
        }

        if (!node.merged) {
            return [];
        }

        let currentDirection: THREE.Vector3 =
            this._spatial.viewingDirection(node.rotation);
        let currentVerticalDirection: number =
            this._spatial.angleToPlane(currentDirection.toArray(), [0, 0, 1]);

        let potentialEdges: PotentialEdge[] = [];

        for (let potential of potentialImages) {
            if (!potential.merged ||
                potential.id === node.id) {
                continue;
            }

            let enu = geodeticToEnu(
                potential.lngLat.lng,
                potential.lngLat.lat,
                potential.computedAltitude,
                node.lngLat.lng,
                node.lngLat.lat,
                node.computedAltitude);

            let motion: THREE.Vector3 = new THREE.Vector3(enu[0], enu[1], enu[2]);
            let distance: number = motion.length();

            if (distance > this._settings.maxDistance &&
                fallbackIds.indexOf(potential.id) < 0) {
                continue;
            }

            let motionChange: number = this._spatial.angleBetweenVector2(
                currentDirection.x,
                currentDirection.y,
                motion.x,
                motion.y);

            let verticalMotion: number = this._spatial.angleToPlane(motion.toArray(), [0, 0, 1]);

            let direction: THREE.Vector3 =
                this._spatial.viewingDirection(potential.rotation);

            let directionChange: number = this._spatial.angleBetweenVector2(
                currentDirection.x,
                currentDirection.y,
                direction.x,
                direction.y);

            let verticalDirection: number = this._spatial.angleToPlane(direction.toArray(), [0, 0, 1]);
            let verticalDirectionChange: number = verticalDirection - currentVerticalDirection;

            let rotation: number = this._spatial.relativeRotationAngle(
                node.rotation,
                potential.rotation);

            let worldMotionAzimuth: number =
                this._spatial.angleBetweenVector2(1, 0, motion.x, motion.y);

            let sameSequence: boolean = potential.sequenceId != null &&
                node.sequenceId != null &&
                potential.sequenceId === node.sequenceId;

            let sameMergeCC: boolean =
                potential.mergeId === node.mergeId;

            let sameUser: boolean =
                potential.creatorId === node.creatorId;

            let potentialEdge: PotentialEdge = {
                capturedAt: potential.capturedAt,
                directionChange: directionChange,
                distance: distance,
                spherical: isSpherical(potential.cameraType),
                id: potential.id,
                motionChange: motionChange,
                rotation: rotation,
                sameMergeCC: sameMergeCC,
                sameSequence: sameSequence,
                sameUser: sameUser,
                sequenceId: potential.sequenceId,
                verticalDirectionChange: verticalDirectionChange,
                verticalMotion: verticalMotion,
                worldMotionAzimuth: worldMotionAzimuth,
            };

            potentialEdges.push(potentialEdge);
        }

        return potentialEdges;
    }