<commit_before>package com.planetmayo.debrief.satc.model.contributions;

import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;

import com.planetmayo.debrief.satc.model.GeoPoint;
import com.planetmayo.debrief.satc.model.states.BaseRange.IncompatibleStateException;
import com.planetmayo.debrief.satc.model.states.BoundedState;
import com.planetmayo.debrief.satc.model.states.LocationRange;
import com.planetmayo.debrief.satc.model.states.ProblemSpace;
import com.planetmayo.debrief.satc.support.SupportServices;
import com.planetmayo.debrief.satc.util.GeoSupport;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.LinearRing;
import com.vividsolutions.jts.geom.Point;
import com.vividsolutions.jts.geom.Polygon;

public class RangeForecastContribution extends BaseContribution
{
	/**
	 * utility class for storing a measurement
	 * 
	 * @author ian
	 * 
	 */
	public static class ROrigin
	{
		private final GeoPoint _origin;
		private final Date _time;

		public ROrigin(GeoPoint loc, Date time)
		{
			_origin = loc;
			_time = time;
		}
	}

	private static final long serialVersionUID = 1L;

	public static final String MIN_RANGE = "minRange";

	public static final String MAX_RANGE = "maxRange";

	/**
	 * for UI components, this is the maximum range that a user can select
	 * 
	 */
	public static final int MAX_SELECTABLE_RANGE_M = 10000;

	private static double ABSOLUTELY_HUGE_RANGE_DEGS = 2;

	/**
	 * utility method to create one of these contributions
	 * 
	 * @return
	 */
	public static BaseContribution getSample()
	{
		BaseContribution res = new RangeForecastContribution();
		res.setActive(true);
		res.setWeight(4);
		res.setName("Easterly Leg");
		res.setStartDate(new Date(111111000));
		res.setFinishDate(new Date(System.currentTimeMillis() - 111111000));
		return res;
	}

	protected double _minRangeM;

	protected double _maxRangeM;

	protected double _estimate;

	/**
	 * the set of measurements we store
	 * 
	 */
	private ArrayList<ROrigin> _measurements = new ArrayList<ROrigin>();

	@Override
	public void actUpon(final ProblemSpace space)
			throws IncompatibleStateException
	{

		// loop through our measurements
		Iterator<ROrigin> iter = _measurements.iterator();
		while (iter.hasNext())
		{
			RangeForecastContribution.ROrigin origin = iter.next();
<commit_msg>reflect time when setting range constraints<commit_after>package com.planetmayo.debrief.satc.model.contributions;

import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;

import com.planetmayo.debrief.satc.model.GeoPoint;
import com.planetmayo.debrief.satc.model.states.BaseRange.IncompatibleStateException;
import com.planetmayo.debrief.satc.model.states.BoundedState;
import com.planetmayo.debrief.satc.model.states.LocationRange;
import com.planetmayo.debrief.satc.model.states.ProblemSpace;
import com.planetmayo.debrief.satc.support.SupportServices;
import com.planetmayo.debrief.satc.util.GeoSupport;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.LinearRing;
import com.vividsolutions.jts.geom.Point;
import com.vividsolutions.jts.geom.Polygon;

public class RangeForecastContribution extends BaseContribution
{
	/**
	 * utility class for storing a measurement
	 * 
	 * @author ian
	 * 
	 */
	public static class ROrigin
	{
		private final GeoPoint _origin;
		private final Date _time;

		public ROrigin(GeoPoint loc, Date time)
		{
			_origin = loc;
			_time = time;
		}
	}

	private static final long serialVersionUID = 1L;

	public static final String MIN_RANGE = "minRange";

	public static final String MAX_RANGE = "maxRange";

	/**
	 * for UI components, this is the maximum range that a user can select
	 * 
	 */
	public static final int MAX_SELECTABLE_RANGE_M = 10000;

	private static double ABSOLUTELY_HUGE_RANGE_DEGS = 2;

	/**
	 * utility method to create one of these contributions
	 * 
	 * @return
	 */
	public static BaseContribution getSample()
	{
		BaseContribution res = new RangeForecastContribution();
		res.setActive(true);
		res.setWeight(4);
		res.setName("Easterly Leg");
		res.setStartDate(new Date(111111000));
		res.setFinishDate(new Date(System.currentTimeMillis() - 111111000));
		return res;
	}

	protected double _minRangeM;

	protected double _maxRangeM;

	protected double _estimate;

	/**
	 * the set of measurements we store
	 * 
	 */
	private ArrayList<ROrigin> _measurements = new ArrayList<ROrigin>();

	@Override
	public void actUpon(final ProblemSpace space)
			throws IncompatibleStateException
	{

		// loop through our measurements
		Iterator<ROrigin> iter = _measurements.iterator();
		while (iter.hasNext())
		{
			RangeForecastContribution.ROrigin origin = iter.next();

			Date thisT = origin._time;

			boolean useIt = true;
			// is it in time?
			if(super.getStartDate() != null)
			{
				if(super.getStartDate().after(thisT))
				{
					useIt = false;
				}
			}
			if(super.getFinishDate() != null)
			{
				if(super.getFinishDate().before(thisT))
				{
					useIt = false;
				}
			}
			
			if(!useIt)
				continue;
			
{'fraction_non_alphanumeric': 0.09824561403508772, 'fraction_numerical': 0.0101364522417154, 'mean_word_length': 4.2517911975435005, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '3638710', 'n_tokens_mistral': 1881, 'n_tokens_neox': 1645, 'n_words': 379}