<commit_before>/*******************************************************************************
 * Copyright (c) 2011 <NAME>.
 * eMail: <EMAIL>
 * 
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v2.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * 
 * Contributors:
 *     <NAME> - initial API and implementation
 ******************************************************************************/
/**
 * 
 */
package util;

import org.apache.log4j.Logger;

import basics.costs.VehicleRoutingTransportCosts;
import basics.route.Driver;
import basics.route.Vehicle;
import basics.route.VehicleImpl.VehicleType;


/**
 * @author <NAME>
 * 
 */
public class CrowFlyCosts implements VehicleRoutingTransportCosts {

	private static Logger logger = Logger.getLogger(CrowFlyCosts.class);

	public int speed = 1;

	public double detourFactor = 1.0;

	private Locations locations;

	public CrowFlyCosts(Locations locations) {
		super();
		this.locations = locations;
	}
	
	@Override
	public String toString() {
		return "[name=crowFlyCosts]";
	}

	@Override
	public double getTransportCost(String fromId, String toId, double time, Driver driver, Vehicle vehicle) {
		double cost;
		try {
			cost = EuclideanDistanceCalculator.calculateDistance(locations.getCoord(fromId), locations.getCoord(toId)) * detourFactor;
		} catch (NullPointerException e) {
			throw new NullPointerException("cannot calculate euclidean distance. coordinates are missing. either add coordinates or use another transport-cost-calculator.");
		}
		return cost;
	}

	@Override
	public double getTransportTime(String fromId, String toId, double time, Driver driver, Vehicle vehicle) {
		double transportTime = getTransportCost(fromId, toId, 0.0, null, null) / speed;
		return transportTime;
	}

	@Override<commit_msg>include fixed and variable vehicle-costs<commit_after>/*******************************************************************************
 * Copyright (c) 2011 <NAME>.
 * eMail: <EMAIL>
 * 
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v2.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * 
 * Contributors:
 *     <NAME> - initial API and implementation
 ******************************************************************************/
/**
 * 
 */
package util;

import org.apache.log4j.Logger;

import basics.costs.VehicleRoutingTransportCosts;
import basics.route.Driver;
import basics.route.Vehicle;
import basics.route.VehicleImpl.VehicleType;


/**
 * @author <NAME>
 * 
 */
public class CrowFlyCosts implements VehicleRoutingTransportCosts {

	private static Logger logger = Logger.getLogger(CrowFlyCosts.class);

	public int speed = 1;

	public double detourFactor = 1.0;

	private Locations locations;

	public CrowFlyCosts(Locations locations) {
		super();
		this.locations = locations;
	}
	
	@Override
	public String toString() {
		return "[name=crowFlyCosts]";
	}

	@Override
	public double getTransportCost(String fromId, String toId, double time, Driver driver, Vehicle vehicle) {
		double distance;
		try {
			distance = EuclideanDistanceCalculator.calculateDistance(locations.getCoord(fromId), locations.getCoord(toId)) * detourFactor;
		} catch (NullPointerException e) {
			throw new NullPointerException("cannot calculate euclidean distance. coordinates are missing. either add coordinates or use another transport-cost-calculator.");
		}
		double costs = distance;
		if(vehicle != null){
			if(vehicle.getType() != null){
				costs = distance * vehicle.getType().getVehicleCostParams().perDistanceUnit;
			}
		}
		return costs;
	}

	@Override
	public double getTransportTime(String fromId, String toId, double time, Driver driver, Vehicle vehicle) {
		double distance;
		try {
			distance = EuclideanDistanceCalculator.calculateDistance(locations.getCoord(fromId), locations.getCoord(toId)) * detourFactor;
		} catch (NullPointerException e) {
			throw new NullPointerException("cannot calculate euclidean distance. coordinates are missing. either add coordinates or use another transport-cost-calculator.");
		}
		double transportTime = distance / speed;
		return transportTime;
	}

	@Override
{'fraction_non_alphanumeric': 0.16068181818181818, 'fraction_numerical': 0.005909090909090909, 'mean_word_length': 4.9959128065395095, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3863625', 'n_tokens_mistral': 1316, 'n_tokens_neox': 1172, 'n_words': 345}