<commit_before>var appControllers = angular.module('appControllers', []);

/*
 *  HELPER
 */
var nearInfoAlert = "Ihr Ziel ist in unmittelbarer Nähe,\n\
                    möchten sie nun Informationen dazu erhalten?";

var calculateDistance = function (lat1, lon1, lat2, lon2) {
    var deg2rad = function (deg) {
        return deg * (Math.PI / 180);
    };
    var R = 6371; // Radius of the earth in km
    var dLat = deg2rad(lat2 - lat1); // deg2rad below
    var dLon = deg2rad(lon2 - lon1);
    var a =
            Math.sin(dLat / 2) * Math.sin(dLat / 2) +
                Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) *
                    Math.sin(dLon / 2) * Math.sin(dLon / 2)
        ;
    var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
    var d = R * c; // Distance in km
    return d = d.toFixed(3); //Distance in m
};


/*
 *  CONTROLLER
 */
appControllers.controller('PoiCtrl', function ($rootScope, $scope, notification, media, geolocation) {

    $scope.pois = $rootScope.tour.pointsOfInterest;
    $scope.poi = $scope.pois[0];

    $scope.shiftPoi = function (shiftCount) {
        var index = $scope.pois.indexOf($scope.poi) + shiftCount;
        index = (index < 0) ? $scope.pois.length - 1 : (index >= $scope.pois.length) ? 0 : index;
        $scope.poi = $scope.pois[index];
    };

    $scope.map = {
        center: {
            latitude: 50.110290,
            longitude: 8.682265
        },
        position: {
            top: -500,
            left: -1500
        },
        draggable: true,
        zoom: 15
    };

    $scope.mapStyle = function() {
        return {
            top: $scope.map.position.top + "px",
            left: $scope.map.position.left + "px",
            height: "285px"
        }
    }

    $scope.mapClicked = function(event) {
        console.log(event);
        var img = angular.element(event.target);
        var parent = img.parent();
        console.log("img: " + img);
        console.log("parent: " + parent);
        console.log("img top: " + img.prop('offsetTop'));
        console.log("img left: " + img.prop('offsetLeft'));
        console.log("img width: " + img.prop('offsetWidth'));
        console.log("img height: " + img.prop('offsetHeight'));
        console.log("parent top: " + parent.prop('offsetTop'));
        console.log("parent left: " + parent.prop('offsetLeft'));
        console.log("parent width: " + parent.prop('offsetWidth'));
        console.log("parent height: " + parent.prop('offsetHeight'));
        console.log("parent marginLeft: " + parent.prop('offsetParent'));

        var viewportOffsetLeft = parent.parent().prop('offsetLeft');
        var viewportWidth = parent.prop('offsetWidth');
        var shiftX = viewportOffsetLeft + viewportWidth/2 - event.pageX;
        console.log(shiftX);

        var viewportOffsetTop = parent.parent().prop('offsetTop');
        var viewportHeight = parent.prop('offsetHeight');
        var shiftY = viewportOffsetTop + viewportHeight/2 - event.pageY;
        console.log(shiftY);




        /*var centerX = par*/




        /*alert("event x: " + event.x);
        alert("event y: " + event.y);
        alert("event offsetX: " + event.offsetX);
        alert("event offsetY: " + event.offsetY);
        alert("event pageX: " + event.pageX);
        alert("event pageY: " + event.pageY);*/
        $scope.map.position.left += shiftX;
        $scope.map.position.top += shiftY;
    }

    /*
     * Watch position for changes.
     * If distance to poi <= 50 alert with media-information
     */
<commit_msg>Finally found real bug reason for wrong map calculations.<commit_after>var appControllers = angular.module('appControllers', []);

/*
 *  HELPER
 */
var nearInfoAlert = "Ihr Ziel ist in unmittelbarer Nähe,\n\
                    möchten sie nun Informationen dazu erhalten?";

var calculateDistance = function (lat1, lon1, lat2, lon2) {
    var deg2rad = function (deg) {
        return deg * (Math.PI / 180);
    };
    var R = 6371; // Radius of the earth in km
    var dLat = deg2rad(lat2 - lat1); // deg2rad below
    var dLon = deg2rad(lon2 - lon1);
    var a =
            Math.sin(dLat / 2) * Math.sin(dLat / 2) +
                Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) *
                    Math.sin(dLon / 2) * Math.sin(dLon / 2)
        ;
    var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
    var d = R * c; // Distance in km
    return d = d.toFixed(3); //Distance in m
};


/*
 *  CONTROLLER
 */
appControllers.controller('PoiCtrl', function ($rootScope, $scope, notification, media, geolocation) {

    $scope.pois = $rootScope.tour.pointsOfInterest;
    $scope.poi = $scope.pois[0];

    $scope.shiftPoi = function (shiftCount) {
        var index = $scope.pois.indexOf($scope.poi) + shiftCount;
        index = (index < 0) ? $scope.pois.length - 1 : (index >= $scope.pois.length) ? 0 : index;
        $scope.poi = $scope.pois[index];
    };

    $scope.map = {
        center: {
            latitude: 50.110290,
            longitude: 8.682265
        },
        position: {
            top: -500,
            left: -1500
        },
        draggable: true,
        zoom: 15
    };

    $scope.mapStyle = function() {
        return {
            top: $scope.map.position.top + "px",
            left: $scope.map.position.left + "px",
            height: "285px"
        }
    }

    $scope.mapClicked = function(event) {
        console.log(event);
        var img = angular.element(event.target);
        var parent = img.parent();
        console.log("img: " + img);
        console.log("parent: " + parent);
        console.log("img top: " + img.prop('offsetTop'));
        console.log("img left: " + img.prop('offsetLeft'));
        console.log("img width: " + img.prop('offsetWidth'));
        console.log("img height: " + img.prop('offsetHeight'));
        console.log("parent top: " + parent.prop('offsetTop'));
        console.log("parent left: " + parent.prop('offsetLeft'));
        console.log("parent width: " + parent.prop('offsetWidth'));
        console.log("parent height: " + parent.prop('offsetHeight'));
        console.log("parent marginLeft: " + parent.prop('offsetParent'));

        var viewportOffsetLeft = parent.parent().prop('offsetLeft');
        var viewportWidth = parent.prop('offsetWidth');
        var clickX = event.clientX || event.changedTouches[0].clientX;
        var shiftX = viewportOffsetLeft + viewportWidth/2 - clickX;
        console.log(shiftX);

        var viewportOffsetTop = parent.parent().prop('offsetTop');
        var viewportHeight = parent.prop('offsetHeight');
        var clickY = event.clientY || event.changedTouches[0].clientY;
        var shiftY = viewportOffsetTop + viewportHeight/2 - clickY;
        console.log(shiftY);

        /*var centerX = par*/
        /*alert("event: " + event);
        alert("viewportOffsetLeft: " + viewportOffsetLeft);
        alert("viewportWidth: " + viewportWidth);
        alert("viewportOffsetTop: " + viewportOffsetTop);
        alert("viewportHeight: " + viewportHeight);
        alert("pageX: " + event.pageX);
        alert("pageY: " + event.pageY);
        alert("x: " + clickX);
        alert("y: " + clickY);
        alert("shiftX: " + shiftX);
        alert("shiftY: " + shiftY);*/
        $scope.map.position.left += shiftX;
        $scope.map.position.top += shiftY;
    }

    /*
     * Watch position for changes.
     * If distance to poi <= 50 alert with media-information
     */

{'fraction_non_alphanumeric': 0.15302443583923087, 'fraction_numerical': 0.017892909600747763, 'mean_word_length': 2.229840448469168, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2720514', 'n_tokens_mistral': 2463, 'n_tokens_neox': 2358, 'n_words': 500}