<commit_before>package com.jayway.trumpet.server.domain;

import static java.util.Objects.requireNonNull;

public class Location {

    public final Double latitude;
    public final Double longitude;

    public static Location create(Double latitude, Double longitude){
        return new Location(latitude, longitude);
    }

    private Location(Double latitude, Double longitude) {
        requireNonNull(latitude, "latitude can not be null");
        requireNonNull(longitude, "longitude can not be null");

        this.latitude = latitude;
        this.longitude = longitude;
    }


    public double distance(Location other, DistanceUnit distanceUnit) {
        double theta = longitude - other.latitude;
        double dist = Math.sin(deg2rad(latitude)) * Math.sin(deg2rad(other.latitude)) + Math.cos(deg2rad(latitude)) * Math.cos(deg2rad(other.latitude)) * Math.cos(deg2rad(theta));
        dist = Math.acos(dist);
        dist = rad2deg(dist);
        dist = dist * 60 * 1.1515;

        switch (distanceUnit){
            case METERS:<commit_msg>Fixed bug in distance calculation.<commit_after>package com.jayway.trumpet.server.domain;

import static java.util.Objects.requireNonNull;

public class Location {

    public final Double latitude;
    public final Double longitude;

    public static Location create(Double latitude, Double longitude){
        return new Location(latitude, longitude);
    }

    private Location(Double latitude, Double longitude) {
        requireNonNull(latitude, "latitude can not be null");
        requireNonNull(longitude, "longitude can not be null");

        this.latitude = latitude;
        this.longitude = longitude;
    }


    public double distance(Location other, DistanceUnit distanceUnit) {
        double theta = longitude - other.longitude;
        double dist = Math.sin(deg2rad(latitude)) * Math.sin(deg2rad(other.latitude)) + Math.cos(deg2rad(latitude)) * Math.cos(deg2rad(other.latitude)) * Math.cos(deg2rad(theta));
        dist = Math.acos(dist);
        dist = rad2deg(dist);
        dist = dist * 60 * 1.1515;

        switch (distanceUnit){
            case METERS:
{'fraction_non_alphanumeric': 0.09943977591036414, 'fraction_numerical': 0.012138188608776844, 'mean_word_length': 3.2019607843137257, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4263885', 'n_tokens_mistral': 633, 'n_tokens_neox': 586, 'n_words': 157}