<commit_before>package calculations;

import java.util.List;

import com.google.common.collect.Lists;

/**
 * Created by Ja on 29.03.14.
 */
public class Terrain {
	private final List<BTS> btss = Lists.newLinkedList();
	private final double maxX;
	private final double maxY;

	public Terrain(double maxX, double maxY) {
		this.maxX = maxX;
		this.maxY = maxY;
	}

	public void addBTS(BTS bts) {
		assert bts.getLocation() != null : "BTS must have a location before placing on terrain!";
		assert bts.getLocation().getX() <= maxX && bts.getLocation().getY() <= maxY : "BTS must be inside terrain boundaries!";
		btss.add(bts);
	}

	public List<BTS> getBtss() {
		return btss;
	}

	public double distance(Location l1, Location l2) {
		return l1.cartesianDistance(l2);
	}

	public double signalReduction(Location l1, Location l2) {
		// TODO implementation
		return 0;
	}

	public double distance(BTS bts, Location l) {
		return distance(bts.getLocation(), l);
	}

	public double signalLevel(BTS bts, Location l) {
		double maxSignalLevel = bts.getMaxSignalLevel();
		double distance = distance(bts, l);
		if (distance == 0d)
			return maxSignalLevel;

		return maxSignalLevel * (1 - signalReduction(bts.getLocation(), l)) / Math.pow(distance, 2);
	}

	public double getSignalLevel(Location l) {
		double signal = 0;
		for (BTS bts : btss) {
			signal += signalLevel(bts, l);
		}
		return signal;
	}

	public double getMaxX() {
		return maxX;
	}

	public double getMaxY() {
		return maxY;
	}

	public double getMaxAvailableSignalLevel() {
		double maxAvailableSignalLevel = 0d;
		for (BTS bts : btss) {
			double maxSignalLevel = bts.getMaxSignalLevel();
			if (maxSignalLevel > maxAvailableSignalLevel) {
				maxAvailableSignalLevel = maxSignalLevel;
			}
		}
		return maxAvailableSignalLevel;
	}
}<commit_msg>Removed calculating signal level if point is beyond BTS range<commit_after>package calculations;

import java.util.List;

import com.google.common.collect.Lists;

/**
 * Created by Ja on 29.03.14.
 */
public class Terrain {
	private final List<BTS> btss = Lists.newLinkedList();
	private final double maxX;
	private final double maxY;

	public Terrain(double maxX, double maxY) {
		this.maxX = maxX;
		this.maxY = maxY;
	}

	public void addBTS(BTS bts) {
		assert bts.getLocation() != null : "BTS must have a location before placing on terrain!";
		assert bts.getLocation().getX() <= maxX && bts.getLocation().getY() <= maxY : "BTS must be inside terrain boundaries!";
		btss.add(bts);
	}

	public List<BTS> getBtss() {
		return btss;
	}

	public double distance(Location l1, Location l2) {
		return l1.cartesianDistance(l2);
	}

	public double signalReduction(Location l1, Location l2) {
		// TODO implementation
		return 0;
	}

	public double distance(BTS bts, Location l) {
		return distance(bts.getLocation(), l);
	}

	public double signalLevel(BTS bts, Location l) {
		double distance = distance(bts, l);
        if(distance > bts.getRange())
            return 0;
        else if (distance == 0d)
            return bts.getMaxSignalLevel();
        else
    		return bts.getMaxSignalLevel() * (1 - signalReduction(bts.getLocation(), l)) / Math.pow(distance, 2);
	}

	public double getSignalLevel(Location l) {
		double signal = 0;
		for (BTS bts : btss) {
			signal += signalLevel(bts, l);
		}
		return signal;
	}

	public double getMaxX() {
		return maxX;
	}

	public double getMaxY() {
		return maxY;
	}

	public double getMaxAvailableSignalLevel() {
		double maxAvailableSignalLevel = 0d;
		for (BTS bts : btss) {
			double maxSignalLevel = bts.getMaxSignalLevel();
			if (maxSignalLevel > maxAvailableSignalLevel) {
				maxAvailableSignalLevel = maxSignalLevel;
			}
		}
		return maxAvailableSignalLevel;
	}
}
{'fraction_non_alphanumeric': 0.11376442178696002, 'fraction_numerical': 0.009927555674805473, 'mean_word_length': 3.76117496807152, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 10, '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': '7045212', 'n_tokens_mistral': 1369, 'n_tokens_neox': 1253, 'n_words': 346}